From patchwork Fri Jul 20 18:42:24 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hollis Blanchard X-Patchwork-Id: 947154 Return-Path: X-Original-To: incoming-buildroot@patchwork.ozlabs.org Delivered-To: patchwork-incoming-buildroot@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=busybox.net (client-ip=140.211.166.133; helo=hemlock.osuosl.org; envelope-from=buildroot-bounces@busybox.net; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=mentor.com Received: from hemlock.osuosl.org (smtp2.osuosl.org [140.211.166.133]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 41XKWj22l4z9s7Q for ; Sat, 21 Jul 2018 04:42:56 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by hemlock.osuosl.org (Postfix) with ESMTP id D21FD8A76A; Fri, 20 Jul 2018 18:42:53 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from hemlock.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id g-oBsPrcU9KD; Fri, 20 Jul 2018 18:42:53 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by hemlock.osuosl.org (Postfix) with ESMTP id EDFA88A766; Fri, 20 Jul 2018 18:42:52 +0000 (UTC) X-Original-To: buildroot@lists.busybox.net Delivered-To: buildroot@osuosl.org Received: from whitealder.osuosl.org (smtp1.osuosl.org [140.211.166.138]) by ash.osuosl.org (Postfix) with ESMTP id 2BC041C0197 for ; Fri, 20 Jul 2018 18:42:52 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by whitealder.osuosl.org (Postfix) with ESMTP id 28FB18AA30 for ; Fri, 20 Jul 2018 18:42:52 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from whitealder.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id y156pOGTS+19 for ; Fri, 20 Jul 2018 18:42:51 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from relay1.mentorg.com (relay1.mentorg.com [192.94.38.131]) by whitealder.osuosl.org (Postfix) with ESMTPS id 65BD28AA24 for ; Fri, 20 Jul 2018 18:42:51 +0000 (UTC) Received: from svr-orw-mbx-02.mgc.mentorg.com ([147.34.90.202]) by relay1.mentorg.com with esmtps (TLSv1.2:ECDHE-RSA-AES256-SHA384:256) id 1fgaMc-0004MI-C7 from Hollis_Blanchard@mentor.com ; Fri, 20 Jul 2018 11:42:50 -0700 Received: from svr-orw-mbx-01.mgc.mentorg.com (147.34.90.201) by svr-orw-mbx-02.mgc.mentorg.com (147.34.90.202) with Microsoft SMTP Server (TLS) id 15.0.1320.4; Fri, 20 Jul 2018 11:42:48 -0700 Received: from cveaol6qa08.wv.mentorg.com (147.34.91.1) by svr-orw-mbx-01.mgc.mentorg.com (147.34.90.201) with Microsoft SMTP Server id 15.0.1320.4 via Frontend Transport; Fri, 20 Jul 2018 11:42:47 -0700 MIME-Version: 1.0 X-Mercurial-Node: 33f2f5c9d9cdbb320e527127e6bf6db4daf93933 X-Mercurial-Series-Index: 1 X-Mercurial-Series-Total: 1 Message-ID: <33f2f5c9d9cdbb320e52.1532112144@cveaol6qa08.wv.mentorg.com> X-Mercurial-Series-Id: <33f2f5c9d9cdbb320e52.1532112144@cveaol6qa08.wv.mentorg.com> User-Agent: Mercurial-patchbomb/4.4.1 Date: Fri, 20 Jul 2018 11:42:24 -0700 From: Hollis Blanchard To: Subject: [Buildroot] [PATCH] support/scripts/check-uniq-files: run with Python 2.6 X-BeenThere: buildroot@busybox.net X-Mailman-Version: 2.1.24 Precedence: list List-Id: Discussion and development of buildroot List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Hollis Blanchard , "Yann E . MORIN" Errors-To: buildroot-bounces@busybox.net Sender: "buildroot" Support Python 2.6 by switching from argparse (introduced in Python 2.7) to optparse. Python 2.6 is the version of Python in RHEL6.5. optparse was deprecated in 2.7, but is still usable, so the script now runs in more environments. Backports of argparse to 2.6 are available, but can be impractical to require on all hosts (e.g. hosts belonging to end-users who are unfamiliar with Python package management, corporate-managed build hosts where installing packages is difficult or impossible). Signed-off-by: Hollis Blanchard diff --git a/support/dependencies/dependencies.sh b/support/dependencies/dependencies.sh --- a/support/dependencies/dependencies.sh +++ b/support/dependencies/dependencies.sh @@ -281,8 +281,3 @@ if [ -n "$missing_perl_modules" ] ; then echo exit 1 fi - -if ! python -c "import argparse" > /dev/null 2>&1 ; then - echo "Your Python installation is not complete enough: argparse module is missing" - exit 1 -fi diff --git a/support/scripts/check-uniq-files b/support/scripts/check-uniq-files --- a/support/scripts/check-uniq-files +++ b/support/scripts/check-uniq-files @@ -1,31 +1,31 @@ #!/usr/bin/env python import sys -import argparse +import optparse from collections import defaultdict warn = 'Warning: {0} file "{1}" is touched by more than one package: {2}\n' def main(): - parser = argparse.ArgumentParser() - parser.add_argument('packages_file_list', nargs='*', - help='The packages-file-list to check from') - parser.add_argument('-t', '--type', metavar="TYPE", + usage = 'usage: %prog -t TYPE ' + parser = optparse.OptionParser(usage=usage) + parser.add_option('-t', '--type', metavar="TYPE", help='Report as a TYPE file (TYPE is either target, staging, or host)') - args = parser.parse_args() + options, args = parser.parse_args() - if not len(args.packages_file_list) == 1: - sys.stderr.write('No packages-file-list was provided.\n') + if not len(args) == 1: + sys.stderr.write('No packages file list was provided.\n') return False + packages_file = args[0] - if args.type is None: + if options.type is None: sys.stderr.write('No type was provided\n') return False file_to_pkg = defaultdict(list) - with open(args.packages_file_list[0], 'rb') as pkg_file_list: + with open(packages_file, 'rb') as pkg_file_list: for line in pkg_file_list.readlines(): pkg, _, file = line.rstrip(b'\n').partition(b',') file_to_pkg[file].append(pkg) @@ -35,12 +35,12 @@ def main(): # If possible, try to decode the binary strings with # the default user's locale try: - sys.stderr.write(warn.format(args.type, file.decode(), + sys.stderr.write(warn.format(options.type, file.decode(), [p.decode() for p in file_to_pkg[file]])) except UnicodeDecodeError: # ... but fallback to just dumping them raw if they # contain non-representable chars - sys.stderr.write(warn.format(args.type, file, + sys.stderr.write(warn.format(options.type, file, file_to_pkg[file]))