@@ -28,28 +28,28 @@ proc cleanCache*() =
2828 removeDir (radTmp)
2929 createDir (radTmp)
3030
31- proc parseInfo * (name : string ): Package =
32- let path = coreRepo / name
31+ proc parseInfo * (nom : string ): Package =
32+ let path = coreRepo / nom
3333
3434 if not dirExists (path):
35- abort (& """ { " name " :8 } { & " \ { name \ } not found" :48 } """ )
35+ abort (& """ { " nom " :8 } { & " \ { nom \ } not found" :48 } """ )
3636
3737 result = Package ()
3838
39- for line in (path / " info" ).lines :
39+ for line in lines (path / " info" ):
4040 if line.isEmptyOrWhitespace () or line.startsWith ('#' ):
4141 continue
4242
4343 if line.contains (" = \" " ) or line.contains (" =\" " ) or '=' notin line:
44- abort (& """ { " name " :8 } { " whitespace found" :48 } """ )
44+ abort (& """ { " nom " :8 } { " whitespace found" :48 } """ )
4545
4646 let
4747 pair = line.split ('=' , 1 )
4848 key = pair[0 ]
4949 var val = pair[1 ]
5050
5151 if not (val.startsWith ('"' ) and val.endsWith ('"' )):
52- abort (& """ { " name " :8 } { " quotes not found" :48 } """ )
52+ abort (& """ { " nom " :8 } { " quotes not found" :48 } """ )
5353
5454 val = val.strip (chars = {'"' })
5555
@@ -67,15 +67,15 @@ proc parseInfo*(name: string): Package =
6767 of " opt" :
6868 result .opt = val
6969 else :
70- abort (& """ { " name " :8 } { & " \ { key\ } not found" :48 } """ )
70+ abort (& """ { " nom " :8 } { & " \ { key\ } not found" :48 } """ )
7171
72- proc printContent (idx: int , name , ver, cmd: string ) =
73- echo & """ { idx + 1 :<8 } { name :24 } { ver:24 } { cmd:8 } """ & now ().format (" hh:mm tt" )
72+ proc printContent (idx: int , nom , ver, cmd: string ) =
73+ echo & """ { idx + 1 :<8 } { nom :24 } { ver:24 } { cmd:8 } """ & now ().format (" hh:mm tt" )
7474
7575proc printHeader () =
7676 echo """
7777~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
78- idx name version cmd time
78+ idx nom ver cmd now
7979~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ """
8080
8181proc genContents (dir, contents: string ) =
@@ -104,18 +104,18 @@ proc isEmpty(dir: string): bool =
104104proc fetchPackages (packages: openArray [string ]) =
105105 printHeader ()
106106
107- for idx, name in packages:
108- let package = parseInfo (name )
107+ for idx, nom in packages:
108+ let package = parseInfo (nom )
109109
110- printContent (idx, name , package.ver, " fetch" )
110+ printContent (idx, nom , package.ver, " fetch" )
111111
112112 # Skip virtual packages
113113 if package.url == " nil" :
114114 continue
115115
116116 let
117- src = srcCache / name
118- tmp = radTmp / name
117+ src = srcCache / nom
118+ tmp = radTmp / nom
119119
120120 if package.sum == " nil" :
121121 if not dirExists (src):
@@ -134,82 +134,84 @@ proc fetchPackages(packages: openArray[string]) =
134134 discard downloadFile (package.url, src)
135135
136136 if not verifyFile (archive, package.sum):
137- abort (& """ { " sum" :8 } { name :24 } { package.ver:24 } """ )
137+ abort (& """ { " sum" :8 } { nom :24 } { package.ver:24 } """ )
138138
139139 createDir (tmp)
140140 discard extractTar (archive, tmp)
141141
142142proc resolveDeps (
143- name : string , packages: var seq [string ], deps: var Table [string , seq [string ]]
143+ nom : string , packages: var seq [string ], deps: var Table [string , seq [string ]]
144144) =
145- if name in packages:
145+ if nom in packages:
146146 return
147147
148148 let
149- package = parseInfo (name )
149+ package = parseInfo (nom )
150150 dep = package.bld
151151
152- deps[name ] =
152+ deps[nom ] =
153153 if dep == " nil" :
154154 @ []
155155 else :
156156 dep.split ()
157157
158- for name in deps[name ]:
159- resolveDeps (name , packages, deps)
158+ for nom in deps[nom ]:
159+ resolveDeps (nom , packages, deps)
160160
161- packages &= name
161+ packages &= nom
162162
163163proc sortPackages (packages: openArray [string ]): seq [string ] =
164164 var
165165 deps: Table [string , seq [string ]]
166166 sorted: seq [string ]
167167
168- for name in packages.deduplicate ():
169- resolveDeps (name , sorted, deps)
168+ for nom in packages.deduplicate ():
169+ resolveDeps (nom , sorted, deps)
170170
171171 sorted
172172
173- proc installPackage (name : string , fs = " /" , pkgCache = pkgCache) =
174- let package = parseInfo (name )
173+ proc installPackage (nom : string , fs = " /" , pkgCache = pkgCache) =
174+ let package = parseInfo (nom )
175175
176176 discard extractTar (
177- pkgCache / name / name &
177+ pkgCache / nom / nom &
178178 (if package.url == " nil" : " "
179179 else : '-' & package.ver & " .tar.zst" ),
180180 fs,
181181 )
182182
183183proc buildPackages * (packages: openArray [string ], bootstrap = false , stage = native) =
184- let queue =
185- if bootstrap:
186- packages.toSeq ()
187- else :
188- sortPackages (packages)
184+ let
185+ sorted = sortPackages (packages)
186+ queue =
187+ if bootstrap:
188+ packages.toSeq ()
189+ else :
190+ sorted
189191
190- fetchPackages (queue )
192+ fetchPackages (sorted )
191193
192194 echo " "
193195
194196 printHeader ()
195197
196- for idx, name in queue:
198+ for idx, nom in queue:
197199 let
198- package = parseInfo (name )
200+ package = parseInfo (nom )
199201 archive =
200202 if package.url == " nil" :
201- pkgCache / name / name & " .tar.zst"
203+ pkgCache / nom / nom & " .tar.zst"
202204 else :
203- pkgCache / name / name & '-' & package.ver & " .tar.zst"
205+ pkgCache / nom / nom & '-' & package.ver & " .tar.zst"
204206
205- printContent (idx, name , package.ver, " build" )
207+ printContent (idx, nom , package.ver, " build" )
206208
207209 if stage == native:
208210 # Skip package if archive exists
209211 if fileExists (archive):
210212 continue
211213
212- putEnv (" dir" , pkgCache / name / " dir" )
214+ putEnv (" dir" , pkgCache / nom / " dir" )
213215 createDir (getEnv (" dir" ))
214216
215217 const env = [
@@ -224,18 +226,19 @@ proc buildPackages*(packages: openArray[string], bootstrap = false, stage = nati
224226 (" NM" , " gcc-nm" ),
225227 (" PKG_CONFIG" , " u-config" ),
226228 (" RANLIB" , " gcc-ranlib" ),
227- (" REPO" , coreRepo),
228- (" TMPD" , radTmp),
229229 (" YACC" , " byacc" ),
230230 ]
231231
232232 for (i, j) in env:
233233 putEnv (i, j)
234234
235- if dirExists (radTmp):
236- setCurrentDir (radTmp)
237- if dirExists (radTmp / name & package.ver):
238- setCurrentDir (radTmp / name & package.ver)
235+ if bootstrap:
236+ putEnv (" PATH" , absolutePath (" ../toolchain/usr/bin" ) & PathSep & getEnv (" PATH" ))
237+
238+ if dirExists (radTmp / nom):
239+ setCurrentDir (radTmp / nom)
240+ if dirExists (radTmp / nom / nom & '-' & package.ver):
241+ setCurrentDir (radTmp / nom / nom & '-' & package.ver)
239242
240243 let env = [
241244 (" ARCH" , " x86-64" ),
@@ -273,7 +276,7 @@ proc buildPackages*(packages: openArray[string], bootstrap = false, stage = nati
273276
274277 let shell = execCmdEx (
275278 & """ sh -efu -c '
276- name= { name } ver={ package.ver} . { coreRepo / name / (if stage == native: " build" else : " build" & '-' & $ stage)}
279+ nom= { nom } ver={ package.ver} . { coreRepo / nom / (if stage == native: " build" else : " build" & '-' & $ stage)}
277280
278281 for i in prepare configure build; do
279282 if command -v $i >/dev/null 2>&1; then
@@ -286,11 +289,11 @@ proc buildPackages*(packages: openArray[string], bootstrap = false, stage = nati
286289 )
287290
288291 writeFile (
289- radLog / name & (if stage == native: " " else : '.' & $ stage), shell.output.strip ()
292+ radLog / nom & (if stage == native: " " else : '.' & $ stage), shell.output.strip ()
290293 )
291294
292295 if shell.exitCode != QuitSuccess :
293- abort (& " { shell.exitCode:<8 } { name :24 } { package.ver:24 } " )
296+ abort (& " { shell.exitCode:<8 } { nom :24 } { package.ver:24 } " )
294297
295298 if stage == native:
296299 let
@@ -301,20 +304,20 @@ proc buildPackages*(packages: openArray[string], bootstrap = false, stage = nati
301304 # if "empty" notin package.opt:
302305
303306 if status == QuitSuccess :
304- genContents (dst, pkgCache / name / " contents" )
307+ genContents (dst, pkgCache / nom / " contents" )
305308 removeDir (dst)
306309
307- copyFileWithPermissions (coreRepo / name / " info" , pkgCache / name / " info" )
310+ copyFileWithPermissions (coreRepo / nom / " info" , pkgCache / nom / " info" )
308311
309312 if " bootstrap" in package.opt:
310- installPackage (name )
313+ installPackage (nom )
311314
312315proc showInfo * (packages: openArray [string ]) =
313- for name in packages.deduplicate ():
314- let package = parseInfo (name )
316+ for nom in packages.deduplicate ():
317+ let package = parseInfo (nom )
315318
316319 echo & """
317- nom :: { name }
320+ nom :: { nom }
318321ver :: { package.ver}
319322url :: { package.url}
320323sum :: { package.sum}
@@ -335,8 +338,8 @@ proc searchPackages*(pattern: openArray[string]) =
335338 var packages: seq [string ]
336339
337340 for package in walkDir (coreRepo, true , skipSpecial = true ):
338- for name in pattern:
339- if name .toLowerAscii () in package[1 ]:
341+ for nom in pattern:
342+ if nom .toLowerAscii () in package[1 ]:
340343 packages &= package[1 ]
341344
342345 if packages.len () == 0 :
0 commit comments