1- from cbuild .core import logger , paths , chroot , profile
1+ from cbuild .core import logger , paths , chroot as cbroot , profile
22
33from . import sign as asign
44
@@ -29,14 +29,14 @@ def collect_repos(mrepo, intree, arch, use_altrepo, use_stage, use_net):
2929 srepos = mrepo .rparent .source_repositories
3030
3131 if not arch :
32- arch = chroot .host_cpu ()
32+ arch = cbroot .host_cpu ()
3333
3434 prof = profile .get_profile (arch )
3535 use_cache = False
3636
3737 rrepos = set (prof .repos )
3838
39- for r in chroot .get_confrepos ():
39+ for r in cbroot .get_confrepos ():
4040 if not r .startswith ("/" ):
4141 # should be a remote repository, skip outright if we
4242 # know that remote repos will not be used during this run
@@ -81,7 +81,7 @@ def collect_repos(mrepo, intree, arch, use_altrepo, use_stage, use_net):
8181 # alt repository comes last in order to be lower priority
8282 # also, always ignore stage for altrepo, as it should be considered opaque
8383 if paths .alt_repository () and use_altrepo :
84- for r in chroot .get_confrepos ():
84+ for r in cbroot .get_confrepos ():
8585 if not r .startswith ("/" ):
8686 continue
8787 r = r .lstrip ("/" )
@@ -125,34 +125,50 @@ def call(
125125 use_stage = True ,
126126 allow_network = True ,
127127 return_repos = False ,
128+ chroot = False ,
128129):
129130 if allow_network :
130131 allow_network = _use_net
131132 cmd = [
132- paths .apk (),
133133 subcmd ,
134134 "--no-interactive" ,
135- "--root" ,
136- root if root else paths .bldroot (),
137135 "--repositories-file" ,
138136 "/dev/null" ,
139137 ]
138+ if not chroot :
139+ cmd += ["--root" , root if root else paths .bldroot ()]
140140 if arch :
141141 cmd += ["--arch" , arch ]
142142 if not allow_network :
143143 cmd += ["--no-network" ]
144144 if allow_untrusted :
145- cmd . append ( "--allow-untrusted" )
145+ cmd += [ "--allow-untrusted" ]
146146 if subcmd in ["add" , "del" , "fix" , "upgrade" ]:
147- cmd . append ( "--clean-protected" )
147+ cmd += [ "--clean-protected" ]
148148
149149 crepos = collect_repos (
150- mrepo , False , arch , use_altrepo , use_stage , allow_network
151- )
152-
153- retv = subprocess .run (
154- cmd + crepos + args , cwd = cwd , env = env , capture_output = capture_output
150+ mrepo , chroot , arch , use_altrepo , use_stage , allow_network
155151 )
152+ cmd += crepos
153+
154+ if chroot :
155+ retv = cbroot .enter (
156+ "apk" ,
157+ * cmd ,
158+ * args ,
159+ capture_output = capture_output ,
160+ fakeroot = True ,
161+ mount_binpkgs = True ,
162+ mount_cbuild_cache = subcmd
163+ in ["add" , "del" , "fix" , "update" , "upgrade" ],
164+ )
165+ else :
166+ retv = subprocess .run (
167+ [paths .apk (), * cmd , * args ],
168+ cwd = cwd ,
169+ env = env ,
170+ capture_output = capture_output ,
171+ )
156172 if return_repos :
157173 return retv , crepos
158174 return retv
@@ -177,55 +193,6 @@ def query(fields, args, mrepo, return_repos=False, **kwargs):
177193 return outv
178194
179195
180- # should never be called during stage 0 builds, only with a real chroot
181- def call_chroot (
182- subcmd ,
183- args ,
184- mrepo ,
185- capture_output = False ,
186- check = False ,
187- arch = None ,
188- allow_untrusted = False ,
189- use_stage = True ,
190- full_chroot = False ,
191- allow_network = True ,
192- ):
193- from cbuild .core import chroot
194-
195- if allow_network :
196- allow_network = _use_net
197-
198- mount_cache = subcmd in ["add" , "del" , "fix" , "update" , "upgrade" ]
199-
200- if full_chroot :
201- cmd = [subcmd ]
202- else :
203- cmd = [subcmd , "--repositories-file" , "/dev/null" ]
204- cmd .append ("--no-interactive" )
205- if arch :
206- cmd += ["--arch" , arch ]
207- if not allow_network :
208- cmd += ["--no-network" ]
209- if allow_untrusted :
210- cmd .append ("--allow-untrusted" )
211- if mount_cache and subcmd != "update" :
212- cmd .append ("--clean-protected" )
213-
214- if not full_chroot :
215- cmd += collect_repos (mrepo , True , arch , True , use_stage , allow_network )
216-
217- return chroot .enter (
218- "apk" ,
219- * cmd ,
220- * args ,
221- capture_output = capture_output ,
222- check = check ,
223- fakeroot = True ,
224- mount_binpkgs = True ,
225- mount_cbuild_cache = mount_cache ,
226- )
227-
228-
229196def get_provider (pkgn , pkg = None ):
230197 cpf = pkg .rparent .profile () if pkg else None
231198
@@ -338,10 +305,8 @@ def summarize_repo(repopath, olist, quiet=False):
338305
339306
340307def prune (repopath , arch = None , dry = False ):
341- from cbuild .core import chroot
342-
343308 if not arch :
344- arch = chroot .host_cpu ()
309+ arch = cbroot .host_cpu ()
345310
346311 repopath = repopath / arch
347312
0 commit comments