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.
This commit is contained in:
EnnoxHD 2024-02-08 00:38:33 +01:00 committed by Allan McRae
parent bcd4aad16c
commit 8aba032de4
4 changed files with 9 additions and 2 deletions

View file

@ -363,6 +363,10 @@ On exit, makepkg will return one of the following error codes.
16:: 16::
Specified GPG key does not exist or failed to sign package. 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 See Also
-------- --------
linkman:makepkg.conf[5], linkman:PKGBUILD[5], linkman:pacman[8] linkman:makepkg.conf[5], linkman:PKGBUILD[5], linkman:pacman[8]

View file

@ -24,6 +24,7 @@ LIBMAKEPKG_SOURCE_FOSSIL_SH=1
MAKEPKG_LIBRARY=${MAKEPKG_LIBRARY:-'@libmakepkgdir@'} MAKEPKG_LIBRARY=${MAKEPKG_LIBRARY:-'@libmakepkgdir@'}
source "$MAKEPKG_LIBRARY/util/error.sh"
source "$MAKEPKG_LIBRARY/util/message.sh" source "$MAKEPKG_LIBRARY/util/message.sh"
source "$MAKEPKG_LIBRARY/util/pkgbuild.sh" source "$MAKEPKG_LIBRARY/util/pkgbuild.sh"
@ -57,7 +58,7 @@ download_fossil() {
if ! [[ $(fossil remote -R "$db") = "$url" ]]; then if ! [[ $(fossil remote -R "$db") = "$url" ]]; then
error "$(gettext "%s is not a clone of %s")" "$db" "$url" error "$(gettext "%s is not a clone of %s")" "$db" "$url"
plainerr "$(gettext "Aborting...")" plainerr "$(gettext "Aborting...")"
exit 1 exit $E_NOT_A_CLONE_OF
fi fi
msg2 "$(gettext "Updating %s %s repo...")" "${repo}" "fossil" msg2 "$(gettext "Updating %s %s repo...")" "${repo}" "fossil"
if ! fossil pull -R "$db"; then if ! fossil pull -R "$db"; then

View file

@ -24,6 +24,7 @@ LIBMAKEPKG_SOURCE_GIT_SH=1
MAKEPKG_LIBRARY=${MAKEPKG_LIBRARY:-'@libmakepkgdir@'} MAKEPKG_LIBRARY=${MAKEPKG_LIBRARY:-'@libmakepkgdir@'}
source "$MAKEPKG_LIBRARY/util/error.sh"
source "$MAKEPKG_LIBRARY/util/message.sh" source "$MAKEPKG_LIBRARY/util/message.sh"
source "$MAKEPKG_LIBRARY/util/pkgbuild.sh" source "$MAKEPKG_LIBRARY/util/pkgbuild.sh"
@ -60,7 +61,7 @@ download_git() {
if [[ "${url%%.git}" != "${remote_url%%.git}" ]] ; then if [[ "${url%%.git}" != "${remote_url%%.git}" ]] ; then
error "$(gettext "%s is not a clone of %s")" "$dir" "$url" error "$(gettext "%s is not a clone of %s")" "$dir" "$url"
plainerr "$(gettext "Aborting...")" plainerr "$(gettext "Aborting...")"
exit 1 exit $E_NOT_A_CLONE_OF
fi fi
msg2 "$(gettext "Updating %s %s repo...")" "${repo}" "git" msg2 "$(gettext "Updating %s %s repo...")" "${repo}" "git"
if ! git fetch --all -p; then if ! git fetch --all -p; then

View file

@ -39,3 +39,4 @@ E_ALREADY_BUILT=13
E_INSTALL_FAILED=14 E_INSTALL_FAILED=14
E_MISSING_MAKEPKG_DEPS=15 E_MISSING_MAKEPKG_DEPS=15
E_PRETTY_BAD_PRIVACY=16 E_PRETTY_BAD_PRIVACY=16
E_NOT_A_CLONE_OF=17