From 3cdafeb9ca49075fc1d5457d6abace3c47ae39be Mon Sep 17 00:00:00 2001 From: Juan RP Date: Thu, 14 Jan 2010 17:45:41 +0100 Subject: [PATCH] Added initial support to install binpkgs to resolve builddeps. if XBPS_PREFER_BINPKG_DEPS is set in xbps-src.conf, the local binpkg repo in XBPS_PACKAGESDIR will be used to install binpkgs. To use this feature you'll need xbps utils >= 20100114 from head. --HG-- extra : convert_revision : 7317e0e2741997007e81ed478f819c36e4858e5d --- xbps-src/etc/xbps-src.conf.in | 7 +++ xbps-src/shutils/builddep_funcs.sh | 4 ++ xbps-src/shutils/chroot.sh | 93 ++++++++++++++++------------- xbps-src/shutils/pkgtarget_funcs.sh | 26 +++++++- 4 files changed, 89 insertions(+), 41 deletions(-) diff --git a/xbps-src/etc/xbps-src.conf.in b/xbps-src/etc/xbps-src.conf.in index 5b2e85ddfe2..67c2980816d 100644 --- a/xbps-src/etc/xbps-src.conf.in +++ b/xbps-src/etc/xbps-src.conf.in @@ -57,3 +57,10 @@ XBPS_COMPRESS_CMD=xz # by the command will be used. # #XBPS_COMPRESS_LEVEL=9 + +# +# Install required build time dependencies from binary packages, +# XBPS_PACKAGESDIR will be used in the chroot to resolve +# builddeps. +# +#XBPS_PREFER_BINPKG_DEPS=yes diff --git a/xbps-src/shutils/builddep_funcs.sh b/xbps-src/shutils/builddep_funcs.sh index 8eb636f33a1..5c435a52ff7 100644 --- a/xbps-src/shutils/builddep_funcs.sh +++ b/xbps-src/shutils/builddep_funcs.sh @@ -119,6 +119,10 @@ install_dependencies_pkg() [ -z "$notinstalled_deps" ] && return 0 for i in ${notinstalled_deps}; do + if [ -n "$XBPS_PREFER_BINPKG_DEPS" ]; then + install_pkg_with_binpkg ${i} + [ $? -ne 0 ] && exit $? + fi pkgn=$($XBPS_PKGDB_CMD getpkgdepname ${i}) check_pkgdep_matched "${i}" [ $? -eq 0 ] && continue diff --git a/xbps-src/shutils/chroot.sh b/xbps-src/shutils/chroot.sh index 2e462b8dc41..7d42f6008fd 100644 --- a/xbps-src/shutils/chroot.sh +++ b/xbps-src/shutils/chroot.sh @@ -31,6 +31,49 @@ # Umount stuff if SIGINT or SIGQUIT was caught trap umount_chroot_fs INT QUIT +[ -n "$base_chroot" ] && return 0 + +. $XBPS_SHUTILSDIR/builddep_funcs.sh +check_installed_pkg xbps-base-chroot-0.11 +if [ $? -ne 0 ]; then + echo "The '$pkgname' package requires to be installed in a chroot." + echo "Please install 'xbps-base-chroot>=0.11' and try again." + exit 1 +fi + +if [ "$(id -u)" -ne 0 ]; then + echo "This package requires to be installed in a chroot." + echo "You cannot do this as normal user, try again being root." + exit 1 +fi + +msg_normal "Entering into the chroot on $XBPS_MASTERDIR." + +EXTDIRS="xbps xbps_builddir xbps_destdir xbps_packagesdir \ + xbps_srcdistdir" +REQDIRS="bin sbin tmp var sys proc dev usr/local/etc ${EXTDIRS}" +for f in ${REQDIRS}; do + [ ! -d $XBPS_MASTERDIR/$f ] && mkdir -p $XBPS_MASTERDIR/$f +done +unset f REQDIRS + +XBPSSRC_CF=$XBPS_MASTERDIR/usr/local/etc/xbps-src.conf + +echo "XBPS_DISTRIBUTIONDIR=/xbps" > $XBPSSRC_CF +echo "XBPS_MASTERDIR=/" >> $XBPSSRC_CF +echo "XBPS_PACKAGESDIR=/xbps_packagesdir" >> $XBPSSRC_CF +echo "XBPS_BUILDDIR=/xbps_builddir" >> $XBPSSRC_CF +echo "XBPS_SRCDISTDIR=/xbps_srcdistdir" >> $XBPSSRC_CF +echo "XBPS_CFLAGS=\"$XBPS_CFLAGS\"" >> $XBPSSRC_CF +echo "XBPS_CXXFLAGS=\"\$XBPS_CFLAGS\"" >> $XBPSSRC_CF +echo "XBPS_FETCH_CMD='xbps-uhelper.static fetch'" >> $XBPSSRC_CF +if [ -n "$XBPS_MAKEJOBS" ]; then + echo "XBPS_MAKEJOBS=$XBPS_MAKEJOBS" >> $XBPSSRC_CF +fi +if [ -n "$XBPS_PREFER_BINPKG_DEPS" ]; then + echo "XBPS_PREFER_BINPKG_DEPS=$XBPS_PREFER_BINPKG_DEPS" >> $XBPSSRC_CF +fi + prepare_chroot() { local f= @@ -103,6 +146,15 @@ rebuild_ldso_cache() echo " done." } +prepare_binpkg_repos() +{ + if [ ! -f "$XBPS_MASTERDIR/.xbps_added_local_repo" ]; then + msg_normal "Registering local binpkg repo..." + chroot $XBPS_MASTERDIR xbps-repo.static add /xbps_packagesdir + [ $? -eq 0 ] && touch -f $XBPS_MASTERDIR/.xbps_added_local_repo + fi +} + create_busybox_links() { local busyboxdir=$XBPS_MASTERDIR/usr/lib/busybox-initramfs @@ -170,6 +222,7 @@ xbps_chroot_handler() create_busybox_links install_xbps_utils mount_chroot_fs + prepare_binpkg_repos # Reinstall xbps-src in the chroot if [ ! -f $XBPS_MASTERDIR/usr/local/sbin/xbps-src ]; then @@ -260,43 +313,3 @@ umount_chroot_fs() [ -d $XBPS_MASTERDIR/$dir ] && rmdir $XBPS_MASTERDIR/$dir done } - -[ -n "$base_chroot" ] && return 0 - -. $XBPS_SHUTILSDIR/builddep_funcs.sh -check_installed_pkg xbps-base-chroot-0.11 -if [ $? -ne 0 ]; then - echo "The '$pkgname' package requires to be installed in a chroot." - echo "Please install 'xbps-base-chroot>=0.11' and try again." - exit 1 -fi - -if [ "$(id -u)" -ne 0 ]; then - echo "This package requires to be installed in a chroot." - echo "You cannot do this as normal user, try again being root." - exit 1 -fi - -msg_normal "Entering into the chroot on $XBPS_MASTERDIR." - -EXTDIRS="xbps xbps_builddir xbps_destdir xbps_packagesdir \ - xbps_srcdistdir" -REQDIRS="bin sbin tmp var sys proc dev usr/local/etc ${EXTDIRS}" -for f in ${REQDIRS}; do - [ ! -d $XBPS_MASTERDIR/$f ] && mkdir -p $XBPS_MASTERDIR/$f -done -unset f REQDIRS - -XBPSSRC_CF=$XBPS_MASTERDIR/usr/local/etc/xbps-src.conf - -echo "XBPS_DISTRIBUTIONDIR=/xbps" > $XBPSSRC_CF -echo "XBPS_MASTERDIR=/" >> $XBPSSRC_CF -echo "XBPS_PACKAGESDIR=/xbps_packagesdir" >> $XBPSSRC_CF -echo "XBPS_BUILDDIR=/xbps_builddir" >> $XBPSSRC_CF -echo "XBPS_SRCDISTDIR=/xbps_srcdistdir" >> $XBPSSRC_CF -echo "XBPS_CFLAGS=\"$XBPS_CFLAGS\"" >> $XBPSSRC_CF -echo "XBPS_CXXFLAGS=\"\$XBPS_CFLAGS\"" >> $XBPSSRC_CF -echo "XBPS_FETCH_CMD='xbps-uhelper.static fetch'" >> $XBPSSRC_CF -if [ -n "$XBPS_MAKEJOBS" ]; then - echo "XBPS_MAKEJOBS=$XBPS_MAKEJOBS" >> $XBPSSRC_CF -fi diff --git a/xbps-src/shutils/pkgtarget_funcs.sh b/xbps-src/shutils/pkgtarget_funcs.sh index b6a36049057..31319ec46a4 100644 --- a/xbps-src/shutils/pkgtarget_funcs.sh +++ b/xbps-src/shutils/pkgtarget_funcs.sh @@ -1,5 +1,5 @@ #- -# Copyright (c) 2008-2009 Juan Romero Pardines. +# Copyright (c) 2008-2010 Juan Romero Pardines. # All rights reserved. # # Redistribution and use in source and binary forms, with or without @@ -122,6 +122,30 @@ install_pkg() fi } +# +# Installs a pkg by installing a binary package from +# repository pool, matching the pkg pattern. +# +install_pkg_with_binpkg() +{ + local pkgpattern="$1" + + # + # Check that installed xbps utils version is recent enough. + # + instver=$(${XBPS_BIN_CMD} -V) + ${XBPS_CMPVER_CMD} "${instver}" "20100114" + if [ $? -eq 255 ]; then + echo -n "Your xbps utilities are too old, " + echo "required version: 20100114" + return 1 + fi + + msg_normal "Installing binary pkg: $pkgpattern" + $XBPS_BIN_CMD -y install "$pkgpattern" + return $? +} + # # Lists files installed by a package. #