def prepare_STAGE2_job_queue(target_pkgs, pkg_dep_graph, installed_pkgs, out_dir): print('BBS> Preparing STAGE2 job queue ...', end=' ') sys.stdout.flush() stage = 'install' jobs = [] nb_target_pkgs_in_queue = nb_skipped_pkgs = 0 for pkg in pkg_dep_graph.keys(): version = None pkgdumps_prefix = pkg + '.' + stage pkgdumps = BBSbase.PkgDumps(None, pkgdumps_prefix) if pkg in target_pkgs: version = bbs.parse.get_Version_from_pkgsrctree(pkg) cmd = BBSbase.getSTAGE2cmd(pkg, version) nb_target_pkgs_in_queue += 1 else: if pkg in installed_pkgs: cmd = pkgdumps = None nb_skipped_pkgs += 1 else: cmd = BBSbase.get_install_cmd_for_non_target_pkg(pkg) job = BBSbase.InstallPkg_Job(pkg, version, cmd, pkgdumps, out_dir) jobs.append(job) nb_jobs = len(jobs) print('OK') sys.stdout.flush() nb_not_needed = len(target_pkgs) - nb_target_pkgs_in_queue nb_non_target_pkgs_in_queue = nb_jobs - nb_target_pkgs_in_queue nb_non_target_pkgs_to_install = nb_non_target_pkgs_in_queue - \ nb_skipped_pkgs nb_pkgs_to_install = nb_jobs - nb_skipped_pkgs print('BBS> Job summary:') print('BBS> | %d (out of %d) target pkgs are not supporting pkgs' % \ (nb_not_needed, len(target_pkgs))) print('BBS> | => no need to install them') print('BBS> | => they\'re not going in the installation queue') print('BBS> | %d pkgs in the installation queue (all supporting pkgs):' % \ nb_jobs) print('BBS> | o %d are target pkgs' % nb_target_pkgs_in_queue) print('BBS> | => will (re-)install them with \'R CMD INSTALL\'') print('BBS> | o %d are non-target pkgs:' % nb_non_target_pkgs_in_queue) print('BBS> | - %d are already installed' % nb_skipped_pkgs) print('BBS> | => won\'t re-install them (job will be skipped)') print('BBS> | - %d are not already installed' % \ nb_non_target_pkgs_to_install) print('BBS> | => will install them with') print('BBS> | install.packages(pkg, repos=non_target_repos,') print('BBS> | dep=FALSE, ...)') print('BBS> | Total nb of packages to install: %d' % nb_pkgs_to_install) print('BBS>') job_queue = bbs.jobs.JobQueue(stage, jobs, pkg_dep_graph) job_queue._nb_pkgs_to_install = nb_pkgs_to_install return job_queue