Преглед изворни кода

updated vbuilder.sh.in: added --unionfs option

git-svn-id: http://trac.vinelinux.org/repos/projects/vbootstrap/trunk@485 ec354946-7b23-47d6-9f5a-488ba84defc7
munepi пре 15 година
родитељ
комит
8e7d3460e3
2 измењених фајлова са 54 додато и 7 уклоњено
  1. 7 1
      vbootstrap.spec
  2. 47 6
      vbuilder.sh.in

+ 7 - 1
vbootstrap.spec

@@ -1,7 +1,7 @@
 # This package is maintained on trac svn repository. Please do not change on local.
 # If you find a BUG, please report to Vine@vinelinux.org or mailing list or BTS.
 
-%define version 0.0.15
+%define version 0.0.16
 
 Summary: bootstrap scripts to create a basic Vine Linux system
 Summary(ja): Vine Linux の基本システムを作成するためのスクリプト
@@ -18,6 +18,7 @@ Buildroot: %{_tmppath}/%{name}-%{version}-%{release}-root
 BuildArch: noarch
 BuildRequires: sed
 Requires: bash, apt
+Requires: unionfs-utils
 
 Vendor: Project Vine
 Distribution: Vine Linux
@@ -60,6 +61,11 @@ make DESTDIR=$RPM_BUILD_ROOT install
 
 
 %changelog
+* Mon Feb 22 2010 Munehiro Yamamoto <munepi@vinelinux.org> 0.0.16-1
+- added Requires: unionfs-utils
+- updated vbuilder.sh.in
+  - added --unionfs option
+
 * Sat Feb 20 2010 Munehiro Yamamoto <munepi@vinelinux.org> 0.0.15-1
 - added vbuilder-bash-completion.sh
 

+ 47 - 6
vbuilder.sh.in

@@ -9,6 +9,7 @@ Options:
 	--version:		set [version] (default: ${DEFAULT_VERSION})
 	--arch:			set [arch] (default: $(uname -i))
 	--dist-upgrade:		make VineSeed bootstrap via ${STABLE_VERSION}
+	--unionfs		cover a bootstrap with unionfs
 	--target:		build rpms with [target]
 	--with-compat32:	build rpms with compat32 on boostrap
 
@@ -140,7 +141,7 @@ check-parameter(){
 		shift
 		check-next-parameter $1 || return 1
 		;;
-	    --dist-upgrade|--with-compat32|--build|--clean)
+	    --dist-upgrade|--unionfs|--with-compat32|--build|--clean)
 		;;
 	    *)
 		Msg_MissingParameter_$LOCALE $1
@@ -191,6 +192,7 @@ setup-vbuilder(){
 
     ## set boolian
     with_setup_vbootstrap=0
+    with_unionfs=0
     with_dist_upgrade=0
 }
 
@@ -267,6 +269,7 @@ setup-vbootstrap(){
     BUILD_DIR=/home/${BUILD_USER}/rpm
     ARCHIVES_DIR=${BUILD_ROOT}/var/cache/apt/archives
     CACHE_DIR=${VBOOTSTRAP_DIR}/cache/${VERSION}/apt/archives
+    UNIONFS_DIR=${VBOOTSTRAP_DIR}/unionfs/${VERSION}
 
     __chroot_sh="/usr/sbin/chroot ${BUILD_ROOT} /bin/sh -c"
 
@@ -349,6 +352,17 @@ mount-chroot-umount(){
     		umount ${ARCHIVES_DIR}
 	    return 0
 	    ;;
+	unionfs_dir)
+	    [ -d ${BUILD_ROOT} ] || return 1
+	    [ -z "$(mount | grep ${BUILD_ROOT} | grep unionfs)" ] || \
+		umount ${BUILD_ROOT}
+	    if [ ! -z "$(mount | grep ${BUILD_ROOT} | grep unionfs)" ]; then
+		echo "Retry lazy unmount ... "
+		umount -l ${BUILD_ROOT}
+		echo "done."
+	    fi
+	    return 0
+	    ;;
 	*)
 	    echo mount-chroot-umount: unknown file system $fs
 	    exit 1
