xbps-src: multiple improvements related to chroot code.

This commit is contained in:
Juan RP 2011-07-06 14:20:27 +02:00
parent 4bc9959d3e
commit ef21557313
3 changed files with 50 additions and 59 deletions

View File

@ -1,6 +1,6 @@
#!/bin/sh #!/bin/sh
#- #-
# Copyright (c) 2010 Juan Romero Pardines. # Copyright (c) 2010-2011 Juan Romero Pardines.
# All rights reserved. # All rights reserved.
# #
# Redistribution and use in source and binary forms, with or without # Redistribution and use in source and binary forms, with or without
@ -36,9 +36,9 @@ fi
set_defvars set_defvars
. $XBPS_SHUTILSDIR/tmpl_funcs.sh for f in $(echo $XBPS_SHUTILSDIR/*.sh); do
. $XBPS_SHUTILSDIR/common_funcs.sh [ -r "$f" ] && . $f
. $XBPS_SHUTILSDIR/builddep_funcs.sh done
install_src_phase() install_src_phase()
{ {

View File

@ -23,12 +23,6 @@
# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#- #-
#
# Script to install packages into a sandbox in masterdir.
# Actually this needs the xbps-base-chroot package installed.
#
trap "_umount && return $?" 0 INT QUIT TERM
_mount() _mount()
{ {
MASTERDIR="${XBPS_MASTERDIR}" CACHEDIR="${XBPS_CACHEDIR}" \ MASTERDIR="${XBPS_MASTERDIR}" CACHEDIR="${XBPS_CACHEDIR}" \
@ -45,31 +39,34 @@ _umount()
return $? return $?
} }
[ -n "$bootstrap" ] && return 0 chroot_init()
{
trap "_umount && return $?" 0 INT QUIT TERM
if [ "${chroot_cmd}" = "chroot" ]; then [ -n "$bootstrap" ] && return 0
if [ "$(id -u)" -ne 0 ]; then
echo "Root permissions are required for the chroot, try again." if [ "${chroot_cmd}" = "chroot" ]; then
if [ "$(id -u)" -ne 0 ]; then
msg_error "Root permissions are required for the chroot, try again."
fi
fi
check_installed_pkg base-chroot-0.11
if [ $? -ne 0 ]; then
echo "${XBPS_MASTERDIR} has not been prepared for chroot operations."
echo "Please install 'base-chroot>=0.11' and try again."
exit 1 exit 1
fi fi
fi
check_installed_pkg base-chroot-0.11 msg_normal "Entering into the chroot on $XBPS_MASTERDIR.\n"
if [ $? -ne 0 ]; then
echo "${XBPS_MASTERDIR} has not been prepared for chroot operations."
echo "Please install 'base-chroot>=0.11' and try again."
exit 1
fi
msg_normal "Entering into the chroot on $XBPS_MASTERDIR.\n" if [ ! -d $XBPS_MASTERDIR/usr/local/etc ]; then
mkdir -p $XBPS_MASTERDIR/usr/local/etc
fi
if [ ! -d $XBPS_MASTERDIR/usr/local/etc ]; then XBPSSRC_CF=$XBPS_MASTERDIR/usr/local/etc/xbps-src.conf
mkdir -p $XBPS_MASTERDIR/usr/local/etc
fi
XBPSSRC_CF=$XBPS_MASTERDIR/usr/local/etc/xbps-src.conf cat > $XBPSSRC_CF <<_EOF
cat > $XBPSSRC_CF <<_EOF
# Generated configuration file by xbps-src, DO NOT EDIT! # Generated configuration file by xbps-src, DO NOT EDIT!
XBPS_DISTRIBUTIONDIR=/xbps XBPS_DISTRIBUTIONDIR=/xbps
XBPS_MASTERDIR=/ XBPS_MASTERDIR=/
@ -80,27 +77,28 @@ XBPS_FETCH_CMD="xbps-uhelper.static fetch"
XBPS_COMPRESS_CMD="$XBPS_COMPRESS_CMD" XBPS_COMPRESS_CMD="$XBPS_COMPRESS_CMD"
_EOF _EOF
if [ -n "$XBPS_MAKEJOBS" ]; then if [ -n "$XBPS_MAKEJOBS" ]; then
echo "XBPS_MAKEJOBS=$XBPS_MAKEJOBS" >> $XBPSSRC_CF 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
if [ -n "$XBPS_COMPRESS_LEVEL" ]; then
echo "XBPS_COMPRESS_LEVEL=$XBPS_COMPRESS_LEVEL" >> $XBPSSRC_CF
fi
if [ -n "$XBPS_CACHEDIR" ]; then
echo "XBPS_CACHEDIR=/cachedir" >> $XBPSSRC_CF
fi
echo "# End of configuration file." >> $XBPSSRC_CF
if [ -d $XBPS_MASTERDIR/tmp ]; then
if [ ! -f $XBPS_MASTERDIR/.xbps_mount_bind_done ]; then
msg_normal "Cleaning up /tmp...\n"
[ -h ${XBPS_MASTERDIR}/tmp ] || rm -rf $XBPS_MASTERDIR/tmp/*
fi fi
fi if [ -n "$XBPS_PREFER_BINPKG_DEPS" ]; then
echo "XBPS_PREFER_BINPKG_DEPS=$XBPS_PREFER_BINPKG_DEPS" >> $XBPSSRC_CF
fi
if [ -n "$XBPS_COMPRESS_LEVEL" ]; then
echo "XBPS_COMPRESS_LEVEL=$XBPS_COMPRESS_LEVEL" >> $XBPSSRC_CF
fi
if [ -n "$XBPS_CACHEDIR" ]; then
echo "XBPS_CACHEDIR=/cachedir" >> $XBPSSRC_CF
fi
echo "# End of configuration file." >> $XBPSSRC_CF
if [ -d $XBPS_MASTERDIR/tmp ]; then
if [ ! -f $XBPS_MASTERDIR/.xbps_mount_bind_done ]; then
msg_normal "Cleaning up /tmp...\n"
[ -h ${XBPS_MASTERDIR}/tmp ] || rm -rf $XBPS_MASTERDIR/tmp/*
fi
fi
}
prepare_chroot() prepare_chroot()
{ {
@ -277,7 +275,7 @@ xbps_chroot_handler()
[ "$action" != "configure" -a "$action" != "build" -a \ [ "$action" != "configure" -a "$action" != "build" -a \
"$action" != "install" -a "$action" != "chroot" -a \ "$action" != "install" -a "$action" != "chroot" -a \
"$action" != "install-destdir" -a "$action" != "remove" ] && return 1 "$action" != "remove" ] && return 1
if [ ! -f $XBPS_MASTERDIR/.xbps_perms_done ]; then if [ ! -f $XBPS_MASTERDIR/.xbps_perms_done ]; then
echo -n "==> Preparing chroot on $XBPS_MASTERDIR... " echo -n "==> Preparing chroot on $XBPS_MASTERDIR... "
@ -285,10 +283,9 @@ xbps_chroot_handler()
echo "done." echo "done."
fi fi
if [ ! -d "$XBPS_MASTERDIR/tmp" ]; then [ ! -d "$XBPS_MASTERDIR/tmp" ] && mkdir -p "$XBPS_MASTERDIR/tmp"
mkdir -p "$XBPS_MASTERDIR/tmp"
fi
chroot_init
create_binsh_symlink create_binsh_symlink
create_busybox_links create_busybox_links
install_xbps_utils install_xbps_utils

View File

@ -266,9 +266,7 @@ fi
. @@XBPS_INSTALL_SHAREDIR@@/shutils/init_funcs.sh . @@XBPS_INSTALL_SHAREDIR@@/shutils/init_funcs.sh
set_defvars set_defvars
for f in $(echo @@XBPS_INSTALL_SHAREDIR@@/shutils/*.sh); do for f in $(echo @@XBPS_INSTALL_SHAREDIR@@/shutils/*.sh); do
if [ -r "$f" -a "$(basename $f)" != "chroot.sh" ]; then [ -r "$f" ] && . $f
. $f
fi
done done
# Disable XBPS_PREFER_BINPKG_DEPS if requested. # Disable XBPS_PREFER_BINPKG_DEPS if requested.
@ -343,7 +341,6 @@ build|configure)
fi fi
if [ -z "$bootstrap" -a -z "$IN_CHROOT" ]; then if [ -z "$bootstrap" -a -z "$IN_CHROOT" ]; then
. $XBPS_SHUTILSDIR/chroot.sh
xbps_chroot_handler $target ${_pkgname} xbps_chroot_handler $target ${_pkgname}
else else
_ORIGINPKG="${_pkgname}" _ORIGINPKG="${_pkgname}"
@ -395,7 +392,6 @@ checkvers)
check_installed_packages check_installed_packages
;; ;;
chroot) chroot)
. $XBPS_SHUTILSDIR/chroot.sh
xbps_chroot_handler chroot dummy xbps_chroot_handler chroot dummy
;; ;;
clean) clean)
@ -427,7 +423,6 @@ install)
setup_tmpl ${_pkgname} setup_tmpl ${_pkgname}
_ORIGINPKG="${_pkgname}" _ORIGINPKG="${_pkgname}"
if [ -z "$IN_CHROOT" -a -z "$bootstrap" ]; then if [ -z "$IN_CHROOT" -a -z "$bootstrap" ]; then
. $XBPS_SHUTILSDIR/chroot.sh
xbps_chroot_handler $target ${_ORIGINPKG} xbps_chroot_handler $target ${_ORIGINPKG}
else else
setup_tmpl ${_ORIGINPKG} setup_tmpl ${_ORIGINPKG}
@ -459,7 +454,6 @@ remove)
fi fi
setup_tmpl ${_pkgname} setup_tmpl ${_pkgname}
if [ -z "$IN_CHROOT" -a -z "$bootstrap" ]; then if [ -z "$IN_CHROOT" -a -z "$bootstrap" ]; then
. $XBPS_SHUTILSDIR/chroot.sh
xbps_chroot_handler $target ${_pkgname} xbps_chroot_handler $target ${_pkgname}
else else
remove_pkg remove_pkg