diff options
-rw-r--r-- | doc/fullpkg | 7 | ||||
-rwxr-xr-x | fullpkg | 184 | ||||
-rwxr-xr-x | librerelease | 8 | ||||
-rwxr-xr-x | mips64el/mipsrelease | 9 | ||||
-rwxr-xr-x | toru | 56 |
5 files changed, 170 insertions, 94 deletions
diff --git a/doc/fullpkg b/doc/fullpkg new file mode 100644 index 0000000..5645fae --- /dev/null +++ b/doc/fullpkg @@ -0,0 +1,7 @@ +# FullPKG +FullPKG is a tool to build a package from ABS, find all needed dependencies +along the way and build them too if necessary. + +## Before running fullpkg +Update PKGBUILD path cache by running `toru -u <repo>` on your ABS root. Once +for each repo you'll be using. @@ -19,7 +19,6 @@ elif [ -e $XDG_CONFIG_HOME/libretools/libretools.conf ]; then fi - usage() { echo "cd to a dir containing a PKGBUILD and run:" @@ -41,6 +40,23 @@ usage() { } +# Finds a PKGBUILD on toru's path cache +# Look in all caches but pick the first one +# TODO move to a toru flag (-p?) +where_is() { + local _repo + local _path + for _repo in ${REPOS[@]}; do + _path=$(grep "^${1}:" "${TORUPATH}/${_repo}.paths.cache" 2>/dev/null| \ + cut -d: -f2 2>/dev/null) + + [ -n "${_path}" ] && break + done + + echo ${_path} + +} + # Removes a package from the buildorder # $1 package name # $2 buildorder file @@ -84,55 +100,70 @@ find_deps() { # Check this level source PKGBUILD +# unset PKGBUILD variables + unset pkgdesc url license groups optdepends provides conflicts replaces \ + backup options install changelog source noextract md5sums build \ + check package + for _pkg in ${pkgname[@]}; do + unset package_${_pkg} >/dev/null 2>&1 + done + local repo=${repo:-$(guess_repo)} local pkgbase=${pkgbase:-${pkgname[0]}} +# Provide a default 0 to epoch local epoch=${epoch:-0} local fullver=$(get_fullver ${epoch} ${pkgver} ${pkgrel}) - if is_built "${pkgbase}>=${fullver}"; then # pkg is built and updated +# Check if the package is already built + if is_built "${pkgbase}>=${fullver}"; then +# pkg is built and updated exit 0 fi - echo "${level}:${pkgbase}" >> "${build_dir}/BUILDORDER" # greater levels are built first - - if [ -d "${build_dir}/${pkgbase}" ]; then # PKGBUILD is already there +# greater levels are built first + echo "${level}:${pkgbase}" >>"${build_dir}/BUILDORDER" +# PKGBUILD is already there + if [ -d "${build_dir}/${pkgbase}" ]; then exit 0 - else # Copy dir to build_dir +# Copy dir to build_dir + else cp -r ../${pkgbase}/ ${build_dir}/ - echo "repo=$repo" > "${build_dir}/${pkgbase}/.INFO" # to identify repo later + +# to identify repo later + echo "repo=$repo" > "${build_dir}/${pkgbase}/.INFO" 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}" - declare -i next_level=$level+1 ## Check next levels +## Check next levels + declare -i next_level=$level+1 - deps=$(echo "${depends[@]} ${makedepends[@]}" | \ +# All deps in separate line, only once, without version. + deps=($(echo "${depends[@]} ${makedepends[@]}" | \ sed "s/[=<>]\+[^ ]\+//g" | \ tr ' ' "\n" | \ - sort -u) # All deps in separate line, only once, without version. + sort -u)) for _dep in ${deps[@]}; do local found=false + local pkgdir=$(where_is ${_dep}) - for _repo in ${REPOS[@]}; do # TODO ask toru where the pkgbuild is - - if [ -e "${ABSROOT}/${_repo}/${_dep}/PKGBUILD" ]; then # ABSROOT/repo/package + if [ -d "${pkgdir}" ]; then + found=true - 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 - local found=true - break 1 # found, end cycle - fi + pushd "${pkgdir}" > /dev/null +# runs itself on dep's PKGBUILD dir + $0 -c -d ${build_dir} -l ${next_level} - done +# probable circular deps + [ $? -eq 20 ] && return 20 + popd > /dev/null + fi - if ${found}; then # go to next dep - continue 1 - else - echo "dep_not_found:$_dep" >> $build_dir/log + if ! (( found )); then + echo "dep_not_found:$_dep" >>$build_dir/log fi done @@ -140,68 +171,74 @@ find_deps() { ## End variable block unset next_level dir -# unset PKGBUILD variables - unset 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 } __build() { - pushd ${build_dir} > /dev/null + pushd ${build_dir} >/dev/null - build_packages=($(sort -gr $buildorder | cut -d: -f2)) # greater levels must be built first +# greater levels must be built first + build_packages=($(sort -gr $buildorder | cut -d: -f2)) while [ ${#build_packages[@]} -ge 1 ]; do - pushd $build_dir/${build_packages[0]} > /dev/null + pushd $build_dir/${build_packages[0]} >/dev/null source PKGBUILD msg2 "${pkgbase:-${pkgname[0]}} $pkgver-$pkgrel" 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 - 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 - - continue # build next package +# build next package + continue fi } msg2 "Building $(basename $PWD)" - $FULLBUILDCMD; r=$? # this buildcmd is on libretools.conf +# this buildcmd is on libretools.conf + $FULLBUILDCMD; r=$? + case $r in - 0) ## Succesfull build +## Succesfull build + 0) + plain "The build was succesful." if source .INFO && [ -n $repo ]; then - if [ ! -z $HOOKLOCALRELEASE ]; then # Calls a local release script +# Calls a local release script if it's used + if [ ! -z $HOOKLOCALRELEASE ]; then find -name "*.pkg.tar.?z" -print0 | xargs -0 $HOOKLOCALRELEASE $repo fi - 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 + 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 + echo "failed:$(basename $PWD)" >>$build_dir/log ;; esac remove_buildorder "${build_packages[0]}" $buildorder || true - build_packages=($(sort -gr $buildorder | cut -d: -f2)) # find out next package +# which is next package? + build_packages=($(sort -gr $buildorder | cut -d: -f2)) popd > /dev/null done @@ -225,12 +262,11 @@ __build() { echo ${pkgs[@]} | tr " " "\n" | cut -d: -f2 } - popd > /dev/null + popd >/dev/null } # End inmediately but print a useful message trap_exit() { - error "$@" warning "Leftover files left on $build_dir" @@ -244,7 +280,6 @@ trap 'trap_exit "(prfullpkg:${level}) TERM signal caught. Exiting..."' TERM HUP 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=false @@ -259,13 +294,17 @@ while getopts 'ha:b:cCd:l:nm:r:' arg; do a) ABSROOT="$OPTARG" ;; b) build_only=true build_dir="$OPTARG" - if [ -z ${build_dir} ]; then + + if [ -z "${build_dir}" ]; then usage fi - if [ ! -r ${build_dir}/BUILDORDER ] ; then + + if [ ! -r "${build_dir}/BUILDORDER" ] ; then error "${build_dir}/BUILDORDER doesn't exist." exit 1 - fi;; + fi + + ;; c) check_deps_only=true ;; C) do_cleanup=true;; d) build_dir="$OPTARG" ;; @@ -277,34 +316,41 @@ while getopts 'ha:b:cCd:l:nm:r:' arg; do esac done -if ! (( ${build_only} )); then +if ! (( build_only )); then - if [ ! -r PKGBUILD ]; then # Check if we are actually on a build directory. Do this early. +# Check if we are actually on a build directory. Do this early. + if [ ! -r PKGBUILD ]; then error "This isn't a build directory" usage fi - if [ ! -z "$HOOKPKGBUILDMOD" ]; then - "$HOOKPKGBUILDMOD" +# Run the pre build hook + if [ ! -z "${HOOKPKGBUILDMOD}" ]; then + ${HOOKPKGBUILDMOD} fi fi -if [ $level -eq 0 ]; then +if [ ${level} -eq 0 ]; then - build_dir=${build_dir:-$(mktemp -d /tmp/fullpkg.XXXXXX)} # use -d option or else mktemp +# use -d option or else mktemp + build_dir="${build_dir:-$(mktemp -d /tmp/fullpkg.XXXXXX)}" - if [ ! -d ${build_dir} ]; then # in case of custom -d option - mkdir -p ${build_dir} +# in case of custom -d option + if [ ! -d "${build_dir}" ]; then + mkdir -p "${build_dir}" else - cleanup # files already there can screw find_deps +# files already there can screw find_deps + cleanup fi - touch ${build_dir}/{log,BUILDORDER} ${ban_file} # make files for log and buildorder - buildorder=${build_dir}/BUILDORDER +# make files for log and buildorder + touch "${build_dir}"/{log,BUILDORDER} + buildorder="${build_dir}/BUILDORDER" if ! (( noupdate )); then +# Always return true msg "Updating pacman db and packages" sudo pacman -Syu --noconfirm || true @@ -312,7 +358,7 @@ if [ $level -eq 0 ]; then if (( build_only )); then - msg "Build Packages" + msg "Building Packages" __build @@ -326,6 +372,7 @@ fi # Probable circular deps [ $level -ge $max_level ] && exit 20 +# Find the dependencies on the ABS itself find_deps || { # Probable circular deps @@ -342,14 +389,15 @@ find_deps || { } # only build on level 0 -$( (( check_deps_only )) || [ $level -gt 0 ] ) && exit 0 - -msg "Building packages:" +if (( check_deps_only )) || [ $level -gt 0 ]; then + exit 0 +fi # Build the packages +msg "Building packages:" __build echo -msg2 "Check if your system works fine and librerelease if it does" +msg2 "Check if your system works fine and librerelease if it does." exit 0 diff --git a/librerelease b/librerelease index 55a1270..56cf856 100755 --- a/librerelease +++ b/librerelease @@ -34,6 +34,7 @@ function usage { echo "$(gettext " -h this message.")" echo "$(gettext " -l only list packages but not upload them.")" echo "$(gettext " -c clean packages on $WORKDIR/staging.")" + echo "$(gettext " -n dry-run")" } function list_packages { @@ -52,16 +53,18 @@ function clean_non_packages { -delete } -# Clean everything +# Clean everything if not on dry-run mode function clean { + [ -z ${dryrun} ] && \ find ${WORKDIR}/staging/ -type f -delete } -while getopts 'hlc' arg; do +while getopts 'hlcn' arg; do case $arg in h) usage; exit 0 ;; l) list_packages; exit 0 ;; c) clean; exit $? ;; + n) dryrun="--dry-run" ;; esac done @@ -72,6 +75,7 @@ done clean_non_packages msg "Uploading packages..." rsync --recursive \ + ${dryrun} \ --no-group \ --no-perms \ --copy-links \ diff --git a/mips64el/mipsrelease b/mips64el/mipsrelease index dae489c..1a4aade 100755 --- a/mips64el/mipsrelease +++ b/mips64el/mipsrelease @@ -10,6 +10,8 @@ source /etc/makepkg.conf source /etc/libretools.conf +libretoolsdir="$(dirname $0)/../" + usage() { echo "$0 repo package1 [ package2 ... packageN ]" echo @@ -35,14 +37,17 @@ repo=$1; shift # Get all needed sources source PKGBUILD fullver=$(get_full_version ${epoch:-0} ${pkgver} ${pkgrel}) +pkgs=() makepkg --source -f msg "Adding packages to [stage3]..." for name in ${pkgname[@]}; do msg2 "${name} ${fullver}" - repo-add ${PKGDEST}/stage3.db.tar.gz ${PKGDEST}/${name}-${fullver}-*.pkg.tar.* + pkgs+=("${PKGDEST}/${name}-${fullver}-*.pkg.tar.*") done +repo-add ${PKGDEST}/stage3.db.tar.gz ${pkgs[@]} + mkdir -p ${WORKDIR}/abs/${CARCH}/${repo} >/dev/null @@ -50,4 +55,6 @@ pushd ${WORKDIR}/abs/${CARCH}/${repo} >/dev/null tar xvf $SRCPKGDEST/${pkgbase:-${pkgname[0]}}-${fullver}${SRCEXT} popd >/dev/null +$libretoolsdir/chcleanup || true + exit $? @@ -21,15 +21,18 @@ if [ ! -w "$TORUPATH" ]; then fi # TODO move to common functions -function in_array { # usage : in_array( $needle, $haystack ) - - [[ $2 ]] || return 1 # Not found - local needle=$1; shift - local item - for item in "$@"; do - [[ ${item#@} = $needle ]] && return 0 # Found - done - return 1 # Not Found +# usage : in_array( $needle, $haystack ) +function in_array { + [[ $2 ]] || return 1 # Not found + + local needle=$1; shift + local item + + for item in "$@"; do + [[ ${item#@} = $needle ]] && return 0 # Found + done + + return 1 # Not Found } # Stores the lastsync date @@ -146,21 +149,32 @@ update() { # Check if the repo is set as such, otherwise skip is_repo ${_repo} || continue +# Fullpath of the repo + _repopath=$(readlink -f ${_repo}) + # This is the syncfile, stores the last date as content and mtime local lastsyncfile=${TORUPATH}/${_repo}.lastsync # Find all the PKGBUILDs newer than the last update # Update newer, otherwise everything if [[ $force = true || ! -e ${lastsyncfile} ]]; then + $quiet || warning "Forcing upgrade" - pkgbuilds=($(find ${_repo} -maxdepth 2 -type f -name 'PKGBUILD')) +# Get all PKGBUILDs + pkgbuilds=($(find ${_repopath} -maxdepth 2 -type f -name 'PKGBUILD')) + else - pkgbuilds=($(find ${_repo} -maxdepth 2 -type f -name 'PKGBUILD' -newer ${lastsyncfile})) + +# Only find newer than lastsyncfile and read everything else from cache + pkgbuilds=($(find ${_repopath} -maxdepth 2 -type f -name 'PKGBUILD' -newer ${lastsyncfile})) packages_in_abs=($(read_cache ${_repo})) - package_paths=($(read_cache paths)) + $quiet || msg2 "Getting ${#packages_in_abs[@]} packages from cache" + fi + package_paths=($(read_cache ${_repo}.paths)) + # Inform how many PKGBUILDS were found and quit immediately if none $quiet || msg "Found $((${#pkgbuilds[*]}-1)) PKGBUILDs to update" @@ -169,13 +183,13 @@ update() { # Update the sync file because there are pkgbuilds to update update_sync_file=true -# Guess pkgbase from PKGBUILD's basedir - _pkgpath=$(dirname "${_pkgbuild}") - _pkgbase=$(basename "${_pkgpath}") - # Load PKGBUILD's metadata source ${_pkgbuild} +# Guess pkgbase from PKGBUILD's basedir + _pkgpath=$(dirname "${_pkgbuild}") + _pkgbase=${pkgbase:-${pkgname[0]}} + # We won't need this (all unsets are for memory efficiency) unset build package url md5sums install pkgdesc backup options # TODO fill a license list @@ -199,9 +213,9 @@ update() { # Sync! (Only if there was an actual sync) ${update_sync_file} && lastsync ${lastsyncfile} - if [ "${lastsyncfile}" -nt "${TORUPATH}/paths.cache" ]; then + if [ "${lastsyncfile}" -nt "${TORUPATH}/${_repo}.paths.cache" ]; then print_package_array "${package_paths[@]}" > $TMPDIR/paths - store_cache paths $TMPDIR/paths + store_cache ${_repo}.paths $TMPDIR/paths fi # If there isn't an update cache or it's older than the last update, we check @@ -256,7 +270,7 @@ update() { store_cache ${_repo}.updates ${TMPDIR}/updates else - msg "Reading updates from cache..." + $quiet || msg "Reading updates from cache..." read_cache ${_repo}.updates fi @@ -292,10 +306,6 @@ TMPDIR=$(mktemp -d) [[ -z ${TMPDIR} ]] && exit 1 -# TODO this is all for debugging -msg2 "force: $force quiet: $quiet repos: $@ commands: ${commands[@]}" -msg2 "read lastsync: $([ -e $lastsyncfile ])" - ${commands[0]} ${@} #rm -rf ${TMPDIR} |