diff options
author | Nicolás Reynolds <apoyosis@correo.inta.gob.ar> | 2011-05-22 11:04:16 -0300 |
---|---|---|
committer | Nicolás Reynolds <apoyosis@correo.inta.gob.ar> | 2011-05-22 11:04:16 -0300 |
commit | e1ef4ce407f51862fc596d48b6609b81f032a162 (patch) | |
tree | 0989ec180c64c0255134e507bd1a6b9e7e8b0838 | |
parent | 162fb6af8d91a83b4e270a1c7e0b94f0cf821d87 (diff) | |
parent | 1332457128ce015dc46561e531740c725c23299e (diff) |
Merge branch 'master' of ssh://vparabola/srv/git/projects/libretools
-rwxr-xr-x | fullpkg | 224 | ||||
-rwxr-xr-x | libremakepkg | 6 | ||||
-rwxr-xr-x | librerelease | 11 | ||||
-rwxr-xr-x | librestage | 2 | ||||
-rwxr-xr-x | mipsrelease | 2 |
5 files changed, 142 insertions, 103 deletions
@@ -4,23 +4,56 @@ # * 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 absdir : set ABSROOT to this dir" + echo " -r reponame : set repo name to reponame" + echo " -R pkgname : build pkgname if it is a dep" + echo +} + +force_build='n' +force_array=() +_fullpkgargs="" +failed=() +missing=() + +while getopts 'hfn:r:R:' arg; do + case $arg in + h) usage; exit 0 ;; + f) force_build='y' ;; + R) force_array=(${force_array[@]} $OPTARG); _fullpkgargs+="-R $OPTARG ";; + 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 +ban_file=$(mktemp /tmp/ban.XXXXXX) -source /etc/makepkg.conf -source /etc/abs.conf -source /etc/libretools.conf - -[[ -r ~/.config/libretools/libretools.conf ]] && \ - source ~/.config/libretools/libretools.conf +## START FUNCTIONS ## # Queue Management # * Always get the queue list from the server @@ -30,10 +63,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 +95,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,61 +112,87 @@ 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 || { - echo ":: Failed to get ban list" - return 0 + plain "Failed to get ban list" + return 1 } - grep -w $1 $ban_file >/dev/null 2>&1 - return $? } +guess_repo() { + basename $(dirname $(pwd)) +} + +# usage : in_array( $needle, $haystack ) +# return : 0 - found +# 1 - not found +function in_array { + [[ $2 ]] || return 1 + local needle=$1; shift + local item + for item in "$@"; do + [[ ${item#@} = $needle ]] && return 0 + done + return 1 # Not Found +} -# TODO keep track of spawned fullpkgs -quit() { +function quit { remove_queue - exit 1 } -repo=${1:-$(guess_repo)} +function cleanup { + rm $ban_file $queue_file + rm -rf $tmp_dir +} + +# TODO keep track of spawned fullpkgs + +## END FUNCTIONS ## source PKGBUILD +repo=${repo:-$(guess_repo)} msg "Building ${repo:-missing repo}/${pkgbase:-${pkgname[@]}}: $pkgdesc" -is_built "${pkgbase:-${pkgname[0]}}>=${pkgver}-${pkgrel}" && exit 0 +# Pre build tests +if [ $force_build == 'n' ]; then -#sudo pacman -Sy + # Be able to write files + 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 -trap "quit" TERM KILL INT + if is_built "${pkgbase:-${pkgname[0]}}>=${pkgver}-${pkgrel}"; then + msg2 "This package is built." + exit 0 + fi -if is_banned ${pkgbase:-$pkgname}; then - error "This package is banned from building. Check the ban list" - exit 1 -fi + if is_banned ${pkgbase:-$pkgname}; then + error "This package is banned from building. Check the ban list" + exit 1 + fi -check_queue || exit 1 + check_queue || exit 1 -failed=() -missing=() +fi + +# This will be executed at exit for any reason. +trap "quit" EXIT INT QUIT TERM KILL HUP if ! grep mips64el PKGBUILD >/dev/null; then msg "Adding mips64el arch" sed -i "s/^\(arch=([^)anym]\+\))/\1 'mips64el')/" "PKGBUILD" fi -# Gets the dependency list from the package_* functions -#pkgdeps=($(cat PKGBUILD | \ -# tr -d "\n" | \ -# sed -n "s/depends=(\([^)]\+\))/\n::\1\n/pg" | \ -# grep --color=never "^::" | \ -# tr -d [:\'\"] | \ -# tr " " "\n" | \ -# sort -u)) - # Clean version checking deps=$(echo "${depends[@]} ${makedepends[@]} ${pkgdeps[@]}" | \ sed "s/[=<>]\+[^ ]\+//g" | \ @@ -145,11 +200,6 @@ deps=$(echo "${depends[@]} ${makedepends[@]} ${pkgdeps[@]}" | \ sort -u) msg "Checking dependencies" -plain "${deps[@]}" - -#msg "Syncing database" -#sudo pacman -Sy - for _dep in ${deps[@]}; do is_banned $_dep && continue @@ -158,14 +208,18 @@ for _dep in ${deps[@]}; do [[ -e "$ABSROOT/${_repo}/$_dep/PKGBUILD" ]] && { 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 - msg2 "No need to build this one" - break - fi - + + if ! in_array $_dep ${force_array[@]}; then + if is_built "$_dep>=$pkgver-$pkgrel"; then + plain "this package is built" + break + fi + else + _fullpkgargs+="-f " + _fullpkgargs="$(echo $_fullpkgargs | sed s/"-R $_dep "//)" + force_array=( $(echo ${forcearray[@]} | tr " " "\n" | grep -vw "^$_dep") ) + fi + cp -r "$ABSROOT/$_repo/$_dep" $tmp_dir/ || { error "Can't copy $_dep to the work dir." exit 1 @@ -173,39 +227,25 @@ 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 $_fullpkgargs [[ $? -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 # TODO probably not elegant enough -# [[ ${#failed[@]} -gt 0 ]] || [[ ${#missing[@]} -gt 0 ]] && { - [[ ${#failed[@]} -gt 0 ]] && { - error "This packages failed to build: ${failed[@]}" - exit 1 - } - -# [[ ${#missing[@]} -gt 0 ]] && { -# echo ":: This packages are missing: ${missing[@]}" -# } - -# exit 1 -#} +# TODO only the last fullpkg should show this message +# and it should contain all failed pkgs +[[ ${#failed[@]} -gt 0 ]] && { + error "This packages failed to build: ${failed[@]}" + exit 1 +} # Let everybody know we're building this update_queue || { @@ -217,25 +257,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 + # cleanup is only on succesfull build so failed can be inspected + cleanup;; + 1) error "There were errors while trying to build the package." ;; + 2) error "The build failed." ;; esac -# Remove from queue -remove_queue - exit $r + diff --git a/libremakepkg b/libremakepkg index 54a5578..8af1581 100755 --- a/libremakepkg +++ b/libremakepkg @@ -29,8 +29,8 @@ function usage { echo "OPTIONS:" echo echo " -h : show this message." - echo " -c : cleans CHCOPY and cachedir." - echo " -u : updates before building." + echo " -c : cleans CHCOPY before building." + echo " -u : updates CHROOT before building." echo " -n : use this dir instead of CHCOPY." echo " -I pkgname : install this package, use it as many times needed." echo @@ -44,7 +44,7 @@ _PKGINSTALL="" #libremakepkg own args libremakepkgargs='hcun:I:' #now makepkg args -libremakepkgargs+='ACdefiLmoprRs' +libremakepkgargs+='ACdefiLmop:rRs' while getopts ${libremakepkgargs} arg ; do case "${arg}" in diff --git a/librerelease b/librerelease index 1505098..4e7c491 100755 --- a/librerelease +++ b/librerelease @@ -37,15 +37,20 @@ function usage { } function list_packages { - find $WORKDIR/staging/ -type f -printf "%f\n" + repos=($(find "$WORKDIR/staging/" -mindepth 1 -type d \! -empty -printf '%f ' 2>/dev/null)) + for _repo in ${repos[@]}; do + msg2 "$_repo" + find ${WORKDIR}/staging/${_repo} -type f -printf "%f\n" + done + unset repos } function clean_non_packages { - find $WORKDIR/staging/ -type -f \! -iname "*.pkg.tar.*" -delete + find $WORKDIR/staging/ -type f \! -iname "*.pkg.tar.?z" -delete } function clean_packages { - find ${WORKDIR}/staging/ -iname "*.pkg.tar.*" -delete + find ${WORKDIR}/staging/ -iname "*.pkg.tar.?z" -delete } while getopts 'hlc' arg; do @@ -74,7 +74,7 @@ PKGEXT=".pkg.tar.?z" staged='n' # Copies the packages to the specified repos inside staging -for _arch in ${arch[@]}; do +for _arch in ${ARCHES[@]}; do for pkg in ${pkgname[@]}; do pkgpath=$(find ${PKGDEST}/ -type f -name "${pkg}-${pkgver}-${pkgrel}-${_arch}${PKGEXT}") diff --git a/mipsrelease b/mipsrelease index 97e12d2..925748f 100755 --- a/mipsrelease +++ b/mipsrelease @@ -4,7 +4,7 @@ source /etc/makepkg.conf pushd ${PKGDEST} >/dev/null - +#TODO: repo-add should stage to a local db and not stage3 repo-add stage3.db.tar.gz $@ popd >/dev/null |