1
|
1 |
"{ Package: 'stx:goodies/metacello' }"
|
|
2 |
|
|
3 |
Object subclass:#ConfigurationOf
|
|
4 |
instanceVariableNames:'project'
|
|
5 |
classVariableNames:''
|
|
6 |
poolDictionaries:''
|
|
7 |
category:'Metacello-Base'
|
|
8 |
!
|
|
9 |
|
|
10 |
|
|
11 |
!ConfigurationOf class methodsFor:'accessing'!
|
|
12 |
|
|
13 |
project
|
|
14 |
|
|
15 |
^self new project
|
|
16 |
!
|
|
17 |
|
|
18 |
validate
|
|
19 |
"Check the configuration for Errors, Critical Warnings, and Warnings (see class comment for MetacelloMCVersionValidator for more information).
|
|
20 |
Errors identify specification issues that will result in unexpected behaviour when you load the configuration.
|
|
21 |
Critical Warnings identify specification issues that may result in unexpected behavior when you load the configuration.
|
|
22 |
Warnings identify specification issues that are technically correct, but are worth take a look at."
|
|
23 |
|
|
24 |
"self validate"
|
|
25 |
|
|
26 |
<apiDocumentation>
|
|
27 |
self ensureMetacello.
|
|
28 |
^ ((Smalltalk at: #MetacelloToolBox) validateConfiguration: self debug: #() recurse: false) explore
|
|
29 |
! !
|
|
30 |
|
|
31 |
!ConfigurationOf class methodsFor:'private'!
|
|
32 |
|
|
33 |
bootstrapMetacelloFrom: repositoryUrl
|
|
34 |
"Corresponds to version 1.0-beta.32.2"
|
|
35 |
|
|
36 |
"KEEP MetacelloConfigTemplate class>>ensureMetacelloBaseConfiguration in synch!!"
|
|
37 |
|
|
38 |
| platformPkg |
|
|
39 |
self ensureGoferVersion: 'Gofer-Core-lr.115' repositoryUrl: repositoryUrl.
|
|
40 |
#('Metacello-Base-dkh.96' 'Metacello-Core-dkh.664' 'Metacello-MC-dkh.656')
|
|
41 |
do: [ :pkg | self bootstrapPackage: pkg from: repositoryUrl ].
|
|
42 |
platformPkg := Smalltalk
|
|
43 |
at: #'SystemVersion'
|
|
44 |
ifPresent: [ :cl |
|
|
45 |
| versionString |
|
|
46 |
versionString := cl current version.
|
|
47 |
(versionString beginsWith: 'Squeak')
|
|
48 |
ifTrue: [
|
|
49 |
(versionString beginsWith: 'Squeak3')
|
|
50 |
ifTrue: [ 'Metacello-Platform.squeak-dkh.5' ]
|
|
51 |
ifFalse: [ 'Metacello-Platform.squeak-dkh.13' ] ]
|
|
52 |
ifFalse: [
|
|
53 |
(versionString beginsWith: 'Pharo')
|
|
54 |
ifTrue: [ 'Metacello-Platform.pharo-dkh.27' ] ] ].
|
|
55 |
self bootstrapPackage: platformPkg from: repositoryUrl
|
|
56 |
!
|
|
57 |
|
|
58 |
bootstrapPackage: aString from: aPath
|
|
59 |
| repository version |
|
|
60 |
repository := (MCCacheRepository default includesVersionNamed: aString)
|
|
61 |
ifTrue: [MCCacheRepository default]
|
|
62 |
ifFalse: [MCHttpRepository
|
|
63 |
location: aPath
|
|
64 |
user: ''
|
|
65 |
password: ''].
|
|
66 |
repository
|
|
67 |
versionReaderForFileNamed: aString , '.mcz'
|
|
68 |
do: [:reader |
|
|
69 |
version := reader version.
|
|
70 |
version load.
|
|
71 |
version workingCopy repositoryGroup addRepository: repository]
|
|
72 |
!
|
|
73 |
|
|
74 |
ensureGoferVersion: goferVersion repositoryUrl: repositoryUrl
|
|
75 |
"load the p=file goferVersion if Gofer isn't loaded or an earlier version of Gofer is currently loaded"
|
|
76 |
|
|
77 |
| goferVersionNumber wc pName |
|
|
78 |
(Smalltalk at: #'Gofer' ifAbsent: [ ]) == nil
|
|
79 |
ifTrue: [ ^ self bootstrapPackage: goferVersion from: repositoryUrl ].
|
|
80 |
goferVersionNumber := (goferVersion copyAfterLast: $.) asNumber.
|
|
81 |
wc := [ ((Smalltalk at: #'GoferPackageReference') name: 'Gofer') workingCopy ]
|
|
82 |
on: Error
|
|
83 |
do: [ :ex | ex return: ((Smalltalk at: #'GoferPackageReference') name: 'Gofer-Core') workingCopy ].
|
|
84 |
pName := wc ancestry ancestors first name.
|
|
85 |
(pName copyAfterLast: $.) asNumber <= goferVersionNumber
|
|
86 |
ifTrue: [ self bootstrapPackage: goferVersion from: repositoryUrl ]
|
|
87 |
!
|
|
88 |
|
|
89 |
ensureMetacello
|
|
90 |
"Bootstrap Metacello and load the 'botstrap' group"
|
|
91 |
|
|
92 |
self ensureMetacello: #('batch')
|
|
93 |
!
|
|
94 |
|
|
95 |
ensureMetacello: loadList
|
|
96 |
"Bootstrap Metacello, retry using alternate repository, if primary repository is not accessible"
|
|
97 |
|
|
98 |
Smalltalk
|
|
99 |
at: #'MetacelloProject'
|
|
100 |
ifAbsent: [
|
|
101 |
| retry version error gofer |
|
|
102 |
retry := false.
|
|
103 |
(Array with: 'http://seaside.gemstone.com/ss/metacello' with: 'http://www.squeaksource.com/metacello')
|
|
104 |
do: [ :repositoryUrl |
|
|
105 |
[
|
|
106 |
"bootstrap Metacello"
|
|
107 |
self bootstrapMetacelloFrom: repositoryUrl.
|
|
108 |
Smalltalk
|
|
109 |
at: #'ConfigurationOfMetacello'
|
|
110 |
ifAbsent: [
|
|
111 |
gofer := (Smalltalk at: #'Gofer') new.
|
|
112 |
gofer
|
|
113 |
perform: #'url:' with: repositoryUrl;
|
|
114 |
perform: #'package:' with: 'ConfigurationOfMetacello';
|
|
115 |
perform: #'load' ].
|
|
116 |
version := (Smalltalk at: #'ConfigurationOfMetacello') project version: '1.0-beta.32'. "bootstrap with 1.0-beta.32"
|
|
117 |
retry
|
|
118 |
ifTrue: [
|
|
119 |
"on retry, use #repositoryOverrides:"
|
|
120 |
version
|
|
121 |
repositoryOverrides:
|
|
122 |
(Array with: (MCHttpRepository location: repositoryUrl user: '' password: '')) ].
|
|
123 |
version load: loadList.
|
|
124 |
gofer := (Smalltalk at: #'Gofer') new.
|
|
125 |
Smalltalk
|
|
126 |
at: #'ConfigurationOfMetacelloPreview'
|
|
127 |
ifAbsent: [
|
|
128 |
gofer
|
|
129 |
perform: #'url:' with: repositoryUrl;
|
|
130 |
perform: #'package:' with: 'ConfigurationOfMetacelloPreview';
|
|
131 |
perform: #'load' ].
|
|
132 |
version := (Smalltalk at: #'ConfigurationOfMetacelloPreview') project version: '1.0.0-beta.32.2'. "load latest from GitHub"
|
|
133 |
version load: loadList.
|
|
134 |
^ self ]
|
|
135 |
on: Error
|
|
136 |
do: [ :ex |
|
|
137 |
error := ex.
|
|
138 |
Transcript
|
|
139 |
cr;
|
|
140 |
show: 'failed ensureMetacello: ';
|
|
141 |
show: ex description printString;
|
|
142 |
show: '...retrying'. "try again"
|
|
143 |
retry := true.
|
|
144 |
ex return: nil ] ]. "shouldn't get here unless the load failed ... throw an error"
|
|
145 |
self error: 'retry with alternate repository failed: ' , error description printString ]
|
|
146 |
! !
|
|
147 |
|
|
148 |
!ConfigurationOf class methodsFor:'unloading Metacello'!
|
|
149 |
|
|
150 |
unloadMetacello
|
|
151 |
"Unload the classes that implement Metacello. Metacello is not needed once a project has been loaded, so it can safely be unloaded."
|
|
152 |
|
|
153 |
"self unloadMetacello"
|
|
154 |
|
|
155 |
<apiDocumentation>
|
|
156 |
| gofer |
|
|
157 |
gofer := (Smalltalk at: #Gofer) new.
|
|
158 |
MCWorkingCopy allManagers do: [:wc |
|
|
159 |
((wc packageName beginsWith: 'Metacello') or: [ wc packageName beginsWith: 'OB-Metacello' ])
|
|
160 |
ifTrue: [ gofer package: wc packageName ]].
|
|
161 |
gofer unload.
|
|
162 |
! !
|
|
163 |
|
|
164 |
!ConfigurationOf methodsFor:'accessing'!
|
|
165 |
|
|
166 |
customProjectAttributes
|
|
167 |
"Edit to return a collection of any custom attributes e.g. for conditional loading: Array with: #'Condition1' with: #'Condition2.
|
|
168 |
For more information see: http://code.google.com/p/metacello/wiki/CustomProjectAttrributes "
|
|
169 |
|
|
170 |
^ #()
|
|
171 |
!
|
|
172 |
|
|
173 |
project
|
|
174 |
^ project
|
|
175 |
ifNil: [
|
|
176 |
"Bootstrap Metacello if it is not already loaded"
|
|
177 |
self class ensureMetacello.
|
|
178 |
project := self projectClass new projectAttributes: self customProjectAttributes. "Create the Metacello project"
|
|
179 |
project versionNumberClass: self versionNumberClass.
|
|
180 |
project class versionConstructorClass on: self project: project. "Construct the project"
|
|
181 |
project loadType: #'linear'. "change to #atomic if desired"
|
|
182 |
project ]
|
|
183 |
!
|
|
184 |
|
|
185 |
project: aProject
|
|
186 |
|
|
187 |
project ifNil: [ self class ensureMetacello ].
|
|
188 |
project := aProject
|
|
189 |
!
|
|
190 |
|
|
191 |
projectClass
|
|
192 |
^ MetacelloMCProject
|
|
193 |
!
|
|
194 |
|
|
195 |
versionNumberClass
|
|
196 |
^ MetacelloSemanticVersionNumber
|
|
197 |
! !
|
|
198 |
|
|
199 |
!ConfigurationOf methodsFor:'defaults'!
|
|
200 |
|
|
201 |
bleedingEdge
|
|
202 |
"override if different behavior desired.
|
|
203 |
Use:
|
|
204 |
self versionDoesNotExistError: #bleedingEdge
|
|
205 |
if #bleedingEdge version is disallowed."
|
|
206 |
|
|
207 |
<defaultSymbolicVersion: #bleedingEdge>
|
|
208 |
|
|
209 |
^self defaultBleedingEdgeVersion
|
|
210 |
!
|
|
211 |
|
|
212 |
defaultBleedingEdgeVersion
|
|
213 |
| bleedingEdgeVersion |
|
|
214 |
bleedingEdgeVersion := (self project map values select: [ :version | version blessing == #baseline ])
|
|
215 |
detectMax: [ :version | version ].
|
|
216 |
bleedingEdgeVersion ifNil: [ ^#'notDefined' ].
|
|
217 |
^ bleedingEdgeVersion versionString
|
|
218 |
! !
|
|
219 |
|
|
220 |
!ConfigurationOf methodsFor:'private'!
|
|
221 |
|
|
222 |
versionDoesNotExistError: versionStringOrSymbol
|
|
223 |
|
|
224 |
((Smalltalk at: #MetacelloSymbolicVersionDoesNotExistError) project: self project versionString: versionStringOrSymbol) signal
|
|
225 |
! !
|
|
226 |
|
|
227 |
!ConfigurationOf class methodsFor:'documentation'!
|
|
228 |
|
|
229 |
version_SVN
|
|
230 |
^ '$Id:: $'
|
|
231 |
! !
|