From a88cb03a58909304603a794e42070656fca6b626 Mon Sep 17 00:00:00 2001 From: Dan McGee Date: Mon, 10 Jan 2011 13:56:27 -0600 Subject: makepkg: perform all sanity checks before erroring out It is pretty annoying to get one, fix it, and then get another. We should be able to continue on through most of the sanity checks in one go so the user gets all the error messages at once. Also ensure $pkgbase is defined by the time we call this function; previously we printed nothing where a package name should have been due to this oversight. Signed-off-by: Dan McGee --- scripts/makepkg.sh.in | 37 +++++++++++++++++++------------------ 1 file changed, 19 insertions(+), 18 deletions(-) diff --git a/scripts/makepkg.sh.in b/scripts/makepkg.sh.in index 6ebfac0e..a2d9c837 100644 --- a/scripts/makepkg.sh.in +++ b/scripts/makepkg.sh.in @@ -1194,36 +1194,37 @@ install_package() { check_sanity() { # check for no-no's in the build script local i + local ret=0 for i in 'pkgname' 'pkgrel' 'pkgver'; do if [[ -z ${!i} ]]; then error "$(gettext "%s is not allowed to be empty.")" "$i" - return 1 + ret=1 fi done for i in "${pkgname[@]}"; do if [[ ${i:0:1} = "-" ]]; then error "$(gettext "%s is not allowed to start with a hyphen.")" "pkgname" - return 1 + ret=1 fi done if [[ ${pkgbase:0:1} = "-" ]]; then error "$(gettext "%s is not allowed to start with a hyphen.")" "pkgbase" - return 1 + ret=1 fi - if [[ $pkgver != ${pkgver//-/} ]]; then - error "$(gettext "%s is not allowed to contain hyphens.")" "pkgver" - return 1 + if [[ $pkgver =~ [:-] ]]; then + error "$(gettext "%s is not allowed to contain colons or hyphens.")" "pkgver" + ret=1 fi if [[ $pkgrel != ${pkgrel//-/} ]]; then error "$(gettext "%s is not allowed to contain hyphens.")" "pkgrel" - return 1 + ret=1 fi if [[ ! $epoch =~ ^[0-9]*$ ]]; then error "$(gettext "%s must be an integer.")" "epoch" - return 1 + ret=1 fi if [[ $arch != 'any' ]]; then @@ -1232,7 +1233,7 @@ check_sanity() { error "$(gettext "%s is not available for the '%s' architecture.")" "$pkgbase" "$CARCH" plain "$(gettext "Note that many packages may need a line added to their %s")" "$BUILDSCRIPT" plain "$(gettext "such as arch=('%s').")" "$CARCH" - return 1 + ret=1 fi fi fi @@ -1242,7 +1243,7 @@ check_sanity() { for i in ${provides_list[@]}; do if [[ $i != ${i///} ]]; then error "$(gettext "Provides array cannot contain comparison (< or >) operators.")" - return 1 + ret=1 fi done @@ -1251,7 +1252,7 @@ check_sanity() { for i in "${backup_list[@]}"; do if [[ ${i:0:1} = "/" ]]; then error "$(gettext "Backup entry should not contain leading slash : %s")" "$i" - return 1 + ret=1 fi done @@ -1272,7 +1273,7 @@ check_sanity() { eval file=${file} if [[ ! -f $file ]]; then error "$(gettext "%s file (%s) does not exist.")" "$i" "$file" - return 1 + ret=1 fi done done @@ -1294,14 +1295,14 @@ check_sanity() { fi done if (( ! valid_options )); then - return 1 + ret=1 fi if (( ${#pkgname[@]} > 1 )); then for i in ${pkgname[@]}; do if ! declare -f package_${i} >/dev/null; then error "$(gettext "missing package function for split package '%s'")" "$i" - return 1 + ret=1 fi done fi @@ -1309,11 +1310,11 @@ check_sanity() { for i in ${PKGLIST[@]}; do if ! in_array $i ${pkgname[@]}; then error "$(gettext "requested package %s is not provided in %s")" "$i" "$BUILDFILE" - return 1 + ret=1 fi done - return 0 + return $ret } devel_check() { @@ -1838,6 +1839,8 @@ if (( GENINTEG )); then exit 0 # $E_OK fi +pkgbase=${pkgbase:-${pkgname[0]}} + # check the PKGBUILD for some basic requirements check_sanity || exit 1 @@ -1868,8 +1871,6 @@ elif [[ $SPLITPKG -eq 0 ]] && declare -f package_${pkgname} >/dev/null; then SPLITPKG=1 fi -pkgbase=${pkgbase:-${pkgname[0]}} - if [[ -n "${PKGLIST[@]}" ]]; then unset pkgname pkgname=("${PKGLIST[@]}") -- cgit v1.2.3-70-g09d2