From 9b52e244c6fc33fa9755ad6e22dcf15b86e82108 Mon Sep 17 00:00:00 2001 From: Juan RP Date: Mon, 4 Jul 2011 19:07:08 +0200 Subject: [PATCH] xbps-src: added -K flag to KEEP automatic installed deps, cleanups. --- xbps-src/shutils/builddep_funcs.sh | 6 +++++ xbps-src/shutils/chroot.sh.in | 13 ++++++----- xbps-src/shutils/common_funcs.sh | 10 +++++---- xbps-src/shutils/extract_funcs.sh | 2 +- xbps-src/shutils/init_funcs.sh.in | 2 +- xbps-src/shutils/pkgtarget_funcs.sh.in | 31 +++++++++++++------------- xbps-src/shutils/stow_funcs.sh | 4 ++-- xbps-src/shutils/tmpl_funcs.sh.in | 2 +- xbps-src/xbps-src.sh.in | 29 ++++++++++++++---------- 9 files changed, 57 insertions(+), 42 deletions(-) diff --git a/xbps-src/shutils/builddep_funcs.sh b/xbps-src/shutils/builddep_funcs.sh index 863c0fb846..b065ef40e4 100644 --- a/xbps-src/shutils/builddep_funcs.sh +++ b/xbps-src/shutils/builddep_funcs.sh @@ -48,6 +48,7 @@ install_pkglist_from_repos() # ENODEV (19): package depends on missing dependencies. # # Any other returned is criticial. + autoremove_pkg_dependencies msg_red "'${pkgname}': failed to install required dependencies! (error $rval)\n" msg_error "'${pkgname}': please take a look the logs in \$wrksrc.\n" fi @@ -81,6 +82,7 @@ install_pkg_from_repos() # ENODEV (19): package depends on missing dependencies. # # Any other returned is criticial. + autoremove_pkg_dependencies msg_red "'${pkgname}': failed to install '${pkg}' dependency! (error $rval)\n" msg_error "Please see ${wrksrc}/.xbps_install_${pkgdepname}.log to see what went wrong!\n" fi @@ -92,6 +94,8 @@ autoremove_pkg_dependencies() { local cmd saved_pkgname x f found + [ -n "$KEEP_AUTODEPS" ] && return 0 + cmd="${fakeroot_cmd} ${fakeroot_cmd_args} ${XBPS_BIN_CMD}" # If XBPS_PREFER_BINPKG_DEPS is set, we should remove those @@ -272,6 +276,8 @@ install_dependencies_pkg() fi done + [ -z "$notinstalled_deps" ] && return 0 + # Install direct build dependencies from binary packages. if [ -n "$XBPS_PREFER_BINPKG_DEPS" -a -z "$base_chroot" ]; then msg_normal "'$pkg': installing dependencies from repositories ...\n" diff --git a/xbps-src/shutils/chroot.sh.in b/xbps-src/shutils/chroot.sh.in index 395c8b9772..26619c34d9 100644 --- a/xbps-src/shutils/chroot.sh.in +++ b/xbps-src/shutils/chroot.sh.in @@ -271,8 +271,7 @@ install_xbps_utils() xbps_chroot_handler() { - local action="$1" pkg="$2" keep_wrksrc="$3" rv=0 - local path="/tools/bin:/usr/local/sbin:/usr/local/bin:/bin:/sbin:/usr/bin:/usr/sbin" + local action="$1" pkg="$2" rv=0 arg [ -z "$action" -o -z "$pkg" ] && return 1 @@ -302,7 +301,7 @@ xbps_chroot_handler() # Reinstall xbps-src in the chroot msg_normal "Installing xbps-src in the masterdir...\n" - env in_chroot=yes LANG=C PATH=$path \ + env IN_CHROOT=yes LANG=C \ ${chroot_cmd} $XBPS_MASTERDIR sh -c \ "cd /xbps/xbps-src && make IN_CHROOT=1 install clean" \ 2>&1 >/dev/null || return $? @@ -312,11 +311,13 @@ xbps_chroot_handler() ${chroot_cmd} $XBPS_MASTERDIR sh -c "ldconfig" || return $? if [ "$action" = "chroot" ]; then - env in_chroot=yes IN_CHROOT=1 LANG=C PATH=$path \ + env IN_CHROOT=1 LANG=C \ ${chroot_cmd} $XBPS_MASTERDIR /bin/sh || rv=$? else - [ -n "$keep_wrksrc" ] && action="-C $action" - env in_chroot=yes LANG=C PATH=$path _ORIGINPKG="$pkg" \ + [ -n "$3" ] && arg="-C" + [ -n "$4" ] && arg="$arg -K" + action="$arg $action" + env in_chroot=1 IN_CHROOT=1 LANG=C _ORIGINPKG="$pkg" \ ${chroot_cmd} $XBPS_MASTERDIR sh -c \ "cd /xbps/srcpkgs/$pkg && xbps-src $action" || rv=$? fi diff --git a/xbps-src/shutils/common_funcs.sh b/xbps-src/shutils/common_funcs.sh index 32ef1d4fea..62eeb9c13a 100644 --- a/xbps-src/shutils/common_funcs.sh +++ b/xbps-src/shutils/common_funcs.sh @@ -70,6 +70,9 @@ remove_pkgdestdir_sighandler() rm -rf "$XBPS_DESTDIR/${sourcepkg}-${version%_*}" msg_red "'${sourcepkg}-${lver}': removed files from DESTDIR...\n" fi + + [ -n "$2" ] && KEEP_AUTODEPS=1 + autoremove_pkg_dependencies } var_is_a_function() @@ -130,7 +133,7 @@ msg_red() { # error messages in bold/red printf >&2 "\033[1m\033[31m" - if [ -n "$in_chroot" ]; then + if [ -n "$IN_CHROOT" ]; then printf >&2 "[chroot] => ERROR: $@" else printf >&2 "=> ERROR: $@" @@ -141,7 +144,6 @@ msg_red() msg_error() { msg_red "$@" - autoremove_pkg_dependencies exit 1 } @@ -157,7 +159,7 @@ msg_warn() { # warn messages in bold/yellow printf >&2 "\033[1m\033[33m" - if [ -n "$in_chroot" ]; then + if [ -n "$IN_CHROOT" ]; then printf >&2 "[chroot] => WARNING: $@" else printf >&2 "=> WARNING: $@" @@ -174,7 +176,7 @@ msg_normal() { # normal messages in bold printf "\033[1m" - if [ -n "$in_chroot" ]; then + if [ -n "$IN_CHROOT" ]; then printf "[chroot] => $@" else printf "=> $@" diff --git a/xbps-src/shutils/extract_funcs.sh b/xbps-src/shutils/extract_funcs.sh index fbd4d90067..edd314d11e 100644 --- a/xbps-src/shutils/extract_funcs.sh +++ b/xbps-src/shutils/extract_funcs.sh @@ -32,7 +32,7 @@ extract_distfiles() local pkg="$1" curfile cursufx f lver [ -f $XBPS_EXTRACT_DONE ] && return 0 - [ -z "$in_chroot" -a ! -w $XBPS_BUILDDIR ] && \ + [ -z "$IN_CHROOT" -a ! -w $XBPS_BUILDDIR ] && \ msg_error "can't extract distfile(s) (permission denied)\n" # diff --git a/xbps-src/shutils/init_funcs.sh.in b/xbps-src/shutils/init_funcs.sh.in index eaa006234e..7844addc33 100644 --- a/xbps-src/shutils/init_funcs.sh.in +++ b/xbps-src/shutils/init_funcs.sh.in @@ -36,7 +36,7 @@ set_defvars() : ${XBPS_META_PATH:=$XBPS_DBDIR/} : ${XBPS_PKGMETADIR:=$XBPS_DBDIR/metadata} : ${XBPS_SRCPKGDIR:=$XBPS_DISTRIBUTIONDIR/srcpkgs} - if [ -n "$in_chroot" ]; then + if [ -n "$IN_CHROOT" ]; then : ${XBPS_DESTDIR:=/pkg-destdir} else : ${XBPS_DESTDIR:=$XBPS_MASTERDIR/pkg-destdir} diff --git a/xbps-src/shutils/pkgtarget_funcs.sh.in b/xbps-src/shutils/pkgtarget_funcs.sh.in index fc3c1c77b5..24ad642915 100644 --- a/xbps-src/shutils/pkgtarget_funcs.sh.in +++ b/xbps-src/shutils/pkgtarget_funcs.sh.in @@ -34,11 +34,14 @@ install_pkg() # If we are being invoked through the chroot, re-read config file # to get correct stuff. # - if [ -n "$in_chroot" ]; then + if [ -n "$IN_CHROOT" ]; then check_config_vars set_defvars fi + # Remove automatic package dependencies if set. + autoremove_pkg_dependencies + pkg="$curpkgn-$version" [ -n "$INSTALLING_DEPS" ] && setup_tmpl $curpkgn # @@ -53,12 +56,15 @@ install_pkg() fi fi + # Always fetch distfiles before installing dependencies if + # template doesn't use nofetch and do_fetch(). + [ -z "$nofetch" ] && fetch_distfiles + # # Install dependencies required by this package. # if [ -z "$INSTALLING_DEPS" ]; then - install_dependencies_pkg $pkg - [ $? -eq 1 ] && return 1 + install_dependencies_pkg $pkg || return $? # # At this point all required deps are installed, and # only remaining is the origin package; install it. @@ -68,10 +74,9 @@ install_pkg() msg_normal "Installing '$pkgname'...\n" fi - # - # Fetch distfiles before checking its dependencies. - # - fetch_distfiles + # Fetch distfiles after installing required dependencies, + # because some of them might be required for do_fetch(). + [ -n "$nofetch" ] && fetch_distfiles # # Fetch, extract, build and install into the destination directory. @@ -104,18 +109,14 @@ install_pkg() env xbps_machine=${xbps_machine} MASTERDIR=${_MASTERDIR} \ wrksrc=${wrksrc} \ ${fakeroot_cmd} ${fakeroot_cmd_args} \ - @@XBPS_INSTALL_LIBEXECDIR@@/xbps-src-doinst-helper ${curpkgn} - if [ $? -ne 0 ]; then - return 1 - fi + @@XBPS_INSTALL_LIBEXECDIR@@/xbps-src-doinst-helper \ + ${curpkgn} || return $? # Strip binaries/libraries. - if [ -z "$noarch" ]; then - strip_files - fi + strip_files # Always write metadata to package's destdir. - trap 'remove_pkgdestdir_sighandler ${pkgname}' INT + trap 'remove_pkgdestdir_sighandler $pkgname $KEEP_AUTODEPS' INT xbps_write_metadata_pkg if [ $? -ne 0 ]; then msg_red "cannot write package metadata for '$pkgname'!\n" diff --git a/xbps-src/shutils/stow_funcs.sh b/xbps-src/shutils/stow_funcs.sh index 1eb99d8860..73473d2132 100644 --- a/xbps-src/shutils/stow_funcs.sh +++ b/xbps-src/shutils/stow_funcs.sh @@ -113,7 +113,7 @@ stow_pkg_real() cp -dp $i $XBPS_MASTERDIR/$lfile continue fi - if [ -n "$in_chroot" -a -n "$stow_copy_files" ]; then + if [ -n "$IN_CHROOT" -a -n "$stow_copy_files" ]; then # Templates that set stow_copy_files require # some files to be copied, rather than symlinked. local found @@ -129,7 +129,7 @@ stow_pkg_real() continue fi fi - if [ -n "$in_chroot" -a -n "$stow_copy" -o -z "$in_chroot" ]; then + if [ -n "$IN_CHROOT" -a -n "$stow_copy" -o -z "$IN_CHROOT" ]; then # In the no-chroot case and templates that # set $stow_copy, we can't stow with symlinks. # Just copy them. diff --git a/xbps-src/shutils/tmpl_funcs.sh.in b/xbps-src/shutils/tmpl_funcs.sh.in index 3b0a7f9877..b8cd315415 100644 --- a/xbps-src/shutils/tmpl_funcs.sh.in +++ b/xbps-src/shutils/tmpl_funcs.sh.in @@ -303,7 +303,7 @@ set_tmpl_common_vars() export LDFLAGS="$XBPS_LDFLAGS $LDFLAGS" fi - if [ -z "$in_chroot" ]; then + if [ -z "$IN_CHROOT" ]; then export CPPFLAGS="-I$XBPS_MASTERDIR/usr/include" if [ -d /usr/lib/libfakeroot ]; then LDLIBPATH="/usr/lib/libfakeroot:$XBPS_MASTERDIR/usr/lib" diff --git a/xbps-src/xbps-src.sh.in b/xbps-src/xbps-src.sh.in index a306d53857..37e9f174eb 100644 --- a/xbps-src/xbps-src.sh.in +++ b/xbps-src/xbps-src.sh.in @@ -39,7 +39,7 @@ REQHOST_UTILS="gawk bash sed gcc msgfmt patch makeinfo perl fakeroot tar xz" check_reqhost_utils() { - [ -n "$in_chroot" ] && return 0 + [ -n "$IN_CHROOT" ] && return 0 for f in ${REQHOST_UTILS}; do if ! command -v ${f} 2>&1 >/dev/null; then @@ -52,7 +52,7 @@ check_reqhost_utils() usage() { cat << _EOF -$progname: [-ChS] [-c ] [-m ] [-p ] [-s ] [] +$progname: [-ChKS] [-c ] [-m ] [-p ] [-s ] [] Targets: bootstrap Build and install the bootstrap packages into . @@ -91,6 +91,8 @@ Options: -c Path to global configuration file: if not specified @@XBPS_INSTALL_ETCDIR@@/xbps-src.conf is used. -h Usage output. + -K Do not remove automatic package dependencies while building + or installing a package with XBPS_PREFER_BINPKG_DEPS enabled. -m Master directory, overwritting the value set in the configuration file xbps-src.conf. -p Package directory, overwritting default path at @@ -171,11 +173,12 @@ check_config_vars() # # main() # -while getopts "Cc:hm:p:Ss:" opt; do +while getopts "Cc:hKm:p:Ss:" opt; do case $opt in C) KEEP_WRKSRC=1;; c) XBPS_CONFIG_FILE="$OPTARG";; h) usage && exit 0;; + K) KEEP_AUTODEPS=1;; m) _MASTERDIR_FLAG=1 _MASTERDIR="$OPTARG" @@ -206,7 +209,7 @@ if [ -z "$target" ]; then usage && exit 1 fi -if [ -n "$in_chroot" ]; then +if [ -n "$IN_CHROOT" ]; then XBPS_CONFIG_FILE="/usr/local/etc/xbps-src.conf" fi @@ -245,7 +248,7 @@ if [ "$(id -u)" -eq 0 ]; then # disable sudo and fakeroot if uid==0 chroot_cmd="chroot" unset sudo_cmd - if [ -n "$in_chroot" ]; then + if [ -n "$IN_CHROOT" ]; then unset fakeroot_cmd unset fakeroot_cmd_args fi @@ -254,7 +257,7 @@ fi # # Sanitize PATH. # -if [ -z "$in_chroot" ]; then +if [ -z "$IN_CHROOT" ]; then # In non chroot case always prefer host tools. MYPATH="$XBPS_MASTERDIR/bin:$XBPS_MASTERDIR/usr/bin:$PATH" MYPATH="$XBPS_MASTERDIR/usr/local/bin:$MYPATH" @@ -286,9 +289,9 @@ build|configure) _pkgname=$(basename_cwd) fi - if [ -z "$base_chroot" -a -z "$in_chroot" ]; then + if [ -z "$base_chroot" -a -z "$IN_CHROOT" ]; then . $XBPS_SHUTILSDIR/chroot.sh - xbps_chroot_handler $target ${_pkgname} + xbps_chroot_handler $target ${_pkgname} $KEEP_WRKSRC $KEEP_AUTODEPS else _ORIGINPKG="${_pkgname}" setup_tmpl ${_ORIGINPKG} @@ -372,9 +375,10 @@ install|install-destdir) [ "$target" = "install-destdir" ] && DESTDIR_ONLY_INSTALL=1 _ORIGINPKG="${_pkgname}" - if [ -z "$in_chroot" -a -z "$base_chroot" ]; then + if [ -z "$IN_CHROOT" -a -z "$base_chroot" ]; then . $XBPS_SHUTILSDIR/chroot.sh - xbps_chroot_handler $target ${_ORIGINPKG} $KEEP_WRKSRC + xbps_chroot_handler $target ${_ORIGINPKG} \ + $KEEP_WRKSRC $KEEP_AUTODEPS else setup_tmpl ${_ORIGINPKG} install_pkg $pkgname @@ -404,9 +408,10 @@ remove) _pkgname=$(basename_cwd) fi setup_tmpl ${_pkgname} - if [ -z "$in_chroot" -a -z "$base_chroot" ]; then + if [ -z "$IN_CHROOT" -a -z "$base_chroot" ]; then . $XBPS_SHUTILSDIR/chroot.sh - xbps_chroot_handler $target ${_pkgname} $KEEP_WRKSRC + xbps_chroot_handler $target ${_pkgname} \ + $KEEP_WRKSRC $KEEP_AUTODEPS else remove_pkg fi