From: Zac Medico Date: Fri, 17 Jun 2011 22:35:29 +0000 (-0700) Subject: repoman: handle PermissionDenied from digestgen X-Git-Tag: v2.2.0_alpha42~48 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=d3d1aee93c9c5f04612c9237d452e9885c10af6d;p=portage.git repoman: handle PermissionDenied from digestgen This will fix bug #371987. --- diff --git a/bin/repoman b/bin/repoman index 164a1278d..487cc67a4 100755 --- a/bin/repoman +++ b/bin/repoman @@ -1095,8 +1095,13 @@ for x in scanlist: portage._doebuild_manifest_exempt_depend -= 1 repoman_settings["O"] = checkdir - generated_manifest = digestgen( - mysettings=repoman_settings, myportdb=portdb) + 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.") diff --git a/pym/portage/checksum.py b/pym/portage/checksum.py index f640fd9f1..eeb5995bb 100644 --- a/pym/portage/checksum.py +++ b/pym/portage/checksum.py @@ -29,8 +29,19 @@ def _generate_hash_function(hashtype, hashobject, origin="unknown"): @type filename: String @return: The hash and size of the data """ - f = open(_unicode_encode(filename, - encoding=_encodings['fs'], errors='strict'), 'rb') + try: + f = open(_unicode_encode(filename, + encoding=_encodings['fs'], errors='strict'), 'rb') + except IOError as e: + func_call = "open('%s')" % filename + if e.errno == errno.EPERM: + raise portage.exception.OperationNotPermitted(func_call) + elif e.errno == errno.EACCES: + raise portage.exception.PermissionDenied(func_call) + elif e.errno == errno.ENOENT: + raise portage.exception.FileNotFound(filename) + else: + raise blocksize = HASHING_BLOCKSIZE data = f.read(blocksize) size = 0