summaryrefslogtreecommitdiff
path: root/src/fullpkg/fullpkg-find
diff options
context:
space:
mode:
Diffstat (limited to 'src/fullpkg/fullpkg-find')
-rwxr-xr-xsrc/fullpkg/fullpkg-find328
1 files changed, 182 insertions, 146 deletions
diff --git a/src/fullpkg/fullpkg-find b/src/fullpkg/fullpkg-find
index a927782..8bd630c 100755
--- a/src/fullpkg/fullpkg-find
+++ b/src/fullpkg/fullpkg-find
@@ -1,5 +1,48 @@
#!/usr/bin/env bash
# set -x # uncomment for debug
+
+# Copyright (C) 2011-2012 Joshua I. Haase H. (xihh) <hahj87@gmail.com>
+# Copyright (C) 2011-2012 Nicolás Reynolds <fauno@kiwwwi.com.ar>
+# Copyright (C) 2012 Michał Masłowski <mtjm@mtjm.eu>
+# Copyright (C) 2012-2014 Luke Shumaker <LukeShu@sbcglobal.net>
+#
+# The copy_files() function is taken from makechrootpkg:
+# Copyright (C) 2007 Armin Luntzer <armin@archlinuxppc.org>
+# Copyright (C) 2007 Jason Chu <jchu@xentac.net>
+# Copyright (C) 2007, 2011 Dan McGee <dan@archlinux.org>
+# Copyright (C) 2007-2008 Travis Willard <travis@archlinux.org>
+# Copyright (C) 2007-2009 Aaron Griffin <aaronmgriffin@gmail.com>
+# Copyright (C) 2008 Simo Leone <simo@archlinux.org>
+# Copyright (C) 2009 Biru Ionut <biru.ionut@gmail.com>
+# Copyright (C) 2009 Biru Ionut <ionut@archlinux.ro>
+# Copyright (C) 2009 Evangelos Foutras <foutrelis@gmail.com>
+# Copyright (C) 2009 Francois Charette <francois@samarqand.localdomain>
+# Copyright (C) 2009 Nezmer <Nezmer@allurelinux.org>
+# Copyright (C) 2009 Ronald van Haren <pressh@gmail.com>
+# Copyright (C) 2009-2011 Andrea Scarpino <andrea@archlinux.org>
+# Copyright (C) 2009-2012 Allan McRae <allan@archlinux.org>
+# Copyright (C) 2009-2012 Eric Bélanger <snowmaniscool@gmail.com>
+# Copyright (C) 2009-2012 Pierre Schmitz <pierre@archlinux.de>
+# Copyright (C) 2010 Byron Clark <byron@theclarkfamily.name>
+# Copyright (C) 2011 Ionut Biru <ibiru@archlinux.org>
+# Copyright (C) 2011 Lukas Fleischer <archlinux@cryptocrack.de>
+# Copyright (C) 2011-2012 Florian Pritz <bluewind@xinu.at>
+# Copyright (C) 2011-2013 Jan Alexander Steffens (heftig) <jan.steffens@gmail.com>
+# Copyright (C) 2013 Sébastien Luttringer <seblu@seblu.net>
+#
+# Because of the code from makechrootpkg, this file is GPLv2, instead of GPLv3
+# like most of libretools.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; version 2 of the License.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+
+
# Builds packages from ABS recursively. It tries to find dependencies that
# aren't built or need update and then makepkg them in order.
@@ -8,114 +51,108 @@
# Get repo name. Asumes ${ABSROOT}/repo/package/PKGBUILD
guess_repo() {
- basename $(dirname $(pwd))
+ basename "$(dirname "$(pwd)")"
}
# This function is stolen from makechrootpkg.
-# That probably has some copyright/licensing implications.
copy_files() {
- local copydir="$build_dir/${pkgbase:-${pkgname[0]}}"
- mkdir -p "$copydir"
-
- # Copy PKGBUILD and sources
- cp PKGBUILD "$copydir"
- (
- load_PKGBUILD
- for file in "${source[@]}"; do
- file="${file%%::*}"
- file="${file##*://*/}"
- if [[ -f $file ]]; then
- cp "$file" "$copydir/"
- elif [[ -f $SRCDEST/$file ]]; then
- cp "$SRCDEST/$file" "$copydir/"
- fi
- done
-
- # Find all changelog and install files, even inside functions
- for i in 'changelog' 'install'; do
- while read -r file; do
- # evaluate any bash variables used
- eval file=\"$(sed 's/^\(['\''"]\)\(.*\)\1$/\2/' <<< "$file")\"
- [[ -f $file ]] && cp "$file" "$copydir"
- done < <(sed -n "s/^[[:space:]]*$i=//p" PKGBUILD)
- done
- )
+ local copydir="$build_dir/${pkgbase:-${pkgname[0]}}"
+ mkdir -p "$copydir"
+
+ # Copy PKGBUILD and sources
+ cp PKGBUILD "$copydir"
+ (
+ load_PKGBUILD
+ for file in "${source[@]}"; do
+ file="${file%%::*}"
+ file="${file##*://*/}"
+ if [[ -f $file ]]; then
+ cp "$file" "$copydir/"
+ elif [[ -f $SRCDEST/$file ]]; then
+ cp "$SRCDEST/$file" "$copydir/"
+ fi
+ done
+
+ # Find all changelog and install files, even inside functions
+ for i in 'changelog' 'install'; do
+ while read -r file; do
+ # evaluate any bash variables used
+ eval file=\"$(sed "s/^\\(['\"]\\)\\(.*\\)\\1\$/\\2/" <<< "$file")\"
+ [[ -f $file ]] && cp "$file" "$copydir"
+ done < <(sed -n "s/^[[:space:]]*$i=//p" PKGBUILD)
+ done
+ )
}
# Checks ABSROOT and look for target pkg deps. Adds them if not built or outdated.
find_deps() {
-# Check this level
- load_PKGBUILD
-
- local repo="${repo:-$(guess_repo)}"
- local pkgbase="${pkgbase:-${pkgname[0]}}"
-
- if ! pkgbuild-check-nonfree > /dev/null 2> /dev/null; then
- if [ "$?" -eq 15 ]; then
- error "pkgbase" has nonfree issues
- return 15
- fi
- fi
-
- # Checking any package built, since otherwise e.g. kdebase would
- # be always considered outdated: there is no package built named kdebase.
- # TODO: maybe check for the package requested in case of recursive calls,
- # instead of the first one listed?
- if is_built "${pkgname[0]}" "$(get_full_version "${pkgname[0]}")"; then
- 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
- exit 0
-# Copy dir to build_dir
- else
- copy_files
-
-# to identify repo later
- echo "repo=$repo" > "${build_dir}/${pkgbase}/.INFO"
- fi
-
-# current package plus a space for every level
- msg2 "%${LEVEL}s${pkgbase}-$(get_full_version)"
-
-## Check next levels
- declare -i next_level=$LEVEL+1
-
-# All deps in separate line, only once, without version.
- deps=($(echo "${depends[@]} ${makedepends[@]}" | \
- sed "s/[=<>]\+[^ ]\+//g" | \
- tr ' ' "\n" | \
- sort -u))
-
- for _dep in ${deps[@]}; do
-
- local found=false
- # May fail, e.g. since abslibre-mips64el doesn't include
- # arch=any packages.
- local pkgdir=$(toru -p ${_dep}) || true
-
- if [ -n "$pkgdir" -a -d "${pkgdir}" ]; then
- found=true
-
- pushd "${pkgdir}" > /dev/null
-# runs itself on dep's PKGBUILD dir
- $0 -l ${next_level} ${build_dir} || return $?
- popd > /dev/null
- fi
-
- if ! (( found )); then
- echo "dep_not_found:$_dep" >>$build_dir/log
- fi
-
- done
-
-## End variable block
-
- unset next_level dir
+ # Check this level
+ load_PKGBUILD
+
+ local repo="${repo:-$(guess_repo)}"
+ local pkgbase="${pkgbase:-${pkgname[0]}}"
+
+ # Checking any package built, since otherwise e.g. kdebase would
+ # be always considered outdated: there is no package built named kdebase.
+ # TODO: maybe check for the package requested in case of recursive calls,
+ # instead of the first one listed?
+ if is_built "${pkgname[0]}" "$(get_full_version "${pkgname[0]}")"; then
+ 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
+ exit 0
+ # Copy dir to build_dir
+ else
+ copy_files
+
+ # to identify repo later
+ echo "repo=$repo" > "${build_dir}/${pkgbase}/.INFO"
+ fi
+
+ # current package plus a space for every level
+ msg2 "%${LEVEL}s%s" '' "${pkgbase}-$(get_full_version)"
+
+ ## Check next levels
+ declare -i next_level=$LEVEL+1
+
+ # All deps
+ local deps=("${depends[@]}" "${makedepends[@]}" "${checkdepends[@]}")
+ # Strip version specifiers
+ deps=("${deps[@]%%[=<>]*}")
+ # Filter out duplicates
+ read -d $'\n' -a deps <<<"$(printf '%s\n' "${deps[@]}"|sort -u)"
+
+ local _dep
+ for _dep in "${deps[@]}"; do
+
+ local found=false
+ # May fail, e.g. since abslibre-mips64el doesn't include
+ # arch=any packages.
+ local pkgdir=$(toru -p ${_dep}) || true
+
+ if [[ -n "$pkgdir" ]] && [[ -d "${pkgdir}" ]; then
+ found=true
+
+ pushd "${pkgdir}" > /dev/null
+ # runs itself on dep's PKGBUILD dir
+ "$0" -l "${next_level}" "${build_dir}" || return $?
+ popd > /dev/null
+ fi
+
+ if ! (( found )); then
+ echo "dep_not_found:$_dep" >>$build_dir/log
+ fi
+
+ done
+
+ ## End variable block
+
+ unset next_level dir
}
. libremessages
@@ -128,68 +165,67 @@ CLEANFIRST='false'
UPDATEDB='true'
usage() {
-
- echo ""
- echo "cd to a dir containing a PKGBUILD and run:"
- echo "$(basename $0) [options] <build_dir>"
- echo ""
- echo "This script will create a build_dir for recursive building"
- echo "it tries to find dependencies that aren't built or need update."
- echo ""
- echo "If no <build_dir> is specified, the script works on a tempdir"
- echo ""
- echo "OPTIONS:"
- echo " -h : this message."
- echo " -A <absroot> : use this ABSROOT."
- echo " -c : clean <build_dir> before working."
- echo " -m <max_level> : check deps until this level"
- echo " -n : don't update pacman db."
- echo ""
- exit 1
-
+ print "Usage: %s [OPTIONS] [BUILD_DIR]" "${0##*/}"
+ print "Finds package dependencies and sets up a build order"
+ echo
+ prose "Run this from a directory containing a PKGBUILD."
+ echo
+ prose "This script will create a BUILD_DIR for recursive building; it
+ tries to find dependencies that aren't built or need update."
+ echo
+ prose "If no BUILD_DIR is specified, it will create a temporary
+ directory."
+ echo
+ print "Options:"
+ flag "-h" "Show this message"
+ flag "-A <$(_ ABSROOT)>" "Use ABSROOT as the root of the ABS tree"
+ flag "-c" "Clean BUILD_DIR before working."
+ flag "-m <$(_ MAX_LEVEL)>" "Limit the depth of the dependency recursion"
+ flag "-n" "Don't update pacman DB"
}
while getopts 'hA:l:cmn' arg; do
- case "$arg" in
- h) usage ;;
- A) ABSROOT="$OPTARG" ;;
- l) LEVEL="$OPTARG" ;; # hidden option to know dep level.
- c) CLEANFIRST='true' ;;
- m) MAXLEVEL="$OPTARG" ;;
- n) UPDATEDB='false' ;;
- esac
+ case "$arg" in
+ h) usage; exit 0 ;;
+ A) ABSROOT="$OPTARG" ;;
+ l) LEVEL="$OPTARG" ;; # hidden option to know dep level.
+ c) CLEANFIRST='true' ;;
+ m) MAXLEVEL="$OPTARG" ;;
+ n) UPDATEDB='false' ;;
+ esac
done
-if [ ! -r PKGBUILD ]; then
- error "This directory doesnt contain a PKGBUILD"
- usage
+if [[ ! -r PKGBUILD ]]; then
+ error "This directory doesnt contain a PKGBUILD"
+ usage
+ exit 1
fi
shift $(( OPTIND - 1 ))
build_dir="${1}"
-if [ "$LEVEL" -eq 0 ]; then
+if [[ "$LEVEL" -eq 0 ]]; then
- build_dir="${1:-$(mktemp -d /tmp/fullpkg.XXXXXX)}"
+ build_dir="${1:-$(mktemp -d /tmp/fullpkg.XXXXXX)}"
- if [ ! -d "$build_dir" ]; then
- mkdir -p "$build_dir"
- elif "$CLEANFIRST"; then
- # Erase files already in dir
- msg "Cleaning up files in dir"
- find "$build_dir" -mindepth 1 -delete
- fi
+ if [[ ! -d "$build_dir" ]]; then
+ mkdir -p "$build_dir"
+ elif "$CLEANFIRST"; then
+ # Erase files already in dir
+ msg "Cleaning up files in dir"
+ find "$build_dir" -mindepth 1 -delete
+ fi
- if "$UPDATEDB"; then
- msg "Updating pacman db"
- sudo pacman -Sy --noconfirm || true
- fi
+ if "$UPDATEDB"; then
+ msg "Updating pacman db"
+ sudo pacman -Sy --noconfirm || true
+ fi
-# make files for log and buildorder
- touch "${build_dir}"/{log,BUILDORDER}
- buildorder="${build_dir}/BUILDORDER"
+ # make files for log and buildorder
+ touch "${build_dir}"/{log,BUILDORDER}
+ buildorder="${build_dir}/BUILDORDER"
- msg "Checking dependencies"
+ msg "Checking dependencies"
fi
find_deps