improved logging
This commit is contained in:
49
master.py
49
master.py
@@ -64,7 +64,8 @@ def build(pkgbuild, repo):
|
|||||||
os.chdir(pathlib.Path(pkgbuild).parent)
|
os.chdir(pathlib.Path(pkgbuild).parent)
|
||||||
res = subprocess.run(["sudo", "extra-x86_64-build"], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
|
res = subprocess.run(["sudo", "extra-x86_64-build"], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
|
||||||
if res.returncode:
|
if res.returncode:
|
||||||
logging.warning("[%s/%s] Build failed: %s", repo, name, res)
|
logging.warning("[%s/%s] Build failed. Check repo/logs for more information.", repo, name)
|
||||||
|
|
||||||
# write packagename to failed list
|
# write packagename to failed list
|
||||||
with open(os.path.join(config["basedir"]["repo"], repo + "_failed.txt"), "a") as f:
|
with open(os.path.join(config["basedir"]["repo"], repo + "_failed.txt"), "a") as f:
|
||||||
f.write(name + "\n")
|
f.write(name + "\n")
|
||||||
@@ -72,21 +73,23 @@ def build(pkgbuild, repo):
|
|||||||
# write logs to file
|
# write logs to file
|
||||||
if not os.path.exists(os.path.join(config["basedir"]["repo"], "logs", repo)):
|
if not os.path.exists(os.path.join(config["basedir"]["repo"], "logs", repo)):
|
||||||
pathlib.Path(os.path.join(config["basedir"]["repo"], "logs", repo)).mkdir(parents=True, exist_ok=True)
|
pathlib.Path(os.path.join(config["basedir"]["repo"], "logs", repo)).mkdir(parents=True, exist_ok=True)
|
||||||
|
|
||||||
with open(os.path.join(config["basedir"]["repo"], "logs", repo, name + ".log"), "w") as log:
|
with open(os.path.join(config["basedir"]["repo"], "logs", repo, name + ".log"), "w") as log:
|
||||||
log.write(res.stdout.decode())
|
log.write(res.stdout.decode())
|
||||||
|
|
||||||
subprocess.run(["git", "clean", "-xdf"], check=True, capture_output=True)
|
logging.debug("[GIT] %s", subprocess.run(["git", "clean", "-xdf"], check=True, stdout=subprocess.PIPE,
|
||||||
|
stderr=subprocess.STDOUT).stdout.decode())
|
||||||
os.chdir(sys.path[0])
|
os.chdir(sys.path[0])
|
||||||
return
|
return
|
||||||
|
|
||||||
# signing
|
# signing
|
||||||
pkgs = glob.glob("*.pkg.tar.zst")
|
pkgs = glob.glob("*.pkg.tar.zst")
|
||||||
for pkg in pkgs:
|
for pkg in pkgs:
|
||||||
s_res = subprocess.run(["gpg", "--batch", "--detach-sign", pkg], capture_output=True)
|
s_res = subprocess.run(["gpg", "--batch", "--detach-sign", pkg], stdout=subprocess.PIPE,
|
||||||
|
stderr=subprocess.STDOUT)
|
||||||
if s_res.returncode:
|
if s_res.returncode:
|
||||||
logging.error("[%s/%s] Signing failed: %s", repo, name, s_res)
|
logging.error("[%s/%s] Signing failed: %s", repo, name, s_res.stdout.decode())
|
||||||
subprocess.run(["git", "clean", "-xdf"], check=True, capture_output=True)
|
logging.debug("[GIT] %s", subprocess.run(["git", "clean", "-xdf"], check=True, stdout=subprocess.PIPE,
|
||||||
|
stderr=subprocess.STDOUT).stdout.decode())
|
||||||
os.chdir(sys.path[0])
|
os.chdir(sys.path[0])
|
||||||
return
|
return
|
||||||
|
|
||||||
@@ -100,24 +103,27 @@ def build(pkgbuild, repo):
|
|||||||
# repo
|
# repo
|
||||||
r_res = subprocess.run(["repo-add", "-s", "-v",
|
r_res = subprocess.run(["repo-add", "-s", "-v",
|
||||||
os.path.join(config["basedir"]["repo"], repo, "os", config["arch"], repo + ".db.tar.xz"),
|
os.path.join(config["basedir"]["repo"], repo, "os", config["arch"], repo + ".db.tar.xz"),
|
||||||
pkgs[0]], capture_output=True)
|
pkgs[0]], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
|
||||||
if r_res.returncode:
|
if r_res.returncode:
|
||||||
logging.error("[%s/%s] Repo action failed: %s", repo, name, r_res)
|
logging.error("[%s/%s] Repo action failed: %s", repo, name, r_res.stdout.decode())
|
||||||
subprocess.run(["git", "clean", "-xdf"], check=True, capture_output=True)
|
logging.debug("[GIT] %s", subprocess.run(["git", "clean", "-xdf"], check=True, stdout=subprocess.PIPE,
|
||||||
|
stderr=subprocess.STDOUT).stdout.decode())
|
||||||
os.chdir(sys.path[0])
|
os.chdir(sys.path[0])
|
||||||
return
|
return
|
||||||
|
|
||||||
p_res = subprocess.run(
|
p_res = subprocess.run(
|
||||||
["paccache", "-rc", os.path.join(config["basedir"]["repo"], repo, "os", config["arch"]), "-k", "1"],
|
["paccache", "-rc", os.path.join(config["basedir"]["repo"], repo, "os", config["arch"]), "-k", "1"],
|
||||||
capture_output=True)
|
stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
|
||||||
if p_res.returncode:
|
if p_res.returncode:
|
||||||
logging.error("[%s/%s] Repo cleanup failed: %s", repo, name, p_res)
|
logging.error("[%s/%s] Repo cleanup failed: %s", repo, name, p_res.stdout.decode())
|
||||||
subprocess.run(["git", "clean", "-xdf"], check=True, capture_output=True)
|
logging.debug("[GIT] %s", subprocess.run(["git", "clean", "-xdf"], check=True, stdout=subprocess.PIPE,
|
||||||
|
stderr=subprocess.STDOUT).stdout.decode())
|
||||||
os.chdir(sys.path[0])
|
os.chdir(sys.path[0])
|
||||||
return
|
return
|
||||||
|
|
||||||
# cleanup
|
# cleanup
|
||||||
subprocess.run(["git", "clean", "-xdf"], check=True, capture_output=True)
|
logging.debug("[GIT] %s", subprocess.run(["git", "clean", "-xdf"], check=True, stdout=subprocess.PIPE,
|
||||||
|
stderr=subprocess.STDOUT).stdout.decode())
|
||||||
os.chdir(sys.path[0])
|
os.chdir(sys.path[0])
|
||||||
logging.info("[%s/%s] Build successful (%s)", repo, name, time.time() - start_time)
|
logging.info("[%s/%s] Build successful (%s)", repo, name, time.time() - start_time)
|
||||||
|
|
||||||
@@ -147,8 +153,11 @@ def import_keys(pkgbuild):
|
|||||||
k = k.replace("'", "")
|
k = k.replace("'", "")
|
||||||
k = k.replace("\"", "")
|
k = k.replace("\"", "")
|
||||||
if len(k) == 40:
|
if len(k) == 40:
|
||||||
logging.debug(subprocess.run(
|
logging.debug("[GPG] %s",
|
||||||
["gpg", "--keyserver", "keyserver.ubuntu.com", "--recv-keys", k], capture_output=True))
|
subprocess.run(
|
||||||
|
["gpg", "--keyserver", "keyserver.ubuntu.com", "--recv-keys", k],
|
||||||
|
stdout=subprocess.PIPE,
|
||||||
|
stderr=subprocess.STDOUT).stdout.decode())
|
||||||
logging.info("[GPG] Imported key %s", k)
|
logging.info("[GPG] Imported key %s", k)
|
||||||
|
|
||||||
|
|
||||||
@@ -160,13 +169,15 @@ def package_exists(name, repo):
|
|||||||
|
|
||||||
def update_git2svn():
|
def update_git2svn():
|
||||||
if not os.path.exists(config["basedir"]["svn2git"]):
|
if not os.path.exists(config["basedir"]["svn2git"]):
|
||||||
logging.debug(subprocess.run(
|
logging.debug("[GIT] %s", subprocess.run(
|
||||||
["git", "clone", "https://github.com/archlinux/svntogit-packages.git", config["basedir"]["svn2git"]],
|
["git", "clone", "https://github.com/archlinux/svntogit-packages.git", config["basedir"]["svn2git"]],
|
||||||
check=True, capture_output=True))
|
check=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT).stdout.decode())
|
||||||
else:
|
else:
|
||||||
os.chdir(config["basedir"]["svn2git"])
|
os.chdir(config["basedir"]["svn2git"])
|
||||||
logging.debug(subprocess.run(["git", "clean", "-xdf"], check=True, capture_output=True))
|
logging.debug("[GIT] %s", subprocess.run(["git", "clean", "-xdf"], check=True, stdout=subprocess.PIPE,
|
||||||
logging.debug(subprocess.run(["git", "pull"], check=True, capture_output=True))
|
stderr=subprocess.STDOUT).stdout.decode())
|
||||||
|
logging.debug("[GIT] %s", subprocess.run(["git", "pull"], check=True, stdout=subprocess.PIPE,
|
||||||
|
stderr=subprocess.STDOUT).stdout.decode())
|
||||||
os.chdir("..")
|
os.chdir("..")
|
||||||
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user