commit: b9098b502f300e410799bd26606564e9546cb96b
Author: Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Mon Jun 1 08:55:35 2020 +0000
Commit: Fabian Groffen <grobian <AT> gentoo <DOT> 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 <grobian <AT> 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
- # [email protected]
- 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
+ # [email protected]
+ 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);