diff options
-rwxr-xr-x | fullpkg | 220 | ||||
-rw-r--r-- | mips64el/mips-add | 1 | ||||
-rw-r--r-- | mips64el/mips64el.conf | 2 | ||||
-rwxr-xr-x | pkgbuild-check-nonfree | 11 | ||||
-rwxr-xr-x | prtools/prfullpkg | 15 | ||||
-rwxr-xr-x | toru | 2 |
6 files changed, 133 insertions, 118 deletions
@@ -1,8 +1,4 @@ #!/bin/bash -# Builds packages from ABS recursively. It tries to find dependencies that -# aren't built or need update and then makepkg them in order. - -# TODO move __build to chroot source /etc/makepkg.conf source /etc/abs.conf @@ -19,7 +15,7 @@ elif [ -e $XDG_CONFIG_HOME/libretools/libretools.conf ]; then fi -usage() { +function usage { echo "cd to a dir containing a PKGBUILD and run:" echo "$0 [options]" @@ -31,7 +27,6 @@ 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" @@ -41,26 +36,27 @@ usage() { } -# 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} - return $? } -# Get repo name. Asumes ${ABSROOT}/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 + } -# return : full version spec, including epoch (if necessary), pkgver, pkgrel +function get_fullver { # return : full version spec, including epoch (if necessary), pkgver, pkgrel + # usage : get_fullver( ${epoch:-0}, $pkgver, $pkgrel ) -get_fullver() { + if [[ $1 -eq 0 ]]; then -# zero epoch case, don't include it in version + # zero epoch case, don't include it in version echo $2-$3 else echo $1:$2-$3 @@ -68,21 +64,20 @@ get_fullver() { } -# Cleans the build_dir. -cleanup() { -# Do nothing or already cleaned. - [[ "${do_cleanup}" = false || ! -d ${build_dir} ]] && return 0 +function cleanup { # Cleans the build_dir. -# Only do cleanup on level 0. - msg "Cleaning up..." - [ $level -eq 0 ] && rm -rf $build_dir/ + [ ! -d "${build_dir}" -o "${build_only}" = 'y' ] && return 0 # Do nothing or already cleaned. + + if [ $level -eq 0 ]; then # Only do cleanup on level 0. + msg "Cleaning up ${build_dir}" + rm -rf "$build_dir/*" + fi } -# Checks ABSROOT and look for target pkg deps. Adds them if not built or outdated. -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]}} @@ -90,37 +85,31 @@ find_deps() { local fullver=$(get_fullver ${epoch} ${pkgver} ${pkgrel}) if is_built "${pkgbase}>=${fullver}"; then -# pkg is built and updated - exit 0 + exit 0 # pkg is built and updated fi -# greater levels are built first - echo "${level}:${pkgbase}" >> "${build_dir}/BUILDORDER" -# PKGBUILD is already there - if [ -d "${build_dir}/${pkgbase}" ]; then + echo "${level}:${pkgbase}" >> "${build_dir}/BUILDORDER" # greater levels are built first + + if [ -d "${build_dir}/${pkgbase}" ]; then # PKGBUILD is already there exit 0 -# Copy dir to build_dir - else + else # Copy dir to build_dir +## variable block for prfullpkg cp -r ../${pkgbase}/ ${build_dir}/ -# to identify repo later - echo "repo=$repo" > "${build_dir}/${pkgbase}/.INFO" + echo "repo=$repo" > "${build_dir}/${pkgbase}/.INFO" # to identify repo later fi + + msg2 "%${level}s${pkgbase}-${fullver}" # current package plus a space for every level -# current package plus a space for every level - msg2 "%${level}s${pkgbase}-${fullver}" - -## Check next levels - declare -i next_level=$level+1 + declare -i next_level=$level+1 ## Check next levels -# All deps in separate line, only once, without version. deps=$(echo "${depends[@]} ${makedepends[@]}" | \ sed "s/[=<>]\+[^ ]\+//g" | \ tr ' ' "\n" | \ - sort -u) + sort -u) # All deps in separate line, only once, without version. for _dep in ${deps[@]}; do @@ -129,26 +118,48 @@ find_deps() { # TODO ask toru where the pkgbuild is for _repo in ${REPOS[@]}; do -# ABSROOT/repo/package - if [ -e "${ABSROOT}/${_repo}/${_dep}/PKGBUILD" ]; then - + if [ -e "${ABSROOT}/${_repo}/${_dep}/PKGBUILD" ]; then # ABSROOT/repo/package + pushd "${ABSROOT}/${_repo}/${_dep}" > /dev/null -# run this cmd on dep's PKGBUILD dir - $0 -c -d ${build_dir} -l ${next_level} -# probable circular deps - [ $? -eq 20 ] && return 20 + $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 -# found, end cycle - break 1 + 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 + fi if ( ${found} ); then -# go to next dep - continue 1 + continue 1 # go to next dep else echo "dep_not_found:$_dep" >> $build_dir/log fi @@ -164,11 +175,10 @@ find_deps() { options install changelog source noextract md5sums build check package } -__build() { +function __build () { pushd ${build_dir} > /dev/null -# 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 @@ -178,33 +188,28 @@ __build() { msg2 "Checking for non free deps" pkgbuild-check-nonfree || { -# this error means nonfree others means fail. - if [ $? -eq 15 ]; then + if [ $? -eq 15 ]; then # this error means nonfree others means fail. echo "nonfree:$(basename $PWD)" >> $build_dir/log -# take out package from $buildorder - remove_buildorder "$(basename $PWD)" $buildorder + remove_buildorder "$(basename $PWD)" $buildorder # take out package from $buildorder -# build next package - continue + 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." if source .INFO && [ -n $repo ]; then -# Calls a local release script if it's used + # Calls a local release script if it's used if [ ! -z $HOOKLOCALRELEASE ]; then find -name "*.pkg.tar.?z" -print0 | xargs -0 $HOOKLOCALRELEASE $repo fi @@ -219,8 +224,7 @@ __build() { echo "built:$(basename $PWD)" >> $build_dir/log ;; -## Build failed - *) + *) ## Build failed error "There were errors while trying to build the package." echo "failed:$(basename $PWD)" >> $build_dir/log ;; @@ -228,8 +232,7 @@ __build() { remove_buildorder "${build_packages[0]}" $buildorder || true -# which is next package? - build_packages=($(sort -gr $buildorder | cut -d: -f2)) + build_packages=($(sort -gr $buildorder | cut -d: -f2)) # which is next package? popd > /dev/null done @@ -256,8 +259,7 @@ __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" @@ -297,9 +299,8 @@ while getopts 'ha:b:cCd:l:nm:r:' arg; do c) check_deps_only=true ;; C) do_cleanup=true;; d) build_dir="$OPTARG" ;; -# hidden option to know dep level. - l) level=$OPTARG ;; - n) noupdate=true;; + l) level=$OPTARG ;; # hidden option to know dep level. + n) noupdate='y';; m) max_level=$OPTARG ;; r) FULLBUILDCMD="$OPTARG" ;; esac @@ -307,8 +308,7 @@ done if [ ! ${build_only} ]; then -# Check if we are actually on a build directory. Do this early. - if [ ! -r PKGBUILD ]; then + if [ ! -r PKGBUILD ]; then # Check if we are actually on a build directory. Do this early. error "This isn't a build directory" usage fi @@ -321,19 +321,15 @@ fi if [ $level -eq 0 ]; then -# use -d option or else mktemp - build_dir=${build_dir:-$(mktemp -d /tmp/fullpkg.XXXXXX)} - -# in case of custom -d option - if [ ! -d ${build_dir} ]; then - mkdir -p ${build_dir} + if [ ! -d ${build_dir} ]; then # in case of custom -d option + mkdir -p ${build_dir} else -# files already there can screw find_deps - cleanup + cleanup # files already there can screw find_deps fi -# make files for log and buildorder - touch ${build_dir}/{log,BUILDORDER} ${ban_file} + build_dir=${build_dir:-$(mktemp -d /tmp/fullpkg.XXXXXX)} # use -d option or else mktemp + + touch ${build_dir}/{log,BUILDORDER} ${ban_file} # make files for log and buildorder buildorder=${build_dir}/BUILDORDER if [ ! ${noupdate} ]; then @@ -356,31 +352,51 @@ if [ $level -eq 0 ]; then msg "Checking dependencies" fi -# Probable circular deps -[ $level -ge $max_level ] && exit 20 +[ $level -ge $max_level ] && exit 20 # Probable circular deps find_deps || { -# Probable circular deps - if [ $? -eq 20 ]; then + if [ $? -eq 20 ]; then # Probable circular deps -# Show error only on level 0 - if [ $level -eq 0 ]; then + if [ $level -eq 0 ]; then # Show error only on level 0 error "Check for circular deps on $build_dir/BUILDORDER"; fi fi -# Pass message 20 - exit 20 + exit 20 # Pass message 20 } -# only build on level 0 -[ $check_deps_only = true -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 + + 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 if it exist + + search=$(cat ${ban_file} | tr "\n" "|") + + 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 msg "Building packages:" -# Build the packages -__build +__build # Build the packages echo msg2 "Check if your system works fine and librerelease if it does" diff --git a/mips64el/mips-add b/mips64el/mips-add index 0d4e494..da9b431 100644 --- a/mips64el/mips-add +++ b/mips64el/mips-add @@ -1,4 +1,5 @@ #!/bin/bash +source /etc/libretools.conf if ! grep mips64el PKGBUILD >/dev/null; then # Add mips64el in ${arch} array if it isn't 'any' warning "Adding mips64el arch" sed -i "s/^\(arch=([^)anym]\+\))/\1 'mips64el')/" "PKGBUILD" diff --git a/mips64el/mips64el.conf b/mips64el/mips64el.conf index 48674b2..0825fad 100644 --- a/mips64el/mips64el.conf +++ b/mips64el/mips64el.conf @@ -2,7 +2,7 @@ ## Run a command for PKGBUILD modifications before building ## Like adding 'mips64el' to arch if it's not there -HOOKPKGBUILDMOD="mipsadd" +HOOKPKGBUILDMOD="mips-add" ## Run a command for local releasing of packages # Useful for mass packaging (ie. mips port) diff --git a/pkgbuild-check-nonfree b/pkgbuild-check-nonfree index b7c1237..55976a8 100755 --- a/pkgbuild-check-nonfree +++ b/pkgbuild-check-nonfree @@ -33,6 +33,7 @@ function in_array { # usage : in_array( $needle, $haystack ) function get_blacklist { # Download the blacklist. + pushd $XDG_CONFIG_HOME/libretools/ >/dev/null msg "Downloading the blacklist of proprietary software packages." wget -N -q -O blacklist.txt "${BLACKLIST}" 2>/dev/null || { [ -e $XDG_CONFIG_HOME/libretools/blacklist.txt ] || { @@ -41,6 +42,7 @@ function get_blacklist { # Download the blacklist. } warning "Using local copy of blacklist" } + popd > /dev/null } function check_deps { # Check wheter a package depends on non-free @@ -68,15 +70,11 @@ function check_deps { # Check wheter a package depends on non-free fi fi done - - return $ev } source /etc/libretools.conf -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 +if [ -e $XDG_CONFIG_HOME/libretools/libretools.conf ]; then source $XDG_CONFIG_HOME/libretools/libretools.conf fi @@ -98,5 +96,4 @@ get_blacklist check_deps -exit $? - +exit $ev diff --git a/prtools/prfullpkg b/prtools/prfullpkg index e3a022b..dd2ba3a 100755 --- a/prtools/prfullpkg +++ b/prtools/prfullpkg @@ -67,11 +67,13 @@ function get_fullver { # return : full version spec, including epoch (if necessa function cleanup { # Cleans the build_dir. - [[ "${do_cleanup}" = "n" || ! -d ${build_dir} ]] && return 0 # Do nothing or already cleaned. + [ ! -d "${build_dir}" -o "${build_only}" = 'y' ] && return 0 # Do nothing or already cleaned. - msg "Cleaning up..." - [ $level -eq 0 ] && rm -rf $build_dir/* # Only do cleanup on level 0. + if [ $level -eq 0 ]; then # Only do cleanup on level 0. + msg "Cleaning up ${build_dir}" + rm -rf "$build_dir/*" + fi } function find_deps { # Checks ABSROOT and look for target pkg deps. Adds them if not built or outdated. @@ -166,7 +168,7 @@ function find_deps { # Checks ABSROOT and look for target pkg deps. Adds them i unset next_level dir # unset PKGBUILD variables - unset pkgname pkgver pkgrel epoch pkgdesc arch url license groups depends \ + unset pkgbase pkgname pkgver pkgrel epoch pkgdesc arch url license groups depends \ makedepens checkdepends optdepends provides conflicts replaces backup \ options install changelog source noextract md5sums build check package } @@ -264,7 +266,6 @@ function trap_exit { # End inmediately but print a useful message # Trap signals from makepkg set -E -trap 'cleanup' 0 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 @@ -314,14 +315,14 @@ fi if [ $level -eq 0 ]; then - 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 + build_dir=${build_dir:-$(mktemp -d /tmp/fullpkg.XXXXXX)} # use -d option or else mktemp + touch ${build_dir}/{log,BUILDORDER} ${ban_file} # make files for log and buildorder buildorder=${build_dir}/BUILDORDER @@ -50,7 +50,7 @@ lastsync() { # Saves contents on a named cache # $1 cache name (repo) # $2+ contents -store_cache() { +function store_cache { cache=$1; shift [ -z "$cache" ] && return 1 |