--- a/AbstractOperatingSystem.st Sun Jun 26 05:38:45 2016 +0100
+++ b/AbstractOperatingSystem.st Sun Jun 26 06:29:46 2016 +0100
@@ -15,8 +15,8 @@
Object subclass:#AbstractOperatingSystem
instanceVariableNames:''
- classVariableNames:'ConcreteClass LastErrorNumber LocaleInfo OSSignals PipeFailed
- ErrorSignal Resources'
+ classVariableNames:'ConcreteClass ErrorSignal LastErrorNumber LocaleInfo OSSignals
+ PipeFailed Resources'
poolDictionaries:''
category:'System-Support'
!
@@ -4649,119 +4649,54 @@
!
defaultPackagePath
- "return a default packagePath - that's a collection of
- dirnames, where ST/X searches for its package subdirs.
+ "Return a default packagePath - that's a collection of
+ dirnames, where ST/X searches for packages.
+
+ The default package path contains
+
+ * $STX_PACKAGEPATH (directories specified in environment variable)
+ * $HOME/.smalltalk/packages (on Windows %USERPROFILE%\.smalltalk\packages)
+ * OperatingSystem pathOfSTXExecutable / '..' / '..' / '..' (only when running from build tree)
+
+
This method might be redefined in concrete OS's to add
OS-specific directory names."
- |packagePath execPath dirName homeDirName priv userPrivateSTXDir appDir topDirName|
-
- "
- the path is set to search files first locally
- - this allows private stuff to override global stuff
- "
+ |packagePath execPath directories|
+
packagePath := OrderedCollection new.
- "/
- "/ the current (default) directory:
- "/ ./packages
+
+ "/ Add all directories from $STX_PACKAGEPATH environment
+ (directories := OperatingSystem getEnvironment:'STX_PACKAGEPATH') notNil ifTrue:[
+ directories := directories asCollectionOfSubstringsSeparatedBy:self pathSeparator.
+ directories reverseDo:[:each|
+ (packagePath includes:each) ifFalse:[
+ packagePath addFirst:each.
+ ].
+ ].
+ ].
+
+ "/ $HOME/.smalltalk/packages (on Windows %USERPROFILE%\.smalltalk\packages)
+ packagePath add: (Filename homeDirectory / '.smalltalk' / 'packages') pathName.
+
+ "/ If and only if running in build tree, add
"/
- packagePath add:('.' "Filename currentDirectory pathName").
-
- "/ accept the fact that sometimes, we cannot figure out, where I im
+ "/ OperatingSystem pathOfSTXExecutable / '..' / '..' / '..' (only when running from build tree)
+ "/
execPath := self pathOfSTXExecutable.
execPath notNil ifTrue:[
- "/
- "/ the executable's directory:
- "/ (/opt/stx/bin/stx -> /opt/stx/bin)
- "/
- appDir := execPath asFilename directory.
- (packagePath includes:appDir) ifFalse:[
- packagePath add:appDir.
- ].
-
- "/
- "/ the executable's parent directory:
- "/ (/opt/stx/bin/stx -> /opt/stx)
- "/
- appDir := appDir directory.
- dirName := appDir pathName.
- (packagePath includes:dirName) ifFalse:[
- packagePath add:dirName.
- ].
- ].
-
- homeDirName := OperatingSystem getHomeDirectory.
- homeDirName notNil ifTrue:[
- "/
- "/ a users private smalltalk directory in its home (login) directory:
- "/ $HOME/.smalltalk/packages or $HOME\smalltalk\packages
- "/
- OperatingSystem isUNIXlike ifTrue:[
- priv := '.smalltalk'.
- ] ifFalse:[
- priv := 'smalltalk'.
- ].
- userPrivateSTXDir := homeDirName asFilename / priv.
- (userPrivateSTXDir isDirectory) ifTrue:[
- dirName := userPrivateSTXDir pathName.
- (packagePath includes:dirName) ifFalse:[
- packagePath add:dirName
- ]
- ].
+ (self isUNIXlike and:[ execPath endsWith: '/stx/projects/smalltalk/stx' ]) ifTrue:[
+ packagePath add: (execPath copyTo: execPath size - '/stx/projects/smalltalk/stx' size)
+ ] ifFalse:[
+ self isMSWINDOWSlike ifTrue:[
+ ((execPath endsWith: '\stx\projects\smalltalk\\stx.com') or:[execPath endsWith: '\stx\projects\smalltalk\\stx.exe']) ifTrue:[
+ packagePath add: (execPath copyTo: execPath size - '\stx\projects\smalltalk\\stx.exe' size)
+ ]
+ ]
+ ]
].
- "/
- "/ STX_TOPDIR from the environment:
- "/ $STX_TOPDIR/packages
- "/
- topDirName := OperatingSystem getEnvironment:'STX_TOPDIR'.
- topDirName notNil ifTrue:[
- (packagePath includes:topDirName) ifFalse:[
- packagePath add:topDirName
- ].
- ].
-
- packagePath := packagePath select:[:each | (each asFilename / 'packages') exists]
- thenCollect:[:each | (each asFilename constructString:'packages')].
-
- "
- unconditionally prepend all directories from $STX_PACKAGEPATH
- "
- (dirName := OperatingSystem getEnvironment:'STX_PACKAGEPATH') notNil ifTrue:[
- dirName := dirName asCollectionOfSubstringsSeparatedBy:$:.
- dirName reverseDo:[:eachDirectoryName|
- (packagePath includes:eachDirectoryName) ifFalse:[
- packagePath addFirst:eachDirectoryName.
- ].
- ].
- ].
-
-false ifTrue:[
- appDir notNil ifTrue:[
- "maybe the sources are kept in a central place..."
- (appDir / 'source') isDirectory ifTrue:[
- packagePath add:(appDir / 'source') pathName.
- ].
- ].
-].
-
- "maybe we are running in the build environment: XXX/stx /projects /smalltalk
- or: XXX/exept /expecco /application
- - if XXX/stx/libbasic exists, add XXX to the package path"
-false ifTrue:[
- topDirName isNil ifTrue:[
- "appdir is now: projects"
- appDir := appDir directory directory.
- (appDir / 'stx' / 'libbasic') isDirectory ifTrue:[
- appDir pathName = homeDirName ifTrue:[
- "but take care, it may be directly in the home directory"
- appDir := appDir / 'stx'.
- ].
- packagePath add:appDir pathName.
- ].
- ].
-].
^ packagePath
"
@@ -4769,6 +4704,7 @@
"
"Modified: / 04-02-2011 / 16:27:15 / cg"
+ "Modified: / 26-06-2016 / 06:26:41 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
defaultSystemPath