@@ -392,6 +406,15 @@ mount-chroot-mount(){
 	    [ -d ${ARCHIVES_DIR}/partial ] || mkdir -p ${ARCHIVES_DIR}/partial
 	    return 0
 	    ;;
+	unionfs_dir)
+	    if [ $with_unionfs -eq 1 ]; then
+		[ -d ${UNIONFS_DIR} ] || mkdir -p ${UNIONFS_DIR}
+		[ -z "$(mount | grep ${BUILD_ROOT})" ] && \
+		    mount -t unionfs -o dirs=${UNIONFS_DIR}=rw:${BUILD_ROOT}=ro unionfs ${BUILD_ROOT}
+		unionctl ${BUILD_ROOT} --list
+	    fi
+	    return 0
+	    ;;
 	*)
 	    echo mount-chroot-mount: unknown file system $fs
 	    exit 1
@@ -410,12 +433,21 @@ Clean(){
     # mount-chroot --umount /tmp
     mount-chroot --umount vfs
     mount-chroot --umount cache_dir
+    mount-chroot --umount unionfs_dir
     apt-get-update --host
 
-    if [ -d ${BUILD_ROOT} ]; then
-	echo -n "Cleaning build root \"${BUILD_ROOT}\" ... "
-	rm -rf ${BUILD_ROOT}
-	echo "done."
+    if [ $with_unionfs -eq 1 ]; then
+	if [ -d ${UNIONFS_DIR} ]; then
+	    echo -n "Cleaning build root \"${UNIONFS_DIR}\" via unionfs ... "
+	    rm -rf ${UNIONFS_DIR}
+	    echo "done."
+	fi
+    else
+	if [ -d ${BUILD_ROOT} ]; then
+	    echo -n "Cleaning build root \"${BUILD_ROOT}\" ... "
+	    rm -rf ${BUILD_ROOT}
+	    echo "done."
+	fi
     fi
 
     echo "Cleanup a build farm for ${VERSION} done."
@@ -498,6 +530,7 @@ Build(){
 
 RPM_Remove(){
     setup-vbootstrap-rpm
+    mount-chroot unionfs_dir
     mount-chroot cache_dir
     mount-chroot vfs
 
@@ -509,11 +542,13 @@ RPM_Remove(){
 
     mount-chroot --umount vfs
     mount-chroot --umount cache_dir
+    mount-chroot --umount unionfs_dir
     apt-get-update --host
 }
 
 RPM_Install(){
     setup-vbootstrap-rpm
+    mount-chroot unionfs_dir
     mount-chroot cache_dir
     mount-chroot vfs
     apt-get-update --chroot
@@ -522,11 +557,13 @@ RPM_Install(){
 
     mount-chroot --umount vfs
     mount-chroot --umount cache_dir
+    mount-chroot --umount unionfs_dir
     apt-get-update --host
 }
 
 RPM_Build(){
     setup-vbootstrap-rpm
+    mount-chroot unionfs_dir
     mount-chroot cache_dir
     mount-chroot vfs
 
@@ -568,6 +605,7 @@ RPM_Build(){
 
     mount-chroot --umount vfs
     mount-chroot --umount cache_dir
+    mount-chroot --umount unionfs_dir
     apt-get-update --host
 
     echo "done."
@@ -586,7 +624,7 @@ while [ $# -gt 0 ]; do
 	--version|--arch|--target|--build-rpm|--install-rpm|--remove-rpm)
 	    shift
 	    ;;
-	--dist-upgrade|--with-compat32|--build|--clean)
+	--dist-upgrade|--unionfs|--with-compat32|--build|--clean)
 	    ;;
 	*)
 	    echo unknown option $1
@@ -604,6 +642,9 @@ while [ $# -gt 0 ]; do
 	--dist-upgrade)
 	    with_dist_upgrade=1
 	    ;;
+	--unionfs)
+	    with_unionfs=1
+	    ;;
 	--target)
 	    TARGET=$1
 	    RPM_OPTS="${RPM_OPTS} --target $TARGET"