From a12379172367f235cd86fa0d80551276ff6eb8d2 Mon Sep 17 00:00:00 2001 From: Jef Roosens Date: Thu, 12 May 2022 09:11:18 +0200 Subject: [PATCH 1/3] feat(build): add target repo as Pacman repo during build --- src/build/build.v | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/build/build.v b/src/build/build.v index fab6c35..081645f 100644 --- a/src/build/build.v +++ b/src/build/build.v @@ -102,16 +102,26 @@ pub fn build_repo(address string, api_key string, base_image_id string, repo &db build_arch := os.uname().machine + repo_url := "$address/$repo.repo" + // TODO what to do with PKGBUILDs that build multiple packages? commands := [ + // This will later be replaced by a proper setting for changing the + // mirrorlist + "echo -e '[$repo.repo]\nServer = $address/\$repo/\$arch\nSigLevel = Optional' >> /etc/pacman.conf" + // We need to update the package list of the repo we just added above. + // This should however not pull in a lot of packages as long as the + // builder image is rebuild frequently. + 'pacman -Syu --needed --noconfirm' + 'su builder' 'git clone --single-branch --depth 1 --branch $repo.branch $repo.url repo', 'cd repo', 'makepkg --nobuild --syncdeps --needed --noconfirm', 'source PKGBUILD', // The build container checks whether the package is already // present on the server - 'curl -s --head --fail $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" $address/$repo.repo/publish; done', + 'curl -s --head --fail $repo_url/$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" $repo_url/publish; done', ] // We convert the list of commands into a base64 string, which then gets @@ -124,7 +134,7 @@ pub fn build_repo(address string, api_key string, base_image_id string, repo &db entrypoint: ['/bin/sh', '-c'] cmd: ['echo \$BUILD_SCRIPT | base64 -d | /bin/bash -e'] work_dir: '/build' - user: 'builder:builder' + /* user: 'builder:builder' */ } id := dd.create_container(c)?.id From 447aa6071d0b01930475591ae4c01235bc3a59b3 Mon Sep 17 00:00:00 2001 From: Jef Roosens Date: Thu, 12 May 2022 09:22:04 +0200 Subject: [PATCH 2/3] fix(ci): better bash substitution --- .woodpecker/.build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.woodpecker/.build.yml b/.woodpecker/.build.yml index 1698129..b0fd267 100644 --- a/.woodpecker/.build.yml +++ b/.woodpecker/.build.yml @@ -45,7 +45,7 @@ pipeline: - export OBJ_PATH="/vieter/commits/$CI_COMMIT_SHA/vieter-$(echo '${PLATFORM}' | sed 's:/:-:g')" - export SIG_STRING="PUT\n\n$CONTENT_TYPE\n$DATE\n$OBJ_PATH" - - export SIGNATURE=`echo -en $SIG_STRING | openssl sha1 -hmac $S3_PASSWORD -binary | base64` + - export SIGNATURE="$(echo -en $SIG_STRING | openssl sha1 -hmac $S3_PASSWORD -binary | base64)" - > curl --silent From 2c4b948a94463a435ddd2ca8b3baa7a91410940a Mon Sep 17 00:00:00 2001 From: Jef Roosens Date: Mon, 16 May 2022 22:02:24 +0200 Subject: [PATCH 3/3] refactor: ran formatter --- src/build/build.v | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/build/build.v b/src/build/build.v index 081645f..9c65ccb 100644 --- a/src/build/build.v +++ b/src/build/build.v @@ -102,7 +102,7 @@ pub fn build_repo(address string, api_key string, base_image_id string, repo &db build_arch := os.uname().machine - repo_url := "$address/$repo.repo" + repo_url := '$address/$repo.repo' // TODO what to do with PKGBUILDs that build multiple packages? commands := [ @@ -111,9 +111,9 @@ pub fn build_repo(address string, api_key string, base_image_id string, repo &db "echo -e '[$repo.repo]\nServer = $address/\$repo/\$arch\nSigLevel = Optional' >> /etc/pacman.conf" // We need to update the package list of the repo we just added above. // This should however not pull in a lot of packages as long as the - // builder image is rebuild frequently. - 'pacman -Syu --needed --noconfirm' - 'su builder' + // builder image is rebuilt frequently. + 'pacman -Syu --needed --noconfirm', + 'su builder', 'git clone --single-branch --depth 1 --branch $repo.branch $repo.url repo', 'cd repo', 'makepkg --nobuild --syncdeps --needed --noconfirm', @@ -134,7 +134,7 @@ pub fn build_repo(address string, api_key string, base_image_id string, repo &db entrypoint: ['/bin/sh', '-c'] cmd: ['echo \$BUILD_SCRIPT | base64 -d | /bin/bash -e'] work_dir: '/build' - /* user: 'builder:builder' */ + // user: 'builder:builder' } id := dd.create_container(c)?.id