Gentoo Archives: gentoo-commits

From: Fabian Groffen <grobian@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] repo/proj/prefix:master commit in: scripts/auto-bootstraps/
Date: Mon, 01 Jun 2020 08:56:12
Message-Id: 1591001735.b9098b502f300e410799bd26606564e9546cb96b.grobian@gentoo
1 commit: b9098b502f300e410799bd26606564e9546cb96b
2 Author: Fabian Groffen <grobian <AT> gentoo <DOT> org>
3 AuthorDate: Mon Jun 1 08:55:35 2020 +0000
4 Commit: Fabian Groffen <grobian <AT> gentoo <DOT> org>
5 CommitDate: Mon Jun 1 08:55:35 2020 +0000
6 URL: https://gitweb.gentoo.org/repo/proj/prefix.git/commit/?id=b9098b50
7
8 scripts/auto-bootstraps/update_distfiles: allow multiple iterations
9
10 allow multiple dirs to be processed in a single call
11
12 Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>
13
14 scripts/auto-bootstraps/update_distfiles.py | 58 +++++++++++++++--------------
15 1 file changed, 30 insertions(+), 28 deletions(-)
16
17 diff --git a/scripts/auto-bootstraps/update_distfiles.py b/scripts/auto-bootstraps/update_distfiles.py
18 index 9287afa83e..76d3da64df 100755
19 --- a/scripts/auto-bootstraps/update_distfiles.py
20 +++ b/scripts/auto-bootstraps/update_distfiles.py
21 @@ -12,32 +12,34 @@ def hash_file(f):
22 hsh.update(fle.read())
23 return hsh.hexdigest()
24
25 -with os.scandir(path=sys.argv[1]) as it:
26 - for f in it:
27 - if not f.is_file() or f.name.startswith('.'):
28 - continue
29 - srcfile = os.path.join(sys.argv[1], f.name)
30 - h = hash_file(srcfile)
31 - distname = os.path.join(distfilessrc,
32 - f.name + "@" + h).lower()
33 - isnew = False
34 - if os.path.exists(distname):
35 - print("DUP %s" % distname.split('/')[-1])
36 - os.remove(srcfile)
37 - os.link(distname, srcfile, follow_symlinks=False)
38 - else:
39 - print("NEW %s" % distname.split('/')[-1])
40 - os.link(srcfile, distname)
41 - isnew = True
42 +for path in sys.argv[1:]:
43 + print("processing %s" % path)
44 + with os.scandir(path=path) as it:
45 + for f in it:
46 + if not f.is_file() or f.name.startswith('.'):
47 + continue
48 + srcfile = os.path.join(path, f.name)
49 + h = hash_file(srcfile)
50 + distname = os.path.join(distfilessrc,
51 + f.name + "@" + h).lower()
52 + isnew = False
53 + if os.path.exists(distname):
54 + print("DUP %s" % distname.split('/')[-1])
55 + os.remove(srcfile)
56 + os.link(distname, srcfile, follow_symlinks=False)
57 + else:
58 + print("NEW %s" % distname.split('/')[-1])
59 + os.link(srcfile, distname)
60 + isnew = True
61
62 - # generate a name match for distfiles serving along the
63 - # specification from gentoo-dev ML 18 Oct 2019 15:41:32 +0200
64 - # 4c7465824f1fb69924c826f6bbe3ee73afa08ec8.camel@g.o
65 - blh = hashlib.blake2b(bytes(f.name.encode('us-ascii'))).hexdigest()
66 - trgpth = os.path.join(distfilessrc, 'public', blh[:2], f.name);
67 - if isnew or !os.path.exists(trgpth):
68 - if os.path.exists(trgpth):
69 - os.remove(trgpth)
70 - os.makedirs(os.path.join(distfilessrc, 'public', blh[:2]),
71 - exist_ok=True)
72 - os.link(distname, trgpth);
73 + # generate a name match for distfiles serving along the
74 + # specification from gentoo-dev ML 18 Oct 2019 15:41:32 +0200
75 + # 4c7465824f1fb69924c826f6bbe3ee73afa08ec8.camel@g.o
76 + blh = hashlib.blake2b(bytes(f.name.encode('us-ascii'))).hexdigest()
77 + trgpth = os.path.join(distfilessrc, 'public', blh[:2], f.name);
78 + if isnew or not os.path.exists(trgpth):
79 + if os.path.exists(trgpth):
80 + os.remove(trgpth)
81 + os.makedirs(os.path.join(distfilessrc, 'public', blh[:2]),
82 + exist_ok=True)
83 + os.link(distname, trgpth);