From cef388f07b0f938bbcc922a7d38454045c7752db Mon Sep 17 00:00:00 2001 From: Juan RP Date: Sun, 16 Aug 2015 10:45:19 +0200 Subject: [PATCH] xbps-src: introduce a new target: "sort-dependencies". This expects a variable argument list with package names that will be returned to stdout topologically sorted. $ ./xbps-src sort-dependencies libarchive-devel liblzma-devel libxbps zlib-devel bzip2-devel bzip2 xz zlib libarchive xbps --- common/xbps-src/shutils/bulk.sh | 24 +++++++++++++++--------- xbps-src | 9 ++++++++- 2 files changed, 23 insertions(+), 10 deletions(-) diff --git a/common/xbps-src/shutils/bulk.sh b/common/xbps-src/shutils/bulk.sh index 0e0e5b88308..75d92340600 100644 --- a/common/xbps-src/shutils/bulk.sh +++ b/common/xbps-src/shutils/bulk.sh @@ -10,17 +10,10 @@ bulk_getlink() { echo $p } -bulk_build() { +bulk_sortdeps() { local _pkgs _pkg pkgs pkg found f x tmpf - if [ "$XBPS_CROSS_BUILD" ]; then - source ${XBPS_COMMONDIR}/cross-profiles/${XBPS_CROSS_BUILD}.sh - export XBPS_ARCH=${XBPS_TARGET_ARCH} - fi - if ! command -v xbps-checkvers &>/dev/null; then - msg_error "xbps-src: cannot find xbps-checkvers(8) command!\n" - fi - _pkgs=$(xbps-checkvers ${1} --distdir=$XBPS_DISTDIR | awk '{print $2}') + _pkgs="$@" # Iterate over the list and make sure that only real pkgs are # added to our pkglist. for pkg in ${_pkgs}; do @@ -60,6 +53,19 @@ bulk_build() { rm -f $tmpf } +bulk_build() { + + if [ "$XBPS_CROSS_BUILD" ]; then + source ${XBPS_COMMONDIR}/cross-profiles/${XBPS_CROSS_BUILD}.sh + export XBPS_ARCH=${XBPS_TARGET_ARCH} + fi + if ! command -v xbps-checkvers &>/dev/null; then + msg_error "xbps-src: cannot find xbps-checkvers(8) command!\n" + fi + + bulk_sortdeps "$(xbps-checkvers ${1} --distdir=$XBPS_DISTDIR | awk '{print $2}')" +} + bulk_update() { local args="$1" pkgs f diff --git a/xbps-src b/xbps-src index 5f8baddd6ab..04a8ae35933 100755 --- a/xbps-src +++ b/xbps-src @@ -103,6 +103,10 @@ show-repo-updates show-sys-updates Prints the list of oudated packages in your system. +sort-dependencies ... + Given a list of packages specified as additional arguments, a sorted dependency + list will be returned to stdout. + update-bulk Rebuilds all packages in the system repositories that are outdated. @@ -381,7 +385,7 @@ while getopts "a:CEfgGhH:Ij:Lm:No:r:tV" opt; do done shift $(($OPTIND - 1)) -[ $# -eq 0 -o $# -gt 3 ] && usage && exit 1 +[ $# -eq 0 ] && usage && exit 1 umask 022 @@ -691,6 +695,9 @@ case "$XBPS_TARGET" in show-sys-updates) bulk_build -i ;; + sort-dependencies) + bulk_sortdeps ${@/$XBPS_TARGET/} + ;; update-bulk) bulk_update ;;