xbps-src: improve bulk code a bit more.

- use `show-avail` to discard broken pkgs.
- the parallel logic was incomplete.
- avoid unnecessary sorting.
This commit is contained in:
Juan RP 2019-07-04 11:51:24 +02:00 committed by Jürgen Buchmüller
parent 3b73edbaa5
commit 4262450928
1 changed files with 32 additions and 13 deletions

View File

@ -8,14 +8,13 @@ bulk_sortdeps() {
tmpf=$(mktemp) || exit 1 tmpf=$(mktemp) || exit 1
# Perform a topological sort of all build dependencies. # Perform a topological sort of all *direct* build dependencies.
if [ $NRUNNING -eq $NPROCS ]; then
NRUNNING=0
wait
fi
for pkg in ${pkgs}; do for pkg in ${pkgs}; do
# async/parallel execution if [ $NRUNNING -eq $NPROCS ]; then
NRUNNING=0
wait
fi
NRUNNING=$((NRUNNING+1))
( (
for _pkg in $(./xbps-src show-build-deps $pkg 2>/dev/null); do for _pkg in $(./xbps-src show-build-deps $pkg 2>/dev/null); do
echo "$pkg $_pkg" >> $tmpf echo "$pkg $_pkg" >> $tmpf
@ -29,6 +28,9 @@ bulk_sortdeps() {
} }
bulk_build() { bulk_build() {
local sys="$1"
local NPROCS=$(($(nproc)*2))
local NRUNNING=0
if [ "$XBPS_CROSS_BUILD" ]; then if [ "$XBPS_CROSS_BUILD" ]; then
source ${XBPS_COMMONDIR}/cross-profiles/${XBPS_CROSS_BUILD}.sh source ${XBPS_COMMONDIR}/cross-profiles/${XBPS_CROSS_BUILD}.sh
@ -38,21 +40,38 @@ bulk_build() {
msg_error "xbps-src: cannot find xbps-checkvers(1) command!\n" msg_error "xbps-src: cannot find xbps-checkvers(1) command!\n"
fi fi
bulk_sortdeps "$(xbps-checkvers -f '%n' ${1} --distdir=$XBPS_DISTDIR)" # Compare installed pkg versions vs srcpkgs
if [[ $sys ]]; then
xbps-checkvers -f '%n' -I -D $XBPS_DISTDIR
return $?
fi
# compare repo pkg versions vs srcpkgs
for f in $(xbps-checkvers -f '%n' -D $XBPS_DISTDIR); do
if [ $NRUNNING -eq $NPROCS ]; then
NRUNNING=0
wait
fi
NRUNNING=$((NRUNNING+1))
(
if ./xbps-src show-avail $f &>/dev/null; then
echo "$f"
fi
) &
done
wait
return $?
} }
bulk_update() { bulk_update() {
local args="$1" pkgs f rval local args="$1" pkgs f rval
pkgs="$(bulk_build ${args})" pkgs="$(bulk_build ${args})"
if [ -z "$pkgs" ]; then [[ -z $pkgs ]] && return 0
return 0
fi
msg_normal "xbps-src: the following packages must be rebuilt and updated:\n" msg_normal "xbps-src: the following packages must be rebuilt and updated:\n"
for f in ${pkgs}; do for f in ${pkgs}; do
echo " $f" echo " $f"
done done
echo
for f in ${pkgs}; do for f in ${pkgs}; do
XBPS_TARGET_PKG=$f XBPS_TARGET_PKG=$f
read_pkg read_pkg