From 0f527db6e225f7e8152d41b32dda434bb58f7e15 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joshua=20Ismael=20Haase=20Hern=C3=A1ndez?= Date: Sun, 19 Jun 2011 00:50:35 -0500 Subject: find_deps use ">=" instead "=" --- fullpkg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'fullpkg') diff --git a/fullpkg b/fullpkg index be9ed70..31bf835 100755 --- a/fullpkg +++ b/fullpkg @@ -157,7 +157,7 @@ function find_deps { # If package and correct ${fullver} is built exit # TODO?: If this package is in force_build: skip this step - if is_built "${pkgbase}=${fullver}"; then + if is_built "${pkgbase}>=${fullver}"; then exit 0 fi -- cgit v1.2.3-2-g168b From 547bd24884bbf044947620330783fcf09d81256b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joshua=20Ismael=20Haase=20Hern=C3=A1ndez?= Date: Fri, 24 Jun 2011 17:10:46 -0500 Subject: Libremakepkg uses new cleaning mode --- fullpkg | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'fullpkg') diff --git a/fullpkg b/fullpkg index 31bf835..f6640dc 100755 --- a/fullpkg +++ b/fullpkg @@ -407,6 +407,13 @@ if [ ${build_only} == 'n' ]; then fi fi +# If the queue file isn't writable go into offline mode +[ ! -w $queue_file ] && { + error "Can't write queue file" + OFFLINE=true +} + + # Only on level 0 if [ $level -eq 0 ]; then # if build_dir exist use it, else make a build_dir @@ -423,6 +430,7 @@ if [ $level -eq 0 ]; then # Build only [ ${build_only} == 'y' ] && { + msg "Build Packages" _pkg_build exit 0 } @@ -473,12 +481,6 @@ find_deps || { ## START Building msg "Building packages:" -# If the queue file isn't writable go into offline mode -[ ! -w $queue_file ] && { - error "Can't write queue file" - OFFLINE=true -} - # Build the package _pkg_build -- cgit v1.2.3-2-g168b From 7499b4f620b052e7ced69972a0ad368cb648f2a7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joshua=20Ismael=20Haase=20Hern=C3=A1ndez?= Date: Wed, 22 Jun 2011 03:23:26 -0500 Subject: Fixed libremakepkg error --- fullpkg | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) (limited to 'fullpkg') diff --git a/fullpkg b/fullpkg index 264a910..22ef39a 100755 --- a/fullpkg +++ b/fullpkg @@ -36,8 +36,6 @@ function usage { echo " -m max_level : check deps until this level" echo " -r \"command\" : use this instead of \"$FULLBUILDCMD\"" echo " -o : work offline (avoid queuing)" - # printf " -f pkgname : build even when a package has been built. " - # printf " Use it as many times as needed\n" echo } @@ -259,9 +257,7 @@ function _pkg_build () { msg2 "Checking for non free deps" pkgbuild-check-nonfree || { -# pkgbuild-check-nonfree fails with 15 if there are nonfree deps, -# fails with something else if blacklist can't be retrieved - if [ $? -eq 15 ]; then + if [ $? -eq 15 ]; then # this error means nonfree others means fail. # log they have nonfree deps and so didn't build echo "nonfree:$(basename $PWD)" >> $build_dir/log # take out package from $buildorder -- cgit v1.2.3-2-g168b From bfc22659aff2cc2a2832b34b7f044146e5b86184 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joshua=20Ismael=20Haase=20Hern=C3=A1ndez?= Date: Wed, 22 Jun 2011 04:30:18 -0500 Subject: fullpg make build_dir --- fullpkg | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'fullpkg') diff --git a/fullpkg b/fullpkg index 22ef39a..6e9ea19 100755 --- a/fullpkg +++ b/fullpkg @@ -377,7 +377,6 @@ while getopts 'ha:b:cCd:l:nm:r:o' arg; do };; c) check_deps_only='y' ;; C) do_cleanup='y';; - # f) force_build+="-f pkgname " ;; d) build_dir="$OPTARG" ;; # hidden option to know what to build first. # if $level > 0 it will not build @@ -413,11 +412,11 @@ fi OFFLINE=true } - # Only on level 0 if [ $level -eq 0 ]; then # if build_dir exist use it, else make a build_dir build_dir=${build_dir:-$(mktemp -d /tmp/fullpkg.XXXXXX)} + mkdir -p ${build_dir} # in case of -d option # make files for log and buildorder touch ${build_dir}/{log,BUILDORDER} -- cgit v1.2.3-2-g168b From d94747c063e65cb5bbe99246157d76079cc4c252 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joshua=20Ismael=20Haase=20Hern=C3=A1ndez?= Date: Sat, 25 Jun 2011 11:46:03 -0500 Subject: *fullpkg don't add mipsel on build_only *mipsrelease adds pkgs from pkgdest --- fullpkg | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'fullpkg') diff --git a/fullpkg b/fullpkg index 6e9ea19..ce31dd4 100755 --- a/fullpkg +++ b/fullpkg @@ -398,12 +398,12 @@ if [ ${build_only} == 'n' ]; then usage && exit 1 } -fi - # Add mips64el if missing from arch=() and it isn't an 'any' package -if ! grep mips64el PKGBUILD >/dev/null; then - warning "Adding mips64el arch" - sed -i "s/^\(arch=([^)anym]\+\))/\1 'mips64el')/" "PKGBUILD" + if ! grep mips64el PKGBUILD >/dev/null; then + warning "Adding mips64el arch" + sed -i "s/^\(arch=([^)anym]\+\))/\1 'mips64el')/" "PKGBUILD" + fi + fi # If the queue file isn't writable go into offline mode -- cgit v1.2.3-2-g168b From e8544402d87c10c0f0b5186800960a99617458ba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joshua=20Ismael=20Haase=20Hern=C3=A1ndez?= Date: Sat, 25 Jun 2011 21:46:37 -0500 Subject: fullpkg doesn't use queue --- fullpkg | 95 +++-------------------------------------------------------------- 1 file changed, 3 insertions(+), 92 deletions(-) (limited to 'fullpkg') diff --git a/fullpkg b/fullpkg index ce31dd4..c25ed85 100755 --- a/fullpkg +++ b/fullpkg @@ -11,10 +11,9 @@ if [ -z $XDG_CONFIG_HOME ]; then error "There's no XDG_CONFIG_HOME var set" exit 1 fi -# set queue_file and ban_file +# set and ban_file [ -e $XDG_CONFIG_HOME/libretools/libretools.conf ] && \ source $XDG_CONFIG_HOME/libretools/libretools.conf -queue_file=$XDG_CONFIG_HOME/libretools/queue ban_file=$XDG_CONFIG_HOME/libretools/ban @@ -35,72 +34,9 @@ function usage { echo " -n : don't update pacman db." echo " -m max_level : check deps until this level" echo " -r \"command\" : use this instead of \"$FULLBUILDCMD\"" - echo " -o : work offline (avoid queuing)" echo } -# Queue Management -# * Always get the queue list from the server -# * Add/Remove from queue -# * Check if a package is listed - -# Get the queue list from the server -get_queue() { - [[ "$OFFLINE" -eq true ]] && return 0 - - rsync -e ssh -aq $PARABOLAHOST:mips64el/queue $queue_file >/dev/null 2>&1 || { - error "Failed to retrieve queue list" - return 1 - } -} - -# Put the queue list on the server -put_queue() { - [[ "$OFFLINE" = true ]] && return 0 - - rsync -e ssh -aq $queue_file $PARABOLAHOST:mips64el/queue >/dev/null 2>&1 || { - error "Failed to put queue list" - return 1 - } -} - -# Add packages to the queue -update_queue() { - get_queue - echo "$(basename $PWD):$PACKAGER" >> $queue_file - put_queue || return $? -} - -# Remove a package from the queue -remove_queue() { - [[ "$OFFLINE" -eq true ]] && return 0 - - get_queue - - grep -Evw "^$(basename $PWD)" ${queue_file} > ${queue_file}2 - mv -f ${queue_file}2 ${queue_file} - - put_queue && return 0 || return $? -} - -# Checks if a package is listed -check_queue() { - [[ "$OFFLINE" = "true" ]] && return 0 - - get_queue - - local packager=$(grep -w "$(basename $PWD)" ${queue_file} | cut -d ':' -f2) - - [ -n "$packager" -a "$packager" != "$PACKAGER" ] && { - warning "$(basename $PWD) is being packaged by $packager. Please wait." - return 1 - } - - return 0 -} - -# END Queue Management # - ## Build order management ## # Removes a package from the buildorder @@ -186,7 +122,7 @@ function find_deps { declare -i next_level=$level+1 # Pass the offline flag to children - [[ "$OFFLINE" -eq true ]] && extra+=" -o" + [[ "$OFFLINE" -eq true ]] for _dep in ${deps[@]}; do for _repo in ${REPOS[@]}; do @@ -194,7 +130,7 @@ function find_deps { if [ -e "${ABSROOT}/${_repo}/${_dep}/PKGBUILD" ]; then pushd "${ABSROOT}/${_repo}/${_dep}" > /dev/null - $0 -c -d ${build_dir} -l ${next_level} ${extra} + $0 -c -d ${build_dir} -l ${next_level} # Circular deps must fail [ $? -eq 20 ] && return 20 @@ -240,21 +176,6 @@ function _pkg_build () { msg2 "${pkgbase:-${pkgname[0]}} $pkgver-$pkgrel" -# Check if pkg is being built - msg2 "Checking build queue" - check_queue || { - echo "someone_is_building:$(basename $PWD)" >> $build_dir/log - - remove_buildorder "$(basename $PWD)" $buildorder - continue - } - -# Let everybody know we're building this. - msg2 "Updating build queue" - update_queue || { - warning "Couldn't update the queue, let your partners know about this." - } - msg2 "Checking for non free deps" pkgbuild-check-nonfree || { if [ $? -eq 15 ]; then # this error means nonfree others means fail. @@ -302,9 +223,6 @@ function _pkg_build () { # Package was built or failed: take it out of $buildorder remove_buildorder "${build_packages[0]}" $buildorder || true -# Take package out from queue - remove_queue || true - # Set build_packages before next cycle run build_packages=($(sort -gr $buildorder | cut -d: -f2)) popd > /dev/null @@ -335,7 +253,6 @@ function _pkg_build () { # End inmediately but print a useful message trap_exit() { - remove_queue error "$@" warning "Leftover files left on $build_dir" @@ -406,12 +323,6 @@ if [ ${build_only} == 'n' ]; then fi -# If the queue file isn't writable go into offline mode -[ ! -w $queue_file ] && { - error "Can't write queue file" - OFFLINE=true -} - # Only on level 0 if [ $level -eq 0 ]; then # if build_dir exist use it, else make a build_dir -- cgit v1.2.3-2-g168b From 0097ea36511596b3de1947a2069d708079887058 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joshua=20Ismael=20Haase=20Hern=C3=A1ndez?= Date: Mon, 27 Jun 2011 00:16:33 -0500 Subject: "first working prtools + fixes" --- fullpkg | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) (limited to 'fullpkg') diff --git a/fullpkg b/fullpkg index c25ed85..7a08112 100755 --- a/fullpkg +++ b/fullpkg @@ -11,7 +11,7 @@ if [ -z $XDG_CONFIG_HOME ]; then error "There's no XDG_CONFIG_HOME var set" exit 1 fi -# set and ban_file +# set ban_file [ -e $XDG_CONFIG_HOME/libretools/libretools.conf ] && \ source $XDG_CONFIG_HOME/libretools/libretools.conf ban_file=$XDG_CONFIG_HOME/libretools/ban @@ -35,6 +35,7 @@ function usage { echo " -m max_level : check deps until this level" echo " -r \"command\" : use this instead of \"$FULLBUILDCMD\"" echo + exit 1 } ## Build order management ## @@ -89,7 +90,6 @@ function find_deps { local fullver=$(get_full_version ${epoch} ${pkgver} ${pkgrel}) # If package and correct ${fullver} is built exit -# TODO?: If this package is in force_build: skip this step if is_built "${pkgbase}>=${fullver}"; then exit 0 fi @@ -121,9 +121,6 @@ function find_deps { # Increase build level declare -i next_level=$level+1 -# Pass the offline flag to children - [[ "$OFFLINE" -eq true ]] - for _dep in ${deps[@]}; do for _repo in ${REPOS[@]}; do # try to find $_dep on each repo from dirname @@ -136,10 +133,11 @@ function find_deps { [ $? -eq 20 ] && return 20 popd > /dev/null break 1 # found, go to next dep - + done # if search pkgname in repo doesn't work # this should find pkgsplits - elif _dir=($(find "$ABSROOT/${_repo}" -type f -name PKGBUILD -print0 2>/dev/null | \ + for _repo in ${REPOS[@]}; do + if _dir=($(find "$ABSROOT/${_repo}" -type f -name PKGBUILD -print0 2>/dev/null | \ "xargs" -0 -e grep -HEw "pkgname=|pkgbase=|provides=" | grep -w "$_dep" 2>&1)); then _dir=$(dirname $(echo $_dir | cut -d: -f1)) @@ -150,7 +148,6 @@ function find_deps { [ $? -eq 20 ] && return 20 popd > /dev/null break 1 # found, go to next dep - else echo "dep_not_found:$_dep:$_repo" >> $build_dir/log fi @@ -278,15 +275,14 @@ check_deps_only='n' do_cleanup='n' max_level=21 OFFLINE=false -while getopts 'ha:b:cCd:l:nm:r:o' arg; do +while getopts 'ha:b:cCd:l:nm:r:' arg; do case $arg in - h) usage; exit 0 ;; + h) usage ;; a) ABSROOT="$OPTARG" ;; b) build_only='y' build_dir="$OPTARG" [ -z ${build_dir} ] && { usage - exit 1 } [ ! -r ${build_dir}/BUILDORDER ] && { error "${build_dir}/BUILDORDER doesn't exist." @@ -301,7 +297,6 @@ while getopts 'ha:b:cCd:l:nm:r:o' arg; do n) noupdate='y';; m) max_level=$OPTARG ;; r) FULLBUILDCMD="$OPTARG" ;; - o) OFFLINE=true ;; esac done @@ -312,7 +307,7 @@ if [ ${build_only} == 'n' ]; then [ ! -r PKGBUILD ] && { error "This isn't a build directory" - usage && exit 1 + usage } # Add mips64el if missing from arch=() and it isn't an 'any' package -- cgit v1.2.3-2-g168b From 75f8632e677bd11bb88be037aa6aab32a79ab008 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joshua=20Ismael=20Haase=20Hern=C3=A1ndez?= Date: Mon, 27 Jun 2011 14:17:50 -0500 Subject: some fixes --- fullpkg | 1 + 1 file changed, 1 insertion(+) (limited to 'fullpkg') diff --git a/fullpkg b/fullpkg index 7a08112..35598eb 100755 --- a/fullpkg +++ b/fullpkg @@ -133,6 +133,7 @@ function find_deps { [ $? -eq 20 ] && return 20 popd > /dev/null break 1 # found, go to next dep + fi done # if search pkgname in repo doesn't work # this should find pkgsplits -- cgit v1.2.3-2-g168b From eb5cbeea0dc649d18ea4d6330c0787fc5a962b52 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joshua=20Ismael=20Haase=20Hern=C3=A1ndez?= Date: Mon, 27 Jun 2011 16:41:39 -0500 Subject: fixes and tabs -> spaces --- fullpkg | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'fullpkg') diff --git a/fullpkg b/fullpkg index 35598eb..cae91da 100755 --- a/fullpkg +++ b/fullpkg @@ -59,12 +59,12 @@ guess_repo() { # return : full version spec, including epoch (if necessary), pkgver, pkgrel ## get_full_version() { - if [[ $1 -eq 0 ]]; then - # zero epoch case, don't include it in version - echo $2-$3 - else - echo $1:$2-$3 - fi + if [[ $1 -eq 0 ]]; then + # zero epoch case, don't include it in version + echo $2-$3 + else + echo $1:$2-$3 + fi } # Usage: cleanup [ $(basename $PWD) ] from PKGBUILD dir -- cgit v1.2.3-2-g168b From 207a930a564e8157e24c3e7f5fbe987494b73d7b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joshua=20Ismael=20Haase=20Hern=C3=A1ndez?= Date: Tue, 28 Jun 2011 21:23:49 -0500 Subject: * Cleanup code + arch specific separated --- fullpkg | 366 +++++++++++++++++++++++++++++++++------------------------------- 1 file changed, 186 insertions(+), 180 deletions(-) (limited to 'fullpkg') diff --git a/fullpkg b/fullpkg index cae91da..be26956 100755 --- a/fullpkg +++ b/fullpkg @@ -1,25 +1,23 @@ #!/bin/bash -# TO TEST: (on find_deps) -# * Detect pkgnames by provides, replaces, etc. instead of dir tree source /etc/makepkg.conf source /etc/abs.conf source /etc/libretools.conf +source /etc/libretools.d/prtools.conf -# Avoid /libretools dir doesn't exist errors -if [ -z $XDG_CONFIG_HOME ]; then - error "There's no XDG_CONFIG_HOME var set" - exit 1 -fi -# set ban_file -[ -e $XDG_CONFIG_HOME/libretools/libretools.conf ] && \ - source $XDG_CONFIG_HOME/libretools/libretools.conf -ban_file=$XDG_CONFIG_HOME/libretools/ban +if [ -z $XDG_CONFIG_HOME ]; then # Avoid /libretools dir doesn't exist errors + + error "There's no XDG_CONFIG_HOME var set"; exit 1 + +elif [ -e $XDG_CONFIG_HOME/libretools/libretools.conf ]; then + + source $XDG_CONFIG_HOME/libretools/libretools.conf +fi -##### START FUNCTIONS ##### 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 " @@ -30,131 +28,144 @@ function usage { echo " -a absdir : set absdir as ABSROOT." echo " -b build_dir : use a fullpkg build_dir and only build." echo " -c : check deps only, do not build." + echo " -C : cleanup the build_dir." echo " -d build_dir : use this dir to build. Defaults to mktemp." echo " -n : don't update pacman db." echo " -m max_level : check deps until this level" echo " -r \"command\" : use this instead of \"$FULLBUILDCMD\"" echo exit 1 -} -## Build order management ## +} -# Removes a package from the buildorder +function remove_buildorder { # Removes a package from the buildorder # $1 package name # $2 buildorder file -remove_buildorder() { + grep -Evw "${1}" ${2} > ${2}2 mv -f ${2}2 ${2} + } -# Guesses the repo name according to the parent dir of the current package -# assuming the form repo/package/PKGBUILD -guess_repo() { - basename $(dirname $(pwd)) +function guess_repo { # Get repo name. Asumes ${ABSROOT}/repo/package/PKGBUILD + + basename $(dirname $(pwd)) # Variable in prfullpkg + } -## -# usage : get_full_version( $epoch, $pkgver, $pkgrel ) -# return : full version spec, including epoch (if necessary), pkgver, pkgrel -## -get_full_version() { +function get_fullver { # return : full version spec, including epoch (if necessary), pkgver, pkgrel + +# usage : get_fullver( ${epoch:-0}, $pkgver, $pkgrel ) + if [[ $1 -eq 0 ]]; then # zero epoch case, don't include it in version echo $2-$3 else echo $1:$2-$3 fi + } -# Usage: cleanup [ $(basename $PWD) ] from PKGBUILD dir -# cleans the build_dir -function cleanup { -# Do nothing OR -# Already cleaned - [[ "${do_cleanup}" = "n" || ! -d ${build_dir} ]] && return 0 +function cleanup { # Cleans the build_dir. + + [[ "${do_cleanup}" = "n" || ! -d ${build_dir} ]] && return 0 # Do nothing or already cleaned. -# Only do cleanup on level 0 msg "Cleaning up..." - [ $level -eq 0 ] && rm -rf $build_dir/* + [ $level -eq 0 ] && rm -rf $build_dir/* # Only do cleanup on level 0. + } -# Check PKGBUILD and find non built or outdated deps -# on ABSROOT which should be abslibre-misp64el -function find_deps { - ## Check this level. - source PKGBUILD +function find_deps { # Checks ABSROOT and look for target pkg deps. Adds them if not built or outdated. + + source PKGBUILD ## Check this level. + local repo=${repo:-$(guess_repo)} local pkgbase=${pkgbase:-${pkgname[0]}} local epoch=${epoch:-0} - local fullver=$(get_full_version ${epoch} ${pkgver} ${pkgrel}) + local fullver=$(get_fullver ${epoch} ${pkgver} ${pkgrel}) -# If package and correct ${fullver} is built exit if is_built "${pkgbase}>=${fullver}"; then - exit 0 + exit 0 # pkg is built and updated fi -# Tell which packages are deeper in deps (even if they are on build_dir) -# so we can build them first. - echo "${level}:${pkgbase}" >> "${build_dir}/BUILDORDER" + echo "${level}:${pkgbase}" >> "${build_dir}/BUILDORDER" # greater levels are built first + + if [ -d "${build_dir}/${pkgbase}" ]; then # PKGBUILD is already there -# if pkgbuild directory is on build_dir, do not copy and exit - if [ -d "${build_dir}/${pkgbase}" ]; then exit 0 - else -# Copy dir to build_dir + + else # Copy dir to build_dir +## variable block for prfullpkg + cp -r ../${pkgbase}/ ${build_dir}/ -# Info to eval later - echo "repo=$repo" > "${build_dir}/${pkgbase}/.INFO" + + echo "repo=$repo" > "${build_dir}/${pkgbase}/.INFO" # to identify repo later fi -# Inform the current package plus a space for every level for indent - msg2 "%${level}s${pkgbase}-${fullver}" + msg2 "%${level}s${pkgbase}-${fullver}" # current package plus a space for every level + + declare -i next_level=$level+1 ## Check next levels -## Check next levels -# Clean version checking deps=$(echo "${depends[@]} ${makedepends[@]}" | \ sed "s/[=<>]\+[^ ]\+//g" | \ tr ' ' "\n" | \ - sort -u) - -# Increase build level - declare -i next_level=$level+1 + sort -u) # All deps in separate line, only once, without version. for _dep in ${deps[@]}; do - for _repo in ${REPOS[@]}; do - # try to find $_dep on each repo from dirname - if [ -e "${ABSROOT}/${_repo}/${_dep}/PKGBUILD" ]; then - pushd "${ABSROOT}/${_repo}/${_dep}" > /dev/null - $0 -c -d ${build_dir} -l ${next_level} + local found=false + + for _repo in ${REPOS[@]}; do - # Circular deps must fail - [ $? -eq 20 ] && return 20 + if [ -e "${ABSROOT}/${_repo}/${_dep}/PKGBUILD" ]; then # ABSROOT/repo/package + + pushd "${ABSROOT}/${_repo}/${_dep}" > /dev/null + $0 -c -d ${build_dir} -l ${next_level} # run this cmd on dep's PKGBUILD dir + [ $? -eq 20 ] && return 20 # probable circular deps popd > /dev/null - break 1 # found, go to next dep - fi - done -# if search pkgname in repo doesn't work -# this should find pkgsplits - for _repo in ${REPOS[@]}; do - if _dir=($(find "$ABSROOT/${_repo}" -type f -name PKGBUILD -print0 2>/dev/null | \ - "xargs" -0 -e grep -HEw "pkgname=|pkgbase=|provides=" | grep -w "$_dep" 2>&1)); - then - _dir=$(dirname $(echo $_dir | cut -d: -f1)) - plain "guess for $_dep -> $_dir" - pushd $_dir > /dev/null - $0 -c -d ${build_dir} -l ${next_level} -# Circular deps must fail - [ $? -eq 20 ] && return 20 - popd > /dev/null - break 1 # found, go to next dep - else - echo "dep_not_found:$_dep:$_repo" >> $build_dir/log + local found=true + break 1 # found, end cycle fi + done + + if ( ${found} ); then + + continue 1 # go to next dep + + else # pkgsplit, needs guess + + for _repo in ${REPOS[@]}; do + if _dir=($(find "$ABSROOT/${_repo}" -type f \ + -name PKGBUILD -print0 2>/dev/null | \ + "xargs" -0 -e grep -HEw "pkgname=|pkgbase=|provides=" | \ + grep -w "$_dep" 2>&1)); + + then + + _dir=$(dirname $(echo $_dir | cut -d: -f1)) + plain "guess for $_dep -> $_dir" + + pushd "$_dir" > /dev/null + $0 -c -d ${build_dir} -l ${next_level} # run this cmd on dep's PKGBUILD dir + [ $? -eq 20 ] && return 20 # probable circular deps + popd > /dev/null + local found=true + break 1 # found, end cycle + fi + + done + + if ( ${found} ); then + continue 1 # go to next dep + else + echo "dep_not_found:$_dep" >> $build_dir/log + fi + done +## End variable block + unset next_level dir # unset PKGBUILD variables unset pkgname pkgver pkgrel epoch pkgdesc arch url license groups depends \ @@ -162,67 +173,64 @@ function find_deps { options install changelog source noextract md5sums build check package } -function _pkg_build () { +function __build () { pushd ${build_dir} > /dev/null - # packages to build are on $buildorder - # greater levels must be built first - build_packages=($(sort -gr $buildorder | cut -d: -f2)) + + build_packages=($(sort -gr $buildorder | cut -d: -f2)) # greater levels must be built first while [ ${#build_packages[@]} -ge 1 ]; do pushd $build_dir/${build_packages[0]} > /dev/null - source PKGBUILD + source PKGBUILD msg2 "${pkgbase:-${pkgname[0]}} $pkgver-$pkgrel" msg2 "Checking for non free deps" pkgbuild-check-nonfree || { if [ $? -eq 15 ]; then # this error means nonfree others means fail. -# log they have nonfree deps and so didn't build + echo "nonfree:$(basename $PWD)" >> $build_dir/log -# take out package from $buildorder - remove_buildorder "$(basename $PWD)" $buildorder -# continue building next package - continue + + remove_buildorder "$(basename $PWD)" $buildorder # take out package from $buildorder + + continue # build next package fi } msg2 "Building $(basename $PWD)" -# this buildcmd is on libretools.conf - $FULLBUILDCMD; r=$? + + $FULLBUILDCMD; r=$? # this buildcmd is on libretools.conf + case $r in -###### Succesfull Build ###### - 0) + + 0) ## Succesfull build + plain "The build was succesful." - source .INFO && [ -n $repo ] && { + if source .INFO && [ -n $repo ]; then -# Calls a local release script if it's used - [ -z $HOOKLOCALRELEASE ] || \ - find -name "*.pkg.tar.?z" -print0 | \ - xargs -0 $HOOKLOCALRELEASE $repo + # Calls a local release script if it's used + if [ ! -z $HOOKLOCALRELEASE ]; then + find -name "*.pkg.tar.?z" -print0 | xargs -0 $HOOKLOCALRELEASE $repo + fi -# Stage for releasing - librestage $repo || { - echo "unstaged:$(basename $PWD)" >> $build_dir/log - } + librestage $repo || echo "unstaged:$(basename $PWD)" >> $build_dir/log msg "Updating pacman db and packages" sudo pacman -Sy || true - } + + fi echo "built:$(basename $PWD)" >> $build_dir/log ;; -###### Failed Build ###### - *) - error "There were errors while trying to build the package." + + *) ## Build failed + error "There were errors while trying to build the package." echo "failed:$(basename $PWD)" >> $build_dir/log ;; esac -# Package was built or failed: take it out of $buildorder remove_buildorder "${build_packages[0]}" $buildorder || true -# Set build_packages before next cycle run - build_packages=($(sort -gr $buildorder | cut -d: -f2)) + build_packages=($(sort -gr $buildorder | cut -d: -f2)) # which is next package? popd > /dev/null done @@ -249,8 +257,7 @@ function _pkg_build () { popd > /dev/null } -# End inmediately but print a useful message -trap_exit() { +function trap_exit { # End inmediately but print a useful message error "$@" warning "Leftover files left on $build_dir" @@ -258,16 +265,14 @@ trap_exit() { exit 1 } -## END FUNCTIONS ## - -## Trap signals -# From makepkg +# Trap signals from makepkg set -E trap 'cleanup' 0 -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 +trap 'trap_exit "(prfullpkg:${level}) TERM signal caught. Exiting..."' TERM HUP QUIT +trap 'trap_exit "(prfullpkg:${level}) Aborted by user! Exiting..."' INT +trap 'trap_exit "(prfullpkg:${level}) An unknown error has occurred. Exiting..."' ERR +ban_file=$XDG_CONFIG_HOME/libretools/ban force_build="" level=0 noupdate='n' @@ -275,26 +280,24 @@ build_only='n' check_deps_only='n' do_cleanup='n' max_level=21 -OFFLINE=false + while getopts 'ha:b:cCd:l:nm:r:' arg; do case $arg in h) usage ;; a) ABSROOT="$OPTARG" ;; - b) build_only='y' + b) build_only='y' build_dir="$OPTARG" - [ -z ${build_dir} ] && { + if [ -z ${build_dir} ]; then usage - } - [ ! -r ${build_dir}/BUILDORDER ] && { + fi + if [ ! -r ${build_dir}/BUILDORDER ] ; then error "${build_dir}/BUILDORDER doesn't exist." exit 1 - };; + fi;; c) check_deps_only='y' ;; C) do_cleanup='y';; d) build_dir="$OPTARG" ;; -# hidden option to know what to build first. -# if $level > 0 it will not build - l) level=$OPTARG ;; + l) level=$OPTARG ;; # hidden option to know dep level. n) noupdate='y';; m) max_level=$OPTARG ;; r) FULLBUILDCMD="$OPTARG" ;; @@ -303,92 +306,95 @@ done if [ ${build_only} == 'n' ]; then -# Check if we are actually on a build directory -# Do this early - - [ ! -r PKGBUILD ] && { + [ ! -r PKGBUILD ] && { # Check if we are actually on a build directory. Do this early. error "This isn't a build directory" usage } -# Add mips64el if missing from arch=() and it isn't an 'any' package - if ! grep mips64el PKGBUILD >/dev/null; then - warning "Adding mips64el arch" - sed -i "s/^\(arch=([^)anym]\+\))/\1 'mips64el')/" "PKGBUILD" + if [ ! -z "$HOOKPKGBUILDMOD" ]; then + "$HOOKPKGBUILDMOD" fi fi -# Only on level 0 if [ $level -eq 0 ]; then -# if build_dir exist use it, else make a build_dir - build_dir=${build_dir:-$(mktemp -d /tmp/fullpkg.XXXXXX)} - mkdir -p ${build_dir} # in case of -d option -# make files for log and buildorder - touch ${build_dir}/{log,BUILDORDER} + build_dir=${build_dir:-$(mktemp -d /tmp/fullpkg.XXXXXX)} # use -d option or else mktemp + + if [ ! -d ${build_dir} ]; then # in case of custom -d option + mkdir -p ${build_dir} + else + cleanup # files already there can screw find_deps + fi + + touch ${build_dir}/{log,BUILDORDER} ${ban_file} # make files for log and buildorder buildorder=${build_dir}/BUILDORDER - [ ${noupdate} = 'n' ] && { + if [ ${noupdate} = 'n' ]; then + msg "Updating pacman db and packages" sudo pacman -Syu --noconfirm || true - } -# Build only - [ ${build_only} == 'y' ] && { + fi + + if [ ${build_only} == 'y' ]; then + msg "Build Packages" - _pkg_build + + __build + exit 0 - } + + fi msg "Checking dependencies" fi -## if $level = 20 it's highly likely there are circular deps -[ $level -ge $max_level ] && exit 20 +[ $level -ge $max_level ] && exit 20 # Probable circular deps -# Tries to find deps and build order -find_deps || { - # if find_deps finds circular deps - # it should exit with status 20 - [ $? -eq 20 ] && { - # only show message on level 0 - [ $level -eq 0 ] && error "Check for circular deps on $build_dir/BUILDORDER"; - } - exit 20 +find_deps || { + + if [ $? -eq 20 ]; then # Probable circular deps + + if [ $level -eq 0 ]; then # Show error only on level 0 + error "Check for circular deps on $build_dir/BUILDORDER"; + fi + + fi + exit 20 # Pass message 20 } -# levels greater than 0 must only check deps -[ $check_deps_only = 'y' -o $level -gt 0 ] && exit 0 +[ $check_deps_only = 'y' -o $level -gt 0 ] && exit 0 # only build on level 0 + +if [ $level -eq 0 -a -d $build_dir ]; then # Sanity check + + if [ ! -w $ban_file -o ! -r $ban_file ]; then # Check ban_file permisions -# check BUILDORDER to not include banned deps and -[ $level -eq 0 -a -d $build_dir ] && { -# Check for banned deps - if [ -w $ban_file -a -r $ban_file ]; then - chmod o+rw $ban_file || error "Ban file is not readable/writable ($ban_file)" + chmod a+rw $ban_file || error "Ban file is not readable/writable ($ban_file)" else + rsync -e ssh -aq $PARABOLAHOST:mips64el/ban >/dev/null 2>&1 || { - warning "Failed to get ban list" && [ -r ${ban_file} ] && { -# Use local copy of ban file if it is avaliable and continue. + warning "Failed to get ban list" && [ -r ${ban_file} ] && { # use local copy if it exist + search=$(cat ${ban_file} | tr "\n" "|") -# Keep track of banned files - egrep -w "$search" ${buildorder} >> ${build_dir}/banned -# Take banned packages out from buildorder - egrep -vw "$search" ${buildorder} > ${buildorder}2 + + egrep -w "$search" ${buildorder} >> ${build_dir}/banned # Keep track of banned files + + egrep -vw "$search" ${buildorder} > ${buildorder}2 # Take banned packages out of buildorder + mv -f ${buildorder}2 ${buildorder} + unset search } } fi -} +fi -## START Building msg "Building packages:" -# Build the package -_pkg_build +__build # Build the packages echo msg2 "Check if your system works fine and librerelease if it does" -- cgit v1.2.3-2-g168b