From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) by finch.gentoo.org (Postfix) with ESMTP id 7286C1393EA for ; Fri, 30 May 2014 13:03:35 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id EF0D2E0887; Fri, 30 May 2014 13:03:34 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id 225F0E0887 for ; Fri, 30 May 2014 13:03:34 +0000 (UTC) Received: from spoonbill.gentoo.org (spoonbill.gentoo.org [81.93.255.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 1020033FDBF for ; Fri, 30 May 2014 13:03:33 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by spoonbill.gentoo.org (Postfix) with ESMTP id B7143182D4 for ; Fri, 30 May 2014 13:03:31 +0000 (UTC) From: "Brian Dolbec" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Brian Dolbec" Message-ID: <1401212868.c74159c33da8945c45b98974274d3db17b882b44.dol-sen@gentoo> Subject: [gentoo-commits] proj/portage:repoman commit in: pym/repoman/, pym/repoman/checks/ebuilds/ X-VCS-Repository: proj/portage X-VCS-Files: pym/repoman/checks/ebuilds/manifests.py pym/repoman/main.py X-VCS-Directories: pym/repoman/ pym/repoman/checks/ebuilds/ X-VCS-Committer: dol-sen X-VCS-Committer-Name: Brian Dolbec X-VCS-Revision: c74159c33da8945c45b98974274d3db17b882b44 X-VCS-Branch: repoman Date: Fri, 30 May 2014 13:03:31 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Archives-Salt: bfcbc8dd-cc01-4769-9c8c-f15a09c752e4 X-Archives-Hash: 8f26bcf923518cf6c18e4127e326d874 commit: c74159c33da8945c45b98974274d3db17b882b44 Author: Brian Dolbec gentoo org> AuthorDate: Tue May 27 17:33:12 2014 +0000 Commit: Brian Dolbec gmail com> CommitDate: Tue May 27 17:47:48 2014 +0000 URL: http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=c74159c3 repoman/main.py: Create checks/ebuilds/manifests.py and Manifests class This moves manifest checks and creation to it's own class --- pym/repoman/checks/ebuilds/manifests.py | 91 +++++++++++++++++++++++++++++++++ pym/repoman/main.py | 76 +++------------------------ 2 files changed, 99 insertions(+), 68 deletions(-) diff --git a/pym/repoman/checks/ebuilds/manifests.py b/pym/repoman/checks/ebuilds/manifests.py new file mode 100644 index 0000000..53c3136 --- /dev/null +++ b/pym/repoman/checks/ebuilds/manifests.py @@ -0,0 +1,91 @@ + +import logging +import sys + +import portage +from portage import os +from portage.package.ebuild.digestgen import digestgen +from portage.util import writemsg_level + + +class Manifests(object): + + + def __init__(self, options, repoman_settings): + self.options = options + self.repoman_settings = repoman_settings + + self.digest_only = options.mode != 'manifest-check' and options.digest == 'y' + self.generated_manifest = False + + + def run(self, checkdir, portdb): + if self.options.pretend: + return False + if self.options.mode in ("manifest", 'commit', 'fix') or self.digest_only: + failed = False + self.auto_assumed = set() + fetchlist_dict = portage.FetchlistDict( + checkdir, self.repoman_settings, portdb) + if self.options.mode == 'manifest' and self.options.force: + portage._doebuild_manifest_exempt_depend += 1 + self.create_manifest(checkdir, fetchlist_dict) + self.repoman_settings["O"] = checkdir + try: + self.generated_manifest = digestgen( + mysettings=self.repoman_settings, myportdb=portdb) + except portage.exception.PermissionDenied as e: + self.generated_manifest = False + writemsg_level( + "!!! Permission denied: '%s'\n" % (e,), + level=logging.ERROR, noiselevel=-1) + + if not self.generated_manifest: + print("Unable to generate manifest.") + failed = True + + if self.options.mode == "manifest": + if not failed and self.options.force and self.auto_assumed and \ + 'assume-digests' in self.repoman_settings.features: + # Show which digests were assumed despite the --force option + # being given. This output will already have been shown by + # digestgen() if assume-digests is not enabled, so only show + # it here if assume-digests is enabled. + pkgs = list(fetchlist_dict) + pkgs.sort() + portage.writemsg_stdout( + " digest.assumed %s" % + portage.output.colorize( + "WARN", str(len(self.auto_assumed)).rjust(18)) + "\n") + for cpv in pkgs: + fetchmap = fetchlist_dict[cpv] + pf = portage.catsplit(cpv)[1] + for distfile in sorted(fetchmap): + if distfile in self.auto_assumed: + portage.writemsg_stdout( + " %s::%s\n" % (pf, distfile)) + + return True # continue, skip remaining loop code + elif failed: + sys.exit(1) + return False # stay in the loop + + + def create_manifest(self, checkdir, fetchlist_dict): + try: + distdir = self.repoman_settings['DISTDIR'] + mf = self.repoman_settings.repositories.get_repo_for_location( + os.path.dirname(os.path.dirname(checkdir))) + mf = mf.load_manifest( + checkdir, distdir, fetchlist_dict=fetchlist_dict) + mf.create( + requiredDistfiles=None, assumeDistHashesAlways=True) + for distfiles in fetchlist_dict.values(): + for distfile in distfiles: + if os.path.isfile(os.path.join(distdir, distfile)): + mf.fhashdict['DIST'].pop(distfile, None) + else: + self.auto_assumed.add(distfile) + mf.write() + finally: + portage._doebuild_manifest_exempt_depend -= 1 diff --git a/pym/repoman/main.py b/pym/repoman/main.py index 9e2ba76..46cdefd 100755 --- a/pym/repoman/main.py +++ b/pym/repoman/main.py @@ -66,6 +66,7 @@ from portage.eapi import eapi_has_iuse_defaults, eapi_has_required_use from repoman.argparser import parse_args from repoman.checks.ebuilds.checks import run_checks, checks_init from repoman.checks.ebuilds.thirdpartymirrors import ThirdPartyMirrors +from repoman.checks.ebuilds.manifests import Manifests from repoman.checks.herds.herdbase import make_herd_base from repoman.ebuild import Ebuild from repoman.errors import err @@ -334,76 +335,15 @@ for x in effective_scanlist: if repolevel < 2: checkdir_relative = os.path.join(catdir, checkdir_relative) checkdir_relative = os.path.join(".", checkdir_relative) - generated_manifest = False - - do_manifest = options.mode == "manifest" - do_digest_only = options.mode != 'manifest-check' and options.digest == 'y' - do_commit_or_fix = options.mode in ('commit', 'fix') - do_something = not options.pretend - - if do_manifest or do_digest_only or do_commit_or_fix and do_something: - auto_assumed = set() - fetchlist_dict = portage.FetchlistDict( - checkdir, repoman_settings, portdb) - if options.mode == 'manifest' and options.force: - portage._doebuild_manifest_exempt_depend += 1 - try: - distdir = repoman_settings['DISTDIR'] - mf = repoman_settings.repositories.get_repo_for_location( - os.path.dirname(os.path.dirname(checkdir))) - mf = mf.load_manifest( - checkdir, distdir, fetchlist_dict=fetchlist_dict) - mf.create( - requiredDistfiles=None, assumeDistHashesAlways=True) - for distfiles in fetchlist_dict.values(): - for distfile in distfiles: - if os.path.isfile(os.path.join(distdir, distfile)): - mf.fhashdict['DIST'].pop(distfile, None) - else: - auto_assumed.add(distfile) - mf.write() - finally: - portage._doebuild_manifest_exempt_depend -= 1 - repoman_settings["O"] = checkdir - try: - generated_manifest = digestgen( - mysettings=repoman_settings, myportdb=portdb) - except portage.exception.PermissionDenied as e: - generated_manifest = False - writemsg_level( - "!!! Permission denied: '%s'\n" % (e,), - level=logging.ERROR, noiselevel=-1) - - if not generated_manifest: - print("Unable to generate manifest.") - dofail = 1 - - if options.mode == "manifest": - if not dofail and options.force and auto_assumed and \ - 'assume-digests' in repoman_settings.features: - # Show which digests were assumed despite the --force option - # being given. This output will already have been shown by - # digestgen() if assume-digests is not enabled, so only show - # it here if assume-digests is enabled. - pkgs = list(fetchlist_dict) - pkgs.sort() - portage.writemsg_stdout( - " digest.assumed %s" % - portage.output.colorize( - "WARN", str(len(auto_assumed)).rjust(18)) + "\n") - for cpv in pkgs: - fetchmap = fetchlist_dict[cpv] - pf = portage.catsplit(cpv)[1] - for distfile in sorted(fetchmap): - if distfile in auto_assumed: - portage.writemsg_stdout( - " %s::%s\n" % (pf, distfile)) - continue - elif dofail: - sys.exit(1) +##################### + manifester = Manifests(options, repoman_settings) + skip = manifester.run(checkdir, portdb) + if skip: + continue +###################### - if not generated_manifest: + if not manifester.generated_manifest: repoman_settings['O'] = checkdir repoman_settings['PORTAGE_QUIET'] = '1' if not portage.digestcheck([], repoman_settings, strict=1):