Compare commits

...

2 Commits

Author SHA1 Message Date
b6dfbbb643 changed way signing works 2021-05-30 18:09:47 +02:00
9f557b9f6b fixed multipkgs not getting parsed correctly 2021-05-30 18:02:23 +02:00

View File

@@ -23,12 +23,13 @@ regex_pkgrel = re.compile(r"^pkgrel\s*=\s*(.+)$", re.MULTILINE)
regex_epoch = re.compile(r"^epoch\s*=\s*(.+)$", re.MULTILINE) regex_epoch = re.compile(r"^epoch\s*=\s*(.+)$", re.MULTILINE)
regex_march = re.compile(r"(-march=)(.+?) ", re.MULTILINE) regex_march = re.compile(r"(-march=)(.+?) ", re.MULTILINE)
regex_validkeys = re.compile(r"^validpgpkeys\+?=\((.*?)\)", re.MULTILINE | re.DOTALL) regex_validkeys = re.compile(r"^validpgpkeys\+?=\((.*?)\)", re.MULTILINE | re.DOTALL)
regex_pkg_repo = re.compile(r"^(.*)-.*-.*-(?:x86_64|any)\.pkg\.tar\.zst(?:\.sig)*$", re.MULTILINE)
fp = None fp = None
update_last = time.time() update_last = time.time()
copy_l = Lock() copy_l = Lock()
def build(pkgbuild: str, repo: str, todo: dict) -> None: def build(pkgbuild: str, repo: str) -> None:
start_time = time.time() start_time = time.time()
name = pathlib.Path(pkgbuild).parts[-4] name = pathlib.Path(pkgbuild).parts[-4]
process_name = current_process().name process_name = current_process().name
@@ -89,11 +90,6 @@ def build(pkgbuild: str, repo: str, todo: dict) -> None:
os.path.join(config["basedir"]["repo"], repo, "os", config["arch"] + "/")) os.path.join(config["basedir"]["repo"], repo, "os", config["arch"] + "/"))
shutil.copy2(pkg, os.path.join(config["basedir"]["repo"], repo, "os", config["arch"] + "/")) shutil.copy2(pkg, os.path.join(config["basedir"]["repo"], repo, "os", config["arch"] + "/"))
# repo
logging.debug("[%s/%s/%s] Adding packages to todo list: %s", process_name, repo, name,
", ".join(glob.glob("*.pkg.tar.zst")))
todo[repo].extend(glob.glob("*.pkg.tar.zst"))
logging.debug("[GIT] %s", subprocess.run(["git", "clean", "-xdff"], check=False, stdout=subprocess.PIPE, logging.debug("[GIT] %s", subprocess.run(["git", "clean", "-xdff"], check=False, stdout=subprocess.PIPE,
stderr=subprocess.STDOUT).stdout.decode(errors="ignore")) stderr=subprocess.STDOUT).stdout.decode(errors="ignore"))
@@ -101,11 +97,11 @@ def build(pkgbuild: str, repo: str, todo: dict) -> None:
format_timespan(time.time() - start_time)) format_timespan(time.time() - start_time))
def run_worker(todo: dict) -> None: def run_worker() -> None:
os.nice(20) os.nice(20)
while True: while True:
try: try:
build(*q.get(block=True), todo=todo) build(*q.get(block=True))
except Exception as e: except Exception as e:
logging.error("Error in worker: %s", e) logging.error("Error in worker: %s", e)
finally: finally:
@@ -114,13 +110,9 @@ def run_worker(todo: dict) -> None:
def do_repo_work() -> None: def do_repo_work() -> None:
for repo in d: for repo in config["repos"]:
if d[repo]: args = ["repo-add", "-s", "-v", "-p", "-n",
logging.info("[REPO/%s] Adding %s", repo, ", ".join(d[repo])) os.path.join(config["basedir"]["repo"], repo, "os", config["arch"], repo + ".db.tar.xz"), "*.zst"]
os.chdir(os.path.join(config["basedir"]["repo"], repo, "os", config["arch"]))
args = ["repo-add", "-s", "-v",
os.path.join(config["basedir"]["repo"], repo, "os", config["arch"], repo + ".db.tar.xz")]
args.extend(d[repo])
r_res = subprocess.run(args, stdout=subprocess.PIPE, stderr=subprocess.STDOUT) r_res = subprocess.run(args, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
logging.debug("[REPO-ADD] %s", r_res.stdout.decode(errors="ignore")) logging.debug("[REPO-ADD] %s", r_res.stdout.decode(errors="ignore"))
if r_res.returncode: if r_res.returncode:
@@ -132,10 +124,7 @@ def do_repo_work() -> None:
logging.debug("[PACCACHE] %s", p_res.stdout.decode(errors="ignore")) logging.debug("[PACCACHE] %s", p_res.stdout.decode(errors="ignore"))
if p_res.returncode: if p_res.returncode:
logging.error("[REPO/%s] Repo cleanup failed: %s", repo, p_res.stdout.decode(errors="ignore")) logging.error("[REPO/%s] Repo cleanup failed: %s", repo, p_res.stdout.decode(errors="ignore"))
d[repo][:] = []
os.chdir(sys.path[0]) os.chdir(sys.path[0])
else:
logging.debug("[REPO/%s] Nothing to do", repo)
def already_running() -> bool: def already_running() -> bool:
@@ -150,8 +139,16 @@ def already_running() -> bool:
def find_all_files_for_pkg(name: str, repo: str) -> list: def find_all_files_for_pkg(name: str, repo: str) -> list:
searchpath = os.path.join(config["basedir"]["repo"], repo, "os", config["arch"]) + "/" + name + "-*.pkg.*" pkgs = []
pkgs = glob.glob(searchpath) for root, dirs, files in os.walk(os.path.join(config["basedir"]["repo"], repo, "os", config["arch"])):
for file in files:
res = regex_pkg_repo.match(file)
if res:
if res.group(1) is name:
pkgs.append(os.path.join(root, file))
# searchpath = os.path.join(config["basedir"]["repo"], repo, "os", config["arch"]) + "/" + name + "-*.pkg.*"
# pkgs = glob.glob(searchpath)
for p in pkgs: for p in pkgs:
if p.endswith(".sig"): if p.endswith(".sig"):
@@ -302,8 +299,6 @@ def sync_marchs_with_config() -> None:
logging.info("Repos: %s", repo_quota) logging.info("Repos: %s", repo_quota)
repos_create = list(set(repo_quota) - set(repos)) repos_create = list(set(repo_quota) - set(repos))
repos_delete = list(set(repos) - set(repo_quota)) repos_delete = list(set(repos) - set(repo_quota))
for repo in repo_quota:
d[repo] = m.list()
for repo in repos_create: for repo in repos_create:
logging.debug("Create repo %s: %s", repo, os.path.join(config["basedir"]["repo"], repo, "os/x86_64")) logging.debug("Create repo %s: %s", repo, os.path.join(config["basedir"]["repo"], repo, "os/x86_64"))
@@ -376,14 +371,12 @@ if __name__ == '__main__':
os.nice(5) os.nice(5)
with Manager() as m:
d = m.dict()
setup_chroot() setup_chroot()
sync_marchs_with_config() sync_marchs_with_config()
update_svn2git() update_svn2git()
q = JoinableQueue() q = JoinableQueue()
with Pool(config["build"]["worker"], initializer=run_worker, initargs=(d,)) as pool: with Pool(config["build"]["worker"], initializer=run_worker) as pool:
fill_queue() fill_queue()
signal.signal(signal.SIGINT, signal.default_int_handler) signal.signal(signal.SIGINT, signal.default_int_handler)
@@ -392,7 +385,6 @@ if __name__ == '__main__':
if time.time() - update_last > 900 and q.empty(): if time.time() - update_last > 900 and q.empty():
logging.info("[SVN2GIT] Waiting for queue to finish...") logging.info("[SVN2GIT] Waiting for queue to finish...")
q.join() q.join()
do_repo_work()
update_last = time.time() update_last = time.time()
update_svn2git() update_svn2git()
setup_chroot() setup_chroot()
@@ -400,7 +392,7 @@ if __name__ == '__main__':
if q.qsize() > 0: if q.qsize() > 0:
logging.info("[SVN2GIT] New Queue size: %d", q.qsize()) logging.info("[SVN2GIT] New Queue size: %d", q.qsize())
else: else:
time.sleep(60) time.sleep(300)
do_repo_work() do_repo_work()
except KeyboardInterrupt: except KeyboardInterrupt:
with copy_l: with copy_l: