Simplify chroot helper and fix a minor glitch in stow_pkg().

--HG--
extra : convert_revision : a84053dacf4768c9a7b8b6d2d8e4548902f8a97e
This commit is contained in:
Juan RP
2008-10-28 07:17:35 +01:00
parent 0a71559ee4
commit c50c3cab2a
2 changed files with 28 additions and 45 deletions

View File

@@ -34,12 +34,15 @@ else
echo "==> Entering into the chroot on $XBPS_MASTERDIR."
fi
for f in bin sbin tmp var sys proc dev xbps xbps_builddir xbps_destdir; do
REQDIRS="bin sbin tmp var sys proc dev xbps xbps_builddir \
xbps_destdir xbps_srcdistdir"
for f in ${REQDIRS}; do
[ ! -d $XBPS_MASTERDIR/$f ] && mkdir -p $XBPS_MASTERDIR/$f
done
unset f
unset f REQDIRS
for f in sys proc dev xbps xbps_builddir xbps_destdir; do
REQFS="sys proc dev xbps xbps_builddir xbps_destdir xbps_srcdistdir"
for f in ${REQFS}; do
if [ ! -f $XBPS_MASTERDIR/.${f}_mount_bind_done ]; then
echo -n "=> Mounting $f in chroot... "
local blah=
@@ -47,6 +50,7 @@ for f in sys proc dev xbps xbps_builddir xbps_destdir; do
xbps) blah=$XBPS_DISTRIBUTIONDIR;;
xbps_builddir) blah=$XBPS_BUILDDIR;;
xbps_destdir) blah=$XBPS_DESTDIR;;
xbps_srcdistdir) blah=$XBPS_SRCDISTDIR;;
*) blah=/$f;;
esac
mount --bind $blah $XBPS_MASTERDIR/$f
@@ -64,7 +68,7 @@ echo "XBPS_DISTRIBUTIONDIR=/xbps" > $XBPS_MASTERDIR/etc/xbps.conf
echo "XBPS_MASTERDIR=/" >> $XBPS_MASTERDIR/etc/xbps.conf
echo "XBPS_DESTDIR=/xbps_destdir" >> $XBPS_MASTERDIR/etc/xbps.conf
echo "XBPS_BUILDDIR=/xbps_builddir" >> $XBPS_MASTERDIR/etc/xbps.conf
echo "XBPS_SRCDISTDIR=/xbps/srcdistdir" >> $XBPS_MASTERDIR/etc/xbps.conf
echo "XBPS_SRCDISTDIR=/xbps_srcdistdir" >> $XBPS_MASTERDIR/etc/xbps.conf
echo "XBPS_CFLAGS=\"$XBPS_CFLAGS\"" >> $XBPS_MASTERDIR/etc/xbps.conf
echo "XBPS_CXXFLAGS=\"\$XBPS_CFLAGS\"" >> $XBPS_MASTERDIR/etc/xbps.conf
if [ -n "$XBPS_MAKEJOBS" ]; then
@@ -79,44 +83,23 @@ rebuild_ldso_cache()
echo " done."
}
configure_chroot_pkg()
chroot_pkg_handler()
{
local pkg="$1"
local action="$1"
local pkg="$2"
[ -z "$pkg" ] && return 1
[ -z "$action" -o -z "$pkg" ] && return 1
[ "$action" != "configure" -a "$action" != "build" -a \
"$action" != "install" -a "$action" != "chroot" ] && return 1
rebuild_ldso_cache
env in_chroot=yes chroot $XBPS_MASTERDIR /xbps/xbps.sh configure $pkg
echo "==> Exiting from the chroot on $XBPS_MASTERDIR."
}
build_chroot_pkg()
{
local pkg="$1"
[ -z "$pkg" ] && return 1
rebuild_ldso_cache
env in_chroot=yes chroot $XBPS_MASTERDIR /xbps/xbps.sh build $pkg
echo "==> Exiting from the chroot on $XBPS_MASTERDIR."
}
install_chroot_pkg()
{
local pkg="$1"
[ -z "$pkg" ] && return 1
rebuild_ldso_cache
env in_chroot=yes chroot $XBPS_MASTERDIR /xbps/xbps.sh install $pkg
echo "==> Exiting from the chroot on $XBPS_MASTERDIR."
umount_chroot_fs
}
enter_chroot()
{
rebuild_ldso_cache
env in_chroot=yes chroot $XBPS_MASTERDIR /bin/bash
if [ "$action" = "chroot" ]; then
env in_chroot=yes chroot $XBPS_MASTERDIR /bin/bash
else
env in_chroot=yes chroot $XBPS_MASTERDIR /xbps/xbps.sh \
$action $pkg
fi
echo "==> Exiting from the chroot on $XBPS_MASTERDIR."
umount_chroot_fs
}
@@ -126,7 +109,7 @@ umount_chroot_fs()
local fs=
local dir=
for fs in sys proc dev xbps xbps_builddir xbps_destdir; do
for fs in ${REQFS}; do
[ ! -f $XBPS_MASTERDIR/.${fs}_mount_bind_done ] && continue
echo -n "=> Unmounting $fs from chroot... "
umount -f $XBPS_MASTERDIR/$fs
@@ -139,7 +122,7 @@ umount_chroot_fs()
unset fs
done
for dir in xbps xbps_builddir xbps_destdir; do
for dir in xbps xbps_builddir xbps_destdir xbps_srcdistdir; do
[ -d $XBPS_MASTERDIR/$dir ] && rmdir $XBPS_MASTERDIR/$dir
done
}