diff options
Diffstat (limited to 'fullpkg')
-rwxr-xr-x | fullpkg | 124 |
1 files changed, 75 insertions, 49 deletions
@@ -4,23 +4,57 @@ # * Detect circular builds # * Detect pkgnames by provides, replaces, etc. instead of dir tree +source /etc/makepkg.conf +source /etc/abs.conf +source /etc/libretools.conf + +[[ -r ~/.config/libretools/libretools.conf ]] && \ + source ~/.config/libretools/libretools.conf + +function usage { + echo "cd to a dir containing a PKGBUILD and run:" + echo "$0 [options]" + printf "This script will check dependencies, build them if possible " + printf "and stage the packages on it's repo." + echo + echo "OPTIONS:" + echo " -h : this message." + echo " -f : build even when a package has been built." + echo " -n : set ABSROOT to this dir" + echo " -r reponame : set repo name to reponame" + echo +} + +force_build='n' + +while getopts 'hfn:r' arg; do + case $arg in + h) usage; exit 0 ;; + f) force_build='y' ;; + n) ABSROOT="$OPTARG" ;; + r) repo="$OPTARG" ;; + esac +done + [[ ! -r PKGBUILD ]] && { - echo "This isn't a build directory" + error "This isn't a build directory" + echo + usage exit 1 } tmp_dir=$(mktemp -d /tmp/$(basename $PWD).XXXXXX) queue_file=$(mktemp /tmp/queue.XXXXXX) ban_file=$(mktemp) -[[ ! -w $queue_file ]] && exit 1 -[[ ! -w $ban_file ]] && exit 1 - -source /etc/makepkg.conf -source /etc/abs.conf -source /etc/libretools.conf +if [[ ! -w $queue_file ]]; then + error "can't write queue file" + exit 1 +elif [[ ! -w $ban_file ]] ; then + error "can't write ban file" + exit 1 +fi -[[ -r ~/.config/libretools/libretools.conf ]] && \ - source ~/.config/libretools/libretools.conf +## START FUNCTIONS ## # Queue Management # * Always get the queue list from the server @@ -30,10 +64,6 @@ source /etc/libretools.conf # TODO # * Check for concurrence -guess_repo() { - basename $(dirname $(pwd)) -} - # Get the queue list from the server get_queue() { rsync -e ssh -aq $PARABOLAHOST:mips64el/queue $queue_file >/dev/null 2>&1 || { @@ -66,7 +96,7 @@ remove_queue() { grep -vw "^$(basename $PWD)" $queue_file > $queue_file.2 cat $queue_file.2 > $queue_file - put_queue || return $? + put_queue && rm $queue_file{,.2} && return 0 || return $? } # Checks if a package is listed @@ -83,32 +113,45 @@ check_queue() { return 0 } +# END Queue Management # + # Checks if the package is banned from building is_banned() { rsync -e ssh -aq $PARABOLAHOST:mips64el/ban $ban_file >/dev/null 2>&1 || { - plain ":: Failed to get ban list" + plain "Failed to get ban list" return 0 } grep -w $1 $ban_file >/dev/null 2>&1 + local rt=$? + rm $ban_file + return $rt +} - return $? +guess_repo() { + basename $(dirname $(pwd)) } # TODO keep track of spawned fullpkgs quit() { remove_queue - exit 1 } -repo=${1:-$(guess_repo)} +## END FUNCTIONS ## + +repo=${repo:-$(guess_repo)} source PKGBUILD msg "Building ${repo:-missing repo}/${pkgbase:-${pkgname[@]}}: $pkgdesc" -is_built "${pkgbase:-${pkgname[0]}}>=${pkgver}-${pkgrel}" && \ - msg2 "This package is built." && exit 0 +if is_built "${pkgbase:-${pkgname[0]}}>=${pkgver}-${pkgrel}"; then + msg2 "This package is built." + if [ $force_build == 'n' ]; then + exit 0 + fi + plain "Building anyway ..." +fi trap "quit" TERM KILL INT @@ -144,10 +187,8 @@ for _dep in ${deps[@]}; do source "$ABSROOT/${_repo}/$_dep/PKGBUILD" msg2 "Checking for $_dep>=$pkgver-$pkgrel" -# If this version is built, continue with the next dep - if is_built "$_dep>=$pkgver-$pkgrel"; then - plain "No need to build this one" + plain "this package is built" break fi @@ -158,22 +199,13 @@ for _dep in ${deps[@]}; do # Enter the work dir and run this command in it pushd $tmp_dir/$_dep >/dev/null - $0 $_repo + $0 -r $_repo [[ $? -ne 0 ]] && { failed=(${failed[@]} $_dep) } popd >/dev/null - - break -# } || { -# The package can't be found -# This can happen if: -# * The package is built inside a split package -# * The package is provided by some other package (ie by *-libre packages) -# echo "==> Missing package $_dep" -# missing=(${missing[@]} $_dep) } done done @@ -194,25 +226,19 @@ pushd $tmp_dir/$(basename $PWD) >/dev/null msg "Syncing database" sudo pacman -Syu --noconfirm -makepkg --noconfirm -sLcr ; r=$? +makepkg --noconfirm --nocheck -sLcr ; r=$? case $r in - 0) - msg "The build was succesful." - mipsrelease *.pkg.tar.* - - librestage $repo - - sudo pacman -Sy - ;; - 1) - error "There were errors while trying to build the package." - ;; - 2) - error "The build failed." - ;; + 0) msg "The build was succesful." + #TODO: mipsrelease should upload to a local db + mipsrelease *.pkg.tar.* + librestage $repo + librerelease + sudo pacman -Sy ;; + 1) error "There were errors while trying to build the package." ;; + 2) error "The build failed." ;; esac -# Remove from queue remove_queue exit $r + |