]> Zhao Yanbai Git Server - minix.git/commitdiff
release.sh: jail install
authorBen Gras <ben@minix3.org>
Wed, 13 Jul 2011 21:59:07 +0000 (23:59 +0200)
committerBen Gras <ben@minix3.org>
Thu, 14 Jul 2011 14:28:39 +0000 (16:28 +0200)
. Feature to do a 'release' into a permanent
  and usable FS hierarchy, usable with chroot
. Just like the temporary staging hierarchy really
. Useful to checking out and building the latest
  version of minix from a host minix; to
  (1) make an uptodate minix jail, and
  (2) make a sterile, reproducible jail environment, and
  (3) use as disposable environment in which moving /usr/pkg
      is ok
  (i.e. pkgsrc bulk builds)

tools/release.sh

index b6dcca3ab9132d4bcc061bc3af31b3a58481497c..3ba2b148e45883955c89d201db06b99e62396cc3 100755 (executable)
@@ -62,6 +62,7 @@ BS=4096
 
 HDEMU=0
 COPY=0
+JAILMODE=0
 SVNREV=""
 REVTAG=""
 PACKAGES=1
@@ -78,11 +79,11 @@ fi
 
 FILENAMEOUT=""
 
-while getopts "ls:pmMchu?r:f:" c
+while getopts "j:ls:pmMchu?r:f:" c
 do
        case "$c" in
        \?)
-               echo "Usage: $0 [-l] [-p] [-c] [-h] [-m] [-M] [-r <tag>] [-u] [-f <filename>] [-s <username>]" >&2
+               echo "Usage: $0 [-l] [-p] [-c] [-h] [-m] [-M] [-r <tag>] [-u] [-f <filename>] [-s <username>] -j<jaildir>" >&2
                exit 1
        ;;
        h)
@@ -100,6 +101,24 @@ do
        r)      
                SVNREV=-r$OPTARG
                ;;
+       j)
+               FINAL_JAILDIR=$OPTARG
+
+               # Make sure no important directory will be wiped
+               if [ -d "$FINAL_JAILDIR" ]
+               then    echo "$FINAL_JAILDIR exists."
+                       exit 1
+               fi
+
+               # Sanity check name
+               if mkdir $FINAL_JAILDIR
+               then    :
+               else    echo "Could not create $FINAL_JAILDIR."
+                       exit 1
+               fi
+               rm -rf $FINAL_JAILDIR
+               JAILMODE=1
+               ;;
        u)
                echo " * Making live USB-stick image"
                IMG_BASE=minix${version}_usb
@@ -149,11 +168,13 @@ then
        exit
 fi
 
-echo " * Cleanup old files"
-umount $TMPDISKUSR || true
-umount $TMPDISKROOT || true
-umount $RELEASEMNTDIR/usr || true
-umount $RELEASEMNTDIR || true
+if [ $JAILMODE = 0 ]
+then   echo " * Cleanup old files"
+       umount $TMPDISKUSR || true
+       umount $TMPDISKROOT || true
+       umount $RELEASEMNTDIR/usr || true
+       umount $RELEASEMNTDIR || true
+fi
 
 rm -rf $RELEASEDIR $RELEASEMNTDIR $IMG $ROOTIMAGE $CDFILES image*
 mkdir -p $CDFILES || exit
@@ -259,6 +280,7 @@ cp issue.install $RELEASEDIR/etc/issue
 
 echo $version_pretty, SVN revision $REVISION, generated `date` >$RELEASEDIR/etc/version
 rm -rf $RELEASEDIR/tmp/*
+
 if [ $MINIMAL -ne 0 ]
 then
        if [ "$MAKEMAP" -ne 0 ]
@@ -275,6 +297,15 @@ then
        ln $RELEASEDIR/boot/image_big $RELEASEDIR/boot/image/$version
 fi
 
+# If we are making a jail, all is done!
+if [ $JAILMODE = 1 ]
+then   mv $RELEASEDIR $FINAL_JAILDIR
+       echo "Created new minix install in $FINAL_JAILDIR."
+       echo "Enter it by typing: "
+       echo "# chroot $FINAL_JAILDIR /bin/sh"
+       exit 0
+fi
+
 echo " * Counting files"
 extrakb=`du -s $RELEASEDIR/usr/install | awk '{ print $1 }'`
 find $RELEASEDIR/usr | fgrep -v /install/ | wc -l >$RELEASEDIR/.usrfiles