From ebe01c2d449cae1198a60e0e50dc120d1274e86b Mon Sep 17 00:00:00 2001 From: Jef Roosens Date: Sat, 9 Apr 2022 12:23:54 +0200 Subject: [PATCH] Added route to request desc file; updated builder for new route (fixes #118) --- src/build/build.v | 2 +- src/server/routes.v | 12 ++++++++++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/build/build.v b/src/build/build.v index cf70894f..942ce8a8 100644 --- a/src/build/build.v +++ b/src/build/build.v @@ -93,7 +93,7 @@ fn build(conf Config) ? { 'source PKGBUILD', // The build container checks whether the package is already // present on the server - 'curl --head --fail $conf.address/$repo.repo/$build_arch/\$pkgname-\$pkgver-\$pkgrel-${build_arch}.pkg.tar.zst && exit 0', + 'curl --head --fail $conf.address/$repo.repo/$build_arch/\$pkgname-\$pkgver-\$pkgrel && exit 0', 'MAKEFLAGS="-j\$(nproc)" makepkg -s --noconfirm --needed && for pkg in \$(ls -1 *.pkg*); do curl -XPOST -T "\$pkg" -H "X-API-KEY: \$API_KEY" $conf.address/$repo.repo/publish; done', ] diff --git a/src/server/routes.v b/src/server/routes.v index a9264256..f259af41 100644 --- a/src/server/routes.v +++ b/src/server/routes.v @@ -22,7 +22,9 @@ fn (mut app App) get_repo_file(repo string, arch string, filename string) web.Re db_exts := ['.db', '.files', '.db.tar.gz', '.files.tar.gz'] - if db_exts.any(filename.ends_with(it)) { + // There's no point in having the ability to serve db archives with wrong + // filenames + if db_exts.any(filename == '$repo$it') { full_path = os.join_path(app.repo.repos_dir, repo, arch, filename) // repo-add does this using symlinks, but we just change the requested @@ -30,8 +32,14 @@ fn (mut app App) get_repo_file(repo string, arch string, filename string) web.Re if !full_path.ends_with('.tar.gz') { full_path += '.tar.gz' } - } else { + } else if filename.contains('.pkg') { full_path = os.join_path_single(app.repo.pkg_dir, filename) + + // Default behavior is to return the desc file for the package, if present. + // This can then also be used by the build system to properly check whether + // a package is present in an arch-repo. + } else { + full_path = os.join_path(app.repo.repos_dir, repo, arch, filename, 'desc') } // Scuffed way to respond to HEAD requests