summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobin H. Johnson <robbat2@gentoo.org>2016-01-27 16:35:56 -0800
committerRobin H. Johnson <robbat2@gentoo.org>2016-01-27 16:35:56 -0800
commitec941f48d43133d34b292eddffa80a45cb880953 (patch)
treed937f6a074595b49427c6ade7e1a0302d1ff9596 /thicken-manifests.py
parentmastermirror-staging: refactor and prepare for mtime changes. (diff)
downloadmastermirror-scripts-ec941f48d43133d34b292eddffa80a45cb880953.tar.gz
mastermirror-scripts-ec941f48d43133d34b292eddffa80a45cb880953.tar.bz2
mastermirror-scripts-ec941f48d43133d34b292eddffa80a45cb880953.zip
Merge changes from dwfreed.
Signed-off-by: Robin H. Johnson <robbat2@gentoo.org>
Diffstat (limited to 'thicken-manifests.py')
-rwxr-xr-xthicken-manifests.py71
1 files changed, 53 insertions, 18 deletions
diff --git a/thicken-manifests.py b/thicken-manifests.py
index 3b04fa4..db52bdc 100755
--- a/thicken-manifests.py
+++ b/thicken-manifests.py
@@ -8,10 +8,10 @@
# alright too)
# - Run egencache against the checkout (this step is NOT optional; manifest generation is torturously slow without md5-cache)
# - Run thicken-manifests.py
-#
-# Takes an optional --jobs parameter, defaults to the number of CPUs on the host; also takes an optional directory to run against, defaults to the current working directory.
-# For GPG signing, add --sign parameter.
-# It behaves exactly like repoman manifest, so you can override GPG behavior by setting PORTAGE_GPG_SIGNING_COMMAND, PORTAGE_GPG_KEY, and PORTAGE_GPG_DIR in make.conf or the environment.
+#
+# Takes an optional --jobs parameter, defaults to the number of CPUs on the host; also takes an optional directory to run against, defaults to the current working directory
+# For GPG signing, add --sign parameter.
+# It behaves exactly like repoman manifest, so you can override GPG behavior by setting PORTAGE_GPG_SIGNING_COMMAND, PORTAGE_GPG_KEY, and PORTAGE_GPG_DIR in make.conf or the environment.
# You do NOT need to modify layout.conf for this script to work. Stick with GPG 2.0 for now, because 2.1 moves key operations into the agent, which makes them not parallel.
import os
@@ -21,6 +21,7 @@ import logging
import argparse
import errno
import math
+import collections
import portage
import portage.exception
@@ -31,6 +32,7 @@ portage_settings = None
portage_portdbapi = None
logger = None
args = None
+dir_contents = collections.defaultdict(list)
def gpg_sign(filename):
@@ -79,8 +81,9 @@ def maybe_thicken_manifest(pkg_dir):
logger.exception("%s OSError thrown trying to stat Manifest", pkg_dir)
manifest_mtime = 0
newest_mtime = manifest_mtime
- for root, subdirectories, files in os.walk(pkg_dir):
- for file in files:
+ manifest_entries = []
+ for root in pkg_dir, os.path.join(pkg_dir, 'files'):
+ for file in dir_contents[root]:
if file == 'Manifest':
continue
@@ -88,11 +91,29 @@ def maybe_thicken_manifest(pkg_dir):
if file_mtime > newest_mtime:
newest_mtime = file_mtime
+ if os.path.split(root)[1] == 'files':
+ manifest_entries.append('AUX ' + file)
+ elif file.endswith('.ebuild'):
+ manifest_entries.append('EBUILD ' + file)
+ else:
+ manifest_entries.append('MISC ' + file)
+
if newest_mtime == manifest_mtime:
try:
with open(os.path.join(pkg_dir, 'Manifest'), 'r') as f:
- if f.readline().startswith('-'):
- return
+ for line in f:
+ if not line.startswith(('AUX', 'EBUILD', 'MISC')):
+ continue
+
+ manifest_entry = ' '.join(line.split(' ')[0:2])
+ if manifest_entry in manifest_entries:
+ manifest_entries.remove(manifest_entry)
+ else:
+ newest_mtime += 1
+ break
+ else:
+ if not manifest_entries:
+ return
except:
pass
@@ -112,13 +133,14 @@ def maybe_thicken_manifest(pkg_dir):
def main():
- global logger, args
+ global logger, args, dir_contents
parser = argparse.ArgumentParser(description='Thicken ebuild manifests as needed')
parser.add_argument('-j', '--jobs', default=multiprocessing.cpu_count(), type=int,
- help='Number of parallel jobs to run; default: number of CPUs')
- parser.add_argument('-s', '--sign', action='store_true')
+ help='Number of parallel jobs to run; default: number of CPUs')
+ parser.add_argument('-s', '--sign', action='store_true', help='Sign manifests with GPG')
parser.add_argument('location', nargs='?', default='.', help='The location to thicken manifests in; default: .')
args = parser.parse_args()
+ args.location = os.path.realpath(args.location)
logger = multiprocessing.log_to_stderr()
logger.setLevel(logging.WARN)
@@ -129,18 +151,31 @@ main-repo = gentoo
[gentoo]
location = %s
-''' % os.path.realpath(args.location)
+''' % args.location
os.chdir(args.location)
pkg_dirs = []
for root, subdirectories, files in os.walk('.'):
- for dir in ('eclass', 'metadata', 'profiles', '.git', 'files'):
- if dir in subdirectories:
+ if root == '.':
+ for dir in ('eclass', 'licenses', 'metadata', 'profiles', 'scripts', '.git'):
+ if dir in subdirectories:
+ subdirectories.remove(dir)
+
+ if (not subdirectories or subdirectories == ['files']) and 'metadata.xml' in files:
+ pkg_dirs.append(root[2:])
+ dir_contents[root[2:]] = files
+ elif os.path.split(root)[1] == 'files' and 'metadata.xml' not in files:
+ dir_contents[root[2:]] = files
+ for dir in subdirectories[:]:
subdirectories.remove(dir)
-
- if not subdirectories and 'metadata.xml' in files:
- pkg_dirs.append(root)
-
+ os.chdir(root)
+ for root2, subdirectories2, files2 in os.walk('.'):
+ if root2 != '.':
+ for file in files2:
+ dir_contents[root[2:]].append(os.path.join(root2[2:], file))
+ os.chdir(args.location)
+
+ pkg_dirs.sort()
pool = multiprocessing.Pool(args.jobs, worker_init)
pool.map(maybe_thicken_manifest, pkg_dirs)
pool.close()