From: "André Erdmann" <dywi@mailerd.de> To: gentoo-commits@lists.gentoo.org Subject: [gentoo-commits] proj/R_overlay:master commit in: roverlay/overlay/ Date: Thu, 13 Jun 2013 16:34:28 +0000 (UTC) [thread overview] Message-ID: <1370455329.fc3eeb0f06119515f8db68311183172923423ded.dywi@gentoo> (raw) commit: fc3eeb0f06119515f8db68311183172923423ded Author: André Erdmann <dywi <AT> mailerd <DOT> de> AuthorDate: Wed Jun 5 18:02:09 2013 +0000 Commit: André Erdmann <dywi <AT> mailerd <DOT> de> CommitDate: Wed Jun 5 18:02:09 2013 +0000 URL: http://git.overlays.gentoo.org/gitweb/?p=proj/R_overlay.git;a=commit;h=fc3eeb0f overlay: fix dynpool rules, remove moved ebuilds --- roverlay/overlay/category.py | 44 +++++++++++++++++++----- roverlay/overlay/creator.py | 6 ++++ roverlay/overlay/root.py | 82 ++++++++++++++++++++++++++++++++++++++++++-- 3 files changed, 120 insertions(+), 12 deletions(-) diff --git a/roverlay/overlay/category.py b/roverlay/overlay/category.py index 2d9b93d..baca2d1 100644 --- a/roverlay/overlay/category.py +++ b/roverlay/overlay/category.py @@ -90,6 +90,12 @@ class Category ( object ): ) # --- end of add (...) --- + def drop_package ( self, name ): + p = self._subdirs [name] + del self._subdirs [name] + p.fs_destroy() + # --- end of drop_package (...) --- + def empty ( self ): """Returns True if this category contains 0 ebuilds.""" return ( @@ -98,6 +104,11 @@ class Category ( object ): ) # --- end of empty (...) --- + def get_nonempty ( self, name ): + subdir = self._subdirs.get ( name, None ) + return subdir if ( subdir and not subdir.empty() ) else None + # --- end of has_nonempty (...) --- + def has ( self, subdir ): return subdir in self._subdirs # --- end of has (...) --- @@ -106,22 +117,37 @@ class Category ( object ): return os.path.isdir ( self.physical_location + os.sep + _dir ) # --- end of has_category (...) --- - def list_packages ( self, for_deprules=False ): + def list_package_names ( self ): + for name, subdir in self._subdirs.items(): + if not subdir.empty(): + yield name + # --- end of list_package_names (...) --- + + def list_packages ( self, + for_deprules=False, is_default_category=False + ): """Lists all packages in this category. Yields <category>/<package name> or a dict (see for_deprules below). arguments: - * for_deprules -- if set and True: - yield keyword args for dependency rules + * for_deprules -- if set and True: + yield keyword args for dependency rules + * is_default_category -- bool indicating whether this category is the + default one or not """ - - for name, subdir in self._subdirs.items(): - if not subdir.empty(): - if for_deprules: + if for_deprules: + for name, subdir in self._subdirs.items(): + if not subdir.empty(): yield dict ( - dep_str=name, resolving_package=self.name + os.sep + name + dep_str = name, + resolving_package = ( self.name + "/" + name ), + is_selfdep = is_default_category, + # prefer packages from the default category (really?) + priority = 80 if is_default_category else 90, ) - else: + else: + for name, subdir in self._subdirs.items(): + if not subdir.empty(): yield self.name + os.sep + name # --- end of list_packages (...) --- diff --git a/roverlay/overlay/creator.py b/roverlay/overlay/creator.py index 8833aef..5ad86d4 100644 --- a/roverlay/overlay/creator.py +++ b/roverlay/overlay/creator.py @@ -274,6 +274,12 @@ class OverlayCreator ( object ): del self.package_rules # --- end of release_package_rules (...) --- + def remove_moved_ebuilds ( self, reverse ): + """See overlay.root.Overlay.remove_moved_ebuilds().""" + if self.overlay.remove_duplicate_ebuilds ( reverse=reverse ): + self.depresolver.reload_pools() + # --- end of remove_moved_ebuilds (...) --- + def add_package ( self, package_info ): """Adds a PackageInfo to the package queue. diff --git a/roverlay/overlay/root.py b/roverlay/overlay/root.py index 3adbb6e..b9030d2 100644 --- a/roverlay/overlay/root.py +++ b/roverlay/overlay/root.py @@ -259,7 +259,9 @@ class Overlay ( object ): write_profiles_file ( 'repo_name', self.name + '\n' ) # profiles/categories - cats = '\n'.join ( self._categories.keys() ) + cats = '\n'.join ( + k for k, v in self._categories.items() if not v.empty() + ) if cats: write_profiles_file ( 'categories', cats + '\n' ) @@ -319,6 +321,78 @@ class Overlay ( object ): return os.path.isdir ( self.physical_location + os.sep + _dir ) # --- end of has_category (...) --- + def find_duplicate_packages ( self, _default_category=None ): + default_category = ( + _default_category if _default_category is None + else self._categories.get ( self.default_category, None ) + ) + + if default_category: + duplicate_pkg = set() + + for category in self._categories.values(): + if category is not default_category: + for name in category.list_package_names(): + if default_category.get_nonempty ( name ): + duplicate_pkg.add ( name ) + # -- end for; + + return frozenset ( duplicate_pkg ) + else: + return None + # --- end of find_duplicate_packages (...) --- + + def remove_duplicate_ebuilds ( self, reverse ): + default_category = self._categories.get ( self.default_category, None ) + if default_category: + if reverse: + d_pkg = self.find_duplicate_packages ( + _default_category=default_category + ) + for pkg_name in d_pkg: + default_category.drop_package ( pkg_name ) + + else: + d_pkg = set() + for category in self._categories.values(): + if category is not default_category: + for name in category.list_package_names(): + if default_category.get_nonempty ( name ): + d_pkg.add ( name ) + category.drop_package ( pkg_name ) + # -- end for category; + + # -- end if; + + if d_pkg: + self.remove_empty_categories() + + self.logger.info ( + '{} ebuilds have been removed from the default category, ' + 'the overlay might be broken now!'.format ( len ( d_pkg ) ) + ) + return True + else: + return False + else: + return False + + # --- end of remove_duplicate_ebuilds (...) --- + + def remove_empty_categories ( self ): + catlist = self._categories.items() + for cat in catlist: + cat[1].remove_empty() + if cat[1].empty(): + del self._categories [cat[0]] + + try: + os.rmdir ( cat [1].physical_location ) + except OSError as ose: + self.logger.exception ( ose ) + + # --- end of remove_empty_categories (...) --- + def list_packages ( self, for_deprules=True ): for cat in self._categories.values(): for package in cat.list_packages ( for_deprules=for_deprules ): @@ -326,9 +400,11 @@ class Overlay ( object ): # --- end of list_packages (...) --- def list_rule_kwargs ( self ): - # FIXME/TODO: depres has to recognize categories for cat in self._categories.values(): - for kwargs in cat.list_packages ( for_deprules=True ): + for kwargs in cat.list_packages ( + for_deprules = True, + is_default_category = ( cat.name is self.default_category ) + ): yield kwargs # --- end of list_rule_kwargs (...) ---
WARNING: multiple messages have this Message-ID (diff)
From: "André Erdmann" <dywi@mailerd.de> To: gentoo-commits@lists.gentoo.org Subject: [gentoo-commits] proj/R_overlay:gsoc13/next commit in: roverlay/overlay/ Date: Wed, 5 Jun 2013 18:08:42 +0000 (UTC) [thread overview] Message-ID: <1370455329.fc3eeb0f06119515f8db68311183172923423ded.dywi@gentoo> (raw) Message-ID: <20130605180842.rW9a7XmTAVEZPCd6stL4GZ9ULDpJd3_HNNPl2lLclK0@z> (raw) commit: fc3eeb0f06119515f8db68311183172923423ded Author: André Erdmann <dywi <AT> mailerd <DOT> de> AuthorDate: Wed Jun 5 18:02:09 2013 +0000 Commit: André Erdmann <dywi <AT> mailerd <DOT> de> CommitDate: Wed Jun 5 18:02:09 2013 +0000 URL: http://git.overlays.gentoo.org/gitweb/?p=proj/R_overlay.git;a=commit;h=fc3eeb0f overlay: fix dynpool rules, remove moved ebuilds --- roverlay/overlay/category.py | 44 +++++++++++++++++++----- roverlay/overlay/creator.py | 6 ++++ roverlay/overlay/root.py | 82 ++++++++++++++++++++++++++++++++++++++++++-- 3 files changed, 120 insertions(+), 12 deletions(-) diff --git a/roverlay/overlay/category.py b/roverlay/overlay/category.py index 2d9b93d..baca2d1 100644 --- a/roverlay/overlay/category.py +++ b/roverlay/overlay/category.py @@ -90,6 +90,12 @@ class Category ( object ): ) # --- end of add (...) --- + def drop_package ( self, name ): + p = self._subdirs [name] + del self._subdirs [name] + p.fs_destroy() + # --- end of drop_package (...) --- + def empty ( self ): """Returns True if this category contains 0 ebuilds.""" return ( @@ -98,6 +104,11 @@ class Category ( object ): ) # --- end of empty (...) --- + def get_nonempty ( self, name ): + subdir = self._subdirs.get ( name, None ) + return subdir if ( subdir and not subdir.empty() ) else None + # --- end of has_nonempty (...) --- + def has ( self, subdir ): return subdir in self._subdirs # --- end of has (...) --- @@ -106,22 +117,37 @@ class Category ( object ): return os.path.isdir ( self.physical_location + os.sep + _dir ) # --- end of has_category (...) --- - def list_packages ( self, for_deprules=False ): + def list_package_names ( self ): + for name, subdir in self._subdirs.items(): + if not subdir.empty(): + yield name + # --- end of list_package_names (...) --- + + def list_packages ( self, + for_deprules=False, is_default_category=False + ): """Lists all packages in this category. Yields <category>/<package name> or a dict (see for_deprules below). arguments: - * for_deprules -- if set and True: - yield keyword args for dependency rules + * for_deprules -- if set and True: + yield keyword args for dependency rules + * is_default_category -- bool indicating whether this category is the + default one or not """ - - for name, subdir in self._subdirs.items(): - if not subdir.empty(): - if for_deprules: + if for_deprules: + for name, subdir in self._subdirs.items(): + if not subdir.empty(): yield dict ( - dep_str=name, resolving_package=self.name + os.sep + name + dep_str = name, + resolving_package = ( self.name + "/" + name ), + is_selfdep = is_default_category, + # prefer packages from the default category (really?) + priority = 80 if is_default_category else 90, ) - else: + else: + for name, subdir in self._subdirs.items(): + if not subdir.empty(): yield self.name + os.sep + name # --- end of list_packages (...) --- diff --git a/roverlay/overlay/creator.py b/roverlay/overlay/creator.py index 8833aef..5ad86d4 100644 --- a/roverlay/overlay/creator.py +++ b/roverlay/overlay/creator.py @@ -274,6 +274,12 @@ class OverlayCreator ( object ): del self.package_rules # --- end of release_package_rules (...) --- + def remove_moved_ebuilds ( self, reverse ): + """See overlay.root.Overlay.remove_moved_ebuilds().""" + if self.overlay.remove_duplicate_ebuilds ( reverse=reverse ): + self.depresolver.reload_pools() + # --- end of remove_moved_ebuilds (...) --- + def add_package ( self, package_info ): """Adds a PackageInfo to the package queue. diff --git a/roverlay/overlay/root.py b/roverlay/overlay/root.py index 3adbb6e..b9030d2 100644 --- a/roverlay/overlay/root.py +++ b/roverlay/overlay/root.py @@ -259,7 +259,9 @@ class Overlay ( object ): write_profiles_file ( 'repo_name', self.name + '\n' ) # profiles/categories - cats = '\n'.join ( self._categories.keys() ) + cats = '\n'.join ( + k for k, v in self._categories.items() if not v.empty() + ) if cats: write_profiles_file ( 'categories', cats + '\n' ) @@ -319,6 +321,78 @@ class Overlay ( object ): return os.path.isdir ( self.physical_location + os.sep + _dir ) # --- end of has_category (...) --- + def find_duplicate_packages ( self, _default_category=None ): + default_category = ( + _default_category if _default_category is None + else self._categories.get ( self.default_category, None ) + ) + + if default_category: + duplicate_pkg = set() + + for category in self._categories.values(): + if category is not default_category: + for name in category.list_package_names(): + if default_category.get_nonempty ( name ): + duplicate_pkg.add ( name ) + # -- end for; + + return frozenset ( duplicate_pkg ) + else: + return None + # --- end of find_duplicate_packages (...) --- + + def remove_duplicate_ebuilds ( self, reverse ): + default_category = self._categories.get ( self.default_category, None ) + if default_category: + if reverse: + d_pkg = self.find_duplicate_packages ( + _default_category=default_category + ) + for pkg_name in d_pkg: + default_category.drop_package ( pkg_name ) + + else: + d_pkg = set() + for category in self._categories.values(): + if category is not default_category: + for name in category.list_package_names(): + if default_category.get_nonempty ( name ): + d_pkg.add ( name ) + category.drop_package ( pkg_name ) + # -- end for category; + + # -- end if; + + if d_pkg: + self.remove_empty_categories() + + self.logger.info ( + '{} ebuilds have been removed from the default category, ' + 'the overlay might be broken now!'.format ( len ( d_pkg ) ) + ) + return True + else: + return False + else: + return False + + # --- end of remove_duplicate_ebuilds (...) --- + + def remove_empty_categories ( self ): + catlist = self._categories.items() + for cat in catlist: + cat[1].remove_empty() + if cat[1].empty(): + del self._categories [cat[0]] + + try: + os.rmdir ( cat [1].physical_location ) + except OSError as ose: + self.logger.exception ( ose ) + + # --- end of remove_empty_categories (...) --- + def list_packages ( self, for_deprules=True ): for cat in self._categories.values(): for package in cat.list_packages ( for_deprules=for_deprules ): @@ -326,9 +400,11 @@ class Overlay ( object ): # --- end of list_packages (...) --- def list_rule_kwargs ( self ): - # FIXME/TODO: depres has to recognize categories for cat in self._categories.values(): - for kwargs in cat.list_packages ( for_deprules=True ): + for kwargs in cat.list_packages ( + for_deprules = True, + is_default_category = ( cat.name is self.default_category ) + ): yield kwargs # --- end of list_rule_kwargs (...) ---
next reply other threads:[~2013-06-13 16:34 UTC|newest] Thread overview: 42+ messages / expand[flat|nested] mbox.gz Atom feed top 2013-06-13 16:34 André Erdmann [this message] 2013-06-05 18:08 ` [gentoo-commits] proj/R_overlay:gsoc13/next commit in: roverlay/overlay/ André Erdmann -- strict thread matches above, loose matches on Subject: below -- 2014-08-23 19:03 [gentoo-commits] proj/R_overlay:master " André Erdmann 2014-07-29 18:29 ` André Erdmann 2014-07-18 16:20 André Erdmann 2014-07-18 2:28 [gentoo-commits] proj/R_overlay:wip/addition_control " André Erdmann 2014-07-18 16:20 ` [gentoo-commits] proj/R_overlay:master " André Erdmann 2014-07-18 2:28 [gentoo-commits] proj/R_overlay:wip/addition_control " André Erdmann 2014-07-18 16:20 ` [gentoo-commits] proj/R_overlay:master " André Erdmann 2014-04-01 16:38 André Erdmann 2013-09-18 14:00 André Erdmann 2013-09-17 13:49 André Erdmann 2013-09-03 15:51 André Erdmann 2013-09-03 13:15 André Erdmann 2013-09-03 8:35 André Erdmann 2013-09-02 16:21 André Erdmann 2013-09-02 16:21 André Erdmann 2013-08-29 12:36 André Erdmann 2013-08-20 21:46 André Erdmann 2013-08-20 21:46 André Erdmann 2013-07-29 14:56 André Erdmann 2013-07-10 15:10 [gentoo-commits] proj/R_overlay:gsoc13/next " André Erdmann 2013-07-10 16:16 ` [gentoo-commits] proj/R_overlay:master " André Erdmann 2013-06-22 15:24 André Erdmann 2013-06-18 14:12 André Erdmann 2013-04-25 16:44 André Erdmann 2013-04-25 16:44 André Erdmann 2013-02-09 21:28 André Erdmann 2013-02-09 20:45 André Erdmann 2013-02-09 20:45 André Erdmann 2013-01-30 20:16 André Erdmann 2012-08-17 17:26 André Erdmann 2012-08-03 13:38 André Erdmann 2012-08-01 21:10 André Erdmann 2012-07-30 15:53 André Erdmann 2012-07-30 8:52 André Erdmann 2012-07-30 8:52 André Erdmann 2012-07-24 16:59 [gentoo-commits] proj/R_overlay:overlay_wip " André Erdmann 2012-07-30 8:52 ` [gentoo-commits] proj/R_overlay:master " André Erdmann 2012-07-05 16:00 André Erdmann 2012-07-04 18:21 André Erdmann 2012-07-03 17:48 André Erdmann 2012-06-27 14:46 André Erdmann 2012-06-26 15:42 André Erdmann 2012-06-22 18:13 André Erdmann 2012-06-21 16:55 André Erdmann
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=1370455329.fc3eeb0f06119515f8db68311183172923423ded.dywi@gentoo \ --to=dywi@mailerd.de \ --cc=gentoo-commits@lists.gentoo.org \ --cc=gentoo-dev@lists.gentoo.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox