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
This commit is contained in:
Juan RP 2015-08-16 10:45:19 +02:00
parent 1779dabd7d
commit cef388f07b
2 changed files with 23 additions and 10 deletions

View File

@ -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

View File

@ -103,6 +103,10 @@ show-repo-updates
show-sys-updates
Prints the list of oudated packages in your system.
sort-dependencies <pkg> <pkgN+1> ...
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
;;