makepkg: only check software once

Move the checks for software and gpg signing ability to after the
fakeroot section so that it is only executed once. This also fixes
gpg (lack of) interaction under fakeroot.

Fixes #69

Signed-off-by: Allan McRae <allan@archlinux.org>
This commit is contained in:
Allan McRae 2023-12-09 11:03:15 +10:00
parent 42fa74e91a
commit f69d9b4475

View file

@ -1183,9 +1183,6 @@ if have_function pkgver; then
PKGVERFUNC=1 PKGVERFUNC=1
fi fi
# check we have the software required to process the PKGBUILD
check_software || exit $E_MISSING_MAKEPKG_DEPS
if (( ${#pkgname[@]} > 1 )) || have_function package_${pkgname}; then if (( ${#pkgname[@]} > 1 )) || have_function package_${pkgname}; then
SPLITPKG=1 SPLITPKG=1
fi fi
@ -1216,19 +1213,6 @@ if have_function package; then
PKGFUNC=1 PKGFUNC=1
fi fi
# check if gpg signature is to be created and if signing key is valid
if { [[ -z $SIGNPKG ]] && check_buildenv "sign" "y"; } || [[ $SIGNPKG == 'y' ]]; then
SIGNPKG='y'
if ! gpg --list-secret-key ${GPGKEY:+"$GPGKEY"} &>/dev/null; then
if [[ ! -z $GPGKEY ]]; then
error "$(gettext "The key %s does not exist in your keyring.")" "${GPGKEY}"
else
error "$(gettext "There is no key in your keyring.")"
fi
exit $E_PRETTY_BAD_PRIVACY
fi
fi
if (( PACKAGELIST )); then if (( PACKAGELIST )); then
print_all_package_names print_all_package_names
exit $E_OK exit $E_OK
@ -1266,6 +1250,22 @@ if (( INFAKEROOT )); then
exit $E_OK exit $E_OK
fi fi
# check we have the software required to process the PKGBUILD
check_software || exit $E_MISSING_MAKEPKG_DEPS
# check if gpg signature is to be created and if signing key is valid
if { [[ -z $SIGNPKG ]] && check_buildenv "sign" "y"; } || [[ $SIGNPKG == 'y' ]]; then
SIGNPKG='y'
if ! gpg --list-secret-key ${GPGKEY:+"$GPGKEY"} &>/dev/null; then
if [[ ! -z $GPGKEY ]]; then
error "$(gettext "The key %s does not exist in your keyring.")" "${GPGKEY}"
else
error "$(gettext "There is no key in your keyring.")"
fi
exit $E_PRETTY_BAD_PRIVACY
fi
fi
msg "$(gettext "Making package: %s")" "$pkgbase $basever ($(date +%c))" msg "$(gettext "Making package: %s")" "$pkgbase $basever ($(date +%c))"
# if we are creating a source-only package, go no further # if we are creating a source-only package, go no further