aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSam James <sam@gentoo.org>2020-06-07 01:15:09 +0000
committerSam James <sam@gentoo.org>2020-09-10 19:07:29 +0000
commit042010b840bd920cece9ef00d06db392f142a7b3 (patch)
tree445a86445f5e50390fe85c08e4c8802ee5055872 /tatt/tool.py
parentpackage lists: Use nattka to parse keywording bugs (diff)
downloadtatt-042010b840bd920cece9ef00d06db392f142a7b3.tar.gz
tatt-042010b840bd920cece9ef00d06db392f142a7b3.tar.bz2
tatt-042010b840bd920cece9ef00d06db392f142a7b3.zip
tool: Refactor repodir handling
* Use given repodir in config if not blank * Ditch ~/gentoo-x86 default (it's ancient) and error out if it doesn't exist * If no repodir given, guess: * /var/db/repos/gentoo, and then * /usr/portage Now that we use nattka, we need a working repodir. Try some sensible defaults if the given one doesn't work. tatt: Support file-only jobs via Nattka Signed-off-by: Sam James <sam@gentoo.org>
Diffstat (limited to 'tatt/tool.py')
-rw-r--r--tatt/tool.py20
1 files changed, 20 insertions, 0 deletions
diff --git a/tatt/tool.py b/tatt/tool.py
index 450ed6a..1322315 100644
--- a/tatt/tool.py
+++ b/tatt/tool.py
@@ -1,3 +1,5 @@
+import os
+
""" Helper functions used in tatt"""
## Getting unique elements of a list ##
@@ -17,3 +19,21 @@ def unique(seq, idfun=None):
seen[marker] = 1
result.append(item)
return result
+
+def get_repo_dir(repodir):
+ # Prefer the repo dir in the config
+ if repodir:
+ if os.path.isdir(repodir):
+ return repodir
+ else:
+ raise ValueError("Repo dir does not seem to be a directory")
+
+ # No path given in config
+ if os.path.isdir("/var/db/repos/gentoo/"):
+ print("Using /var/db/repos/gentoo/ as fallback")
+ return "/var/db/repos/gentoo"
+ elif os.path.isdir("/usr/portage/"):
+ print("Using /usr/portage/ as fallback")
+ return "/usr/portage/"
+
+ raise ValueError("Repo dir not given and fallbacks failed")