PackageIt.cm
Copyright Ó 1991, 1992, 1993 by Xerox Corporation. All rights reserved.
Michael Plass, June 24, 1993 11:55 am PDT
Willie-s, July 15, 1992 3:14 pm PDT
This creates a script that builds a packaged world almost like the running one.
Arguments: outname initialcommand
Output is a c program, outname.c, and a shell script, outname.ld, to compile and link the c program.
Bugs: the cc command uses vuxy names, which generates warnings out of cc.
Restrictions: This only works starting from a dynamically loaded world.
Example:
dyload a RawViewers world (e.g. CedarCommander RawViewers)
...
% cd bindir -- The place where you want the package to end up.
% PackageIt RV RawViewers
% sh1 ./RV.ld
( The RawViewers initial command does a few things (like CommandsFromProfile ...) that are not captured by the checkpointing process ).
This will create the UnixTM executable named bindir/RV
Provide some default PCR options:
ReadTo EOF >TMP.pcroptions
-msgs 0 -vp 2 -slaveiop 1 -striop 1 -stdiop 2 -thread 85 -mem 524288 -stack 90000 -tmp /tmp -nodbxscript -shmtype sv
EOF
Allow for user-provided overrides:
Copy TMP.pcroptions ← $1.pcroptions
Echo PCR options are: $(Type TMP.pcroptions)
Next, write a c program that starts everything up
Echo -s "char XR←packageVersion[] = \""($(date))"\";" >TMP.c
Echo "char *defaultArgs = \"" $(type TMP.pcroptions) -- -install𡤊nd←run←package -- "\";" >>TMP.c
ReadTo /*ENDHEADER*/ >>TMP.c
void XR←SetupPackage() {}
void XR←InstallAndRunPackage () {
/*ENDHEADER*/
LoadedFiles -ccode -after PortableCommonRuntime -except CommanderOnStandardStreamsImpl >> TMP.c
Echo " XR𡤍oCommanderCommands(\"Installed " $(Installed) "\");" >> TMP.c
Echo -n " XR𡤍oCommanderCommands(\n " >> TMP.c
Prop -q 2 >> TMP.c
Echo -n " );\n" >> TMP.c
LoadedFiles -ccode -first CommanderOnStandardStreamsImpl -last CommanderOnStandardStreamsImpl >> TMP.c
ReadTo /*ENDTRAILER*/ >>TMP.c
}
#include <string.h>
static char *argvec[25];
static char **defaultArgv = &argvec[0];
static int firstTime = 1;
static int defaultArgc = 0;
void XR←GetPackageDefaultArgs(argc←ptr, argv←ptr)
 int *argc←ptr; char ***argv←ptr; {
 /* extern char defaultArgs[]; */
 char *nextArg;
 if( (argc←ptr == 0) || (argv←ptr == 0) ) return;
 if(!firstTime) {
  *argv←ptr = defaultArgv;
  *argc←ptr = defaultArgc;
  return;}
 for (;;) {
  if (firstTime) {
   nextArg = strtok(defaultArgs, " ");
   firstTime = 0;}
  else nextArg = strtok(0, " ");
  if (nextArg == 0) break;
  defaultArgv[defaultArgc] = nextArg;
  defaultArgc++;};
 *argv←ptr = defaultArgv;
 *argc←ptr = defaultArgc;
}
/*ENDTRAILER*/
Rename $1.c ← TMP.c
Del TMP.pcroptions
Write a shell script to do the compiling and linking
SetProcessProperty LDNAMES ""
echo -n -s > TMP.ld
Echo Alias PackageIt.PCRName ((BIN PortableCommonRuntime)) Echo $(LoadedFiles -names -first PortableCommonRuntime -last PortableCommonRuntime) | Commander
Alias PackageIt.UnixLoad (foo) SetProcessProperty LDNAMES ($LDNAMES foo)
Alias PackageIt.LoadAndRun (foo bar) SetProcessProperty LDNAMES ($LDNAMES FILE-bar.c2c.o); echo "ln -s" foo FILE-bar.c2c.o >> TMP.ld
LoadedFiles -pcr -after PortableCommonRuntime | PrefixLines PackageIt. | Commander
Echo -n cc -o $1 -Qoption ld -Bstatic $1.c $(PackageIt.PCRName LIB XRRoot.o) $LDNAMES $(PackageIt.PCRName LIB xr.a) " " >> TMP.ld
LoadedFiles -libs >> TMP.ld
Echo -s "\nrm FILE-*.c2c.o" >> TMP.ld
Rename $1.ld ← TMP.ld
SetFileProperties -UnixMode 550B $1.ld
SetProcessProperty LDNAMES ""
List -f $1.c $1.ld