summaryrefslogtreecommitdiffstats
path: root/scripts/makepkg.sh.in
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/makepkg.sh.in')
-rw-r--r--scripts/makepkg.sh.in95
1 files changed, 40 insertions, 55 deletions
diff --git a/scripts/makepkg.sh.in b/scripts/makepkg.sh.in
index 02f5a02d..2a391575 100644
--- a/scripts/makepkg.sh.in
+++ b/scripts/makepkg.sh.in
@@ -2095,6 +2095,10 @@ install_package() {
fi
}
+have_function() {
+ declare -f "$1" >/dev/null
+}
+
check_sanity() {
# check for no-no's in the build script
local i
@@ -2240,9 +2244,14 @@ check_sanity() {
ret=1
fi
- if (( ${#pkgname[@]} > 1 )); then
+ if (( ${#pkgname[@]} == 1 )); then
+ if have_function build && ! ( have_function package || have_function package_${pkgname}); then
+ error "$(gettext "Missing %s function in %s")" "package()" "$BUILDFILE"
+ ret=1
+ fi
+ else
for i in ${pkgname[@]}; do
- if ! declare -f package_${i} >/dev/null; then
+ if ! have_function package_${i}; then
error "$(gettext "Missing %s function for split package '%s'")" "package_$i()" "$i"
ret=1
fi
@@ -2510,6 +2519,7 @@ usage() {
printf -- "$(gettext " --holdver Do not update VCS sources")\n"
printf -- "$(gettext " --key <key> Specify a key to use for %s signing instead of the default")\n" "gpg"
printf -- "$(gettext " --nocheck Do not run the %s function in the %s")\n" "check()" "$BUILDSCRIPT"
+ printf -- "$(gettext " --noprepare Do not run the %s function in the %s")\n" "prepare()" "$BUILDSCRIPT"
printf -- "$(gettext " --nosign Do not create a signature for the package")\n"
printf -- "$(gettext " --pkg <list> Only build listed packages from a split package")\n"
printf -- "$(gettext " --sign Sign the resulting package with %s")\n" "gpg"
@@ -2552,7 +2562,7 @@ ARGLIST=("$@")
OPT_SHORT="AcdefFghiLmop:rRsSV"
OPT_LONG=('allsource' 'asroot' 'check' 'clean' 'config:' 'force' 'geninteg'
'help' 'holdver' 'ignorearch' 'install' 'key:' 'log' 'nobuild' 'nocolor'
- 'nocheck' 'nodeps' 'noextract' 'nosign' 'pkg:' 'repackage' 'rmdeps'
+ 'nocheck' 'nodeps' 'noextract' 'noprepare' 'nosign' 'pkg:' 'repackage' 'rmdeps'
'sign' 'skipchecksums' 'skipinteg' 'skippgpcheck' 'source' 'syncdeps'
'verifysource' 'version')
@@ -2591,6 +2601,7 @@ while true; do
-L|--log) LOGGING=1 ;;
-m|--nocolor) USE_COLOR='n' ;;
--nocheck) RUN_CHECK='n' ;;
+ --noprepare) RUN_PREPARE='n' ;;
--nosign) SIGNPKG='n' ;;
-o|--nobuild) NOBUILD=1 ;;
-p) shift; BUILDFILE=$1 ;;
@@ -2631,6 +2642,7 @@ trap 'trap_exit USR1 "$(gettext "An unknown error has occurred. Exiting...")"' E
[[ -n ${SRCEXT} ]] && _SRCEXT=${SRCEXT}
[[ -n ${GPGKEY} ]] && _GPGKEY=${GPGKEY}
[[ -n ${PACKAGER} ]] && _PACKAGER=${PACKAGER}
+[[ -n ${CARCH} ]] && _CARCH=${CARCH}
# default config is makepkg.conf
MAKEPKG_CONF=${MAKEPKG_CONF:-$confdir/makepkg.conf}
@@ -2667,12 +2679,12 @@ if [[ -t 2 && ! $USE_COLOR = "n" ]] && check_buildenv "color" "y"; then
RED="${BOLD}$(tput setaf 1)"
YELLOW="${BOLD}$(tput setaf 3)"
else
- ALL_OFF="\e[1;0m"
- BOLD="\e[1;1m"
- BLUE="${BOLD}\e[1;34m"
- GREEN="${BOLD}\e[1;32m"
- RED="${BOLD}\e[1;31m"
- YELLOW="${BOLD}\e[1;33m"
+ ALL_OFF="\e[0m"
+ BOLD="\e[1m"
+ BLUE="${BOLD}\e[34m"
+ GREEN="${BOLD}\e[32m"
+ RED="${BOLD}\e[31m"
+ YELLOW="${BOLD}\e[33m"
fi
fi
readonly ALL_OFF BOLD BLUE GREEN RED YELLOW
@@ -2730,6 +2742,7 @@ PKGEXT=${_PKGEXT:-$PKGEXT}
SRCEXT=${_SRCEXT:-$SRCEXT}
GPGKEY=${_GPGKEY:-$GPGKEY}
PACKAGER=${_PACKAGER:-$PACKAGER}
+CARCH=${_CARCH:-$CARCH}
if (( ! INFAKEROOT )); then
if (( EUID == 0 && ! ASROOT )); then
@@ -2762,17 +2775,10 @@ unset makedepends optdepends options noextract
BUILDFILE=${BUILDFILE:-$BUILDSCRIPT}
if [[ ! -f $BUILDFILE ]]; then
- if [[ -t 0 ]]; then
- error "$(gettext "%s does not exist.")" "$BUILDFILE"
- exit 1
- else
- # PKGBUILD passed through a pipe
- BUILDFILE=/dev/stdin
- source_safe "$BUILDFILE"
- fi
+ error "$(gettext "%s does not exist.")" "$BUILDFILE"
+ exit 1
else
- crlftest=$(file "$BUILDFILE" | grep -F 'CRLF' || true)
- if [[ -n $crlftest ]]; then
+ if [[ $(<"$BUILDFILE") = *$'\r'* ]]; then
error "$(gettext "%s contains %s characters and cannot be sourced.")" "$BUILDFILE" "CRLF"
exit 1
fi
@@ -2808,7 +2814,7 @@ if (( GENINTEG )); then
exit 0 # $E_OK
fi
-if declare -f pkgver >/dev/null; then
+if have_function pkgver; then
PKGVERFUNC=1
fi
@@ -2823,21 +2829,24 @@ if (( ${#pkgname[@]} > 1 )); then
fi
# test for available PKGBUILD functions
-if declare -f prepare >/dev/null; then
- PREPAREFUNC=1
+if have_function prepare; then
+ # "Hide" prepare() function if not going to be run
+ if [[ $RUN_PREPARE != "n" ]]; then
+ PREPAREFUNC=1
+ fi
fi
-if declare -f build >/dev/null; then
+if have_function build; then
BUILDFUNC=1
fi
-if declare -f check >/dev/null; then
+if have_function check; then
# "Hide" check() function if not going to be run
if [[ $RUN_CHECK = 'y' ]] || { ! check_buildenv "check" "n" && [[ $RUN_CHECK != "n" ]]; }; then
CHECKFUNC=1
fi
fi
-if declare -f package >/dev/null; then
+if have_function package; then
PKGFUNC=1
-elif [[ $SPLITPKG -eq 0 ]] && declare -f package_${pkgname} >/dev/null; then
+elif [[ $SPLITPKG -eq 0 ]] && have_function package_${pkgname}; then
SPLITPKG=1
fi
@@ -2875,17 +2884,7 @@ if (( INFAKEROOT )); then
if (( ! SPLITPKG )); then
pkgdir="$pkgdirbase/$pkgname"
mkdir "$pkgdir"
- if (( ! PKGFUNC )); then
- if (( ! REPKG )); then
- if (( BUILDFUNC )); then
- run_build
- (( CHECKFUNC )) && run_check
- fi
- else
- warning "$(gettext "Repackaging without the use of a %s function is deprecated.")" "package()"
- plain "$(gettext "File permissions may not be preserved.")"
- fi
- else
+ if (( PKGFUNC )); then
run_package
fi
tidy_install
@@ -2902,10 +2901,6 @@ fi
fullver=$(get_full_version)
msg "$(gettext "Making package: %s")" "$pkgbase $fullver ($(date))"
-if (( !PKGFUNC && !SPLITPKG )); then
- warning "$(gettext "Using a %s without a %s function is deprecated.")" "$BUILDSCRIPT" "package()"
-fi
-
# if we are creating a source-only package, go no further
if (( SOURCEONLY )); then
if [[ -f $SRCPKGDEST/${pkgbase}-${fullver}${SRCEXT} ]] \
@@ -2983,14 +2978,7 @@ cd_safe "$srcdir"
if (( NOEXTRACT && ! VERIFYSOURCE )); then
warning "$(gettext "Using existing %s tree")" "src/"
-elif (( REPKG )); then
- if (( ! PKGFUNC && ! SPLITPKG )) \
- && { [[ ! -d $pkgdirbase ]] || dir_is_empty "$pkgdirbase"; }; then
- error "$(gettext "The package directory is empty, there is nothing to repackage!")"
- plain "$(gettext "Aborting...")"
- exit 1
- fi
-else
+elif (( !REPKG )); then
download_sources
check_source_integrity
(( VERIFYSOURCE )) && exit 0 # $E_OK
@@ -3004,8 +2992,8 @@ if (( NOBUILD )); then
msg "$(gettext "Sources are ready.")"
exit 0 #E_OK
else
- # check for existing pkg directory; don't remove if we are repackaging
- if [[ -d $pkgdirbase ]] && (( ! REPKG || PKGFUNC || SPLITPKG )); then
+ # clean existing pkg directory
+ if [[ -d $pkgdirbase ]]; then
msg "$(gettext "Removing existing %s directory...")" "pkg/"
rm -rf "$pkgdirbase"
fi
@@ -3029,9 +3017,6 @@ else
mkdir -p "$pkgdir"
if (( PKGFUNC )); then
run_package
- elif (( REPKG )); then
- warning "$(gettext "Repackaging without the use of a %s function is deprecated.")" "package()"
- plain "$(gettext "File permissions may not be preserved.")"
fi
tidy_install
create_package
@@ -3040,7 +3025,7 @@ else
run_split_packaging
fi
else
- if (( ! REPKG && ( PKGFUNC || SPLITPKG ) )); then
+ if (( ! REPKG )); then
(( BUILDFUNC )) && run_build
(( CHECKFUNC )) && run_check
cd_safe "$startdir"