From 6dfbe0e2ab6178a243a732aab721da6d2b583745 Mon Sep 17 00:00:00 2001 From: Joshua Ismael Haase Hernandez Date: Wed, 11 May 2011 22:37:58 -0500 Subject: Some message changes and cleanup --- fullpkg | 39 ++++++++------------------------------- 1 file changed, 8 insertions(+), 31 deletions(-) (limited to 'fullpkg') diff --git a/fullpkg b/fullpkg index c292bdd..f74c0b5 100755 --- a/fullpkg +++ b/fullpkg @@ -86,7 +86,7 @@ check_queue() { # 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" + plain ":: Failed to get ban list" return 0 } @@ -95,7 +95,6 @@ is_banned() { return $? } - # TODO keep track of spawned fullpkgs quit() { remove_queue @@ -108,9 +107,8 @@ repo=${1:-$(guess_repo)} source PKGBUILD msg "Building ${repo:-missing repo}/${pkgbase:-${pkgname[@]}}: $pkgdesc" -is_built "${pkgbase:-${pkgname[0]}}>=${pkgver}-${pkgrel}" && exit 0 - -#sudo pacman -Sy +is_built "${pkgbase:-${pkgname[0]}}>=${pkgver}-${pkgrel}" && \ + msg2 "This package is built." && exit 0 trap "quit" TERM KILL INT @@ -129,15 +127,6 @@ if ! grep mips64el PKGBUILD >/dev/null; then 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,10 +134,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 @@ -162,7 +147,7 @@ for _dep in ${deps[@]}; do # If this version is built, continue with the next dep if is_built "$_dep>=$pkgver-$pkgrel"; then - msg2 "No need to build this one" + plain "No need to build this one" break fi @@ -194,18 +179,10 @@ for _dep in ${deps[@]}; do 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 -#} +[[ ${#failed[@]} -gt 0 ]] && { + error "This packages failed to build: ${failed[@]}" + exit 1 +} # Let everybody know we're building this update_queue || { -- cgit v1.2.3-2-g168b From 2e4d78c7768119a75bba8ae5eab98c1a6026ea89 Mon Sep 17 00:00:00 2001 From: Joshua Ismael Haase Hernandez Date: Thu, 19 May 2011 02:02:22 -0500 Subject: * fullpkg uses options and librerelease * librerelease tell wich repo for each pkg when listing --- fullpkg | 124 +++++++++++++++++++++++++++++++++++++++------------------------- 1 file changed, 75 insertions(+), 49 deletions(-) (limited to 'fullpkg') diff --git a/fullpkg b/fullpkg index f74c0b5..41bc5c5 100755 --- a/fullpkg +++ b/fullpkg @@ -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 + -- cgit v1.2.3-2-g168b From af81fffea91ae472a9b0bbee7ed88317fbff468a Mon Sep 17 00:00:00 2001 From: Joshua Ismael Haase Hernandez Date: Thu, 19 May 2011 02:29:20 -0500 Subject: Fullpkg cleanup and exec quit on exit --- fullpkg | 61 ++++++++++++++++++++++++++++++++++--------------------------- 1 file changed, 34 insertions(+), 27 deletions(-) (limited to 'fullpkg') diff --git a/fullpkg b/fullpkg index 41bc5c5..692ddb0 100755 --- a/fullpkg +++ b/fullpkg @@ -26,6 +26,8 @@ function usage { } force_build='n' +failed=() +missing=() while getopts 'hfn:r' arg; do case $arg in @@ -45,14 +47,8 @@ done tmp_dir=$(mktemp -d /tmp/$(basename $PWD).XXXXXX) queue_file=$(mktemp /tmp/queue.XXXXXX) -ban_file=$(mktemp) -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 +ban_file=$(mktemp /tmp/ban.XXXXXX) +repo=${repo:-$(guess_repo)} ## START FUNCTIONS ## @@ -124,7 +120,6 @@ is_banned() { grep -w $1 $ban_file >/dev/null 2>&1 local rt=$? - rm $ban_file return $rt } @@ -138,32 +133,44 @@ quit() { exit 1 } -## END FUNCTIONS ## +function cleanup { + rm $ban_file $queue_file + rm -rf $tmp_dir +} -repo=${repo:-$(guess_repo)} +## END FUNCTIONS ## source PKGBUILD msg "Building ${repo:-missing repo}/${pkgbase:-${pkgname[@]}}: $pkgdesc" -if is_built "${pkgbase:-${pkgname[0]}}>=${pkgver}-${pkgrel}"; then - msg2 "This package is built." - if [ $force_build == 'n' ]; then +# Pre build tests +if [ $force_build == 'n' ]; then + + # 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 + + if is_built "${pkgbase:-${pkgname[0]}}>=${pkgver}-${pkgrel}"; then + msg2 "This package is built." exit 0 fi - plain "Building anyway ..." -fi -trap "quit" TERM KILL INT + if is_banned ${pkgbase:-$pkgname}; then + error "This package is banned from building. Check the ban list" + exit 1 + fi + + check_queue || exit 1 -if is_banned ${pkgbase:-$pkgname}; then - error "This package is banned from building. Check the ban list" - exit 1 fi -check_queue || exit 1 - -failed=() -missing=() +# 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" @@ -233,12 +240,12 @@ case $r in mipsrelease *.pkg.tar.* librestage $repo librerelease - sudo pacman -Sy ;; + 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_queue - exit $r -- cgit v1.2.3-2-g168b From 69b193a18370aa18c1f59715f7909821f2bf2310 Mon Sep 17 00:00:00 2001 From: Joshua Ismael Haase Hernandez Date: Thu, 19 May 2011 02:38:37 -0500 Subject: * guess_repo executed after it is declared --- fullpkg | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'fullpkg') diff --git a/fullpkg b/fullpkg index 692ddb0..8bc29d9 100755 --- a/fullpkg +++ b/fullpkg @@ -48,7 +48,6 @@ done tmp_dir=$(mktemp -d /tmp/$(basename $PWD).XXXXXX) queue_file=$(mktemp /tmp/queue.XXXXXX) ban_file=$(mktemp /tmp/ban.XXXXXX) -repo=${repo:-$(guess_repo)} ## START FUNCTIONS ## @@ -142,6 +141,7 @@ function cleanup { source PKGBUILD msg "Building ${repo:-missing repo}/${pkgbase:-${pkgname[@]}}: $pkgdesc" +repo=${repo:-$(guess_repo)} # Pre build tests if [ $force_build == 'n' ]; then @@ -184,7 +184,6 @@ deps=$(echo "${depends[@]} ${makedepends[@]} ${pkgdeps[@]}" | \ sort -u) msg "Checking dependencies" - for _dep in ${deps[@]}; do is_banned $_dep && continue -- cgit v1.2.3-2-g168b From ec04d0e7dbfad8840869b64167b824c197806ddd Mon Sep 17 00:00:00 2001 From: Joshua Ismael Haase Hernandez Date: Thu, 19 May 2011 02:41:39 -0500 Subject: * is_banned always returns false --- fullpkg | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'fullpkg') diff --git a/fullpkg b/fullpkg index 8bc29d9..95d0080 100755 --- a/fullpkg +++ b/fullpkg @@ -116,10 +116,8 @@ is_banned() { plain "Failed to get ban list" return 0 } - grep -w $1 $ban_file >/dev/null 2>&1 - local rt=$? - return $rt + return $? } guess_repo() { -- cgit v1.2.3-2-g168b From fc33a9740b0142e24049afc6d485db1d689bba9a Mon Sep 17 00:00:00 2001 From: Joshua Ismael Haase Hernandez Date: Thu, 19 May 2011 02:54:00 -0500 Subject: * fullpkg printing repo all the times is confusing --- fullpkg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'fullpkg') diff --git a/fullpkg b/fullpkg index 95d0080..35916d3 100755 --- a/fullpkg +++ b/fullpkg @@ -138,8 +138,8 @@ function cleanup { ## END FUNCTIONS ## source PKGBUILD -msg "Building ${repo:-missing repo}/${pkgbase:-${pkgname[@]}}: $pkgdesc" repo=${repo:-$(guess_repo)} +msg "Building ${repo:-missing repo}/${pkgbase:-${pkgname[@]}}: $pkgdesc" # Pre build tests if [ $force_build == 'n' ]; then -- cgit v1.2.3-2-g168b From 5636a97ca66e432cc59a0dcaf2b05398150b4e1f Mon Sep 17 00:00:00 2001 From: Joshua Ismael Haase Hernandez Date: Thu, 19 May 2011 11:26:54 -0500 Subject: is_banned should be false if no ban list is downloaded --- fullpkg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'fullpkg') diff --git a/fullpkg b/fullpkg index 35916d3..0088045 100755 --- a/fullpkg +++ b/fullpkg @@ -114,7 +114,7 @@ check_queue() { is_banned() { rsync -e ssh -aq $PARABOLAHOST:mips64el/ban $ban_file >/dev/null 2>&1 || { plain "Failed to get ban list" - return 0 + return 1 } grep -w $1 $ban_file >/dev/null 2>&1 return $? -- cgit v1.2.3-2-g168b From d53c7ad69c8f52513ee6c2f82b07af9b486c6d85 Mon Sep 17 00:00:00 2001 From: Joshua Ismael Haase Hernandez Date: Thu, 19 May 2011 13:25:47 -0500 Subject: * fullpkg can be asked to rebuild some package if it's a dep --- fullpkg | 51 ++++++++++++++++++++++++++++++++++++++------------- 1 file changed, 38 insertions(+), 13 deletions(-) (limited to 'fullpkg') diff --git a/fullpkg b/fullpkg index 0088045..911a11c 100755 --- a/fullpkg +++ b/fullpkg @@ -18,21 +18,25 @@ function usage { 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 " -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' arg; do +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 @@ -124,8 +128,20 @@ guess_repo() { basename $(dirname $(pwd)) } -# TODO keep track of spawned fullpkgs -quit() { +# 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 +} + +function quit { remove_queue exit 1 } @@ -135,6 +151,8 @@ function cleanup { rm -rf $tmp_dir } +# TODO keep track of spawned fullpkgs + ## END FUNCTIONS ## source PKGBUILD @@ -190,12 +208,16 @@ for _dep in ${deps[@]}; do [[ -e "$ABSROOT/${_repo}/$_dep/PKGBUILD" ]] && { source "$ABSROOT/${_repo}/$_dep/PKGBUILD" msg2 "Checking for $_dep>=$pkgver-$pkgrel" - - if is_built "$_dep>=$pkgver-$pkgrel"; then - plain "this package is built" - 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 " + fi + cp -r "$ABSROOT/$_repo/$_dep" $tmp_dir/ || { error "Can't copy $_dep to the work dir." exit 1 @@ -203,7 +225,8 @@ for _dep in ${deps[@]}; do # Enter the work dir and run this command in it pushd $tmp_dir/$_dep >/dev/null - $0 -r $_repo + + $0 -r $_repo $_fullpkgargs [[ $? -ne 0 ]] && { failed=(${failed[@]} $_dep) @@ -215,6 +238,8 @@ for _dep in ${deps[@]}; do done # TODO probably not elegant enough +# 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 -- cgit v1.2.3-2-g168b From 1332457128ce015dc46561e531740c725c23299e Mon Sep 17 00:00:00 2001 From: Joshua Ismael Haase Hernandez Date: Thu, 19 May 2011 14:37:31 -0500 Subject: * fullpkg clean $_fullpkgargs and $force_array when use them --- fullpkg | 2 ++ 1 file changed, 2 insertions(+) (limited to 'fullpkg') diff --git a/fullpkg b/fullpkg index 911a11c..d5c7468 100755 --- a/fullpkg +++ b/fullpkg @@ -216,6 +216,8 @@ for _dep in ${deps[@]}; do 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/ || { -- cgit v1.2.3-2-g168b From 3c53f6e6e8a9dc767680c5a53969e3d9aa3c5d81 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=A1s=20Reynolds?= Date: Sun, 22 May 2011 11:11:59 -0300 Subject: FullPKG already uses a local db called stage3 and it's URL is file://$PKGDEST --- fullpkg | 1 - 1 file changed, 1 deletion(-) (limited to 'fullpkg') diff --git a/fullpkg b/fullpkg index d5c7468..d66067e 100755 --- a/fullpkg +++ b/fullpkg @@ -260,7 +260,6 @@ sudo pacman -Syu --noconfirm makepkg --noconfirm --nocheck -sLcr ; r=$? case $r in 0) msg "The build was succesful." - #TODO: mipsrelease should upload to a local db mipsrelease *.pkg.tar.* librestage $repo librerelease -- cgit v1.2.3-2-g168b