1616type Package = object
1717 nom, ver, url, sum, bld, run* , opt = " nil"
1818
19- proc `$` (self: Package ): string =
20- self.nom
21-
2219proc cleanPackages * () =
2320 for i in [pathLog, pathTmp]:
2421 removeDir (i)
@@ -33,29 +30,29 @@ proc parsePackage*(nom: string): Package =
3330 Toml .loadFile (path / " info" , Package )
3431
3532proc printContent (idx: int , nom, ver, cmd: string ) =
36- echo & """ { idx + 1 :<8 } { nom:24 } { ver:24 } { cmd:8 } { now ().format (" hh:mm tt" )} """
33+ echo & """ { idx + 1 :<8 } { nom:24 } { ver:24 } { cmd:8 } """ & now ().format (" hh:mm tt" )
3734
3835proc printHeader () =
3936 echo & """
40- { '~' . repeat ( 72 ) }
37+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
4138{ " idx" :8 } { " nom" :24 } { " ver" :24 } { " cmd" :8 } fin
42- { '~' . repeat ( 72 ) } """
39+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ """
4340
4441proc fetchPackages (packages: openArray [string ]) =
4542 printHeader ()
4643
4744 for idx, nom in packages:
4845 let package = parsePackage (nom)
4946
50- printContent (idx, $ package, package.ver, " fetch" )
47+ printContent (idx, package.nom , package.ver, " fetch" )
5148
5249 # Skip virtual packages
5350 if package.url == " nil" :
5451 continue
5552
5653 let
57- src = getEnv (" SRCD" ) / $ package
58- tmp = getEnv (" TMPD" ) / $ package
54+ src = getEnv (" SRCD" ) / package.nom
55+ tmp = getEnv (" TMPD" ) / package.nom
5956
6057 if package.sum == " nil" :
6158 if not dirExists (src):
@@ -92,13 +89,13 @@ proc resolveDeps(
9289 package = parsePackage (nom)
9390 dep = if run: package.run else : package.bld
9491
95- deps[$ package] =
92+ deps[package.nom ] =
9693 if dep == " nil" :
9794 @ []
9895 else :
9996 dep.split ()
10097
101- for nom in deps[$ package]:
98+ for nom in deps[package.nom ]:
10299 resolveDeps (nom, cluster, deps, run)
103100
104101 cluster &= nom
@@ -125,20 +122,22 @@ proc installPackage(
125122 skel = parsePackage (" skel" ).run
126123
127124 discard extractTar (
128- pkgCache / $ package / $ package &
125+ pkgCache / package.nom / package.nom &
129126 (if package.url == " nil" : " "
130127 else : '-' & package.ver & " .tar.zst" ),
131128 fs,
132129 )
133130
134- createDir (pkgLib / $ package)
131+ createDir (pkgLib / package.nom)
132+ copyFileWithPermissions (
133+ pkgCache / package.nom / " contents" , pkgLib / package.nom / " contents"
134+ )
135135 copyFileWithPermissions (
136- pkgCache / $ package / " contents " , pkgLib / $ package / " contents "
136+ pkgCache / package.nom / " info " , pkgLib / package.nom / " info "
137137 )
138- copyFileWithPermissions (pkgCache / $ package / " info" , pkgLib / $ package / " info" )
139138
140- if implicit and $ package notin skel:
141- writeFile (pkgLib / $ package / " implicit" , " " )
139+ if implicit and package.nom notin skel:
140+ writeFile (pkgLib / package.nom / " implicit" , " " )
142141
143142 if package.run.len () > 0 :
144143 for dep in package.run.split ():
@@ -167,35 +166,35 @@ proc buildPackages*(
167166 let
168167 package = parsePackage (nom)
169168 archive =
170- $ pkgCache / $ package / $ package &
169+ $ pkgCache / package.nom / package.nom &
171170 (if package.url == " nil" : " "
172171 else : '-' & package.ver & " .tar.zst" )
173- tmp = getEnv (" TMPD" ) / $ package
172+ tmp = getEnv (" TMPD" ) / package.nom
174173
175- printContent (idx, $ package, package.ver, " build" )
174+ printContent (idx, package.nom , package.ver, " build" )
176175
177176 if stage == $ native:
178177 # Skip installed packages
179- if dirExists (pkgLib / $ package):
178+ if dirExists (pkgLib / package.nom ):
180179 continue
181180
182181 # Skip package if archive exists
183182 if fileExists (archive):
184183 # Install build-time dependency (if not installed)
185184 if implicit:
186- installPackage ($ package, implicit = true )
185+ installPackage (package.nom , implicit = true )
187186 continue
188187
189- putEnv (" DSTD" , pkgCache / $ package / " dst" )
188+ putEnv (" DSTD" , pkgCache / package.nom / " dst" )
190189 createDir (getEnv (" DSTD" ))
191190
192191 if stage != $ toolchain:
193192 setEnvFlags ()
194193
195- if " no-lto" in $ package.opt:
194+ if " no-lto" in package.opt:
196195 setEnvFlags (lto = false )
197196
198- if " no-parallel" in $ package.opt:
197+ if " no-parallel" in package.opt:
199198 setEnvFlags (parallel = false )
200199 else :
201200 putEnv (" MAKEFLAGS" , " parallel" )
@@ -207,7 +206,7 @@ proc buildPackages*(
207206
208207 let shell = execCmdEx (
209208 & """ sh -efu -c '
210- nom={ package} ver={ package.ver} . { pathCoreRepo / $ package / (if stage == $ native: " build" else : " build" & '-' & stage)}
209+ nom={ package} ver={ package.ver} . { pathCoreRepo / package.nom / (if stage == $ native: " build" else : " build" & '-' & stage)}
211210
212211 for i in prepare configure build; do
213212 if command -v $i { shellRedirect} ; then
@@ -220,7 +219,7 @@ proc buildPackages*(
220219 )
221220
222221 writeFile (
223- getEnv (" LOGD" ) / $ package & (if stage == $ native: " " else : stage),
222+ getEnv (" LOGD" ) / package.nom & (if stage == $ native: " " else : stage),
224223 shell.output.strip (),
225224 )
226225
@@ -233,18 +232,18 @@ proc buildPackages*(
233232 status = createTarZst (archive, dst)
234233
235234 # Purge
236- # if "empty" notin $ package.opt:
235+ # if "empty" notin package.opt:
237236
238237 if status == QuitSuccess :
239- genContents (dst, $ pkgCache / $ package / " contents" )
238+ genContents (dst, $ pkgCache / package.nom / " contents" )
240239 removeDir (dst)
241240
242241 copyFileWithPermissions (
243- pathCoreRepo / $ package / " info" , pkgCache / $ package / " info"
242+ pathCoreRepo / package.nom / " info" , pkgCache / package.nom / " info"
244243 )
245244
246- if " bootstrap" in $ package.opt or implicit:
247- installPackage ($ package, implicit = true )
245+ if " bootstrap" in package.opt or implicit:
246+ installPackage (package.nom , implicit = true )
248247
249248proc installPackages * (
250249 packages: openArray [string ],
@@ -261,12 +260,12 @@ proc installPackages*(
261260 let
262261 package = parsePackage (nom)
263262 archive =
264- pkgCache / $ package / $ package &
263+ pkgCache / package.nom / package.nom &
265264 (if package.url == " nil" : " "
266265 else : '-' & package.ver & " .tar.zst" )
267266
268267 if not fileExists (archive):
269- notBuilt &= $ package
268+ notBuilt &= package.nom
270269
271270 if notBuilt.len () > 0 :
272271 buildPackages (notBuilt, implicit = true )
@@ -278,30 +277,32 @@ proc installPackages*(
278277 for idx, nom in cluster:
279278 let package = parsePackage (nom)
280279
281- printContent (idx, $ package, package.ver, " install" )
280+ printContent (idx, package.nom , package.ver, " install" )
282281
283282 # Skip installed packages
284- if dirExists (pkgLib / $ package):
285- if $ package notin packages and $ package notin skel:
286- writeFile (pkgLib / $ package / " implicit" , " " )
283+ if dirExists (pkgLib / package.nom ):
284+ if package.nom notin packages and package.nom notin skel:
285+ writeFile (pkgLib / package.nom / " implicit" , " " )
287286
288287 for nom in packages:
289288 removeFile (pkgLib / nom / " implicit" )
290289
291290 continue
292291
293292 discard extractTar (
294- pkgCache / $ package / $ package &
293+ pkgCache / package.nom / package.nom &
295294 (if package.url == " nil" : " "
296295 else : '-' & package.ver & " .tar.zst" ),
297296 fs,
298297 )
299298
300- createDir (pkgLib / $ package)
299+ createDir (pkgLib / package.nom)
300+ copyFileWithPermissions (
301+ pkgCache / package.nom / " contents" , pkgLib / package.nom / " contents"
302+ )
301303 copyFileWithPermissions (
302- pkgCache / $ package / " contents " , pkgLib / $ package / " contents "
304+ pkgCache / package.nom / " info " , pkgLib / package.nom / " info "
303305 )
304- copyFileWithPermissions (pkgCache / $ package / " info" , pkgLib / $ package / " info" )
305306
306307 if package.run.len () > 0 :
307308 for dep in package.run.split ():
@@ -330,7 +331,7 @@ proc listContents*(packages: openArray[string]) =
330331 for nom in packages.deduplicate ():
331332 let package = parsePackage (nom)
332333
333- for line in lines (pathLocalLib / $ package / " contents" ):
334+ for line in lines (pathLocalLib / package.nom / " contents" ):
334335 echo & " /{ line} "
335336
336337proc listOrphans * (pkgLib = pathLocalLib) =
@@ -374,23 +375,23 @@ proc removePackages*(packages: openArray[string], pkgLib = pathLocalLib) =
374375 for idx, nom in packages:
375376 let package = parsePackage (nom)
376377
377- printContent (idx, $ package, package.ver, " remove" )
378+ printContent (idx, package.nom , package.ver, " remove" )
378379
379- for line in lines (pathLocalLib / $ package / " contents" ):
380+ for line in lines (pathLocalLib / package.nom / " contents" ):
380381 if not line.endsWith (" /" ):
381382 removeFile (& " /{ line} " )
382383
383- for line in lines (pathLocalLib / $ package / " contents" ):
384+ for line in lines (pathLocalLib / package.nom / " contents" ):
384385 if line.endsWith (" /" ):
385386 let path = & " /{ line} "
386387
387388 if path.isEmpty ():
388389 removeDir (path)
389390
390- removeDir (pathLocalLib / $ package)
391+ removeDir (pathLocalLib / package.nom )
391392
392393 for installedPackage in walkDir (pkgLib, true , skipSpecial = true ).toSeq ().unzip ()[1 ].sorted ():
393- removeFile (pkgLib / $ installedPackage / " run" / $ package)
394+ removeFile (pkgLib / $ installedPackage / " run" / package.nom )
394395 if isEmpty (pkgLib / $ installedPackage / " run" ):
395396 removeDir (pkgLib / $ installedPackage / " run" )
396397
0 commit comments