xbps-src: added -K flag to KEEP automatic installed deps, cleanups.

This commit is contained in:
Juan RP 2011-07-04 19:07:08 +02:00
parent 16b5107f61
commit 9b52e244c6
9 changed files with 57 additions and 42 deletions

View file

@ -48,6 +48,7 @@ install_pkglist_from_repos()
# ENODEV (19): package depends on missing dependencies. # ENODEV (19): package depends on missing dependencies.
# #
# Any other returned is criticial. # Any other returned is criticial.
autoremove_pkg_dependencies
msg_red "'${pkgname}': failed to install required dependencies! (error $rval)\n" msg_red "'${pkgname}': failed to install required dependencies! (error $rval)\n"
msg_error "'${pkgname}': please take a look the logs in \$wrksrc.\n" msg_error "'${pkgname}': please take a look the logs in \$wrksrc.\n"
fi fi
@ -81,6 +82,7 @@ install_pkg_from_repos()
# ENODEV (19): package depends on missing dependencies. # ENODEV (19): package depends on missing dependencies.
# #
# Any other returned is criticial. # Any other returned is criticial.
autoremove_pkg_dependencies
msg_red "'${pkgname}': failed to install '${pkg}' dependency! (error $rval)\n" 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" msg_error "Please see ${wrksrc}/.xbps_install_${pkgdepname}.log to see what went wrong!\n"
fi fi
@ -92,6 +94,8 @@ autoremove_pkg_dependencies()
{ {
local cmd saved_pkgname x f found local cmd saved_pkgname x f found
[ -n "$KEEP_AUTODEPS" ] && return 0
cmd="${fakeroot_cmd} ${fakeroot_cmd_args} ${XBPS_BIN_CMD}" cmd="${fakeroot_cmd} ${fakeroot_cmd_args} ${XBPS_BIN_CMD}"
# If XBPS_PREFER_BINPKG_DEPS is set, we should remove those # If XBPS_PREFER_BINPKG_DEPS is set, we should remove those
@ -272,6 +276,8 @@ install_dependencies_pkg()
fi fi
done done
[ -z "$notinstalled_deps" ] && return 0
# Install direct build dependencies from binary packages. # Install direct build dependencies from binary packages.
if [ -n "$XBPS_PREFER_BINPKG_DEPS" -a -z "$base_chroot" ]; then if [ -n "$XBPS_PREFER_BINPKG_DEPS" -a -z "$base_chroot" ]; then
msg_normal "'$pkg': installing dependencies from repositories ...\n" msg_normal "'$pkg': installing dependencies from repositories ...\n"

View file

@ -271,8 +271,7 @@ install_xbps_utils()
xbps_chroot_handler() xbps_chroot_handler()
{ {
local action="$1" pkg="$2" keep_wrksrc="$3" rv=0 local action="$1" pkg="$2" rv=0 arg
local path="/tools/bin:/usr/local/sbin:/usr/local/bin:/bin:/sbin:/usr/bin:/usr/sbin"
[ -z "$action" -o -z "$pkg" ] && return 1 [ -z "$action" -o -z "$pkg" ] && return 1
@ -302,7 +301,7 @@ xbps_chroot_handler()
# Reinstall xbps-src in the chroot # Reinstall xbps-src in the chroot
msg_normal "Installing xbps-src in the masterdir...\n" 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 \ ${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 || return $? 2>&1 >/dev/null || return $?
@ -312,11 +311,13 @@ xbps_chroot_handler()
${chroot_cmd} $XBPS_MASTERDIR sh -c "ldconfig" || return $? ${chroot_cmd} $XBPS_MASTERDIR sh -c "ldconfig" || return $?
if [ "$action" = "chroot" ]; then 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=$? ${chroot_cmd} $XBPS_MASTERDIR /bin/sh || rv=$?
else else
[ -n "$keep_wrksrc" ] && action="-C $action" [ -n "$3" ] && arg="-C"
env in_chroot=yes LANG=C PATH=$path _ORIGINPKG="$pkg" \ [ -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 \ ${chroot_cmd} $XBPS_MASTERDIR sh -c \
"cd /xbps/srcpkgs/$pkg && xbps-src $action" || rv=$? "cd /xbps/srcpkgs/$pkg && xbps-src $action" || rv=$?
fi fi

View file

@ -70,6 +70,9 @@ remove_pkgdestdir_sighandler()
rm -rf "$XBPS_DESTDIR/${sourcepkg}-${version%_*}" rm -rf "$XBPS_DESTDIR/${sourcepkg}-${version%_*}"
msg_red "'${sourcepkg}-${lver}': removed files from DESTDIR...\n" msg_red "'${sourcepkg}-${lver}': removed files from DESTDIR...\n"
fi fi
[ -n "$2" ] && KEEP_AUTODEPS=1
autoremove_pkg_dependencies
} }
var_is_a_function() var_is_a_function()
@ -130,7 +133,7 @@ msg_red()
{ {
# error messages in bold/red # error messages in bold/red
printf >&2 "\033[1m\033[31m" printf >&2 "\033[1m\033[31m"
if [ -n "$in_chroot" ]; then if [ -n "$IN_CHROOT" ]; then
printf >&2 "[chroot] => ERROR: $@" printf >&2 "[chroot] => ERROR: $@"
else else
printf >&2 "=> ERROR: $@" printf >&2 "=> ERROR: $@"
@ -141,7 +144,6 @@ msg_red()
msg_error() msg_error()
{ {
msg_red "$@" msg_red "$@"
autoremove_pkg_dependencies
exit 1 exit 1
} }
@ -157,7 +159,7 @@ msg_warn()
{ {
# warn messages in bold/yellow # warn messages in bold/yellow
printf >&2 "\033[1m\033[33m" printf >&2 "\033[1m\033[33m"
if [ -n "$in_chroot" ]; then if [ -n "$IN_CHROOT" ]; then
printf >&2 "[chroot] => WARNING: $@" printf >&2 "[chroot] => WARNING: $@"
else else
printf >&2 "=> WARNING: $@" printf >&2 "=> WARNING: $@"
@ -174,7 +176,7 @@ msg_normal()
{ {
# normal messages in bold # normal messages in bold
printf "\033[1m" printf "\033[1m"
if [ -n "$in_chroot" ]; then if [ -n "$IN_CHROOT" ]; then
printf "[chroot] => $@" printf "[chroot] => $@"
else else
printf "=> $@" printf "=> $@"

View file

@ -32,7 +32,7 @@ extract_distfiles()
local pkg="$1" curfile cursufx f lver local pkg="$1" curfile cursufx f lver
[ -f $XBPS_EXTRACT_DONE ] && return 0 [ -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" msg_error "can't extract distfile(s) (permission denied)\n"
# #

View file

@ -36,7 +36,7 @@ set_defvars()
: ${XBPS_META_PATH:=$XBPS_DBDIR/} : ${XBPS_META_PATH:=$XBPS_DBDIR/}
: ${XBPS_PKGMETADIR:=$XBPS_DBDIR/metadata} : ${XBPS_PKGMETADIR:=$XBPS_DBDIR/metadata}
: ${XBPS_SRCPKGDIR:=$XBPS_DISTRIBUTIONDIR/srcpkgs} : ${XBPS_SRCPKGDIR:=$XBPS_DISTRIBUTIONDIR/srcpkgs}
if [ -n "$in_chroot" ]; then if [ -n "$IN_CHROOT" ]; then
: ${XBPS_DESTDIR:=/pkg-destdir} : ${XBPS_DESTDIR:=/pkg-destdir}
else else
: ${XBPS_DESTDIR:=$XBPS_MASTERDIR/pkg-destdir} : ${XBPS_DESTDIR:=$XBPS_MASTERDIR/pkg-destdir}

View file

@ -34,11 +34,14 @@ install_pkg()
# If we are being invoked through the chroot, re-read config file # If we are being invoked through the chroot, re-read config file
# to get correct stuff. # to get correct stuff.
# #
if [ -n "$in_chroot" ]; then if [ -n "$IN_CHROOT" ]; then
check_config_vars check_config_vars
set_defvars set_defvars
fi fi
# Remove automatic package dependencies if set.
autoremove_pkg_dependencies
pkg="$curpkgn-$version" pkg="$curpkgn-$version"
[ -n "$INSTALLING_DEPS" ] && setup_tmpl $curpkgn [ -n "$INSTALLING_DEPS" ] && setup_tmpl $curpkgn
# #
@ -53,12 +56,15 @@ install_pkg()
fi fi
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. # Install dependencies required by this package.
# #
if [ -z "$INSTALLING_DEPS" ]; then if [ -z "$INSTALLING_DEPS" ]; then
install_dependencies_pkg $pkg install_dependencies_pkg $pkg || return $?
[ $? -eq 1 ] && return 1
# #
# At this point all required deps are installed, and # At this point all required deps are installed, and
# only remaining is the origin package; install it. # only remaining is the origin package; install it.
@ -68,10 +74,9 @@ install_pkg()
msg_normal "Installing '$pkgname'...\n" msg_normal "Installing '$pkgname'...\n"
fi fi
# # Fetch distfiles after installing required dependencies,
# Fetch distfiles before checking its dependencies. # because some of them might be required for do_fetch().
# [ -n "$nofetch" ] && fetch_distfiles
fetch_distfiles
# #
# Fetch, extract, build and install into the destination directory. # Fetch, extract, build and install into the destination directory.
@ -104,18 +109,14 @@ install_pkg()
env xbps_machine=${xbps_machine} MASTERDIR=${_MASTERDIR} \ env xbps_machine=${xbps_machine} MASTERDIR=${_MASTERDIR} \
wrksrc=${wrksrc} \ wrksrc=${wrksrc} \
${fakeroot_cmd} ${fakeroot_cmd_args} \ ${fakeroot_cmd} ${fakeroot_cmd_args} \
@@XBPS_INSTALL_LIBEXECDIR@@/xbps-src-doinst-helper ${curpkgn} @@XBPS_INSTALL_LIBEXECDIR@@/xbps-src-doinst-helper \
if [ $? -ne 0 ]; then ${curpkgn} || return $?
return 1
fi
# Strip binaries/libraries. # Strip binaries/libraries.
if [ -z "$noarch" ]; then strip_files
strip_files
fi
# Always write metadata to package's destdir. # 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 xbps_write_metadata_pkg
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
msg_red "cannot write package metadata for '$pkgname'!\n" msg_red "cannot write package metadata for '$pkgname'!\n"

View file

@ -113,7 +113,7 @@ stow_pkg_real()
cp -dp $i $XBPS_MASTERDIR/$lfile cp -dp $i $XBPS_MASTERDIR/$lfile
continue continue
fi 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 # Templates that set stow_copy_files require
# some files to be copied, rather than symlinked. # some files to be copied, rather than symlinked.
local found local found
@ -129,7 +129,7 @@ stow_pkg_real()
continue continue
fi fi
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 # In the no-chroot case and templates that
# set $stow_copy, we can't stow with symlinks. # set $stow_copy, we can't stow with symlinks.
# Just copy them. # Just copy them.

View file

@ -303,7 +303,7 @@ set_tmpl_common_vars()
export LDFLAGS="$XBPS_LDFLAGS $LDFLAGS" export LDFLAGS="$XBPS_LDFLAGS $LDFLAGS"
fi fi
if [ -z "$in_chroot" ]; then if [ -z "$IN_CHROOT" ]; then
export CPPFLAGS="-I$XBPS_MASTERDIR/usr/include" export CPPFLAGS="-I$XBPS_MASTERDIR/usr/include"
if [ -d /usr/lib/libfakeroot ]; then if [ -d /usr/lib/libfakeroot ]; then
LDLIBPATH="/usr/lib/libfakeroot:$XBPS_MASTERDIR/usr/lib" LDLIBPATH="/usr/lib/libfakeroot:$XBPS_MASTERDIR/usr/lib"

View file

@ -39,7 +39,7 @@ REQHOST_UTILS="gawk bash sed gcc msgfmt patch makeinfo perl fakeroot tar xz"
check_reqhost_utils() check_reqhost_utils()
{ {
[ -n "$in_chroot" ] && return 0 [ -n "$IN_CHROOT" ] && return 0
for f in ${REQHOST_UTILS}; do for f in ${REQHOST_UTILS}; do
if ! command -v ${f} 2>&1 >/dev/null; then if ! command -v ${f} 2>&1 >/dev/null; then
@ -52,7 +52,7 @@ check_reqhost_utils()
usage() usage()
{ {
cat << _EOF cat << _EOF
$progname: [-ChS] [-c <file>] [-m <dir>] [-p <dir>] [-s <dir>] <target> [<pkgname>] $progname: [-ChKS] [-c <file>] [-m <dir>] [-p <dir>] [-s <dir>] <target> [<pkgname>]
Targets: Targets:
bootstrap Build and install the bootstrap packages into <masterdir>. bootstrap Build and install the bootstrap packages into <masterdir>.
@ -91,6 +91,8 @@ Options:
-c Path to global configuration file: -c Path to global configuration file:
if not specified @@XBPS_INSTALL_ETCDIR@@/xbps-src.conf is used. if not specified @@XBPS_INSTALL_ETCDIR@@/xbps-src.conf is used.
-h Usage output. -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 -m Master directory, overwritting the value set in the configuration
file xbps-src.conf. file xbps-src.conf.
-p Package directory, overwritting default path at -p Package directory, overwritting default path at
@ -171,11 +173,12 @@ check_config_vars()
# #
# main() # main()
# #
while getopts "Cc:hm:p:Ss:" opt; do while getopts "Cc:hKm:p:Ss:" opt; do
case $opt in case $opt in
C) KEEP_WRKSRC=1;; C) KEEP_WRKSRC=1;;
c) XBPS_CONFIG_FILE="$OPTARG";; c) XBPS_CONFIG_FILE="$OPTARG";;
h) usage && exit 0;; h) usage && exit 0;;
K) KEEP_AUTODEPS=1;;
m) m)
_MASTERDIR_FLAG=1 _MASTERDIR_FLAG=1
_MASTERDIR="$OPTARG" _MASTERDIR="$OPTARG"
@ -206,7 +209,7 @@ if [ -z "$target" ]; then
usage && exit 1 usage && exit 1
fi fi
if [ -n "$in_chroot" ]; then if [ -n "$IN_CHROOT" ]; then
XBPS_CONFIG_FILE="/usr/local/etc/xbps-src.conf" XBPS_CONFIG_FILE="/usr/local/etc/xbps-src.conf"
fi fi
@ -245,7 +248,7 @@ if [ "$(id -u)" -eq 0 ]; then
# disable sudo and fakeroot if uid==0 # disable sudo and fakeroot if uid==0
chroot_cmd="chroot" chroot_cmd="chroot"
unset sudo_cmd unset sudo_cmd
if [ -n "$in_chroot" ]; then if [ -n "$IN_CHROOT" ]; then
unset fakeroot_cmd unset fakeroot_cmd
unset fakeroot_cmd_args unset fakeroot_cmd_args
fi fi
@ -254,7 +257,7 @@ fi
# #
# Sanitize PATH. # Sanitize PATH.
# #
if [ -z "$in_chroot" ]; then if [ -z "$IN_CHROOT" ]; then
# In non chroot case always prefer host tools. # In non chroot case always prefer host tools.
MYPATH="$XBPS_MASTERDIR/bin:$XBPS_MASTERDIR/usr/bin:$PATH" MYPATH="$XBPS_MASTERDIR/bin:$XBPS_MASTERDIR/usr/bin:$PATH"
MYPATH="$XBPS_MASTERDIR/usr/local/bin:$MYPATH" MYPATH="$XBPS_MASTERDIR/usr/local/bin:$MYPATH"
@ -286,9 +289,9 @@ build|configure)
_pkgname=$(basename_cwd) _pkgname=$(basename_cwd)
fi fi
if [ -z "$base_chroot" -a -z "$in_chroot" ]; then if [ -z "$base_chroot" -a -z "$IN_CHROOT" ]; then
. $XBPS_SHUTILSDIR/chroot.sh . $XBPS_SHUTILSDIR/chroot.sh
xbps_chroot_handler $target ${_pkgname} xbps_chroot_handler $target ${_pkgname} $KEEP_WRKSRC $KEEP_AUTODEPS
else else
_ORIGINPKG="${_pkgname}" _ORIGINPKG="${_pkgname}"
setup_tmpl ${_ORIGINPKG} setup_tmpl ${_ORIGINPKG}
@ -372,9 +375,10 @@ install|install-destdir)
[ "$target" = "install-destdir" ] && DESTDIR_ONLY_INSTALL=1 [ "$target" = "install-destdir" ] && DESTDIR_ONLY_INSTALL=1
_ORIGINPKG="${_pkgname}" _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_SHUTILSDIR/chroot.sh
xbps_chroot_handler $target ${_ORIGINPKG} $KEEP_WRKSRC xbps_chroot_handler $target ${_ORIGINPKG} \
$KEEP_WRKSRC $KEEP_AUTODEPS
else else
setup_tmpl ${_ORIGINPKG} setup_tmpl ${_ORIGINPKG}
install_pkg $pkgname install_pkg $pkgname
@ -404,9 +408,10 @@ remove)
_pkgname=$(basename_cwd) _pkgname=$(basename_cwd)
fi fi
setup_tmpl ${_pkgname} 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_SHUTILSDIR/chroot.sh
xbps_chroot_handler $target ${_pkgname} $KEEP_WRKSRC xbps_chroot_handler $target ${_pkgname} \
$KEEP_WRKSRC $KEEP_AUTODEPS
else else
remove_pkg remove_pkg
fi fi