[misc] 05/05: Drop unreproducible-installed - replaced with reproducible-check in devscripts
Chris Lamb
chris at chris-lamb.co.uk
Wed Nov 1 20:40:25 UTC 2017
This is an automated email from the git hooks/post-receive script.
lamby pushed a commit to branch master
in repository misc.
commit 242616afda8eef3a3b1023ccec36ff63416d406f
Author: Chris Lamb <lamby at debian.org>
Date: Wed Nov 1 21:39:01 2017 +0100
Drop unreproducible-installed - replaced with reproducible-check in devscripts
---
unreproducible-installed | 202 -----------------------------------------------
1 file changed, 202 deletions(-)
diff --git a/unreproducible-installed b/unreproducible-installed
deleted file mode 100755
index 5923ce8..0000000
--- a/unreproducible-installed
+++ /dev/null
@@ -1,202 +0,0 @@
-#!/usr/bin/env python3
-
-# Written in 2015 by Valentin Lorentz <progval at progval.net
-#
-# To the extent possible under law, the author(s) have dedicated all copyright
-# and related and neighboring rights to this software to the public domain
-# worldwide. This software is distributed without any warranty.
-# You should have received a copy of the CC0 Public Domain Dedication along
-# with this software. If not, see <http://creativecommons.org/publicdomain/zero/1.0/>.
-
-import os
-import sys
-import json
-import time
-import os.path
-import argparse
-import subprocess
-
-try:
- import apt
-except ImportError:
- apt = None
-try:
- import yaml
-except ImportError:
- yaml = None
-
-if sys.version_info[0] >= 3: # Python 3
- from urllib.request import urlopen
-else: # Python 2
- from urllib2 import urlopen
-
-IGNORE_REPORTED = True
-DEFAULT_SAVE_TO = '/tmp/reproducible.json'
-DEFAULT_FILE_NAMES = ('./reproducible.json', DEFAULT_SAVE_TO)
-DEFAULT_SUITES = ['unstable']
-DEFAULT_EXCLUDED_STATUSES = ['reproducible', 'FTBFS']
-
-parser = argparse.ArgumentParser(
- description='Lists unreproducible packages installed on this system.')
-parser.add_argument('--show-issues', action='store_true',
- help='Show the list of issues identified with this package.')
-rj_group = parser.add_argument_group('reproducible.json')
-rj_group.add_argument('--max-age', type=int, default=60*60,
- help='Maximum age of the reproducible.json file. If the file is older, '
- 'it will be redownloaded. Setting this to 0 disables this check.')
-rj_group.add_argument('--download-url', type=str,
- default='https://reproducible.debian.net/reproducible.json',
- help='URL where to download reproducible.json from.')
-rj_group.add_argument('--file-name', type=str, default=None,
- help='Where to find the reproducible.json file.')
-rj_group.add_argument('--save-to', type=str, default=None,
- help='Where to store the reproducible.json if it was downloaded. '
- 'Defaults to --file-name if given, %s otherwise.' %
- DEFAULT_SAVE_TO)
-npy_group = parser.add_argument_group('notes/packages.yml')
-npy_group.add_argument('--ignore-with-bugs', action='store_true',
- help='Do not show packages with bugs reported by the RB team.')
-npy_group.add_argument('--package-notes-file', type=str,
- default=os.path.join(os.path.dirname(__file__), '../notes/packages.yml'),
- help='File containing packages notes, used with --ignore-with-bugs.')
-filter_group = parser.add_argument_group('filters')
-filter_group.add_argument('--suite', type=str, action='append',
- help='The suite where to look packages for. Use this option multiple '
- 'times to look in multiple suites. "any" looks in all suites. '
- 'Defaults to "%s".' % ', '.join(DEFAULT_SUITES))
-filter_group.add_argument('--arch', type=str, action='append',
- help='The architecture where to look packages for. Use this option multiple '
- 'times to look in multiple architectures. '
- 'Defaults to all architectures.')
-filter_group.add_argument('--exclude-status', type=str, action='append',
- help='The package status to remove. Use this option multiple times to '
- 'exclude many. Defaults to "%s".' %
- ', '.join(DEFAULT_EXCLUDED_STATUSES))
-filter_group.add_argument('--with-issue', type=str, action='append',
- help='Keep only packages with the given issue. Use this option multiple '
- 'times to make it an OR clause.')
-filter_group.add_argument('--with-uninstalled', action='store_true',
- help='Show uninstalled packages too.')
-
-def find_data(args):
- """Search for the reproducible.json file and load it."""
- if args.file_name:
- filenames = (args.file_name,)
- else:
- filenames = DEFAULT_FILE_NAMES
- for filename in filenames:
- if os.path.isfile(filename) and \
- (args.max_age == 0 or
- os.path.getmtime(filename) + args.max_age > time.time()):
- # If this file is recent enough, read it
- with open(filename) as fd:
- return json.load(fd)
- return None
-
-
-def download_data(args):
- """Download the reproducible.json file, save it, and return its content."""
- response = urlopen(args.download_url).read()
- if sys.version_info[0] >= 3:
- response = response.decode('utf-8')
-
- # Take the first that is not None.
- save_to = args.save_to or args.file_name or DEFAULT_SAVE_TO
-
- if os.path.isfile(save_to):
- os.unlink(save_to)
- with open(save_to, 'a') as fd:
- fd.write(response)
- return json.loads(response)
-
-def filter_packages(args, notes):
- data = find_data(args)
- if not data:
- data = download_data(args)
-
- filters = []
-
- suites = frozenset(args.suite or DEFAULT_SUITES)
- if 'any' not in suites:
- filters.append(lambda x:x['suite'] in suites)
-
- exclude_statuses = frozenset(args.exclude_status or
- DEFAULT_EXCLUDED_STATUSES)
- filters.append(lambda x:x['status'] not in exclude_statuses)
-
- if args.with_issue:
- with_issues = frozenset(args.with_issue)
- def predicate(x):
- issues = set(notes.get(x['package'], {}).get('issues', [])) & with_issues
- return bool(issues)
- filters.append(predicate)
-
- if args.arch:
- architectures = frozenset(args.arch)
- filters.append(lambda x:x['architecture'] in architectures)
-
- unreproducible = {x['package']
- for x in data
- if all(f(x) for f in filters)}
- return unreproducible
-
-if apt:
- def get_installed_packages(args):
- if args.with_uninstalled:
- packages = {x.name
- for x in apt.cache.Cache()}
- else:
- packages = {x.name
- for x in apt.cache.Cache()
- if x.installed}
- return packages
-else:
- # Fallback in case python-apt is not installed.
- def get_installed_packages(args):
- if args.with_uninstalled:
- apt_output = subprocess.check_output(['apt-cache', 'search', '.*'], universal_newlines=True)
- apt_list = apt_output.split('\n')
- packages = {x.split(' ')[0].split(':')[0] for x in apt_list}
- else:
- dpkg_output = subprocess.check_output(['dpkg', '-l'], universal_newlines=True)
- dpkg_list = dpkg_output.split('\n')
- packages = {x.split(' ')[1].split(':')[0] # keep the second field, strip arch
- for x in dpkg_list
- if x.startswith('i')} # ignore headers
- return packages
-
-def main(args):
- if yaml:
- with open(args.package_notes_file) as fd:
- notes = yaml.load(fd)
- else:
- notes = None
- unreproducible = filter_packages(args, notes=notes)
-
- if args.ignore_with_bugs:
- unreproducible = {x for x in unreproducible if 'bugs' not in notes.get(x, {})}
-
- installed = get_installed_packages(args)
-
- max_name_length = max(map(len, installed & unreproducible))
- for package in sorted(installed & unreproducible):
- issues = notes.get(package, {}).get('issues', [])
- if args.show_issues and issues:
- print('%s %s' %
- (package.ljust(max_name_length), ' '.join(issues)))
- else:
- print(package)
-
-if __name__ == '__main__':
- args = parser.parse_args()
- if not yaml:
- require_yaml = ['ignore-with-bugs', 'with-issue', 'show-issues']
- errors = []
- for option in require_yaml:
- if not getattr(args, option.replace('-', '_')):
- errors.append(option)
- if errors:
- print('Requires PyYaml to be installed: --%s' %
- ', --'.join(errors))
- exit(1)
- main(args)
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/reproducible/misc.git
More information about the Reproducible-commits
mailing list