[squeak-dev] A thought about 'Cannot locate .sources file' message

David T. Lewis lewis at mail.msen.com
Mon Dec 20 23:34:21 UTC 2010


On Mon, Dec 20, 2010 at 05:16:41AM +0100, Alexander Lazarevi?? wrote:
> 2010/12/20 Igor Stasenko <siguctua at gmail.com>
> 
> > On 20 December 2010 02:09, Hern??n Morales Durand
> > <hernan.morales at gmail.com> wrote:
> > > Yes, or locate it in a directory and/or copy to the current one. By
> > > the way, it could be configured a location for just having only one
> > > sources file?
> >
> > +1 . it would be nice to be able to specify a system-wide location for
> > .sources files,
> > so any image could look for them at this place first than looking at
> > current directory.
> >
> 
> First the sources are searched at the vmPath, then at the imagePath and
> finally at the defaultPath (which could be the same as the imagePath, see
> [1]).
> On Unix the vmPath will be no option for a central directory to hold the
> sources files, because it's usually /usr/bin, unless you have installed your
> vm locally in your home directory.
> I think it would be nice to have a vm SystemAttribute to hold the sources
> path. This could be defined during installation, overridden by .ini files,
> command line switches, props or whatever and always default to vmPath if no
> other info is available. But the reception for this change wasn't so good as
> far as I remember, maybe mainly because the issue isn't so pressing while
> running on Windows/MacOS (or that everything that defines the concept of
> having a sources file should be completely on the image side).
> 
> Alex
> 
> [1] FileDirectory class openSources: fullSourcesName forImage: imageName

I don't like the idea of adding a system attribute because it adds
a dependency on the VM version, and also because the issue can be handled
completely in the image.

Given that the concern exists only for Unix VM installations, we can make
use of existing installation directory conventions. The Unix VMs are
installed under /usr/local/lib/squeak/ with a different subdirectory for
each version of the VM (e.g. /usr/local/lib/squeak/4.4.1-2329/). Thus a
solution would be to put the sources files for all images (Squeak, Pharo,
etc) under /usr/local/lib/squeak/. In this scenario, the image would look
first in the vmPath (e.g. /usr/local/lib/squeak/4.4.1-2329/) and then look
one level up in /usr/local/lib/squeak/. This would be harmless for non-Unix
platforms, and would address the problem for Unix. All sources files could
be shared from a single location, and no new concepts or VM modifications
are needed.

Patch attached to illustrate the approach.

Dave

-------------- next part --------------
'From Squeak3.11alpha of 12 December 2010 [latest update: #10768] on 20 December 2010 at 6:16:10 pm'!
"Change Set:		ChangesFilesInSharedDirectory-dtl
Date:			20 December 2010
Author:			David T. Lewis

When searching for the sources file, look first in vmPath, then one level up. Permits sources files to be shared from /usr/local/lib/squeak/ when the VM is installed in /usr/local/lib/squeak/<version>/ ."!


!FileDirectory class methodsFor: 'system start up' stamp: 'dtl 12/20/2010 17:58'!
openSources: fullSourcesName forImage: imageName 
"We first do a check to see if a compressed version ofthe sources file is present.
Open the .sources file read-only after searching in:
a) the directory where the VM lives
b) the directory where the image came from
c) the DefaultDirectory (which is likely the same as b unless the SecurityManager has changed it).
"

	| sources fd sourcesName vmPath |
	(fullSourcesName endsWith: 'sources') ifTrue:
		["Look first for a sources file in compressed format."
		sources := self openSources: (fullSourcesName allButLast: 7) , 'stc'
						forImage: imageName.
		sources ifNotNil: [^ CompressedSourceStream on: sources]].

	sourcesName := FileDirectory localNameFor: fullSourcesName.
	"look for the sources file or an alias to it in the VM's directory"
	vmPath := SmalltalkImage current vmPath.
	fd := FileDirectory on: vmPath.
	(fd fileExists: sourcesName)
		ifTrue: [sources := fd readOnlyFileNamed: sourcesName].
	sources ifNotNil: [^ sources].
	"look in a directory one level above the VM's directory, e.g. /usr/local/lib/squeak/"
	fd := FileDirectory on: (vmPath
				first: (vmPath allButLast findLastOccurrenceOfString: FileDirectory slash startingAt: 1)).
	(fd fileExists: sourcesName)
		ifTrue: [sources := fd readOnlyFileNamed: sourcesName].
	sources ifNotNil: [^ sources].
	"look for the sources file or an alias to it in the image directory"
	fd := FileDirectory on: (FileDirectory dirPathFor: imageName).
	(fd fileExists: sourcesName)
		ifTrue: [sources := fd readOnlyFileNamed: sourcesName].
	sources ifNotNil: [^ sources].
	"look for the sources in the current directory"
	fd := DefaultDirectory.
	(fd fileExists: sourcesName)
		ifTrue: [sources := fd readOnlyFileNamed: sourcesName].
	"sources may still be nil here"
	^sources
! !



More information about the Squeak-dev mailing list