diff --git a/scripts/Package.st b/scripts/Package.st index 4b0d905..931d060 100644 --- a/scripts/Package.st +++ b/scripts/Package.st @@ -202,10 +202,10 @@ Kernel.PackageContainer subclass: PackageCheckout [ mainPackage := addedPackages first. MainPackage use: mainPackage during: [ mainPackage prerequisites printNl do: [ :each || file | - ((each startsWith: mainPackage name, '-') and: [ + ((each startsWith: mainPackage name, '-') and: [ (file := mainPackage baseDirectories first - / (each copyFrom: mainPackage name size + 2) - / 'package.xml') exists ]) + / (each copyFrom: mainPackage name size + 2) + / 'package.xml') exists ]) ifTrue: [ self parseFile: file ]]]. ^addedPackages @@ -228,11 +228,11 @@ PackageCheckout subclass: SvnPackageCheckout [ | realUrl command saveDir | self checkoutDirectory exists ifFalse: [ - self checkoutDirectory emitMkdir. + self checkoutDirectory emitMkdir. realUrl := url copy. url scheme = 'svn+http' ifTrue: [ realUrl scheme: 'http' ]. url host = '' ifTrue: [ realUrl := realUrl path ]. - command := 'svn checkout %1 .' % {realUrl} ] + command := 'svn checkout %1 .' % {realUrl} ] ifTrue: [ command := 'svn update' ]. @@ -240,7 +240,7 @@ PackageCheckout subclass: SvnPackageCheckout [ saveDir := Directory working. Command execute: [ - Directory working: self checkoutDirectory. + Directory working: self checkoutDirectory. Smalltalk system: command ] ensure: [ Directory working: saveDir ] ] @@ -252,12 +252,12 @@ PackageCheckout subclass: GitPackageCheckout [ | realUrl command saveDir | self checkoutDirectory exists ifFalse: [ - self checkoutDirectory emitMkdir. + self checkoutDirectory emitMkdir. realUrl := url copy. url scheme ~ 'git+(https?|rsync)' ifTrue: [ realUrl scheme: (url scheme copyFrom: 5) ]. url host = '' ifTrue: [ realUrl := realUrl path ]. - command := 'git clone --depth 1 %1 .' % {realUrl} ] + command := 'git clone --depth 1 %1 .' % {realUrl} ] ifTrue: [ command := 'git fetch' ]. @@ -265,7 +265,7 @@ PackageCheckout subclass: GitPackageCheckout [ saveDir := Directory working. Command execute: [ - Directory working: self checkoutDirectory. + Directory working: self checkoutDirectory. Smalltalk system: command ] ensure: [ Directory working: saveDir ]. @@ -274,10 +274,10 @@ PackageCheckout subclass: GitPackageCheckout [ ('cd %1 && ' % { self checkoutDirectory }, command) displayNl. Command - execute: [ - Directory working: self checkoutDirectory. + execute: [ + Directory working: self checkoutDirectory. Smalltalk system: command ] - ensure: [ Directory working: saveDir ] ] + ensure: [ Directory working: saveDir ] ] ] ] @@ -326,7 +326,7 @@ Kernel.PackageDirectories subclass: PackageFiles [ package packages do: [ :each | (each url notNil and: [each url notEmpty]) ifTrue: [ found := true. - each url = urlString ifTrue: [ + each url = urlString ifTrue: [ ^self error: 'infinite loop in package.xml urls' ]. self addURL: (NetClients.URL fromString: each url) ]]. found ifTrue: [^self]. @@ -381,7 +381,7 @@ File extend [ saveDir := Directory working. Command execute: [ - Directory working: dir name. + Directory working: dir name. Smalltalk system: '%1 -n .st:.xml -qr %2 .' % { Command zip. self } ] ensure: [ Directory working: saveDir ] @@ -411,10 +411,10 @@ File extend [ displayNl. Command execute: [ - destFile exists ifTrue: [ destFile remove ]. - srcStream := self readStream. + destFile exists ifTrue: [ destFile remove ]. + srcStream := self readStream. destStream := destFile writeStream. - destStream nextPutAll: srcStream. + destStream nextPutAll: srcStream. ] ensure: [ destStream isNil ifFalse: [ destStream close ]. @@ -467,7 +467,7 @@ Object subclass: Command [ optionsCollection := OrderedCollection new. options keysDo: [ :opt | (options at: opt) do: [ :arg | - optionsCollection add: opt->arg ]]. + optionsCollection add: opt->arg ]]. ^optionsCollection ] @@ -475,9 +475,9 @@ Object subclass: Command [ options := Dictionary new. aCollection do: [ :assoc | (options at: assoc key ifAbsentPut: [ OrderedCollection new ]) - addLast: assoc value. + addLast: assoc value. (self isValidOption: assoc key) ifFalse: [ - self error: ('--%1 invalid for this mode' % {assoc key}) ] ] + self error: ('--%1 invalid for this mode' % {assoc key}) ] ] ] isValidOption: aString [ @@ -753,19 +753,19 @@ PackageCommand subclass: PkgInstall [ baseDir emitMkdir. Command execute: [ - (baseDir / 'package.xml') withWriteStreamDo: [ :s | - pkg printOn: s ]. + (baseDir / 'package.xml') withWriteStreamDo: [ :s | + pkg printOn: s ]. - files := pkg allFiles. + files := pkg allFiles. dirs := files collect: [ :file | File pathFor: file ]. - (dirs asSet remove: '' ifAbsent: []; asSortedCollection) + (dirs asSet remove: '' ifAbsent: []; asSortedCollection) do: [ :dir | (baseDir / dir) emitMkdir ]. files do: [ :file || srcFile | - srcFile := (aPackage fullPathOf: file). - srcFile emitSymlink: (baseDir nameAt: file) ]. + srcFile := (aPackage fullPathOf: file). + srcFile emitSymlink: (baseDir nameAt: file) ]. - (self installDir / aPackage name, '.star') + (self installDir / aPackage name, '.star') emitZipDir: baseDir ] ensure: [ baseDir all remove ]. @@ -885,11 +885,11 @@ PackageCommand subclass: PkgPrepare [ srcFile isNil ifTrue: [ f := self srcdir / aString. (File exists: f) - ifTrue: [ srcFile := (File name: self srcdir) pathTo: f ]. + ifTrue: [ srcFile := (File name: self srcdir) pathTo: f ]. f := f, '.in'. (File exists: f) - ifTrue: [ srcFile := (File name: self srcdir) pathTo: f ]. + ifTrue: [ srcFile := (File name: self srcdir) pathTo: f ]. (File exists: aString) ifTrue: [ srcFile := File name: aString ]. @@ -910,15 +910,15 @@ PackageCommand subclass: PkgPrepare [ configureAC exists ifFalse: [ 'creating configure.ac' displayNl. Command dryRun ifFalse: [ - configureAC withWriteStreamDo: [ :ws | self writeConfigure: ws ] ] ]. + configureAC withWriteStreamDo: [ :ws | self writeConfigure: ws ] ] ]. gstIN exists ifFalse: [ 'creating gst.in' displayNl. Command dryRun ifFalse: [ - gstIN withWriteStreamDo: [ :ws | self writeGstIn: ws ] ] ]. + gstIN withWriteStreamDo: [ :ws | self writeGstIn: ws ] ] ]. makefileAM exists ifFalse: [ 'creating Makefile.am' displayNl. Command dryRun ifFalse: [ - makefileAM withWriteStreamDo: [ :ws | self writeMakefile: ws ] ] ] + makefileAM withWriteStreamDo: [ :ws | self writeMakefile: ws ] ] ] ] writeGstIn: ws [ @@ -984,8 +984,8 @@ AC_OUTPUT (File name: each) withReadStreamDo: [ :rs | | pkg | [ pkg := Package parse: rs ] - on: Kernel.PackageNotAvailable - do: [ :ex | ex resume ]. + on: Kernel.PackageNotAvailable + do: [ :ex | ex resume ]. pkgName := pkg name ]. ws nextPutAll: ('GST_PACKAGE_ENABLE([%1], [%2]' % { @@ -1043,7 +1043,7 @@ Object subclass: PackageManager [ ModeClasses isNil ifTrue: [ ModeClasses := Dictionary new. Command allSubclassesDo: [ :each | - each selectionOptions do: [ :opt | + each selectionOptions do: [ :opt | ModeClasses at: opt put: each ] ] ]. ^ModeClasses @@ -1095,8 +1095,8 @@ Operation modes: Common suboptions: -n, --dry-run print commands without running them --srcdir DIR look for non-built files in directory DIR - --distdir DIR for --dist, place files in directory DIR - --destdir DIR prefix the destination directory with DIR + --distdir DIR for --dist, place files in directory DIR + --destdir DIR prefix the destination directory with DIR --target-directory DIR install the files in DIR (unused for --dist) -I, --image-file=FILE load into the specified image --kernel-dir=PATH use the specified kernel directory @@ -1129,7 +1129,15 @@ The default target directory is ', Directory image name, ' ' ] + displayHelpAndQuit: anInteger [ + + + self helpString displayOn: stderr. + ObjectMemory quit: anInteger + ] + parseArguments: args [ + args isEmpty ifTrue: [ self displayHelpAndQuit: 1 ]. Getopt "--kernel-directory and --image-file are processed by gst-tool. --no-load present for backwards compatibility, it is now the @@ -1142,11 +1150,10 @@ The default target directory is ', Directory image name, ' --update|--download --version' do: [ :opt :arg || modeClass | - opt = 'help' ifTrue: [ - self helpString displayOn: stdout. - ObjectMemory quit: 0 ]. + opt = 'help' ifTrue: [ + self displayHelpAndQuit: 0 ]. - opt = 'version' ifTrue: [ + opt = 'version' ifTrue: [ ('gst-package - %1' % {Smalltalk version}) displayNl. ObjectMemory quit: 0 ]. @@ -1159,8 +1166,7 @@ The default target directory is ', Directory image name, ' ifFalse: [ self addOption: opt argument: arg. ] ifTrue: [ self addArgument: arg ]]] ifError: [ - self helpString displayOn: stderr. - ObjectMemory quit: 1 ]. + self displayHelpAndQuit: 1 ]. ] run [