From cb2ba862000b3b492c1cd4e80bc8aebbae12aa47 Mon Sep 17 00:00:00 2001 From: Jef Roosens Date: Sun, 27 Mar 2022 18:22:30 +0200 Subject: [PATCH] Updated logging for multi-repo setup --- CHANGELOG.md | 6 +++++- src/{archive.v => archive.c.v} | 0 src/repo/repo.v | 17 +++++++++-------- src/server/routes.v | 5 +++-- test.py | 4 ++-- 5 files changed, 19 insertions(+), 13 deletions(-) rename src/{archive.v => archive.c.v} (100%) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9eaf477..754f04e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,17 +18,21 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 * Very basic build system * Build is triggered by separate cron container * Packages build on cron container's system - * Packages are always rebuilt, even if they haven't changed + * A HEAD request is used to determine whether a package should be rebuilt + or not * Hardcoded planning of builds * Builds are sequential * API for managing Git repositories to build * CLI to list, add & remove Git repos to build * Published packages on my Vieter instance +* Support for multiple repositories +* Support for multiple architectures per repository ## Fixed * Each package can now only have one version in the repository at once (required by Pacman) +* Packages with unknown fields in .PKGINFO are now allowed ## [0.1.0](https://git.rustybever.be/Chewing_Bever/vieter/src/tag/0.1.0) diff --git a/src/archive.v b/src/archive.c.v similarity index 100% rename from src/archive.v rename to src/archive.c.v diff --git a/src/repo/repo.v b/src/repo/repo.v index bf5ab02..e1c9fdb 100644 --- a/src/repo/repo.v +++ b/src/repo/repo.v @@ -81,15 +81,16 @@ fn (r &RepoGroupManager) add_pkg_in_repo(repo string, pkg &package.Pkg) ?bool { arch_repos << r.default_arch } - for arch in arch_repos { - r.add_pkg_in_arch_repo(repo, arch, pkg) ? - } - }else{ - r.add_pkg_in_arch_repo(repo, pkg.info.arch, pkg) ? - } + mut added := false - // TODO properly handle this - return true + for arch in arch_repos { + added = added || r.add_pkg_in_arch_repo(repo, arch, pkg) ? + } + + return added + }else{ + return r.add_pkg_in_arch_repo(repo, pkg.info.arch, pkg) + } } // add_pkg_in_repo adds the given package to the specified repo. A repo is an diff --git a/src/server/routes.v b/src/server/routes.v index 55964db..0f697f9 100644 --- a/src/server/routes.v +++ b/src/server/routes.v @@ -86,15 +86,16 @@ fn (mut app App) put_package(repo string) web.Result { return app.text('Failed to add package.') } + if !res.added { os.rm(pkg_path) or { app.lerror("Failed to remove download '$pkg_path': $err.msg") } - app.lwarn("Duplicate package '$res.pkg.full_name()'.") + app.lwarn("Duplicate package '$res.pkg.full_name()' in repo '$repo ($res.pkg.info.arch)'.") return app.text('File already exists.') } - app.linfo("Added '$res.pkg.full_name()' to repository.") + app.linfo("Added '$res.pkg.full_name()' to repo '$repo ($res.pkg.info.arch)'.") return app.text('Package added successfully.') } diff --git a/test.py b/test.py index 9b0116e..f1668d7 100644 --- a/test.py +++ b/test.py @@ -46,7 +46,7 @@ def create_random_pkginfo(words, name_min_len, name_max_len): "pkgname": name, "pkgbase": name, "pkgver": ver, - "arch": "any" + "arch": "x86_64" } return "\n".join(f"{key} = {value}" for key, value in data.items()) @@ -97,7 +97,7 @@ async def upload_random_package(tar_path, sem): async with sem: with open(tar_path, 'rb') as f: async with aiohttp.ClientSession() as s: - async with s.post("http://localhost:8000/vieter/publish", data=f.read(), headers={"x-api-key": "test"}) as r: + async with s.post("http://localhost:8000/vieter2/publish", data=f.read(), headers={"x-api-key": "test"}) as r: return await check_output(r)