aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStanislav Ochotnicky <sochotnicky@gmail.com>2009-08-12 19:23:29 +0200
committerStanislav Ochotnicky <sochotnicky@gmail.com>2009-08-12 19:28:48 +0200
commitf3bb910d55b590efe294c86b388f56914380b6a7 (patch)
tree42979dc05b761eab59e44393a2f957e8d9676709
parentFix non-null problem when no of deps worked (diff)
downloadcollagen-f3bb910d55b590efe294c86b388f56914380b6a7.tar.gz
collagen-f3bb910d55b590efe294c86b388f56914380b6a7.tar.bz2
collagen-f3bb910d55b590efe294c86b388f56914380b6a7.zip
More flexibility for mktinderboxchroot
We no longer bind /etc/portage to WORK_CHROOT. Instead we copy it first to BASE_CHROOT where user can modify settings without touching machine settings Also DISTDIR/PKGDIR can be modified in make.conf and we will map these directories inside chroot instead of standard paths (note that this is quite possibly buggy, especially make.conf parsing). If these dirs don't exist outside of chroot they will be created so watch out! All of this is supposed to take care of various RO mounts over nfs
-rwxr-xr-xutil/mktinderboxchroot.sh59
1 files changed, 51 insertions, 8 deletions
diff --git a/util/mktinderboxchroot.sh b/util/mktinderboxchroot.sh
index 61bf410..8b36554 100755
--- a/util/mktinderboxchroot.sh
+++ b/util/mktinderboxchroot.sh
@@ -29,9 +29,13 @@ clean_work_chroot()
{
echo -n "Cleaning work chroot..."
if [ -d $WORK_CHROOT ];then
- for dir in $WORK_CHROOT/{"/dev","/proc","/sys","/usr/portage/distfiles","/usr/portage/packages","/usr/portage/","/etc/portage"};do
+ for dir in {"PKGDIR","DISTDIR"};do
+ umount_dir $dir
+ done
+ for dir in $WORK_CHROOT/{"/dev","/proc","/sys","$PORTAGE_DIR"};do
umount "$dir" || umount -l "$dir"
done
+
rm -rf --one-file-system "$WORK_CHROOT"
fi
echo Done
@@ -49,6 +53,49 @@ clean_base_chroot()
echo Done
}
+GPSRET=""
+get_portage_setting()
+{
+ setting=`grep $1 "$BASE_CHROOT/etc/make.conf" | sed -e "s/.*$1[[:space:]]*=[[:space:]]*//;s/\"//g;"`
+ if [ "y$setting" == "y" ];then
+ case $1 in
+ "PORTDIR" )
+ GPSRET=`portageq portdir`
+ return 0;;
+ "DISTDIR" )
+ GPSRET=`portageq distdir`
+ return 0;;
+ "PKGDIR" )
+ GPSRET=`portageq pkgdir`
+ return 0;;
+ * )
+ return 1;;
+ esac
+ fi
+ GPSRET=$setting
+ return 0;
+}
+
+mount_dir()
+{
+ get_portage_setting $1
+ if [ $? -eq 0 ];then
+ if [ ! -e "$GPSRET" ];then
+ mkdir -p "$GPSRET"
+ fi
+ mkdir -p "$WORK_CHROOT/$GPSRET"
+ mount -o bind "$GPSRET" "$WORK_CHROOT/$GPSRET"
+ else
+ echo "Unable to get setting for $1 variable"
+ exit 1
+ fi
+}
+
+umount_dir()
+{
+ get_portage_setting $1
+ umount "$WORK_CHROOT/$GPSRET" || umount -l "$WORK_CHROOT/$GPSRET"
+}
FORCE_CLEAN_BASE=0
@@ -110,6 +157,7 @@ else
echo -n "Copying settings..."
cp -L /etc/resolv.conf "$BASE_CHROOT/etc"
cp -L /etc/make.conf "$BASE_CHROOT/etc"
+ cp -RL /etc/portage "$BASE_CHROOT/etc"
echo Done
fi
@@ -149,15 +197,10 @@ mount -o bind "$PORTAGE_DIR" "$WORK_CHROOT/usr/portage"
mount -o remount,ro "$WORK_CHROOT/usr/portage"
-mount -o bind "$PORTAGE_DIR/distfiles" "$WORK_CHROOT/usr/portage/distfiles"
+mount_dir "DISTDIR"
+mount_dir "PKGDIR"
-if [ ! -e "$PORTAGE_DIR/packages/" ];then
- mkdir "$PORTAGE_DIR/packages/"
-fi
-mount -o bind "$PORTAGE_DIR/packages/" "$WORK_CHROOT/usr/portage/packages/"
-mount -o bind /etc/portage "$WORK_CHROOT/etc/portage"
-mount -o remount,ro "$WORK_CHROOT/etc/portage"
echo Done