From 8aba032de40e4b83a36cae791ce1bbf77310d6a3 Mon Sep 17 00:00:00 2001 From: EnnoxHD Date: Thu, 8 Feb 2024 00:38:33 +0100 Subject: [PATCH] makepkg: make 'not a clone of' visible with a new error code Add a new error code to expose the 'not a clone of' error state of some source providers (git and fossil). This allows other tools integrating further and handle this specific error state. One usecase evolves around frequently changing source locations in PKGBUILDs of packages in the AUR. --- doc/makepkg.8.asciidoc | 4 ++++ scripts/libmakepkg/source/fossil.sh.in | 3 ++- scripts/libmakepkg/source/git.sh.in | 3 ++- scripts/libmakepkg/util/error.sh.in | 1 + 4 files changed, 9 insertions(+), 2 deletions(-) diff --git a/doc/makepkg.8.asciidoc b/doc/makepkg.8.asciidoc index cf819b9c..5ba13ace 100644 --- a/doc/makepkg.8.asciidoc +++ b/doc/makepkg.8.asciidoc @@ -363,6 +363,10 @@ On exit, makepkg will return one of the following error codes. 16:: Specified GPG key does not exist or failed to sign package. +17:: + The local repository is not a clone of the source repository + specified in PKGBUILD. + See Also -------- linkman:makepkg.conf[5], linkman:PKGBUILD[5], linkman:pacman[8] diff --git a/scripts/libmakepkg/source/fossil.sh.in b/scripts/libmakepkg/source/fossil.sh.in index 4ffc4a3d..bf2fa53e 100644 --- a/scripts/libmakepkg/source/fossil.sh.in +++ b/scripts/libmakepkg/source/fossil.sh.in @@ -24,6 +24,7 @@ LIBMAKEPKG_SOURCE_FOSSIL_SH=1 MAKEPKG_LIBRARY=${MAKEPKG_LIBRARY:-'@libmakepkgdir@'} +source "$MAKEPKG_LIBRARY/util/error.sh" source "$MAKEPKG_LIBRARY/util/message.sh" source "$MAKEPKG_LIBRARY/util/pkgbuild.sh" @@ -57,7 +58,7 @@ download_fossil() { if ! [[ $(fossil remote -R "$db") = "$url" ]]; then error "$(gettext "%s is not a clone of %s")" "$db" "$url" plainerr "$(gettext "Aborting...")" - exit 1 + exit $E_NOT_A_CLONE_OF fi msg2 "$(gettext "Updating %s %s repo...")" "${repo}" "fossil" if ! fossil pull -R "$db"; then diff --git a/scripts/libmakepkg/source/git.sh.in b/scripts/libmakepkg/source/git.sh.in index 0f835c3c..e8051760 100644 --- a/scripts/libmakepkg/source/git.sh.in +++ b/scripts/libmakepkg/source/git.sh.in @@ -24,6 +24,7 @@ LIBMAKEPKG_SOURCE_GIT_SH=1 MAKEPKG_LIBRARY=${MAKEPKG_LIBRARY:-'@libmakepkgdir@'} +source "$MAKEPKG_LIBRARY/util/error.sh" source "$MAKEPKG_LIBRARY/util/message.sh" source "$MAKEPKG_LIBRARY/util/pkgbuild.sh" @@ -60,7 +61,7 @@ download_git() { if [[ "${url%%.git}" != "${remote_url%%.git}" ]] ; then error "$(gettext "%s is not a clone of %s")" "$dir" "$url" plainerr "$(gettext "Aborting...")" - exit 1 + exit $E_NOT_A_CLONE_OF fi msg2 "$(gettext "Updating %s %s repo...")" "${repo}" "git" if ! git fetch --all -p; then diff --git a/scripts/libmakepkg/util/error.sh.in b/scripts/libmakepkg/util/error.sh.in index 88f87be1..b3def432 100644 --- a/scripts/libmakepkg/util/error.sh.in +++ b/scripts/libmakepkg/util/error.sh.in @@ -39,3 +39,4 @@ E_ALREADY_BUILT=13 E_INSTALL_FAILED=14 E_MISSING_MAKEPKG_DEPS=15 E_PRETTY_BAD_PRIVACY=16 +E_NOT_A_CLONE_OF=17