@@ -32,7 +32,20 @@ from fablib.installer import (PoolInstaller,
3232from chroot import Chroot
3333from fablib .plan import Plan , Dependency
3434from fablib import cpp , annotate , resolve , removelist
35-
35+ import logging
36+
37+ log_level = {
38+ 'DEBUG' : logging .DEBUG ,
39+ 'WARN' : logging .WARNING ,
40+ 'WARNING' : logging .WARNING ,
41+ 'INFO' : logging .INFO ,
42+ 'ERROR' : logging .ERROR ,
43+ 'ERR' : logging .ERROR ,
44+ 'CRITICAL' : logging .CRITICAL ,
45+ 'FATAL' : logging .CRITICAL ,
46+ }[os .getenv ('FAB_LOG_LEVEL' , 'warn' ).upper ()]
47+ logger = logging .getLogger ().getChild ("fab" )
48+ logger .setLevel (log_level )
3649
3750class SupportsStr (Protocol ):
3851 def __str__ (self ) -> str :
@@ -198,6 +211,18 @@ def cmd_install(
198211 env_vars_raw : Optional [str ],
199212 cpp_opts : List [Tuple [str , str ]],
200213) -> None :
214+ logger .debug (
215+ "fab-install("
216+ f"{ chroot_path = } , "
217+ f"{ packages = } , "
218+ f"{ pool_path = } , "
219+ f"{ arch = } , "
220+ f"{ no_deps = } , "
221+ f"{ apt_proxy = } , "
222+ f"{ ignore_errors_raw = } , "
223+ f"{ env_vars_raw = } , "
224+ f"{ cpp_opts = } )"
225+ )
201226 if not isdir (chroot_path ):
202227 fatal (f"no such chroot ({ chroot_path } )" )
203228
@@ -225,26 +250,52 @@ def cmd_install(
225250 else :
226251 ignore_errors = ignore_errors_raw .split (":" )
227252
253+ logger .debug (f" with environ={ environ } " )
254+ logger .debug (f" with ignore_errors={ ignore_errors } " )
255+ logger .debug (f" with pool_path={ pool_path } " )
256+
228257 plan = Plan (pool_path = pool_path )
229258 for package in packages :
230259 if package == "-" or os .path .exists (package ):
231260 plan |= Plan .init_from_file (package , cpp_opts , pool_path )
232261 else :
233262 plan .add (package )
234263
264+ logger .debug (f"plan={ plan } " )
265+
235266 installer : Installer
236267 if pool_path is not None :
237268 if no_deps :
238- packages = list (plan )
269+ pool_packages = list (plan )
270+ other_packages = []
239271 else :
240- packages = list (plan .resolve ())
272+ pool_packages , other_packages = plan .resolve ()
273+ pool_packages = list (pool_packages )
274+ logger .debug ("using PoolInstaller for " )
275+ logger .debug ('\n ' .join (map (repr , pool_packages )))
276+ # find all packages which are present in pool
277+
278+ pool_installer = PoolInstaller (chroot_path , pool_path , arch , environ )
279+ installer = LiveInstaller (chroot_path , apt_proxy , environ )
241280
242- installer = PoolInstaller (chroot_path , pool_path , arch , environ )
281+ print ("note these packages will be installed via pool:" )
282+ for pkg in pool_packages :
283+ print (f" - { pkg } " )
284+ print ("these packages will be installed via apt:" )
285+ for pkg in other_packages :
286+ print (f" - { pkg } " )
287+ pool_installer .install (pool_packages , ignore_errors )
288+ installer .install (other_packages , ignore_errors )
289+ return
243290 else :
244291 packages = list (plan )
292+ logger .debug ("using LiveInstaller for " )
293+ logger .debug ('\n ' .join (packages ))
245294 installer = LiveInstaller (chroot_path , apt_proxy , environ )
246295
296+ logger .debug ("pre package install" )
247297 installer .install (packages , ignore_errors )
298+ logger .debug ("post package install" )
248299
249300
250301def cmd_plan_annotate (pool_path : str , inplace : bool , plan_path : str ) -> None :
@@ -597,6 +648,7 @@ Environment:
597648 parser .exit (status = 1 ,
598649 message = '\n No command, options or arguments passed\n ' )
599650 args = parser .parse_args (unparsed )
651+ logger .debug (f"fab command: { ' ' .join (map (repr , unparsed ))} " )
600652
601653 if args .command == "query" :
602654 cmd_query (args .pool , args .packages )
0 commit comments