From 4045af8344b06ae5c75da28ec164cb9d33334b7d Mon Sep 17 00:00:00 2001 From: Alessandro Fulgini Date: Sun, 13 Nov 2022 21:31:26 +0100 Subject: [PATCH 1/4] Add `test_flags` input The input sets the command-line flags provided to `makepkg` when trying to build the package (if the `test` option is enabled). The input is optional and its default value is the same as before introducing this input. --- README.md | 4 ++++ action.yml | 4 ++++ build.sh | 3 ++- 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 473aa22..56464ac 100644 --- a/README.md +++ b/README.md @@ -25,6 +25,10 @@ Glob patterns will be expanded by bash when copying the files to the repository. **Optional** Check that PKGBUILD could be built. +### `test_flags` + +**Optional** Command line flags for makepkg to build the package (if `test` is enabled). The default flags are `--clean --cleanbuild --nodeps`. + ### `commit_username` **Required** The username to use when creating the new commit. diff --git a/action.yml b/action.yml index 91d0f57..6ce6b01 100644 --- a/action.yml +++ b/action.yml @@ -23,6 +23,10 @@ inputs: description: 'Check that PKGBUILD could be built' required: false default: 'false' + test_flags: + description: 'Command line flags for makepkg to build the package (if `test` is enabled)' + required: false + default: '--clean --cleanbuild --nodeps' commit_username: description: 'The username to use when creating the new commit' required: true diff --git a/build.sh b/build.sh index 988b53e..b219b7b 100755 --- a/build.sh +++ b/build.sh @@ -8,6 +8,7 @@ pkgbuild=$INPUT_PKGBUILD assets=$INPUT_ASSETS updpkgsums=$INPUT_UPDPKGSUMS test=$INPUT_TEST +test_flags=$INPUT_TEST_FLAGS commit_username=$INPUT_COMMIT_USERNAME commit_email=$INPUT_COMMIT_EMAIL ssh_private_key=$INPUT_SSH_PRIVATE_KEY @@ -82,7 +83,7 @@ fi if [ "$test" == "true" ]; then echo '::group::Building package with makepkg' cd /tmp/local-repo/ - makepkg --clean --cleanbuild --nodeps + makepkg $test_flags echo '::endgroup::' fi From c6a18b44bca5c7ffe42b8628aa3cd2ce28bf49d5 Mon Sep 17 00:00:00 2001 From: Alessandro Fulgini Date: Sun, 13 Nov 2022 22:02:28 +0100 Subject: [PATCH 2/4] Add builder user to sudoers This is needed to be able to install packages with makepkg --- entrypoint.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/entrypoint.sh b/entrypoint.sh index 6b012ba..9de0de0 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -5,6 +5,7 @@ set -o errexit -o pipefail -o nounset echo '::group::Creating builder user' useradd --create-home --shell /bin/bash builder passwd --delete builder +echo "builder ALL=(root) NOPASSWD:ALL" > /etc/sudoers.d/builder echo '::endgroup::' echo '::group::Initializing SSH directory' From bdefd9f7ff1514fc31f6aeef4c611d853bd4a3f9 Mon Sep 17 00:00:00 2001 From: Alessandro Fulgini Date: Mon, 14 Nov 2022 18:21:53 +0100 Subject: [PATCH 3/4] Treat `test_flags` as a bash array See https://www.shellcheck.net/wiki/SC20086 and https://www.shellcheck.net/wiki/SC2206 --- build.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/build.sh b/build.sh index b219b7b..dcd6db5 100755 --- a/build.sh +++ b/build.sh @@ -8,7 +8,7 @@ pkgbuild=$INPUT_PKGBUILD assets=$INPUT_ASSETS updpkgsums=$INPUT_UPDPKGSUMS test=$INPUT_TEST -test_flags=$INPUT_TEST_FLAGS +read -r -a test_flags <<< "$INPUT_TEST_FLAGS" commit_username=$INPUT_COMMIT_USERNAME commit_email=$INPUT_COMMIT_EMAIL ssh_private_key=$INPUT_SSH_PRIVATE_KEY @@ -83,7 +83,7 @@ fi if [ "$test" == "true" ]; then echo '::group::Building package with makepkg' cd /tmp/local-repo/ - makepkg $test_flags + makepkg "${test_flags[@]}" echo '::endgroup::' fi From acad6af83ff1af982631547ef32b0e11ddac34b8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kh=E1=BA=A3i?= Date: Tue, 15 Nov 2022 00:59:32 +0700 Subject: [PATCH 4/4] Make sure `/etc/sudoers.d/` always exist --- entrypoint.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/entrypoint.sh b/entrypoint.sh index 9de0de0..a2d9894 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -5,6 +5,7 @@ set -o errexit -o pipefail -o nounset echo '::group::Creating builder user' useradd --create-home --shell /bin/bash builder passwd --delete builder +mkdir -p /etc/sudoers.d/ echo "builder ALL=(root) NOPASSWD:ALL" > /etc/sudoers.d/builder echo '::endgroup::'