From 4e4997786067bfb8af52887d289bb52774f8b897 Mon Sep 17 00:00:00 2001 From: Romain Gallet Date: Sun, 21 Jun 2020 14:05:09 +0100 Subject: [PATCH] More flexible path --- .gitignore | 2 ++ README.md | 17 +++++++++++------ action.yml | 9 ++++++--- entrypoint.sh | 22 +++++++++++++--------- 4 files changed, 32 insertions(+), 18 deletions(-) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..c38fa4e --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +.idea +*.iml diff --git a/README.md b/README.md index 504bc1c..6c2003f 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,12 @@ This action builds an validates Arch Linux package. The `PKGBUILD` and `.SRCINFO` files should be under a subdirectory named the same as the `pkgbuild` of the package. -This assumption is made so this action works well with [aurpublish]. + +This assumption made is so that this action works well with [aurpublish] (_untested in this fork yet_). + +This version is a fork from the original [arch-pkgbuild-builder](https://github.com/2m/arch-pkgbuild-builder). + +It differs in that the `PKGBUILD` and related files do not need to be place in the root of the github workspace. [aurpublish]: https://github.com/eli-schwartz/aurpublish @@ -23,10 +28,10 @@ This assumption is made so this action works well with [aurpublish]. Verifies and builds the package. ```yml -uses: 2m/arch-pkgbuild-builder@v1 +uses: grumlimited/arch-pkgbuild-builder@v1 with: target: 'pkgbuild' - pkgname: 'ucm-bin' + pkgname: 'data/arch/authenticator-rs/PKGBUILD' ``` ### srcinfo @@ -34,7 +39,7 @@ with: Verifies if the `.SRCINFO` is up to date with the `PKGBUILD`. ```yml -uses: 2m/arch-pkgbuild-builder@v1 +uses: grumlimited/arch-pkgbuild-builder@v1 with: target: 'srcinfo' pkgname: 'ucm-bin' @@ -45,7 +50,7 @@ with: Installs the package and runs a given `command`. ```yml -uses: 2m/arch-pkgbuild-builder@v1 +uses: grumlimited/arch-pkgbuild-builder@v1 with: target: 'run' pkgname: 'ucm-bin' @@ -56,4 +61,4 @@ with: So far this action is used by the following packages: -* [ucm-bin](https://github.com/2m/ucm-bin-pkgbuild) +* [authenticator-rs](https://github.com/grumlimited/authenticator-rs) diff --git a/action.yml b/action.yml index 7d5f01a..5976bf0 100644 --- a/action.yml +++ b/action.yml @@ -1,11 +1,13 @@ name: 'Arch Linux PKGBUILD builder action' description: 'Builds an validates PKGBUILD definition' + branding: icon: 'triangle' color: 'blue' + inputs: - pkgname: - description: 'The pkgname of the package to be validated' + pkgbuild: + description: 'Path to file PKGBUILD. Assumes to be placed in a directory with the name of package, ie /path/to/pkgname' required: true target: description: 'Validation target. Can be one of: "pkgbuild", "srcinfo"' @@ -14,10 +16,11 @@ inputs: command: description: 'Command to run after package installation' required: false + runs: using: 'docker' image: 'Dockerfile' args: - ${{ inputs.target }} - - ${{ inputs.pkgname }} + - ${{ inputs.pkgbuild }} - ${{ inputs.command }} diff --git a/entrypoint.sh b/entrypoint.sh index 71efc49..3b44062 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -1,24 +1,28 @@ #!/bin/sh -l target=$1 -pkgname=$2 +pkgbuild=$2 command=$3 -# '/github/workspace' is mounted as a volume and has owner set to root -# set the owner to the 'build' user, so it can access package files -sudo chown -R build /github/workspace /github/home - # assumes that package files are in a subdirectory # of the same name as "pkgname", so this works well # with "aurpublish" tool -cd "$pkgname" || exit + +pkgbuild_dir=$(dirname $(readlink $pkgbuild -f)) +cd $pkgbuild_dir || exit + +# '/github/workspace' is mounted as a volume and has owner set to root +# set the owner to the 'build' user, so it can access package files +sudo chown -R build $pkgbuild_dir + +pkgname=$(basename $pkgbuild_dir) install_deps() { # install make and regular package dependencies grep -E 'depends|makedepends' PKGBUILD | \ sed -e 's/.*depends=//' -e 's/ /\n/g' | \ tr -d "'" | tr -d "(" | tr -d ")" | \ - xargs yay -S --noconfirm + xargs sudo yay -S --noconfirm } case $target in @@ -27,8 +31,8 @@ case $target in install_deps makepkg --syncdeps --noconfirm namcap "${pkgname}"-* - pacman -Qip "${pkgname}"-* - pacman -Qlp "${pkgname}"-* + pacman -Qip "${pkgname}"-*.xz + pacman -Qlp "${pkgname}"-*.xz ;; run) install_deps