2008-10-23 17:14:00 +02:00
|
|
|
#
|
|
|
|
# Helper to install packages into a sandbox in masterdir.
|
|
|
|
# Actually this needs the xbps-base-chroot package installed.
|
|
|
|
#
|
|
|
|
|
|
|
|
# Umount stuff if SIGINT or SIGQUIT was caught
|
|
|
|
trap umount_chroot_fs INT QUIT
|
|
|
|
|
|
|
|
check_installed_pkg xbps-base-chroot 0.1
|
|
|
|
if [ $? -ne 0 ]; then
|
|
|
|
echo "*** ERROR: xbps-base-chroot pkg not installed ***"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ "$(id -u)" -ne 0 ]; then
|
|
|
|
echo "*** ERROR: you must be root to use this target ***"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2008-10-24 02:05:48 +02:00
|
|
|
echo "==> Preparing chroot on $XBPS_MASTERDIR... "
|
2008-10-23 17:14:00 +02:00
|
|
|
|
|
|
|
if [ ! -f $XBPS_MASTERDIR/.xbps_perms_done ]; then
|
|
|
|
chown -R root:root $XBPS_MASTERDIR/*
|
|
|
|
chmod +s $XBPS_MASTERDIR/usr/libexec/pt_chown
|
|
|
|
cp -af /etc/passwd /etc/shadow /etc/group /etc/hosts $XBPS_MASTERDIR/etc
|
|
|
|
touch $XBPS_MASTERDIR/.xbps_perms_done
|
|
|
|
fi
|
|
|
|
|
|
|
|
for f in bin sbin tmp var sys proc dev xbps; do
|
|
|
|
[ ! -d $XBPS_MASTERDIR/$f ] && mkdir -p $XBPS_MASTERDIR/$f
|
|
|
|
done
|
|
|
|
|
2008-10-24 02:05:48 +02:00
|
|
|
for f in sys proc dev xbps; do
|
2008-10-23 17:14:00 +02:00
|
|
|
if [ ! -f $XBPS_MASTERDIR/.${f}_mount_bind_done ]; then
|
2008-10-24 02:05:48 +02:00
|
|
|
echo -n "=> Mounting $f in chroot... "
|
|
|
|
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
|
2008-10-23 17:14:00 +02:00
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
|
|
|
if [ ! -f $XBPS_MASTERDIR/.xbps_builddir_mount_bind_done ]; then
|
2008-10-24 04:25:31 +02:00
|
|
|
[ ! -d $XBPS_MASTERDIR/xbps_builddir ] && mkdir -p \
|
|
|
|
$XBPS_MASTERDIR/xbps_builddir
|
|
|
|
echo -n "=> Mounting builddir in chroot... "
|
|
|
|
mount -o bind $XBPS_BUILDDIR $XBPS_MASTERDIR/xbps_builddir
|
2008-10-24 02:05:48 +02:00
|
|
|
if [ $? -eq 0 ]; then
|
|
|
|
touch $XBPS_MASTERDIR/.xbps_builddir_mount_bind_done
|
|
|
|
echo "done."
|
|
|
|
else
|
|
|
|
echo "failed."
|
|
|
|
fi
|
2008-10-23 17:14:00 +02:00
|
|
|
fi
|
|
|
|
|
2008-10-24 04:25:31 +02:00
|
|
|
if [ ! -f $XBPS_MASTERDIR/.xbps_destdir_mount_bind_done ]; then
|
|
|
|
[ ! -d $XBPS_MASTERDIR/xbps_destdir ] && mkdir -p \
|
|
|
|
$XBPS_MASTERDIR/xbps_destdir
|
|
|
|
echo -n "=> Mounting destdir in chroot... "
|
|
|
|
mount -o bind $XBPS_DESTDIR $XBPS_MASTERDIR/xbps_destdir
|
|
|
|
if [ $? -eq 0 ]; then
|
|
|
|
touch $XPS_MASTERDIR/.xbps_destdir_mount_bind_done
|
|
|
|
echo "done."
|
|
|
|
else
|
|
|
|
echo "failed."
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
2008-10-23 17:14:00 +02:00
|
|
|
echo "XBPS_DISTRIBUTIONDIR=/xbps" > $XBPS_MASTERDIR/etc/xbps.conf
|
|
|
|
echo "XBPS_MASTERDIR=/" >> $XBPS_MASTERDIR/etc/xbps.conf
|
2008-10-24 04:25:31 +02:00
|
|
|
echo "XBPS_DESTDIR=/xbps_destdir" >> $XBPS_MASTERDIR/etc/xbps.conf
|
|
|
|
echo "XBPS_BUILDDIR=/xbps_builddir" >> $XBPS_MASTERDIR/etc/xbps.conf
|
2008-10-23 17:14:00 +02:00
|
|
|
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
|
|
|
|
|
|
|
|
install_chroot_pkg()
|
|
|
|
{
|
|
|
|
local pkg="$1"
|
|
|
|
|
|
|
|
[ -z "$pkg" ] && return 1
|
|
|
|
|
2008-10-24 02:05:48 +02:00
|
|
|
echo -n "==> Rebuilding chroot's dynamic linker cache..."
|
2008-10-23 17:14:00 +02:00
|
|
|
chroot $XBPS_MASTERDIR /sbin/ldconfig -c /etc/ld.so.conf
|
|
|
|
chroot $XBPS_MASTERDIR /sbin/ldconfig -C /etc/ld.so.cache
|
|
|
|
echo " done."
|
|
|
|
|
|
|
|
chroot $XBPS_MASTERDIR /xbps/xbps.sh install $pkg
|
|
|
|
umount_chroot_fs
|
|
|
|
}
|
|
|
|
|
|
|
|
umount_chroot_fs()
|
|
|
|
{
|
2008-10-24 04:25:31 +02:00
|
|
|
for f in sys proc dev xbps xbps_builddir xbps_destdir; do
|
2008-10-24 02:05:48 +02:00
|
|
|
[ ! -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
|
2008-10-23 17:14:00 +02:00
|
|
|
done
|
|
|
|
}
|