diff --git a/client/equo.py b/client/equo.py index c66d5b868..9ae1a6a2f 100644 --- a/client/equo.py +++ b/client/equo.py @@ -304,6 +304,9 @@ myopts = [ (3,'compile',2,_('compilation function')), (4,'categories',1,_('compile packages belonging to the provided categories')), (5,'--list',1,_('just list packages')), + (4,'pkgset',2,_('compile packages in provided package set names')), + (5,'--list',1,_('just list packages')), + (5,'--rebuild',1,_('rebuild everything')), (3,'orphans',2,_('scan orphaned packages on SPM')), None, diff --git a/docs/TODO b/docs/TODO index 4d04cfd50..bc7bc6620 100644 --- a/docs/TODO +++ b/docs/TODO @@ -2,8 +2,6 @@ TODO list Proposed for Entropy 1.0 (before and after) (requires API changes, perhaps): - - reagent spm pkgset-update - - equo: --verbose shows extended options? - SHA512 instead of MD5 - Improve packages injection speed diff --git a/server/reagent.py b/server/reagent.py index d8d0b5879..316039a05 100644 --- a/server/reagent.py +++ b/server/reagent.py @@ -95,6 +95,9 @@ myopts = [ (2,'compile',4,_('compilation function')), (3,'categories',2,_('compile packages belonging to the provided categories')), (4,'--list',2,_('just list packages')), + (3,'pkgset',2,_('compile packages in provided package set names')), + (4,'--list',2,_('just list packages')), + (4,'--rebuild',1,_('rebuild everything')), (2,'orphans',4,_('scan orphaned packages on SPM')), None, (1,'deptest',3,_('look for unsatisfied dependencies')), diff --git a/server/server_reagent.py b/server/server_reagent.py index e984c5a87..8c338638a 100644 --- a/server/server_reagent.py +++ b/server/server_reagent.py @@ -20,6 +20,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ''' +import subprocess from entropy.const import * from entropy.output import * from entropy.server.interfaces import Server @@ -618,9 +619,12 @@ def spm(options): opts = [] do_list = False + do_rebuild = False for opt in options: if opt == "--list": do_list = True + if opt == "--rebuild": + do_rebuild = True else: opts.append(opt) options = opts[:] @@ -632,18 +636,72 @@ def spm(options): options = options[1:] if not options: - return 0 - categories = list(set(options[1:])) - categories.sort() - packages = Entropy.SpmService.get_available_packages(categories) - packages = list(packages) - packages.sort() - if do_list: - print ' '.join(["="+x for x in packages]) - else: - os.system(etpConst['spm']['exec']+" "+etpConst['spm']['ask_cmd']+" "+etpConst['spm']['verbose_cmd']+" "+" ".join(["="+x for x in packages])) + return 1 + + if options[0] == "categories": + return spm_compile_categories(options[1:]) + elif options[0] == "pkgset": + return spm_compile_pkgset(options[1:], do_rebuild = do_rebuild) elif action == "orphans": not_found = Entropy.orphaned_spm_packages_test() return 0 + + +def spm_compile_categories(options): + + categories = sorted(set(options)) + packages = Entropy.SpmService.get_available_packages(categories) + packages = sorted(packages) + if do_list: + print ' '.join(["="+x for x in packages]) + else: + os.system(etpConst['spm']['exec']+" "+etpConst['spm']['ask_cmd']+" "+etpConst['spm']['verbose_cmd']+" "+" ".join(["="+x for x in packages])) + return 0 + +def spm_compile_pkgset(pkgsets, do_rebuild = False): + + if not pkgsets: + print_error(bold(" !!! ")+darkred("%s." % ( + _("No package sets found"),) )) + return 1 + + # filter available sets + avail_sets = Entropy.SpmService.get_sets(False) + avail_pkgsets = dict(((x,avail_sets.get(x),) for x in pkgsets \ + if x in avail_sets)) + for pkgset in pkgsets: + if pkgset not in avail_sets: + print_error(bold(" !!! ")+darkred("%s: %s" % ( + _("package set not found"),pkgset,) )) + return 1 + + extra_args = [] + if etpUi['ask']: + extra_args.append(etpConst['spm']['ask_cmd']) + if etpUi['verbose']: + extra_args.append(etpConst['spm']['verbose_cmd']) + if etpUi['pretend']: + extra_args.append(etpConst['spm']['pretend_cmd']) + + # expand package sets + for pkgset in pkgsets: + + set_pkgs = [str(x) for x in Entropy.SpmService.get_set_atoms(pkgset)] + set_atoms = [Entropy.SpmService.get_best_atom(x) for x in set_pkgs] + set_atoms = [x for x in set_atoms if x != None] + + if not do_rebuild: + set_atoms = [x for x in set_atoms if not \ + Entropy.SpmService.get_installed_atom(x)] + set_atoms = ["="+x for x in set_atoms] + + args = [etpConst['spm']['exec']] + args.extend(extra_args) + args.extend(set_atoms) + rc = subprocess.call(args) + if rc != 0: + return rc + + return 0