Gentoo Archives: gentoo-commits

From: Sam James <sam@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] proj/tatt:master commit in: tatt/, scripts/
Date: Fri, 11 Sep 2020 16:00:53
Message-Id: 1599764849.042010b840bd920cece9ef00d06db392f142a7b3.sam@gentoo
1 commit: 042010b840bd920cece9ef00d06db392f142a7b3
2 Author: Sam James <sam <AT> gentoo <DOT> org>
3 AuthorDate: Sun Jun 7 01:15:09 2020 +0000
4 Commit: Sam James <sam <AT> gentoo <DOT> org>
5 CommitDate: Thu Sep 10 19:07:29 2020 +0000
6 URL: https://gitweb.gentoo.org/proj/tatt.git/commit/?id=042010b8
7
8 tool: Refactor repodir handling
9
10 * Use given repodir in config if not blank
11 * Ditch ~/gentoo-x86 default (it's ancient)
12 and error out if it doesn't exist
13 * If no repodir given, guess:
14 * /var/db/repos/gentoo, and then
15 * /usr/portage
16
17 Now that we use nattka, we need a working repodir.
18 Try some sensible defaults if the given one doesn't
19 work.
20
21 tatt: Support file-only jobs via Nattka
22
23 Signed-off-by: Sam James <sam <AT> gentoo.org>
24
25 scripts/tatt | 8 ++++----
26 tatt/dot-tatt-spec | 2 +-
27 tatt/tool.py | 20 ++++++++++++++++++++
28 3 files changed, 25 insertions(+), 5 deletions(-)
29
30 diff --git a/scripts/tatt b/scripts/tatt
31 index 9936006..27e9b61 100755
32 --- a/scripts/tatt
33 +++ b/scripts/tatt
34 @@ -19,6 +19,7 @@ from tatt.scriptwriter import writecommitscript as writeCommit
35 from tatt.scriptwriter import writeCleanUpScript as writeCleanup
36 from tatt.tattConfig import tattConfig as tattConfig
37 from tatt.job import job as job
38 +from tatt.tool import get_repo_dir
39
40 ##### Generate a global config obj, reading from ~/.tatt #####
41 config = tattConfig()
42 @@ -142,7 +143,6 @@ if options.infile:
43 myJob.type="stable"
44
45 myJob.packageList = packageFinder.findPackages(packraw, targetarch)
46 -
47 ## -b and a bugnumber was given ?
48 if options.bugnum:
49 print("Bugnumber: " + options.bugnum)
50 @@ -166,9 +166,9 @@ if options.bugnum:
51 sys.exit(1)
52 if myJob.packageList==None:
53 if response["cf_stabilisation_atoms"]:
54 - myJob.packageList = packageFinder.findPackages(response["cf_stabilisation_atoms"], config['arch'], config['repodir'], options.bugnum)
55 + myJob.packageList = packageFinder.findPackages(response["cf_stabilisation_atoms"], config['arch'], get_repo_dir(config['repodir']), options.bugnum)
56 if len(myJob.packageList) == 0 and ("KEYWORDREQ" in response["keywords"] or response["component"] == "Keywording"):
57 - myJob.packageList = packageFinder.findPackages(response["cf_stabilisation_atoms"], '~' + config['arch'], config['repodir'], options.bugnum)
58 + myJob.packageList = packageFinder.findPackages(response["cf_stabilisation_atoms"], '~' + config['arch'], get_repo_dir(config['repodir']), options.bugnum)
59 else:
60 response = session.get(config["bugzilla-url"] + "/rest/bug/{}/attachment".format(options.bugnum), params=params).json()["bugs"][str(options.bugnum)]
61 for attachment in response:
62 @@ -176,7 +176,7 @@ if options.bugnum:
63 continue
64 for flag in attachment['flags']:
65 if flag["name"] == "stabilization-list" and flag["status"] == '+':
66 - myJob.packageList = packageFinder.findPackages(base64.b64decode(attachment["data"]).decode("utf8"), config['arch'], config['repodir'], options.bugnum)
67 + myJob.packageList = packageFinder.findPackages(base64.b64decode(attachment["data"]).decode("utf8"), config['arch'], get_repo_dir(config['repodir']), options.bugnum)
68
69
70 # joint code for -f and -b
71
72 diff --git a/tatt/dot-tatt-spec b/tatt/dot-tatt-spec
73 index 1d9fe9d..33aff95 100644
74 --- a/tatt/dot-tatt-spec
75 +++ b/tatt/dot-tatt-spec
76 @@ -7,7 +7,7 @@ defaultopts=string(default="")
77 emergeopts=string(default="")
78 rdeps=integer(0,512,default=10)
79 usecombis=integer(0,512,default=12)
80 -repodir=string(default="./gentoo-x86")
81 +repodir=string(default="")
82 tinderbox-url=string(default="https://qa-reports.gentoo.org/output/genrdeps/rindex/")
83 safedir=string(default="")
84 bugzilla-url=string(default="https://bugs.gentoo.org")
85
86 diff --git a/tatt/tool.py b/tatt/tool.py
87 index 450ed6a..1322315 100644
88 --- a/tatt/tool.py
89 +++ b/tatt/tool.py
90 @@ -1,3 +1,5 @@
91 +import os
92 +
93 """ Helper functions used in tatt"""
94
95 ## Getting unique elements of a list ##
96 @@ -17,3 +19,21 @@ def unique(seq, idfun=None):
97 seen[marker] = 1
98 result.append(item)
99 return result
100 +
101 +def get_repo_dir(repodir):
102 + # Prefer the repo dir in the config
103 + if repodir:
104 + if os.path.isdir(repodir):
105 + return repodir
106 + else:
107 + raise ValueError("Repo dir does not seem to be a directory")
108 +
109 + # No path given in config
110 + if os.path.isdir("/var/db/repos/gentoo/"):
111 + print("Using /var/db/repos/gentoo/ as fallback")
112 + return "/var/db/repos/gentoo"
113 + elif os.path.isdir("/usr/portage/"):
114 + print("Using /usr/portage/ as fallback")
115 + return "/usr/portage/"
116 +
117 + raise ValueError("Repo dir not given and fallbacks failed")