From c01a66c5ee39a08fc82b9727b26c5a24db136f47 Mon Sep 17 00:00:00 2001 From: Fabio Erculiani Date: Tue, 19 Feb 2013 17:57:18 +0000 Subject: [PATCH] [matter] add new drop-old-injected argument support. This will make possible to fully support automated injected packages bump. --- matter/matter/binpms/entropysrv.py | 53 ++++++++++++++++--- matter/matter_examples/entropy.particle | 5 ++ matter/matter_examples/fail.particle | 5 ++ matter/matter_examples/misc.particle | 5 ++ matter/matter_examples/zlib.injected.particle | 11 ++-- matter/matter_examples/zlib.particle | 11 ++++ 6 files changed, 80 insertions(+), 10 deletions(-) diff --git a/matter/matter/binpms/entropysrv.py b/matter/matter/binpms/entropysrv.py index 02eceeaac..02716dea6 100644 --- a/matter/matter/binpms/entropysrv.py +++ b/matter/matter/binpms/entropysrv.py @@ -218,6 +218,7 @@ class EntropyBinaryPMS(BaseBinaryPMS): settings, _trees, _db = self.load_emerge_config() pkgdir = settings["PKGDIR"] repository = spec["repository"] + drop_old_injected = spec["drop-old-injected"] == "yes" print_info("committing build-only packages: %s, to repository: %s" % ( ", ".join(sorted(packages)), repository,)) @@ -237,11 +238,40 @@ class EntropyBinaryPMS(BaseBinaryPMS): pkg_files = [([x], True) for x in package_files] package_ids = self._entropy.add_packages_to_repository( repository, pkg_files, ask=False) - if package_ids: - # checking dependencies and print issues - self._entropy.dependencies_test(repository) self._entropy.commit_repositories() + if package_ids: + + # drop old injected packages if they are in the + # same key + slot of the newly added ones. + # This is not atomic, but we don't actually care. + if drop_old_injected: + repo = self._entropy.open_repository(repository) + + key_slots = set() + for package_id in package_ids: + key, slot = repo.retrieveKeySlot(package_id) + key_slots.add((key, slot)) + + key_slot_package_ids = set() + for key, slot in key_slots: + ks_package_ids = [x for x in repo.searchKeySlot(key, slot) \ + if repo.isInjected(x)] + key_slot_package_ids.update(ks_package_ids) + # remove the newly added packages, of course + key_slot_package_ids -= package_ids + key_slot_package_ids = sorted(key_slot_package_ids) + if key_slot_package_ids: + print_info("removing old injected packages, " + "as per drop-old-injected:") + for package_id in key_slot_package_ids: + atom = repo.retrieveAtom(package_id) + print_info(" %s" % (atom,)) + self._entropy.remove_packages( + repository, key_slot_package_ids) + + self._entropy.dependencies_test(repository) + return exit_st def _commit(self, spec, packages): @@ -340,11 +370,11 @@ class EntropyBinaryPMS(BaseBinaryPMS): # (beside those blacklisted), since this execution is not interactive package_ids = self._entropy.add_packages_to_repository( repository, etp_pkg_files, ask=False) - if package_ids: - # checking dependencies and print issues - self._entropy.dependencies_test(repository) self._entropy.commit_repositories() + if package_ids: + self._entropy.dependencies_test(repository) + return exit_st def push(self, repository): @@ -386,7 +416,16 @@ class EntropySpecParser(MatterSpecParser): """ Overridden from MatterSpecParser. """ - return {} + return { + "drop-old-injected": { + "cb": self._funcs.valid_yes_no, + "ve": self._funcs.ve_string_stripper, + "default": "no", + "desc": "Drop older packages in the same slot when\n " + "adding an injected package. Injected packages come\n " + "into play when 'build-only: yes'", + }, + } MatterSpec.register_parser(EntropySpecParser()) diff --git a/matter/matter_examples/entropy.particle b/matter/matter_examples/entropy.particle index c32de3214..58d8c2eaf 100644 --- a/matter/matter_examples/entropy.particle +++ b/matter/matter_examples/entropy.particle @@ -39,6 +39,11 @@ stable: inherit # Default is: no # build-only: no +# Drop older packages in the same slot when adding an injected package. +# Injected packages come into play when 'build-only: yes' +# Default is: no +# drop-old-injected: no + # Allow Source Package Manager (Portage) repository change? # Valid values are either "yes" or "no" # Default is: no diff --git a/matter/matter_examples/fail.particle b/matter/matter_examples/fail.particle index edb10f320..44a0a3110 100644 --- a/matter/matter_examples/fail.particle +++ b/matter/matter_examples/fail.particle @@ -27,6 +27,11 @@ repository: community0 # Default is: no # build-only: no +# Drop older packages in the same slot when adding an injected package. +# Injected packages come into play when 'build-only: yes' +# Default is: no +# drop-old-injected: no + # Allow Source Package Manager (Portage) repository change? # Valid values are either "yes" or "no" # Default is: no diff --git a/matter/matter_examples/misc.particle b/matter/matter_examples/misc.particle index a781cf0b2..21d731aac 100644 --- a/matter/matter_examples/misc.particle +++ b/matter/matter_examples/misc.particle @@ -27,6 +27,11 @@ repository: community0 # Default is: no # build-only: no +# Drop older packages in the same slot when adding an injected package. +# Injected packages come into play when 'build-only: yes' +# Default is: no +# drop-old-injected: no + # Allow Source Package Manager (Portage) repository change? # Valid values are either "yes" or "no" # Default is: no diff --git a/matter/matter_examples/zlib.injected.particle b/matter/matter_examples/zlib.injected.particle index 52de0c7f5..79eeecb6d 100644 --- a/matter/matter_examples/zlib.injected.particle +++ b/matter/matter_examples/zlib.injected.particle @@ -3,7 +3,7 @@ # List of packages required to be built. # Comma separated, example: app-foo/bar, bar-baz/foo # Mandatory, cannot be empty -packages: sys-libs/zlib, asd-foo/foo +packages: sys-libs/zlib # Enforce stable or unstable packages on emerge. # yes = only stable packages are accepted @@ -27,6 +27,11 @@ repository: community0 # Default is: no build-only: yes +# Drop older packages in the same slot when adding an injected package. +# Injected packages come into play when 'build-only: yes' +# Default is: no +drop-old-injected: yes + # Allow Source Package Manager (Portage) repository change? # Valid values are either "yes" or "no" # Default is: no @@ -42,7 +47,7 @@ spm-repository-change-if-upstreamed: yes # Allow compiling package even if it's not actually installed on system? # Valid values are either "yes" or "no" # Default is: no -not-installed: no +not-installed: yes # Allow soft-blockers in the merge queue? Packages will be unmerged if yes. # Valid values are either "yes" or "no" @@ -62,7 +67,7 @@ dependencies: yes # Allow package downgrade? # Valid values are either "yes" or "no" # Default is: no -downgrade: no +downgrade: yes # Allow package rebuild? # Valid values are either "yes" or "no" diff --git a/matter/matter_examples/zlib.particle b/matter/matter_examples/zlib.particle index 6f179db7d..52ab8c62a 100644 --- a/matter/matter_examples/zlib.particle +++ b/matter/matter_examples/zlib.particle @@ -18,9 +18,20 @@ stable: inherit repository: community0 # Provide custom build arguments to Portage. +# --ask and --buildpkgonly are not allowed and automatically filtered. # Default is: --verbose --nospinner build-args: --verbose --nospinner +# Only build the packages without merging them into the system. +# Valid values are either "yes" or "no" +# Default is: no +# build-only: no + +# Drop older packages in the same slot when adding an injected package. +# Injected packages come into play when 'build-only: yes' +# Default is: no +# drop-old-injected: no + # Allow Source Package Manager (Portage) repository change? # Valid values are either "yes" or "no" # Default is: no