Browse Source

updated vbuilder.sh.in: defined mount_cache_dir()

git-svn-id: http://trac.vinelinux.org/repos/projects/vbootstrap/trunk@452 ec354946-7b23-47d6-9f5a-488ba84defc7
munepi 15 years ago
parent
commit
c9f93aee61
2 changed files with 39 additions and 15 deletions
  1. 7 1
      vbootstrap.spec
  2. 32 14
      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.12
+%define version 0.0.13
 
 Summary: bootstrap scripts to create a basic Vine Linux system
 Summary(ja): Vine Linux の基本システムを作成するためのスクリプト
@@ -59,6 +59,12 @@ make DESTDIR=$RPM_BUILD_ROOT install
 
 
 %changelog
+* Sat Feb 06 2010 Munehiro Yamamoto <munepi@vinelinux.org> 0.0.13-1
+- updated vbuilder.sh.in
+  - fixed /home/vbuilder/.rpmmacros for VineSeed_i386, VineSeed
+  - improved some mounting processes
+    - defined mount_cache_dir()
+
 * Sun Jan 17 2010 Munehiro Yamamoto <munepi@vinelinux.org> 0.0.12-1
 - added 4.2_i386
 - updated vbuilder.sh.in

+ 32 - 14
vbuilder.sh.in

@@ -257,8 +257,9 @@ setup-vbootstrap(){
 
     BUILD_ROOT=${VBOOTSTRAP_DIR}/${VERSION}
     BUILD_USER=vbuilder
-    CACHE_DIR=${VBOOTSTRAP_DIR}/cache/${VERSION}
     BUILD_DIR=/home/${BUILD_USER}/rpm
+    ARCHIVES_DIR=${BUILD_ROOT}/var/cache/apt/archives
+    CACHE_DIR=${VBOOTSTRAP_DIR}/cache/${VERSION}/apt/archives
 
     mkdir -p $VBOOTSTRAP_DIR
 }
@@ -347,6 +348,21 @@ mount_vfs(){
     fi
 }
 
+## mount ${CACHE_DIR} to ${ARCHIVES_DIR}
+mount_cache_dir(){
+    if [ "$1" = "--umount" ]; then
+	[ -d ${ARCHIVES_DIR} ] || return 1
+	[ -z "$(mount | grep ${ARCHIVES_DIR})" ] || \
+    	    umount ${ARCHIVES_DIR}
+    else
+	[ -d ${CACHE_DIR} ] || mkdir -p ${CACHE_DIR}
+	[ -d ${ARCHIVES_DIR} ] || mkdir -p ${ARCHIVES_DIR}
+	[ -z "$(mount | grep ${ARCHIVES_DIR})" ] && \
+	    mount --bind ${CACHE_DIR} ${ARCHIVES_DIR}
+	[ -d ${ARCHIVES_DIR}/partial ] || mkdir -p ${ARCHIVES_DIR}/partial
+    fi
+}
+
 
 ##############################################################################
 
@@ -356,15 +372,9 @@ Clean(){
     # mount_home --umount
     # mount_tmp --umount
     mount_vfs --umount
+    mount_cache_dir --umount
     apt-get-update --host
 
-    if [ -d ${BUILD_ROOT}/var/cache/apt/archives ]; then
-	echo -n "Caching RPMs in ${CACHE_DIR}/apt/archives ... "
-	[ -d ${CACHE_DIR}/apt/archives ] || mkdir -p ${CACHE_DIR}/apt/archives
-	mv -f ${BUILD_ROOT}/var/cache/apt/archives/*.rpm ${CACHE_DIR}/apt/archives/
-	echo "done."
-    fi
-
     if [ -d ${BUILD_ROOT} ]; then
 	echo -n "Cleaning build root \"${BUILD_ROOT}\" ... "
 	rm -rf ${BUILD_ROOT}
@@ -390,16 +400,11 @@ Build(){
 	/usr/sbin/vbootstrap ${VERSION} ${BUILD_ROOT}
     fi
 
+    mount_cache_dir
     mount_vfs
     # mount_tmp
     # mount_home
 
-    if [ -d ${CACHE_DIR} ]; then
-	echo -n "Copying cached RPMs to ${BUILD_ROOT}/var/cache/apt/archives ... "
-	cp -f ${CACHE_DIR}/apt/archives/*.rpm ${BUILD_ROOT}/var/cache/apt/archives/
-	echo "done."
-    fi
-
     /usr/sbin/chroot ${BUILD_ROOT} \
 	/bin/sh -c 'apt-get update && apt-get -y dist-upgrade'
 
@@ -430,9 +435,16 @@ Build(){
     /usr/sbin/chroot ${BUILD_ROOT} /bin/sh -c '/usr/sbin/pwconv'
     /usr/sbin/chroot ${BUILD_ROOT} /bin/sh -c "/usr/sbin/useradd ${BUILD_USER}"
 
+    ##!! for rpm-4.8.0 or higher
+    ##!! (See http://trac.vinelinux.org/wiki/Vine6/AboutUpdateToolchain)
+    if [ "$(echo ${VERSION} | sed -e "s/\(VineSeed\).*/\1/")" = "VineSeed" ]; then
+	/usr/sbin/chroot ${BUILD_ROOT} /bin/sh -c "sed -i -e 's/^%_topdir/#%_topdir/' /home/${BUILD_USER}/.rpmmacros"
+    fi
+
     # mount_home --umount
     # mount_tmp --umount
     mount_vfs --umount
+    mount_cache_dir --umount
     apt-get-update --host
 
     echo "Making a build farm for ${VERSION} done."
@@ -440,6 +452,7 @@ Build(){
 
 RPM_Remove(){
     setup-vbootstrap-rpm
+    mount_cache_dir
     mount_vfs
 
     if [ -f $RPM_PKG ]; then
@@ -450,11 +463,13 @@ RPM_Remove(){
 	/bin/sh -c "apt-get -y remove $BASE_RPM_PKG"
 
     mount_vfs --umount
+    mount_cache_dir --umount
     apt-get-update --host
 }
 
 RPM_Install(){
     setup-vbootstrap-rpm
+    mount_cache_dir
     mount_vfs
     apt-get-update --chroot
 
@@ -462,11 +477,13 @@ RPM_Install(){
 	/bin/sh -c "cd ${BUILD_DIR} && apt-get -y install $BASE_RPM_PKG"
 
     mount_vfs --umount
+    mount_cache_dir --umount
     apt-get-update --host
 }
 
 RPM_Build(){
     setup-vbootstrap-rpm
+    mount_cache_dir
     mount_vfs
 
     if [ ! -f $RPM_PKG ]; then
@@ -511,6 +528,7 @@ RPM_Build(){
     done
 
     mount_vfs --umount
+    mount_cache_dir --umount
     apt-get-update --host
 
     echo "done."