diff options
author | Luke Shumaker <LukeShu@sbcglobal.net> | 2014-03-05 11:20:14 -0500 |
---|---|---|
committer | Luke Shumaker <LukeShu@sbcglobal.net> | 2014-03-05 11:20:14 -0500 |
commit | 19896860cab0ecee691bf336c98c2c2b18ea5e20 (patch) | |
tree | 5fd409ffcdfd4c0df7a591d68d80f224a09a4882 /src | |
parent | 74f68d0149f2a94780c860b0775d1e880dbe9225 (diff) |
dagpkg: Do a couple things the librelib way
Diffstat (limited to 'src')
-rwxr-xr-x | src/dagpkg | 71 |
1 files changed, 36 insertions, 35 deletions
@@ -3,8 +3,8 @@ # dagpkg - create a directed graph of package dependencies and build # them in topological order # -# (c) 2014 Nicolás Reynolds <fauno@parabola.nu> -# Michał Masłowski <mtjm@mtjm.eu> +# Copyright (C) 2014 Nicolás Reynolds <fauno@parabola.nu> +# Copyright (C) 2014 Michał Masłowski <mtjm@mtjm.eu> # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -20,37 +20,42 @@ # along with this program. If not, see <http://www.gnu.org/licenses/>. set -e +source $(librelib conf) + # Source variables from libretools -source /etc/libretools.conf -source $XDG_CONFIG_HOME/libretools/libretools.conf &>/dev/null || true +load_files libretools +check_vars libretools FULLBUILDCMD || exit 1 +#check_vars libretools HOOKPREBUILD HOOKLOCALRELEASE || exit 1 # optional # Source variables from makepkg -source /etc/makepkg.conf -source $XDG_CONFIG_HOME/.makepkg.conf &>/dev/null || true +load_files makepkg +check_vars makepkg CARCH || exit 1 + # End inmediately but print an useful message trap_exit() { + local signal=$1; shift + local msg=("$@") term_title "error!" + echo error "(%s) %s (leftovers on %s)" \ - "${0##*/}" "$@" "${temp_dir}" - exit 1 + "${0##*/}" "$(print "${msg[@]}")" "${temp_dir}" + trap -- "$signal" + kill "-$signal" "$$" } -# Trap signals from makepkg -trap 'trap_exit "TERM signal caught. Exiting..."' TERM HUP QUIT -trap 'trap_exit "Aborted by user! Exiting..."' INT -trap 'trap_exit "An unknown error has occurred. Exiting..."' ERR +setup_traps trap_exit source_pkgbuild() { # Source this PKGBUILD, if it doesn't exist, exit - unset pkgbase pkgname depends makedepends - unset pkgrel pkgver epoch - if ! source ./PKGBUILD &>/dev/null ; then + if ! load_PKGBUILD &>/dev/null; then error "No PKGBUILD in %s" "$PWD" exit 1 fi # Save resources + # This is intentionally less exhaustive than unset_PKGBUILD() + # XXX: document which things we actually *want* to not be unset. unset pkgdesc license groups backup install md5sums sha1sums \ sha256sums source options &>/dev/null @@ -70,17 +75,6 @@ source_pkgbuild temp_dir="${1:-$(mktemp -dt ${name}-testpkg-XXXX)}" log="${temp_dir}/buildorder" -# Generate the full version with epoch -get_fullver() { - if [ $1 -eq 0 ]; then - # zero epoch case, don't include it in version - echo $2-$3 - else - echo $1:$2-$3 - fi - -} - # Mark array for DFS-based topological sort. See # https://en.wikipedia.org/wiki/Topological_sort for an explanation of # the algorithm. Key: package name, value: 0 for unvisited package, 1 @@ -96,8 +90,9 @@ visit_pkgbuild() { source_pkgbuild # If it's already built we don't bother - is_built ${pkgname[0]} $(get_fullver ${epoch:-0} ${pkgver} ${pkgrel}) && - return + if is_built "${pkgname[0]}" "$(get_full_version "${pkgname[0]}")"; then + return + fi # Detect cycle or already visited package case "${marks[$name]:-0}" in @@ -108,13 +103,15 @@ visit_pkgbuild() { msg "%s (%s)" ${name} ${prev} - echo "${arch[@]}" | grep -qw "$CARCH" || - warning "%s isn't ported to %s yet" ${name} ${CARCH} + if ! in_array "${CARCH}" "${arch[@]}"; then + warning "%s isn't ported to %s yet" ${name} ${CARCH} + fi # If the envvar I contains this package, ignore it and exit - echo "$I" | grep -qw "$name" && - msg2 "%s ignored" ${name} && - return + if in_array "$name" $I; then + msg2 "%s ignored" ${name} + return + fi # Mark the package as being visited marks[$name]=1 @@ -183,13 +180,17 @@ nl ${log} | while read order pkg; do sudo -E pacman -Syu --noconfirm # run the pre build command from libretools.conf - ${HOOKPREBUILD} + if [[ -n "$HOOKPREBUILD" ]]; then + ${HOOKPREBUILD} + fi # run the build command ${FULLBUILDCMD} # Run local release hook with $1 = $repo - ${HOOKLOCALRELEASE} "$(basename "$(dirname "$w")")" + if [[ -n "$HOOKLOCALRELEASE" ]]; then + ${HOOKLOCALRELEASE} "$(basename "$(dirname "$w")")" + fi # it's built! touch built_ok |