{BUG][FIX]Re: AutoStart doesn't work with a shrunken image

Tim Rowledge tim at sumeru.stanford.edu
Tue Aug 28 23:55:05 UTC 2001


Duh. Tags....

In message <735d53b14a.rowledge at goldskin.stcla1.sfba.home.com>
          Tim Rowledge <tim at sumeru.stanford.edu> wrote:

> I've just been making a shrunk image intended to work headless. After
> carefully testing my headless linux VM witha normal 4282 level image,
> I was more than a little disturbed to find that it didn't work after
> shrinking.
> 
> The problems turned out to be two places in the AutoStart /
> AbstractLauncher class worlds.
> 
> When you shrink an image and remove Morphic you suddenly find that
> commandline scripts no longer get processed. This is because:-
> 
> a) ProjectLauncher tries to setup some Flaps, which no longer exist
> 
> b) AutoStart only starts its installed launchers if there is a
> WorldState - which no longer exists.
> 
> This changeset provides a reasonably tidy fix by making AutoStart delegate a bit better to the luncher class involved, and by providing a default #startUp that continues to check for WorldState. The CommandLineLauncher is an example of overriding that to work without Morphic in a shrunk, headless image.
> 
> To activate CommandLineLauncher, remember to use
> ProjectLauncher deactivate.
> CommandLineLauncher activate
> before saving the image.
> 
> tim

-- 
Tim Rowledge, tim at sumeru.stanford.edu, http://sumeru.stanford.edu/tim
Strange OpCodes: SDD: Scratch Disk and Die
-------------- next part --------------
'From Squeak3.1alpha of 7 March 2001 [latest update: #4164] on 28 August 2001 at 3:14:25 pm'!
"Change Set:		AutoStartfixes
Date:			28 August 2001
Author:			tim at sumeru.stanford.edu

When you shrink an image and remove Morphic you suddenly find that commandline scripts no longer get processed. This is because:-
a) ProjectLauncher tries to setup some Flaps, which no longer exist
b) AutoStart only starts its installed launchers if there is a WorldState - which no longer exists.

This changeset provides a reasonably tidy fix by making AutoStart delegate a bit better to the luncher class involved, and by providing a default #startUp that continues to check for WorldState. The CommandLineLauncher is an example of overriding that to work without Morphic in a shrunk, headless image.

To activate CommandLineLauncher, remember to use
ProjectLauncher deactivate.
CommandLineLauncher activate
before saving the image.

"!

AbstractLauncher subclass: #CommandLineLauncher
	instanceVariableNames: ''
	classVariableNames: ''
	poolDictionaries: ''
	category: 'Framework-Download'!

!AbstractLauncher methodsFor: 'running' stamp: 'tpr 8/28/2001 13:31'!
startUp
"Default - add a deferred UI action to do the real startup work.
Subclasses can override to handle Morphiclessness etc"
Smalltalk at: #WorldState ifPresent: [ :ws | ws addDeferredUIMessage: [self actualStartUp]]! !

!AutoStart class methodsFor: 'class initialization' stamp: 'tpr 8/28/2001 13:38'!
startUp
	| startupParameters launchers |
	self checkForUpdates
		ifTrue: [^self].
	self checkForPluginUpdate.
	startupParameters _ AbstractLauncher extractParameters.
	launchers _ self installedLaunchers collect: [:launcher |
		launcher new].
	launchers do: [:launcher |
		launcher parameters: startupParameters].
	launchers do: [:launcher |
		launcher startUp]! !


!CommandLineLauncher methodsFor: 'running' stamp: 'tpr 8/28/2001 13:41'!
startUp
"Override the default - this is intended for headless type systems andchecking for a WorldState will do us no good at all"
	| scriptName loader isUrl |

	scriptName _ (Smalltalk getSystemAttribute: 2) ifNil:[''].
	scriptName isEmpty ifFalse:[
		"figure out if script name is a URL by itself"
		isUrl _ (scriptName asLowercase beginsWith:'http://') or:[
				(scriptName asLowercase beginsWith:'file://') or:[
				(scriptName asLowercase beginsWith:'ftp://')]].
		isUrl ifFalse:[scriptName _ 'file://',scriptName]].

	scriptName isEmptyOrNil ifTrue:[^self].
	loader _ CodeLoader new.
	loader loadSourceFiles: (Array with: scriptName).
	loader installSourceFiles! !


!CommandLineLauncherExample methodsFor: 'running' stamp: 'tpr 8/28/2001 13:32'!
actualStartUp
	| className |
	className _ self parameterAt: 'class'.
	(Smalltalk at: className asSymbol ifAbsent: [Object]) browse! !


!ProjectLauncher methodsFor: 'running' stamp: 'tpr 8/28/2001 13:29'!
actualStartUp
	| scriptName loader isUrl |
	World ifNotNil: [World install].
	HTTPClient determineIfRunningInBrowser.
	HTTPClient isRunningInBrowser ifTrue:[
		self setupFromParameters.
		scriptName _ self parameterAt: 'src'.
		CodeLoader defaultBaseURL: (self parameterAt: 'Base').
	] ifFalse:[
		scriptName _ (Smalltalk getSystemAttribute: 2) ifNil:[''].
		scriptName isEmpty ifFalse:[
			"figure out if script name is a URL by itself"
			isUrl _ (scriptName asLowercase beginsWith:'http://') or:[
					(scriptName asLowercase beginsWith:'file://') or:[
					(scriptName asLowercase beginsWith:'ftp://')]].
			isUrl ifFalse:[scriptName _ 'file://',scriptName]].
	].
	scriptName isEmptyOrNil ifTrue:[^self].
	self setupFlaps.
	loader _ CodeLoader new.
	loader loadSourceFiles: (Array with: scriptName).
	(scriptName asLowercase endsWith: '.pr') 
		ifTrue:[self installProjectFrom: loader]
		ifFalse:[loader installSourceFiles].
! !

ProjectLauncher removeSelector: #startUp!
CommandLineLauncherExample removeSelector: #startUp!


More information about the Squeak-dev mailing list