diff options
Diffstat (limited to 'scripts')
-rw-r--r-- | scripts/makepkg.sh.in | 168 | ||||
-rw-r--r-- | scripts/rankmirrors.py.in | 2 |
2 files changed, 92 insertions, 78 deletions
diff --git a/scripts/makepkg.sh.in b/scripts/makepkg.sh.in index 3662228c..2941a5d3 100644 --- a/scripts/makepkg.sh.in +++ b/scripts/makepkg.sh.in @@ -175,6 +175,7 @@ clean_up() { ## # Signal Traps ## +set -E trap 'clean_up' 0 trap 'trap_exit "$(gettext "TERM signal caught. Exiting...")"' TERM HUP QUIT trap 'trap_exit "$(gettext "Aborted by user! Exiting...")"' INT @@ -355,7 +356,7 @@ check_deps() { fi } -handledeps() { +handle_deps() { local R_DEPS_SATISFIED=0 local R_DEPS_MISSING=1 @@ -403,7 +404,7 @@ resolve_deps() { return $R_DEPS_SATISFIED fi - if handledeps $deplist; then + if handle_deps $deplist; then pkgdeps="$pkgdeps $deplist" # check deps again to make sure they were resolved deplist="$(check_deps $*)" @@ -693,72 +694,23 @@ extract_sources() { fi } -run_build() { - # use distcc if it is requested (check buildenv and PKGBUILD opts) - if [ "$(check_buildenv distcc)" = "y" -a "$(check_option distcc)" != "n" ]; then - [ -d /usr/lib/distcc/bin ] && export PATH="/usr/lib/distcc/bin:$PATH" - export DISTCC_HOSTS - elif [ "$(check_option distcc)" = "n" ]; then - # if it is not wanted, clear the makeflags too - MAKEFLAGS="" - fi - - # use ccache if it is requested (check buildenv and PKGBUILD opts) - if [ "$(check_buildenv ccache)" = "y" -a "$(check_option ccache)" != "n" ]; then - [ -d /usr/lib/ccache/bin ] && export PATH="/usr/lib/ccache/bin:$PATH" - fi - - # clear user-specified makeflags if requested - if [ "$(check_option makeflags)" = "n" ]; then - MAKEFLAGS="" - fi - - msg "$(gettext "Starting build()...")" - cd "$srcdir" - - # ensure all necessary build variables are exported - export CFLAGS CXXFLAGS MAKEFLAGS LDFLAGS CHOST - # save our shell options so build() can't override what we need - local shellopts=$(shopt -p) - - local ret=0 - if [ "$LOGGING" -eq 1 ]; then - BUILDLOG="${startdir}/${pkgbase}-${pkgver}-${pkgrel}-${CARCH}-build.log" - if [ -f "$BUILDLOG" ]; then - local i=1 - while true; do - if [ -f "$BUILDLOG.$i" ]; then - i=$(($i +1)) - else - break - fi - done - mv "$BUILDLOG" "$BUILDLOG.$i" - fi - - build 2>&1 | tee "$BUILDLOG"; ret=${PIPESTATUS[0]} - else - build 2>&1 || ret=$? +error_function() { + if [ -p "$logpipe" ]; then + rm "$logpipe" fi - # reset our shell options - eval "$shellopts" - - if [ $ret -gt 0 ]; then - error "$(gettext "Build Failed.")" + # first exit all subshells, then print the error + if [ $BASH_SUBSHELL -eq 0 ]; then plain "$(gettext "Aborting...")" remove_deps - exit 2 # $E_BUILD_FAILED fi + exit 2 # $E_BUILD_FAILED } -run_package() { +run_function() { if [ -z "$1" ]; then - pkgfunc="package" - nameofpkg="$pkgname" - else - pkgfunc="package_$1" - nameofpkg="$1" + return 1 fi + pkgfunc="$1" # clear user-specified makeflags if requested if [ "$(check_option makeflags)" = "n" ]; then @@ -770,10 +722,12 @@ run_package() { # ensure all necessary build variables are exported export CFLAGS CXXFLAGS LDFLAGS MAKEFLAGS CHOST + # save our shell options so pkgfunc() can't override what we need + local shellopts=$(shopt -p) local ret=0 if [ "$LOGGING" -eq 1 ]; then - BUILDLOG="${startdir}/${nameofpkg}-${pkgver}-${pkgrel}-${CARCH}-package.log" + BUILDLOG="${startdir}/${pkgname}-${pkgver}-${pkgrel}-${CARCH}-$pkgfunc.log" if [ -f "$BUILDLOG" ]; then local i=1 while true; do @@ -792,20 +746,49 @@ run_package() { exec 3>&1 tee "$BUILDLOG" < "$logpipe" & exec 1>"$logpipe" 2>"$logpipe" - $pkgfunc 2>&1 || ret=$? + restoretrap=$(trap -p ERR) + trap 'error_function' ERR + $pkgfunc 2>&1 + eval $restoretrap sync exec 1>&3 2>&3 3>&- rm "$logpipe" else - $pkgfunc 2>&1 || ret=$? + restoretrap=$(trap -p ERR) + trap 'error_function' ERR + $pkgfunc 2>&1 + eval $restoretrap fi + # reset our shell options + eval "$shellopts" +} - if [ $ret -gt 0 ]; then - error "$(gettext "Packaging Failed.")" - plain "$(gettext "Aborting...")" - remove_deps - exit 2 # $E_BUILD_FAILED +run_build() { + # use distcc if it is requested (check buildenv and PKGBUILD opts) + if [ "$(check_buildenv distcc)" = "y" -a "$(check_option distcc)" != "n" ]; then + [ -d /usr/lib/distcc/bin ] && export PATH="/usr/lib/distcc/bin:$PATH" + export DISTCC_HOSTS + elif [ "$(check_option distcc)" = "n" ]; then + # if it is not wanted, clear the makeflags too + MAKEFLAGS="" fi + + # use ccache if it is requested (check buildenv and PKGBUILD opts) + if [ "$(check_buildenv ccache)" = "y" -a "$(check_option ccache)" != "n" ]; then + [ -d /usr/lib/ccache/bin ] && export PATH="/usr/lib/ccache/bin:$PATH" + fi + + run_function "build" +} + +run_package() { + if [ -z "$1" ]; then + pkgfunc="package" + else + pkgfunc="package_$1" + fi + + run_function "$pkgfunc" } tidy_install() { @@ -966,6 +949,18 @@ write_pkginfo() { fi } +check_package() { + cd "$pkgdir" + + # check existence of backup files + local file + for file in "${backup[@]}"; do + if [ ! -f "$file" ]; then + warning "$(gettext "Invalid backup entry : %s")" "$file" + fi + done +} + create_package() { if [ ! -d "$pkgdir" ]; then error "$(gettext "Missing pkg/ directory.")" @@ -973,6 +968,8 @@ create_package() { exit 1 # $E_MISSING_PKGDIR fi + check_package + cd "$pkgdir" msg "$(gettext "Creating package...")" @@ -1175,6 +1172,22 @@ check_sanity() { fi done + local file + for file in "${backup[@]}"; do + if [ "${file:0:1}" = "/" ]; then + error "$(gettext "Invalid backup entry : %s")" "$file" + return 1 + fi + done + + local optdepend + for optdepend in "${optdepends[@]}"; do + pkg=${optdepend%%:*} + if [[ ! $pkg =~ ^[[:alnum:]\>\<\=\.\+\_\-]*$ ]]; then + error "$(gettext "Invalid syntax for optdepend : '%s'")" "$optdepend" + fi + done + if [ "$install" -a ! -f "$install" ]; then error "$(gettext "Install scriptlet (%s) does not exist.")" "$install" return 1 @@ -1414,31 +1427,30 @@ usage() { printf "$(gettext " -A, --ignorearch Ignore incomplete arch field in %s")\n" "$BUILDSCRIPT" echo "$(gettext " -c, --clean Clean up work files after build")" echo "$(gettext " -C, --cleancache Clean up source files from the cache")" - printf "$(gettext " --config <config> Use an alternate config file (instead of '%s')")\n" "$confdir/makepkg.conf" echo "$(gettext " -d, --nodeps Skip all dependency checks")" echo "$(gettext " -e, --noextract Do not extract source files (use existing src/ dir)")" echo "$(gettext " -f, --force Overwrite existing package")" echo "$(gettext " -g, --geninteg Generate integrity checks for source files")" - echo "$(gettext " --skipinteg Do not fail when integrity checks are missing")" echo "$(gettext " -h, --help This help")" echo "$(gettext " -i, --install Install package after successful build")" echo "$(gettext " -L, --log Log package build process")" echo "$(gettext " -m, --nocolor Disable colorized output messages")" echo "$(gettext " -o, --nobuild Download and extract files only")" - printf "$(gettext " -p <buildscript> Use an alternate build script (instead of '%s')")\n" "$BUILDSCRIPT" + printf "$(gettext " -p <file> Use an alternate build script (instead of '%s')")\n" "$BUILDSCRIPT" echo "$(gettext " -r, --rmdeps Remove installed dependencies after a successful build")" - # fix flyspray feature request #2978 echo "$(gettext " -R, --repackage Repackage contents of the package without rebuilding")" echo "$(gettext " -s, --syncdeps Install missing dependencies with pacman")" - echo "$(gettext " --allsource Generate a source-only tarball including downloaded sources")" - echo "$(gettext " --asroot Allow makepkg to run as root user")" - echo "$(gettext " --holdver Prevent automatic version bumping for development PKGBUILDs")" - echo "$(gettext " --source Generate a source-only tarball without downloaded sources")" + echo "$(gettext " --allsource Generate a source-only tarball including downloaded sources")" + echo "$(gettext " --asroot Allow makepkg to run as root user")" + printf "$(gettext " --config <file> Use an alternate config file (instead of '%s')")\n" "$confdir/makepkg.conf" + echo "$(gettext " --holdver Prevent automatic version bumping for development PKGBUILDs")" + echo "$(gettext " --skipinteg Do not fail when integrity checks are missing")" + echo "$(gettext " --source Generate a source-only tarball without downloaded sources")" echo echo "$(gettext "These options can be passed to pacman:")" echo - echo "$(gettext " --noconfirm Do not ask for confirmation when resolving dependencies")" - echo "$(gettext " --noprogressbar Do not show a progress bar when downloading files")" + echo "$(gettext " --noconfirm Do not ask for confirmation when resolving dependencies")" + echo "$(gettext " --noprogressbar Do not show a progress bar when downloading files")" echo printf "$(gettext "If -p is not specified, makepkg will look for '%s'")\n" "$BUILDSCRIPT" echo diff --git a/scripts/rankmirrors.py.in b/scripts/rankmirrors.py.in index 4b253b67..6bfa6612 100644 --- a/scripts/rankmirrors.py.in +++ b/scripts/rankmirrors.py.in @@ -156,6 +156,8 @@ if __name__ == "__main__": # if the $repo var is used in the url, replace it by core tempUrl = Template(serverUrl).safe_substitute(repo='core') + # if the $arch var is used in the url, replace it by i686 + tempUrl = Template(tempUrl).safe_substitute(arch='i686') # add @DBEXT@ to server name. the repo name is parsed # from the mirror url; it is the third (or fourth) dir |