Parcourir la source

vbootstrap: add support overlayfs

git-svn-id: http://trac.vinelinux.org/repos/projects/vbootstrap/trunk@11148 ec354946-7b23-47d6-9f5a-488ba84defc7
iwamoto il y a 7 ans
Parent
commit
ff5ea82417
2 fichiers modifiés avec 35 ajouts et 6 suppressions
  1. 18 3
      libvbuilder.sh.in
  2. 17 3
      vbuilder.sh.in

+ 18 - 3
libvbuilder.sh.in

@@ -302,6 +302,7 @@ setup-vbootstrap(){
     fi
     ARCHIVES_DIR=${BUILD_ROOT}/var/cache/apt/archives
     EXTERNAL_ARCHIVES_DIR=${CACHE_DIR}/${BASE_PROFILE}/apt/archives
+    UNIONFS_WORK=${UNIONFS_DIR}/unionfs_work
 
     __chroot_sh="/usr/sbin/chroot ${BUILD_ROOT} /bin/sh -c -l"
 
@@ -393,9 +394,9 @@ mount-chroot-umount(){
 	    ;;
 	unionfs_dir)
 	    [ -d ${BUILD_ROOT} ] || return 1
-	    [ -z "$(mount | grep ${BUILD_ROOT} | egrep '(unionfs|aufs)')" ] || \
+	    [ -z "$(mount | grep ${BUILD_ROOT} | egrep '(unionfs|aufs|overlay)')" ] || \
 		umount ${BUILD_ROOT}
-	    if [ ! -z "$(mount | grep ${BUILD_ROOT} | egrep '(unionfs|aufs)')" ]; then
+	    if [ ! -z "$(mount | grep ${BUILD_ROOT} | egrep '(unionfs|aufs|overlay)')" ]; then
 		echo $"Retry lazy unmount ${BUILD_ROOT} ... "
 		umount -l ${BUILD_ROOT}
 		echo $"done."
@@ -459,10 +460,24 @@ mount-chroot-mount(){
 	unionfs_dir)
 	    if [ $with_unionfs -eq 1 ]; then
 		[ -d ${UNIONFS_ROOT} ] || mkdir -p ${UNIONFS_ROOT}
-		if ( /sbin/modprobe aufs >& /dev/null ) ; then
+		if [ -d ${UNIONFS_WORK} ]; then
+		    #workdir needs emply
+		    rm -rf ${UNIONFS_WORK}; mkdir -p ${UNIONFS_WORK}
+		else
+		    mkdir -p ${UNIONFS_WORK}
+		fi
+		/sbin/modprobe overlay >& /dev/null ||:
+		/sbin/modprobe aufs >& /dev/null ||:
+		#overlayfs
+		if ( grep -q overlay /proc/filesystems ) ; then
+		    [ -z "$(mount | grep ${UNIONFS_ROOT})" ] && \
+			mount -t overlay overlay -o lowerdir=${BUILD_ROOT},upperdir=${UNIONFS_ROOT},workdir=${UNIONFS_WORK} ${BUILD_ROOT}
+		#aufs
+		elif ( grep -q aufs /proc/filesystems ) ; then
 		    [ -z "$(mount | grep ${UNIONFS_ROOT})" ] && \
 		        mount -t aufs -o br=${UNIONFS_ROOT}=rw:${BUILD_ROOT}=ro aufs ${BUILD_ROOT}
 		else
+		#unionfs
 		    [ -z "$(mount | grep ${UNIONFS_ROOT})" ] && \
 		        mount -t unionfs -o dirs=${UNIONFS_ROOT}=rw:${BUILD_ROOT}=ro unionfs ${BUILD_ROOT}
 		    unionctl ${BUILD_ROOT} --list

+ 17 - 3
vbuilder.sh.in

@@ -369,6 +369,7 @@ setup-vbootstrap(){
     fi
     ARCHIVES_DIR=${BUILD_ROOT}/var/cache/apt/archives
     EXTERNAL_ARCHIVES_DIR=${CACHE_DIR}/${BASE_PROFILE}/apt/archives
+    UNIONFS_WORK=${UNIONFS_DIR}/unionfs_work
 
     __chroot_sh="/usr/sbin/chroot ${BUILD_ROOT} /bin/sh -c -l"
 
@@ -460,9 +461,9 @@ mount-chroot-umount(){
 	    ;;
 	unionfs_dir)
 	    [ -d ${BUILD_ROOT} ] || return 1
-	    [ -z "$(mount | grep ${BUILD_ROOT} | egrep '(unionfs|aufs)')" ] || \
+	    [ -z "$(mount | grep ${BUILD_ROOT} | egrep '(unionfs|aufs|overlay)')" ] || \
 		umount ${BUILD_ROOT}
-	    if [ ! -z "$(mount | grep ${BUILD_ROOT} | egrep '(unionfs|aufs)')" ]; then
+	    if [ ! -z "$(mount | grep ${BUILD_ROOT} | egrep '(unionfs|aufs|overlay)')" ]; then
 		echo $"Retry lazy unmount ${BUILD_ROOT} ... "
 		umount -l ${BUILD_ROOT}
 		echo $"done."
@@ -526,11 +527,24 @@ mount-chroot-mount(){
 	unionfs_dir)
 	    if [ $with_unionfs -eq 1 ]; then
 		[ -d ${UNIONFS_ROOT} ] || mkdir -p ${UNIONFS_ROOT}
+		if [ -d ${UNIONFS_WORK} ]; then
+		    #workdir needs emply
+		    rm -rf ${UNIONFS_WORK}; mkdir -p ${UNIONFS_WORK}
+		else
+		    mkdir -p ${UNIONFS_WORK}
+		fi
+		/sbin/modprobe overlay >& /dev/null ||:
 		/sbin/modprobe aufs >& /dev/null ||:
-		if ( grep -q aufs /proc/filesystems ) ; then
+		#overlayfs
+		if ( grep -q overlay /proc/filesystems ) ; then
+		    [ -z "$(mount | grep ${UNIONFS_ROOT})" ] && \
+			mount -t overlay overlay -o lowerdir=${BUILD_ROOT},upperdir=${UNIONFS_ROOT},workdir=${UNIONFS_WORK} ${BUILD_ROOT}
+		#aufs
+		elif ( grep -q aufs /proc/filesystems ) ; then
 		    [ -z "$(mount | grep ${UNIONFS_ROOT})" ] && \
 		        mount -t aufs -o br=${UNIONFS_ROOT}=rw:${BUILD_ROOT}=ro aufs ${BUILD_ROOT}
 		else
+		#unionfs
 		    [ -z "$(mount | grep ${UNIONFS_ROOT})" ] && \
 		        mount -t unionfs -o dirs=${UNIONFS_ROOT}=rw:${BUILD_ROOT}=ro unionfs ${BUILD_ROOT}
 		    unionctl ${BUILD_ROOT} --list