From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id 5EBFD1382C5 for ; Mon, 1 Jun 2020 08:56:12 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 61E71E08F4; Mon, 1 Jun 2020 08:56:11 +0000 (UTC) Received: from smtp.gentoo.org (mail.gentoo.org [IPv6:2001:470:ea4a:1:5054:ff:fec7:86e4]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id 37DB8E08F4 for ; Mon, 1 Jun 2020 08:56:11 +0000 (UTC) Received: from oystercatcher.gentoo.org (unknown [IPv6:2a01:4f8:202:4333:225:90ff:fed9:fc84]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id BB51B34E851 for ; Mon, 1 Jun 2020 08:56:09 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id 7011DAF for ; Mon, 1 Jun 2020 08:56:07 +0000 (UTC) From: "Fabian Groffen" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Fabian Groffen" Message-ID: <1591001735.b9098b502f300e410799bd26606564e9546cb96b.grobian@gentoo> Subject: [gentoo-commits] repo/proj/prefix:master commit in: scripts/auto-bootstraps/ X-VCS-Repository: repo/proj/prefix X-VCS-Files: scripts/auto-bootstraps/update_distfiles.py X-VCS-Directories: scripts/auto-bootstraps/ X-VCS-Committer: grobian X-VCS-Committer-Name: Fabian Groffen X-VCS-Revision: b9098b502f300e410799bd26606564e9546cb96b X-VCS-Branch: master Date: Mon, 1 Jun 2020 08:56:07 +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-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply X-Archives-Salt: fcdddb78-a8d4-4957-8adb-69fb1a21efcd X-Archives-Hash: 91651c57575eee2042005e0bdacb3f98 commit: b9098b502f300e410799bd26606564e9546cb96b Author: Fabian Groffen gentoo org> AuthorDate: Mon Jun 1 08:55:35 2020 +0000 Commit: Fabian Groffen gentoo org> CommitDate: Mon Jun 1 08:55:35 2020 +0000 URL: https://gitweb.gentoo.org/repo/proj/prefix.git/commit/?id=b9098b50 scripts/auto-bootstraps/update_distfiles: allow multiple iterations allow multiple dirs to be processed in a single call Signed-off-by: Fabian Groffen gentoo.org> scripts/auto-bootstraps/update_distfiles.py | 58 +++++++++++++++-------------- 1 file changed, 30 insertions(+), 28 deletions(-) diff --git a/scripts/auto-bootstraps/update_distfiles.py b/scripts/auto-bootstraps/update_distfiles.py index 9287afa83e..76d3da64df 100755 --- a/scripts/auto-bootstraps/update_distfiles.py +++ b/scripts/auto-bootstraps/update_distfiles.py @@ -12,32 +12,34 @@ def hash_file(f): hsh.update(fle.read()) return hsh.hexdigest() -with os.scandir(path=sys.argv[1]) as it: - for f in it: - if not f.is_file() or f.name.startswith('.'): - continue - srcfile = os.path.join(sys.argv[1], f.name) - h = hash_file(srcfile) - distname = os.path.join(distfilessrc, - f.name + "@" + h).lower() - isnew = False - if os.path.exists(distname): - print("DUP %s" % distname.split('/')[-1]) - os.remove(srcfile) - os.link(distname, srcfile, follow_symlinks=False) - else: - print("NEW %s" % distname.split('/')[-1]) - os.link(srcfile, distname) - isnew = True +for path in sys.argv[1:]: + print("processing %s" % path) + with os.scandir(path=path) as it: + for f in it: + if not f.is_file() or f.name.startswith('.'): + continue + srcfile = os.path.join(path, f.name) + h = hash_file(srcfile) + distname = os.path.join(distfilessrc, + f.name + "@" + h).lower() + isnew = False + if os.path.exists(distname): + print("DUP %s" % distname.split('/')[-1]) + os.remove(srcfile) + os.link(distname, srcfile, follow_symlinks=False) + else: + print("NEW %s" % distname.split('/')[-1]) + os.link(srcfile, distname) + isnew = True - # generate a name match for distfiles serving along the - # specification from gentoo-dev ML 18 Oct 2019 15:41:32 +0200 - # 4c7465824f1fb69924c826f6bbe3ee73afa08ec8.camel@gentoo.org - blh = hashlib.blake2b(bytes(f.name.encode('us-ascii'))).hexdigest() - trgpth = os.path.join(distfilessrc, 'public', blh[:2], f.name); - if isnew or !os.path.exists(trgpth): - if os.path.exists(trgpth): - os.remove(trgpth) - os.makedirs(os.path.join(distfilessrc, 'public', blh[:2]), - exist_ok=True) - os.link(distname, trgpth); + # generate a name match for distfiles serving along the + # specification from gentoo-dev ML 18 Oct 2019 15:41:32 +0200 + # 4c7465824f1fb69924c826f6bbe3ee73afa08ec8.camel@gentoo.org + blh = hashlib.blake2b(bytes(f.name.encode('us-ascii'))).hexdigest() + trgpth = os.path.join(distfilessrc, 'public', blh[:2], f.name); + if isnew or not os.path.exists(trgpth): + if os.path.exists(trgpth): + os.remove(trgpth) + os.makedirs(os.path.join(distfilessrc, 'public', blh[:2]), + exist_ok=True) + os.link(distname, trgpth);