install-chroot.sh: remove specific tmpl stuff and misc cosmetics.

--HG--
extra : convert_revision : 9437554e4066a6d29729ba8947301df5c58d8a05
This commit is contained in:
Juan RP 2008-10-24 02:05:48 +02:00
parent 86184903d4
commit f9e72536ee
1 changed files with 42 additions and 28 deletions

View File

@ -17,11 +17,7 @@ if [ "$(id -u)" -ne 0 ]; then
exit 1 exit 1
fi fi
echo -n "=> Preparing sandbox on $XBPS_MASTERDIR... " echo "==> Preparing chroot on $XBPS_MASTERDIR... "
if [ ! -x $XBPS_MASTERDIR/bin/sh ]; then
cd $XBPS_MASTERDIR/bin && ln -s bash sh
fi
if [ ! -f $XBPS_MASTERDIR/.xbps_perms_done ]; then if [ ! -f $XBPS_MASTERDIR/.xbps_perms_done ]; then
chown -R root:root $XBPS_MASTERDIR/* chown -R root:root $XBPS_MASTERDIR/*
@ -30,31 +26,38 @@ if [ ! -f $XBPS_MASTERDIR/.xbps_perms_done ]; then
touch $XBPS_MASTERDIR/.xbps_perms_done touch $XBPS_MASTERDIR/.xbps_perms_done
fi fi
if [ ! -h $XBPS_MASTERDIR/usr/bin/cc ]; then
cd $XBPS_MASTERDIR/usr/bin && ln -s gcc cc
fi
for f in bin sbin tmp var sys proc dev xbps; do for f in bin sbin tmp var sys proc dev xbps; do
[ ! -d $XBPS_MASTERDIR/$f ] && mkdir -p $XBPS_MASTERDIR/$f [ ! -d $XBPS_MASTERDIR/$f ] && mkdir -p $XBPS_MASTERDIR/$f
done done
for f in sys proc dev; do for f in sys proc dev xbps; do
if [ ! -f $XBPS_MASTERDIR/.${f}_mount_bind_done ]; then if [ ! -f $XBPS_MASTERDIR/.${f}_mount_bind_done ]; then
mount -o bind /$f $XBPS_MASTERDIR/$f echo -n "=> Mounting $f in chroot... "
[ $? -eq 0 ] && touch $XBPS_MASTERDIR/.${f}_mount_bind_done if [ "$f" = "xbps" ]; then
mount -o bind $XBPS_DISTRIBUTIONDIR $XBPS_MASTERDIR/$f
else
mount -o bind /$f $XBPS_MASTERDIR/$f
fi
if [ $? -eq 0 ]; then
touch $XBPS_MASTERDIR/.${f}_mount_bind_done
echo "done."
else
echo "failed."
fi
fi fi
done done
if [ ! -f $XBPS_MASTERDIR/.xbps_mount_bind_done ]; then
mount -o bind $XBPS_DISTRIBUTIONDIR $XBPS_MASTERDIR/xbps
[ $? -eq 0 ] && touch $XBPS_MASTERDIR/.xbps_mount_bind_done
fi
if [ ! -f $XBPS_MASTERDIR/.xbps_builddir_mount_bind_done ]; then if [ ! -f $XBPS_MASTERDIR/.xbps_builddir_mount_bind_done ]; then
[ ! -d $XBPS_MASTERDIR/xbps-builddir ] && mkdir -p \ [ ! -d $XBPS_MASTERDIR/xbps-builddir ] && mkdir -p \
$XBPS_MASTERDIR/xbps-builddir $XBPS_MASTERDIR/xbps-builddir
echo -n "=> Mounting xbps-builddir in chroot... "
mount -o bind $XBPS_BUILDDIR $XBPS_MASTERDIR/xbps-builddir mount -o bind $XBPS_BUILDDIR $XBPS_MASTERDIR/xbps-builddir
[ $? -eq 0 ] && touch $XBPS_MASTERDIR/.xbps_builddir_mount_bind_done if [ $? -eq 0 ]; then
touch $XBPS_MASTERDIR/.xbps_builddir_mount_bind_done
echo "done."
else
echo "failed."
fi
fi fi
echo "XBPS_DISTRIBUTIONDIR=/xbps" > $XBPS_MASTERDIR/etc/xbps.conf echo "XBPS_DISTRIBUTIONDIR=/xbps" > $XBPS_MASTERDIR/etc/xbps.conf
@ -65,15 +68,13 @@ echo "XBPS_SRCDISTDIR=/xbps/srcdistdir" >> $XBPS_MASTERDIR/etc/xbps.conf
echo "XBPS_CFLAGS=\"$XBPS_CFLAGS\"" >> $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 echo "XBPS_CXXFLAGS=\"\$XBPS_CFLAGS\"" >> $XBPS_MASTERDIR/etc/xbps.conf
echo "done."
install_chroot_pkg() install_chroot_pkg()
{ {
local pkg="$1" local pkg="$1"
[ -z "$pkg" ] && return 1 [ -z "$pkg" ] && return 1
echo -n "=> Rebuilding dynamic linker's cache..." echo -n "==> Rebuilding chroot's dynamic linker cache..."
chroot $XBPS_MASTERDIR /sbin/ldconfig -c /etc/ld.so.conf chroot $XBPS_MASTERDIR /sbin/ldconfig -c /etc/ld.so.conf
chroot $XBPS_MASTERDIR /sbin/ldconfig -C /etc/ld.so.cache chroot $XBPS_MASTERDIR /sbin/ldconfig -C /etc/ld.so.cache
echo " done." echo " done."
@ -84,13 +85,26 @@ install_chroot_pkg()
umount_chroot_fs() umount_chroot_fs()
{ {
for f in sys proc dev xbps xbps-builddir; do for f in sys proc dev xbps; do
umount $XBPS_MASTERDIR/$f [ ! -f $XBPS_MASTERDIR/.${f}_mount_bind_done ] && continue
echo -n "=> Unmounting $f from chroot... "
umount -f $XBPS_MASTERDIR/$f
if [ $? -eq 0 ]; then
rm -f $XBPS_MASTERDIR/.${f}_mount_bind_done
echo "done."
else
echo "failed."
fi
done done
rm -f $XBPS_MASTERDIR/.xbps_builddir_mount_bind_done if [ -f $XBPS_MASTERDIR/.xbps_builddir_mount_bind_done ]; then
rm -f $XBPS_MASTERDIR/.xbps_mount_bind_done echo -n "=> Unmounting xbps-builddir from chroot... "
rm -f $XBPS_MASTERDIR/.sys_mount_bind_done umount -f $XBPS_MASTERDIR/xbps-builddir
rm -f $XBPS_MASTERDIR/.dev_mount_bind_done if [ $? -eq 0 ]; then
rm -f $XBPS_MASTERDIR/.proc_mount_bind_done rm -f $XBPS_MASTERDIR/.xbps_builddir_mount_bind_done
echo "done."
else
echo "failed."
fi
fi
} }