'From etoys2.3 of 3 December 2007 [latest update: #1875] on 22 January 2008 at 7:06:45 pm'! "Change Set: xobundle2-bf Date: 22 January 2008 Author: Bert Freudenberg Create bundle compatible with more etoys versions, and care for non-ascii chars in filenames"! !SugarLauncher methodsFor: 'bundling' stamp: 'bf 1/22/2008 17:25'! bundleInfoTemplate "template for activity/activity.info" ^'[Activity] name = {TITLE} activity_version = {VERSION} host_version = 1 bundle_id = {BUNDLE} icon = {ICON} exec = {SCRIPT} show_launcher = yes '! ! !SugarLauncher methodsFor: 'bundling' stamp: 'bf 1/22/2008 18:00'! bundleInfoTitle: aTitle version: aVersion bundle: aBundle script: aScriptName icon: anIconName | s | s := self bundleInfoTemplate. { '{TITLE}'. aTitle. '{VERSION}'. aVersion asString. '{BUNDLE}'. aBundle. '{ICON}'. anIconName. '{SCRIPT}'. aScriptName. String cr. String lf. } pairsDo: [:key :val | s := s copyReplaceAll: key with: val]. ^s squeakToUtf8! ! !SugarLauncher methodsFor: 'bundling' stamp: 'bf 1/22/2008 17:54'! bundleScriptTemplate "template for MyActivity.activity/bin/MyActivity.sh" ^'#!!/bin/sh # Author: Bert Freudenberg # Purpose: Run {FILE} in Etoys # arguments are unordered, have to loop args="" while [ -n "$2" ] ; do case "$1" in -b | --bundle-id) bundle_id="$2" ; args="$args BUNDLE_ID $2" ;; -a | --activity-id) activity_id="$2" ; args="$args ACTIVITY_ID $2";; -o | --object-id) object_id="$2" ; args="$args OBJECT_ID $2";; -u | --uri) uri="$2" ; args="$args URI $2";; *) echo unknown argument $1 $2 ;; esac shift;shift done # really need bundle id and activity id if [ -z "$bundle_id" -o -z "$activity_id" ] ; then echo ERROR: bundle-id and activity-id arguments required echo Aborting exit 1 fi # more useful args args="$args BUNDLE_PATH $SUGAR_BUNDLE_PATH" # some debug output echo launching $bundle_id instance $activity_id [ -n "$object_id" ] && echo with journal obj $object_id [ -n "$uri" ] && echo loading uri $uri echo # sanitize [ -z "$SUGAR_PROFILE" ] && SUGAR_PROFILE=default [ -z "$SUGAR_ACTIVITY_ROOT" ] && SUGAR_ACTIVITY_ROOT="$HOME/.sugar/$SUGAR_PROFILE/etoys" # rainbow-enforced locations export SQUEAK_SECUREDIR="$SUGAR_ACTIVITY_ROOT/data/private" export SQUEAK_USERDIR="$SUGAR_ACTIVITY_ROOT/data/MyEtoys" # make group-writable for rainbow umask 0002 [ !! -d "$SQUEAK_SECUREDIR" ] && mkdir -p "$SQUEAK_SECUREDIR" && chmod o-rwx "$SQUEAK_SECUREDIR" [ !! -d "$SQUEAK_USERDIR" ] && mkdir -p "$SQUEAK_USERDIR" # do not crash on dbus errors export DBUS_FATAL_WARNINGS=0 # now run Squeak VM with Etoys image exec etoys \ -sugarBundleId $bundle_id \ -sugarActivityId $activity_id \ --document "{FILE}" \ $args '! ! !SugarLauncher methodsFor: 'bundling' stamp: 'bf 1/22/2008 17:52'! bundle: aFileName as: aBundleName title: aTitle version: aVersion id: aBundleID icon: anSVGIcon "Create a ZIP file named aBundleName-aVersion.xo containing aBundleName.activity/ aFileName bin/etoys-launch activity/activity.info activity/aBundleName-icon.svg " | dir archive fileAttr execAttr dirAttr localFileName scriptName | fileAttr := 16r81A4. execAttr := 16r81ED. dirAttr := 16r41ED. dir := aBundleName, '.activity/'. localFileName := FileDirectory localNameFor: aFileName. scriptName := aBundleName, '.sh'. archive := ZipArchive new. #('' 'bin' 'activity') do: [:dirName | (archive addDirectory: dir, dirName) unixFileAttributes: dirAttr]. (archive addFile: aFileName as: dir, localFileName) unixFileAttributes: fileAttr. (archive addString: (self bundleScript: localFileName) as: dir, 'bin/', scriptName) unixFileAttributes: execAttr. (archive addString: (self bundleInfoTitle: aTitle version: aVersion bundle: aBundleID script: scriptName icon: aBundleName, '-icon') as: dir, 'activity/activity.info') unixFileAttributes: fileAttr. (archive addString: self bundleIcon as: dir, 'activity/', aBundleName, '-icon.svg') unixFileAttributes: fileAttr. archive members do: [:m | m setLastModFileDateTimeFrom: Time totalSeconds]. archive writeToFileNamed: aBundleName, '-', aVersion asString, '.xo'. archive close.! ! !SugarLauncher methodsFor: 'as yet unclassified' stamp: 'bf 1/22/2008 18:00'! bundleScript: aFileName | s | s := self bundleScriptTemplate. { '{FILE}'. aFileName. String cr. String lf. } pairsDo: [:key :val | s := s copyReplaceAll: key with: val]. ^s squeakToUtf8 ! ! SugarLauncher removeSelector: #bundleInfoTitle:version:bundle:file:icon:! SugarLauncher removeSelector: #bundleScript!