xbps-src: new targets: update-bulk and update-sys.

* update-bulk:
	This rebuilds all pkgs in system repositories that are outdated.
	with this xbps-bulk is now considered fully obsolete.

* update-sys:
	This rebuilds all pkgs in system that are oudated and once built,
	updates them via xbps-install(8).

	This target defines a new configuration option "XBPS_SUCMD" that
	is the command to execute to update the system. By default set to
	"sudo sh -c".

CAVEATS
	- need to check if binpkg is in local repo.
	- need to add support to specify alternative rootdir.
	- need to add support to specify system repos.
This commit is contained in:
Juan RP 2014-04-09 16:42:07 +02:00
parent 1af40eb476
commit d4e4d826e6
3 changed files with 97 additions and 48 deletions

View File

@ -0,0 +1,78 @@
# vim: set ts=4 sw=4 et:
bulk_getlink() {
local p="$(basename $1)"
local target="$(readlink $XBPS_SRCPKGDIR/$p)"
if [ $? -eq 0 -a -n "$target" ]; then
p=$target
fi
echo $p
}
bulk_build() {
local args="$1" pkg= pkgs= _pkgs= _realdep= _deps= found= x= result=
if ! command -v xbps-checkvers &>/dev/null; then
msg_error "xbps-src: cannot find xbps-checkvers(8) command!\n"
fi
_pkgs=$(xbps-checkvers ${args} -d $XBPS_DISTDIR | awk '{print $2}')
# Only add to the list real pkgs, not subpkgs.
for pkg in ${_pkgs}; do
_realdep=$(bulk_getlink $pkg)
unset found
for x in ${pkgs}; do
if [ "$x" = "${_realdep}" ]; then
found=1
break
fi
done
if [ -z "$found" ]; then
pkgs="$pkgs ${_realdep}"
fi
done
for pkg in ${pkgs}; do
unset found
setup_pkg $pkg $XBPS_CROSS_BUILD
_deps="$(show_pkg_build_deps | sed -e 's|[<>].*\$||g')"
_realdep=$(bulk_getlink $pkg)
for x in ${_deps}; do
if [ "${_realdep}" = "${pkg}" ]; then
found=1
break
fi
done
[ -n $found ] && result="${_realdep} ${result}"
done
[ -n "$result" ] && echo "$result"
}
bulk_update() {
local args="$1" pkgs=
pkgs="$(bulk_build ${args})"
msg_normal "xbps-src: the following packages must be rebuilt and updated:\n"
for f in ${pkgs}; do
echo " $f"
done
echo
for f in ${pkgs}; do
BEGIN_INSTALL=1
XBPS_TARGET_PKG="$f"
read_pkg
msg_normal "xbps-src: building ${pkgver} ...\n"
if [ -n "$CHROOT_READY" -a -z "$IN_CHROOT" ]; then
chroot_handler pkg $XBPS_TARGET_PKG
else
install_pkg pkg $XBPS_CROSS_BUILD
fi
if [ $? -ne 0 ]; then
msg_error "xbps-src: failed to build $pkgver pkg!\n"
fi
done
if [ -n "$pkgs" -a -n "$args" ]; then
echo
msg_normal "xbps-src: updating your system, confirm to proceed...\n"
${XBPS_SUCMD} "xbps-install --repository=$XBPS_REPOSITORY --repository=$XBPS_REPOSITORY/nonfree -u ${pkgs}"
fi
}

View File

@ -59,6 +59,12 @@ XBPS_CXXFLAGS="${XBPS_CFLAGS}"
#
XBPS_LDFLAGS="-Wl,--as-needed"
# [REQUIRED]
# Command to execute to gain root privileges when using the `update-sys`
# target to update your system.
#
XBPS_SUCMD="sudo /bin/sh -c"
# [OPTIONAL]
# Enable or disable ccache when building packages.
#

View File

@ -79,11 +79,17 @@ Targets: (only one may be specified)
Prints the value of <var> if it's defined in xbps-src.
show-repo-updates
Prints the list of outdated packages in repositories.
Prints the list of outdated packages in XBPS repositories.
show-sys-updates
Prints the list of oudated packages in your system.
update-bulk
Rebuilds all packages in the system repositories that are outdated.
update-sys
Rebuilds all packages in your system that are outdated and updates them.
zap
Removes a masterdir but preserving ccache, distcc and host directories.
@ -479,53 +485,6 @@ check_build_requirements
trap 'exit_func' INT TERM HUP
bulk_getlink() {
local p="$(basename $1)"
local target="$(readlink $XBPS_SRCPKGDIR/$p)"
if [ $? -eq 0 -a -n "$target" ]; then
p=$target
fi
echo $p
}
bulk_build() {
local args="$1" pkg= pkgs= _pkgs= _realdep= _deps= found= x= result=
if ! command -v xbps-checkvers &>/dev/null; then
msg_error "xbps-src: cannot find xbps-{repo,}checkvers command!\n"
fi
_pkgs=$(xbps-checkvers ${args} -d $XBPS_DISTDIR | awk '{print $2}')
# Only add to the list real pkgs, not subpkgs.
for pkg in ${_pkgs}; do
_realdep=$(bulk_getlink $pkg)
unset found
for x in ${pkgs}; do
if [ "$x" = "${_realdep}" ]; then
found=1
break
fi
done
if [ -z "$found" ]; then
pkgs="$pkgs ${_realdep}"
fi
done
for pkg in ${pkgs}; do
unset found
setup_pkg $pkg $XBPS_CROSS_BUILD
_deps="$(show_pkg_build_deps | sed -e 's|[<>].*\$||g')"
_realdep=$(bulk_getlink $pkg)
for x in ${_deps}; do
if [ "${_realdep}" = "${pkg}" ]; then
found=1
break
fi
done
[ -n $found ] && result="${_realdep} ${result}"
done
echo "$result"
}
#
# Main switch.
#
@ -625,6 +584,12 @@ show-repo-updates)
show-sys-updates)
bulk_build -i
;;
update-bulk)
bulk_update
;;
update-sys)
bulk_update -i
;;
zap)
masterdir_zap
;;