Hi,
Here is a simple patch for that.
Cheers,
Gwen
On Thu, 2009-12-10 at 22:57 +0100, Nicolas Petton wrote:
> Hi,
>
> Now that we have the infrastructure for downloading and installing star
> packages from smalltalk.gnu.org, I think it would be nice to have the
> version number information in the package.xml (and then in the package
> object).
>
> What about adding two tags, one for the major version, one for the minor
> version and one for the patch version?
>
> This would give: maj.min.patch -> 0.8.4
>
> Cheers!
>
> Nico
> _______________________________________________
> help-smalltalk mailing list
> [email protected]
> http://lists.gnu.org/mailman/listinfo/help-smalltalk
diff --git a/kernel/PkgLoader.st b/kernel/PkgLoader.st
index 260d8b8..2118433 100644
--- a/kernel/PkgLoader.st
+++ b/kernel/PkgLoader.st
@@ -431,7 +431,7 @@ PackageContainer subclass: PackageDirectory [
self file withReadStreamDo: [ :fileStream |
[self parse: fileStream]
on: SystemExceptions.PackageNotAvailable
- do: [:ex | ex resignalAs: PackageSkip new]].
+ do: [:ex | ex resignalAs: PackageSkip new]].
self packages: (self packages reject: [:each | each isDisabled])
]
@@ -1101,16 +1101,100 @@ PackageInfo subclass: StarPackage [
+Namespace current: Kernel [
+
+Object subclass: Version [
+ | major minor patch |
+
+ Version class >> major: major minor: minor patch: patch [
+ <category: 'instance creation'>
+
+ ^ self new
+ major: major minor: minor patch: patch
+ ]
+
+ major: major minor: minor patch: patch [
+ <category: 'initialization'>
+
+ self
+ major: major;
+ minor: minor;
+ patch: patch
+ ]
+
+ major [
+ <category: 'accessing'>
+
+ ^ major
+ ]
+
+ major: anInteger [
+ <category: 'accessing'>
+
+ major := anInteger
+ ]
+
+ minor [
+ <category: 'accessing'>
+
+ ^ minor
+ ]
+
+ minor: anInteger [
+ <category: 'accessing'>
+
+ minor := anInteger
+ ]
+
+ patch [
+ <category: 'accessing'>
+
+ ^ patch
+ ]
+
+ patch: anInteger [
+ <category: 'accessing'>
+
+ patch := anInteger
+ ]
+]
+]
+
+
Kernel.PackageInfo subclass: Package [
| features prerequisites builtFiles files fileIns relativeDirectory
baseDirectories libraries modules callouts url namespace sunitScripts
- startScript stopScript test |
+ startScript stopScript test version |
<category: 'Language-Packaging'>
<comment: 'I am not part of a standard Smalltalk system. I store internally the
information on a Smalltalk package, and can output my description in
XML.'>
+ Package class [ | Tags | ]
+
+ Package class >> tags [
+ <category: 'accessing'>
+
+ ^ Tags ifNil: [ Tags := Dictionary from: {
+ 'file' -> #addFile:.
+ 'filein' -> #addFileIn:.
+ 'prereq' -> #addPrerequisite:.
+ 'provides' -> #addFeature:.
+ 'module' -> #addModule:.
+ 'directory' -> #relativeDirectory:.
+ 'name' -> #name:.
+ 'url' -> #url:.
+ 'version' -> #parseVersion:.
+ 'namespace' -> #namespace:.
+ 'library' -> #addLibrary:.
+ 'built-file' -> #addBuiltFile:.
+ 'sunit' -> #addSunitScript:.
+ 'start' -> #startScript:.
+ 'stop' -> #stopScript:.
+ 'callout' -> #addCallout: } ]
+ ]
+
Package class >> parse: file [
"Answer a package from the XML description in file."
<category: 'instance creation'>
@@ -1209,6 +1293,12 @@ XML.'>
namespace := aString
]
+ addFeature: aString [
+ <category: 'accessing'>
+
+ self features add: aString
+ ]
+
features [
"Answer a (modifiable) Set of features provided by the package."
@@ -1217,6 +1307,12 @@ XML.'>
^features
]
+ addPrerequisite: aString [
+ <category: 'accessing'>
+
+ self prerequisites add: aString
+ ]
+
prerequisites [
"Answer a (modifiable) Set of prerequisites."
@@ -1225,6 +1321,12 @@ XML.'>
^prerequisites
]
+ addBuiltFile: aString [
+ <category: 'accessing'>
+
+ self builtFiles add: aString
+ ]
+
builtFiles [
"Answer a (modifiable) OrderedCollection of files that are part of
the package but are not distributed."
@@ -1234,6 +1336,12 @@ XML.'>
^builtFiles
]
+ addFile: aString [
+ <category: 'accessing'>
+
+ self files add: aString
+ ]
+
files [
"Answer a (modifiable) OrderedCollection of files that are part of
the package."
@@ -1243,6 +1351,12 @@ XML.'>
^files
]
+ addFileIn: aString [
+ <category: 'accessing'>
+
+ self fileIns add: aString
+ ]
+
fileIns [
"Answer a (modifiable) OrderedCollections of files that are to be
filed-in to load the package. This is usually a subset of
@@ -1253,6 +1367,12 @@ XML.'>
^fileIns
]
+ addLibrary: aString [
+ <category: 'accessing'>
+
+ self libraries add: aString
+ ]
+
libraries [
"Answer a (modifiable) Set of shared library names
that are required to load the package."
@@ -1262,6 +1382,12 @@ XML.'>
^libraries
]
+ addModule: aString [
+ <category: 'accessing'>
+
+ self modules add: aString
+ ]
+
modules [
"Answer a (modifiable) Set of modules that are
required to load the package."
@@ -1271,6 +1397,12 @@ XML.'>
^modules
]
+ addSunitScript: aString [
+ <category: 'accessing'>
+
+ self sunitScripts add: aString
+ ]
+
sunitScripts [
"Answer a (modifiable) OrderedCollection of SUnit scripts that
compose the package's test suite."
@@ -1280,6 +1412,12 @@ XML.'>
^sunitScripts
]
+ addCallout: aString [
+ <category: 'accessing'>
+
+ self callouts add: aString
+ ]
+
callouts [
"Answer a (modifiable) Set of call-outs that are required to load
the package. Their presence is checked after the libraries and
@@ -1366,6 +1504,26 @@ XML.'>
relativeDirectory := dir
]
+ version [
+ <category: 'accessing'>
+
+ ^ version
+ ]
+
+ version: aVersion [
+ <category: 'accessing'>
+
+ version := aVersion
+ ]
+
+ parseVersion: aString [
+ <category: 'version parsing'>
+
+ | tokens |
+ (tokens := aString tokenize: '\.') size = 3 ifFalse: [ self error: 'Bad version string : ', aString, ' should be xx.yy.zz' ].
+ self version: (Version major: tokens first asInteger minor: tokens second asInteger patch: tokens third asInteger)
+ ]
+
primFileIn [
"Private - File in the given package without paying attention at
dependencies and C callout availability"
@@ -1417,24 +1575,8 @@ XML.'>
(file upTo: $>) = tag
ifFalse: [^self error: 'error in packages file: unmatched end tag ' , tag].
- "I tried to put these from the most common to the least common"
- tag = 'file' ifTrue: [self files add: cdata] ifFalse: [
- tag = 'filein' ifTrue: [self fileIns add: cdata] ifFalse: [
- tag = 'prereq' ifTrue: [self prerequisites add: cdata] ifFalse: [
- tag = 'provides' ifTrue: [self features add: cdata] ifFalse: [
- tag = 'module' ifTrue: [self modules add: cdata] ifFalse: [
- tag = 'directory' ifTrue: [self relativeDirectory: cdata] ifFalse: [
- tag = 'name' ifTrue: [self name: cdata] ifFalse: [
- tag = 'url' ifTrue: [self url: cdata] ifFalse: [
- tag = 'namespace' ifTrue: [self namespace: cdata] ifFalse: [
- tag = 'library' ifTrue: [self libraries add: cdata] ifFalse: [
- tag = 'built-file' ifTrue: [self builtFiles add: cdata] ifFalse: [
- tag = 'sunit' ifTrue: [self sunitScripts add: cdata] ifFalse: [
- tag = 'start' ifTrue: [self startScript: cdata] ifFalse: [
- tag = 'stop' ifTrue: [self stopScript: cdata] ifFalse: [
- tag = 'callout' ifTrue: [self callouts add: cdata] ifFalse: [
- tag = openingTag ifTrue: [^self] ifFalse: [
- self error: 'invalid tag ' , tag]]]]]]]]]]]]]]]].
+ tag = openingTag ifTrue: [ ^ self ].
+ self perform: (self class tags at: tag ifAbsent: [ self error: 'invalid tag ', tag ]) with: cdata.
cdata := nil].
ch isAlphaNumeric
ifTrue:
_______________________________________________
help-smalltalk mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/help-smalltalk