From ddea9b0360a413abf5692776f70e7ee5bfe20343 Mon Sep 17 00:00:00 2001 From: James Waters Date: Thu, 26 Aug 2021 23:41:09 +0100 Subject: [PATCH 1/5] Automatically update pkgver using makepkg --- README.md | 4 ++++ action.yml | 4 ++++ build.sh | 14 ++++++++++++++ 3 files changed, 22 insertions(+) diff --git a/README.md b/README.md index 482efd4..43641e2 100644 --- a/README.md +++ b/README.md @@ -45,6 +45,10 @@ Glob patterns will be expanded by bash when copying the files to the repository. **Optional** Comma-separated list of types to use when adding aur.archlinux.org to known hosts. +### `update_pkgver` + +**Optional** Run `makepkg -od` to update `pkgver`. Requires that the `pkgver()` function defined in the `PKGBUILD` file doesn't required any dependencies other than git. The default value is `false`. + ## Example usage ```yaml diff --git a/action.yml b/action.yml index 56cfdab..d43a85a 100644 --- a/action.yml +++ b/action.yml @@ -40,6 +40,10 @@ inputs: description: 'Comma-separated list of types to use when adding aur.archlinux.org to known hosts' required: false default: 'rsa,dsa,ecdsa,ed25519' + update_pkgver: + description: "Run `makepkg -od` to update `pkgver`. Requires that the `pkgver()` function defined in the `PKGBUILD` file doesn't required any dependencies other than git" + required: false + default: 'false' runs: using: 'docker' image: 'Dockerfile' diff --git a/build.sh b/build.sh index a0a0991..6397ede 100755 --- a/build.sh +++ b/build.sh @@ -13,6 +13,7 @@ commit_message=$INPUT_COMMIT_MESSAGE allow_empty_commits=$INPUT_ALLOW_EMPTY_COMMITS force_push=$INPUT_FORCE_PUSH ssh_keyscan_types=$INPUT_SSH_KEYSCAN_TYPES +update_pkgver=$INPUT_UPDATE_PKGVER assert_non_empty() { name=$1 @@ -53,6 +54,19 @@ git config --global user.name "$commit_username" git config --global user.email "$commit_email" echo '::endgroup::' +if [ "$update_pkgver" = "true" ]; then + echo '::group::Updating pkgver' + echo 'Running `makepkg -od` to update pkgver' + mkdir -p /tmp/makepkg + cp "$pkgbuild" /tmp/makepkg/PKGBUILD + ( + cd /tmp/makepkg; + makepkg -od; + ) + pkgbuild=/tmp/makepkg/PKGBUILD + echo '::endgroup::' +fi + echo '::group::Cloning AUR package into /tmp/local-repo' git clone -v "https://aur.archlinux.org/${pkgname}.git" /tmp/local-repo echo '::endgroup::' From d2c84a2b978f854fc951ec59fb714f5b33a1e436 Mon Sep 17 00:00:00 2001 From: Keivin Yue Date: Sun, 17 Oct 2021 10:57:44 +0800 Subject: [PATCH 2/5] update the pkgver --- build.sh | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/build.sh b/build.sh index 6397ede..0f66a4d 100755 --- a/build.sh +++ b/build.sh @@ -54,19 +54,6 @@ git config --global user.name "$commit_username" git config --global user.email "$commit_email" echo '::endgroup::' -if [ "$update_pkgver" = "true" ]; then - echo '::group::Updating pkgver' - echo 'Running `makepkg -od` to update pkgver' - mkdir -p /tmp/makepkg - cp "$pkgbuild" /tmp/makepkg/PKGBUILD - ( - cd /tmp/makepkg; - makepkg -od; - ) - pkgbuild=/tmp/makepkg/PKGBUILD - echo '::endgroup::' -fi - echo '::group::Cloning AUR package into /tmp/local-repo' git clone -v "https://aur.archlinux.org/${pkgname}.git" /tmp/local-repo echo '::endgroup::' @@ -80,10 +67,25 @@ echo '::group::Copying files into /tmp/local-repo' # Ignore quote rule because we need to expand glob patterns to copy $assets if [[ -n "$assets" ]]; then echo 'Copying' $assets - cp -rt /tmp/local-repo/ $assets + cp -vrt /tmp/local-repo/ $assets fi echo '::endgroup::' +if [ "$update_pkgver" = "true" ]; then + echo '::group::Updating pkgver' + echo 'Running `makepkg -od` to update pkgver' + + # Update the pkgver in a temp folder + tmp_makepkg=$(mktemp -d makepkg.XXXX) + cp -vr /tmp/local-repo/* $tmp_makepkg + BUILDDIR=$tmp_makepkg makepkg -od + + # Copy back the PKGBUILD + cp $tmp_makepkg/PKGBUILD /tmp/local-repo/ + + echo '::endgroup::' +fi + echo '::group::Generating .SRCINFO' cd /tmp/local-repo makepkg --printsrcinfo >.SRCINFO From 6395a6987f7410923cffa3cce268eaad8c9eb3cc Mon Sep 17 00:00:00 2001 From: Kevin Yue Date: Sun, 17 Oct 2021 11:05:49 +0800 Subject: [PATCH 3/5] fix mktemp permission --- build.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.sh b/build.sh index 0f66a4d..d861186 100755 --- a/build.sh +++ b/build.sh @@ -76,7 +76,7 @@ if [ "$update_pkgver" = "true" ]; then echo 'Running `makepkg -od` to update pkgver' # Update the pkgver in a temp folder - tmp_makepkg=$(mktemp -d makepkg.XXXX) + tmp_makepkg=$(mktemp -d) cp -vr /tmp/local-repo/* $tmp_makepkg BUILDDIR=$tmp_makepkg makepkg -od From 006099624a0eed759cea11bfaad396e7a11178f1 Mon Sep 17 00:00:00 2001 From: Kevin Yue Date: Sun, 17 Oct 2021 11:13:57 +0800 Subject: [PATCH 4/5] fix makgepkg build error --- build.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/build.sh b/build.sh index d861186..47c8ec9 100755 --- a/build.sh +++ b/build.sh @@ -77,8 +77,8 @@ if [ "$update_pkgver" = "true" ]; then # Update the pkgver in a temp folder tmp_makepkg=$(mktemp -d) - cp -vr /tmp/local-repo/* $tmp_makepkg - BUILDDIR=$tmp_makepkg makepkg -od + cp -r /tmp/local-repo/* $tmp_makepkg + (cd $tmp_makepkg && makepkg -od) # Copy back the PKGBUILD cp $tmp_makepkg/PKGBUILD /tmp/local-repo/ From 0f713162f11b41dc57856e78880507377b526bf1 Mon Sep 17 00:00:00 2001 From: Kevin Yue Date: Sun, 17 Oct 2021 11:49:22 +0800 Subject: [PATCH 5/5] copy all files --- build.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/build.sh b/build.sh index 47c8ec9..a1728c4 100755 --- a/build.sh +++ b/build.sh @@ -77,10 +77,10 @@ if [ "$update_pkgver" = "true" ]; then # Update the pkgver in a temp folder tmp_makepkg=$(mktemp -d) - cp -r /tmp/local-repo/* $tmp_makepkg + cp -r /tmp/local-repo/. $tmp_makepkg (cd $tmp_makepkg && makepkg -od) - # Copy back the PKGBUILD + # Copy the PKGBUILD back cp $tmp_makepkg/PKGBUILD /tmp/local-repo/ echo '::endgroup::'