From 522437b90fc2efd5cff12edd3fe4be2b8b0fd839 Mon Sep 17 00:00:00 2001 From: Juan RP Date: Tue, 27 Apr 2010 23:09:08 +0200 Subject: [PATCH] Multiple improvements for XBPS_PREFER_BINPKG_DEPS. - Added a new var XBPS_REPO_LIST for the conf file, to specify a list of remote repositories to be used in a masterdir. - Install all required binpkgs in one pass, if that fails install one of them at every pass. - Fixed xbps-src-chroot-helper to properly catch SIG{INT,QUIT} when -m is specified. - Misc cosmetics improvements. --HG-- extra : convert_revision : 0ad7d559477ccc1fc04ab09deb791343ee453de6 --- xbps-src/etc/xbps-src.conf.in | 5 ++- xbps-src/libexec/xbps-src-chroot-helper.sh.in | 6 ++-- xbps-src/shutils/builddep_funcs.sh | 36 ++++++++++++++----- xbps-src/shutils/chroot.sh.in | 30 ++++++++++++---- xbps-src/shutils/pkgtarget_funcs.sh.in | 3 +- 5 files changed, 60 insertions(+), 20 deletions(-) diff --git a/xbps-src/etc/xbps-src.conf.in b/xbps-src/etc/xbps-src.conf.in index 640539772ba..48448cb4eb9 100644 --- a/xbps-src/etc/xbps-src.conf.in +++ b/xbps-src/etc/xbps-src.conf.in @@ -39,9 +39,12 @@ XBPS_COMPRESS_CMD=xz # # Install required build time dependencies from binary packages, -# XBPS_PACKAGESDIR will be used in the chroot to resolve builddeps. +# Local repository associated with the masterdir at /pkg-binpkgs, +# and remote repositories specified in XBPS_REPO_LIST will be used +# to resolve build dependencies. # #XBPS_PREFER_BINPKG_DEPS=yes +#XBPS_REPO_LIST="http://xbps.nopcode.org/repos/stable" # # Build packages with your unprivileged user in the chroot thanks diff --git a/xbps-src/libexec/xbps-src-chroot-helper.sh.in b/xbps-src/libexec/xbps-src-chroot-helper.sh.in index f69f5ebd356..74f94259dc0 100644 --- a/xbps-src/libexec/xbps-src-chroot-helper.sh.in +++ b/xbps-src/libexec/xbps-src-chroot-helper.sh.in @@ -24,9 +24,6 @@ # THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #- -# Umount stuff if SIGINT or SIGQUIT was caught -trap umount_chroot_fs INT QUIT - HANDLER="$1" . @@XBPS_INSTALL_ETCDIR@@/xbps-src.conf @@ -35,6 +32,9 @@ if [ -n "${MASTERDIR}" ]; then export XBPS_MASTERDIR="${MASTERDIR}" fi +# Umount stuff if SIGINT or SIGQUIT was caught +trap umount_chroot_fs INT QUIT + REQFS="sys proc dev xbps" mount_chroot_fs() diff --git a/xbps-src/shutils/builddep_funcs.sh b/xbps-src/shutils/builddep_funcs.sh index 8d59640a8d1..adbf04206f4 100644 --- a/xbps-src/shutils/builddep_funcs.sh +++ b/xbps-src/shutils/builddep_funcs.sh @@ -78,7 +78,7 @@ install_pkg_deps() done if [ -n "$XBPS_PREFER_BINPKG_DEPS" ]; then - install_pkg_with_binpkg ${curpkg} + install_pkg_with_binpkg "${curpkg}" if [ $? -eq 255 ]; then # xbps-bin returned unexpected error return $? @@ -97,7 +97,7 @@ install_pkg_deps() # install_dependencies_pkg() { - local pkg="$1" + local pkg="$1" rval pkgdep_list local lpkgname=$(${XBPS_PKGDB_CMD} getpkgname ${pkg}) local i pkgn iver reqver notinstalled_deps lver @@ -129,13 +129,32 @@ install_dependencies_pkg() [ -z "$notinstalled_deps" ] && return 0 + if [ -n "$XBPS_PREFER_BINPKG_DEPS" ]; then + for i in ${notinstalled_deps}; do + pkgdeplist="${pkgdeplist} \"${i}\" " + done + msg_normal "Installing required build dependencies from binpkgs..." + ${fakeroot_cmd} ${fakeroot_cmd_args} ${XBPS_BIN_CMD} \ + -y install ${pkgdeplist} + rval=$? + if [ $rval -eq 255 ]; then + # xbps-bin returned unexpected error (-1) + return $? + elif [ $rval -eq 0 ]; then + # Install successfully + echo + return 0 + fi + fi + for i in ${notinstalled_deps}; do if [ -n "$XBPS_PREFER_BINPKG_DEPS" ]; then - install_pkg_with_binpkg ${i} - if [ $? -eq 255 ]; then + install_pkg_with_binpkg "${i}" + rval=$? + if [ $rval -eq 255 ]; then # xbps-bin returned unexpected error (-1) return $? - elif [ $? -eq 0 ]; then + elif [ $rval -eq 0 ]; then # installed successfully continue fi @@ -149,11 +168,12 @@ install_dependencies_pkg() if [ $? -eq 1 ]; then msg_normal "Installing $lpkgname dependency: $pkgn." if [ -n "$XBPS_PREFER_BINPKG_DEPS" ]; then - install_pkg_with_binpkg ${i} - if [ $? -eq 255 ]; then + install_pkg_with_binpkg "${i}" + rval=$? + if [ $rval -eq 255 ]; then # xbps-bin returned unexpected error return $? - elif [ $? -eq 0 ]; then + elif [ $rval -eq 0 ]; then # installed successfully continue else diff --git a/xbps-src/shutils/chroot.sh.in b/xbps-src/shutils/chroot.sh.in index ebb70a6de60..3e955a6a2f4 100644 --- a/xbps-src/shutils/chroot.sh.in +++ b/xbps-src/shutils/chroot.sh.in @@ -29,7 +29,8 @@ # # Umount stuff if SIGINT or SIGQUIT was caught -trap "${sudo_cmd} @@XBPS_INSTALL_LIBEXECDIR@@/xbps-src-chroot-helper umount && exit $?" INT QUIT +trap "MASTERDIR=${XBPS_MASTERDIR} ${sudo_cmd} \ + @@XBPS_INSTALL_LIBEXECDIR@@/xbps-src-chroot-helper umount && exit $?" INT QUIT [ -n "$base_chroot" ] && return 0 @@ -150,12 +151,24 @@ create_binsh_symlink() prepare_binpkg_repos() { + local repo + if [ ! -f "$XBPS_MASTERDIR/.xbps_added_local_repo" ]; then - msg_normal "Registering local binpkg repo..." - ${chroot_cmd} $XBPS_MASTERDIR \ - ${XBPS_REPO_CMD} add /xbps_packagesdir - [ $? -eq 0 ] && touch -f $XBPS_MASTERDIR/.xbps_added_local_repo + if [ ! -f ${XBPS_PACKAGESDIR}/${xbps_machine}/pkg-index.plist ]; then + : + else + msg_normal "Registering local binpkg repo..." + ${chroot_cmd} $XBPS_MASTERDIR \ + ${XBPS_REPO_CMD} add /xbps_packagesdir 2>/dev/null + [ $? -eq 0 ] && touch -f \ + $XBPS_MASTERDIR/.xbps_added_local_repo + fi fi + for repo in ${XBPS_REPO_LIST}; do + ${chroot_cmd} ${XBPS_MASTERDIR} ${XBPS_REPO_CMD} \ + add ${repo} 2>/dev/null + [ $? -eq 0 ] && msg_normal "Registered remote repository: ${repo}" + done } create_busybox_links() @@ -189,7 +202,7 @@ install_xbps_utils() done if [ -n "$needed" ]; then - echo "=> Installing the required XBPS utils." + echo "=> Installing static XBPS utils into masterdir." for f in bin repo uhelper; do _cmd=$(which xbps-${f}.static 2>/dev/null) if [ -z "${_cmd}" ]; then @@ -233,9 +246,11 @@ xbps_chroot_handler() # Reinstall xbps-src in the chroot if [ ! -f $XBPS_MASTERDIR/usr/local/sbin/xbps-src ]; then + msg_normal "Installing xbps-src in the masterdir..." env in_chroot=yes LANG=C PATH=$path \ ${chroot_cmd} $XBPS_MASTERDIR sh -c \ - "cd /xbps/xbps-src && make IN_CHROOT=1 install clean" + "cd /xbps/xbps-src && make IN_CHROOT=1 install clean" \ + 2>&1 >/dev/null fi if [ "$action" = "chroot" ]; then @@ -251,6 +266,7 @@ xbps_chroot_handler() ${lenv} ${chroot_cmd} $XBPS_MASTERDIR sh -c \ "cd /xbps/srcpkgs/$pkg && xbps-src $action" fi + msg_normal "Exiting from the chroot on $XBPS_MASTERDIR." MASTERDIR="${XBPS_MASTERDIR}" ${sudo_cmd} \ @@XBPS_INSTALL_LIBEXECDIR@@/xbps-src-chroot-helper umount diff --git a/xbps-src/shutils/pkgtarget_funcs.sh.in b/xbps-src/shutils/pkgtarget_funcs.sh.in index b1af3244907..a6f3114984d 100644 --- a/xbps-src/shutils/pkgtarget_funcs.sh.in +++ b/xbps-src/shutils/pkgtarget_funcs.sh.in @@ -65,6 +65,7 @@ install_pkg() # if [ -z "$doing_deps" ]; then install_dependencies_pkg $pkg + [ $? -ne 0 ] && return $? # # At this point all required deps are installed, and # only remaining is the origin package; install it. @@ -123,7 +124,7 @@ install_pkg_with_binpkg() msg_normal "Installing binary pkg: $pkgpattern" ${fakeroot_cmd} ${fakeroot_cmd_args} ${XBPS_BIN_CMD} \ - -y install "$pkgpattern" + -y install \""$pkgpattern\"" return $? }