Browse Source

vbuilder.sh.in: added --dist-upgrade option

git-svn-id: http://trac.vinelinux.org/repos/projects/vbootstrap/trunk@411 ec354946-7b23-47d6-9f5a-488ba84defc7
munepi 14 years ago
parent
commit
43c2533b60
3 changed files with 70 additions and 13 deletions
  1. 3 1
      Makefile
  2. 6 1
      vbootstrap.spec
  3. 61 11
      vbuilder.sh.in

+ 3 - 1
Makefile

@@ -1,6 +1,7 @@
 NAME=vbootstrap
 VERSION=$(shell awk '/%define version/ { print $$3 }' ${NAME}.spec)
 
+VBUILDER_STABLE_VERSION=5.0
 VBUILDER_DEFAULT_VERSION=VineSeed
 VBUILDER_VBOOTSTRAP_DIR=/var/local/vbootstrap
 VBUILDER_BUILT_RPMS_DIR=$$\{HOME\}/rpm/vbuilder
@@ -9,7 +10,8 @@ DESTDIR=
 
 all:
 	sed -e "s/@@VBOOTSTRAP_VERSION@@/${VERSION}/g" vbootstrap.sh.in > vbootstrap.sh
-	sed -e "s/@@VBUILDER_DEFAULT_VERSION@@/${VBUILDER_DEFAULT_VERSION}/g" \
+	sed -e "s/@@VBUILDER_STABLE_VERSION@@/${VBUILDER_STABLE_VERSION}/g" \
+	    -e "s/@@VBUILDER_DEFAULT_VERSION@@/${VBUILDER_DEFAULT_VERSION}/g" \
 	    -e "s|@@VBUILDER_VBOOTSTRAP_DIR@@|${VBUILDER_VBOOTSTRAP_DIR}|g" \
 	    -e "s|@@VBUILDER_BUILT_RPMS_DIR@@|${VBUILDER_BUILT_RPMS_DIR}|g" \
 		vbuilder.sh.in > vbuilder.sh

+ 6 - 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.9
+%define version 0.0.10
 
 Summary: bootstrap scripts to create a basic Vine Linux system
 Summary(ja): Vine Linux の基本システムを作成するためのスクリプト
@@ -59,6 +59,11 @@ make DESTDIR=$RPM_BUILD_ROOT install
 
 
 %changelog
+* Tue Dec 29 2009 Munehiro Yamamoto <munepi@vinelinux.org> 0.0.10-1
+- updated vbuilder.sh.in
+  - added --dist-upgrade option which provides a flag to build 
+    VineSeed bootstrap via stable relase version
+
 * Sat Dec 26 2009 Munehiro Yamamoto <munepi@vinelinux.org> 0.0.9-1
 - fixed vbuilder.sh.in around --target option
 

+ 61 - 11
vbuilder.sh.in

@@ -3,11 +3,16 @@
 
 Usage_C(){
     cat<<EOF
-Usage:	$(basename $0) {--version [version]} {--arch [arch]} {--target [target]|--with-compat32} {--build|--clean|--build-rpm [src.rpm]|--install-rpm [arch.rpm|package]|--remove-rpm [package]}
+Usage:	$(basename $0) {--version [version]} {--arch [arch]} {--dist-upgrade} {--target [target]} {--with-compat32} {--build|--clean|--build-rpm [src.rpm]|--install-rpm [arch.rpm|package]|--remove-rpm [package]}
+
+Options:
 	--version:		set [version] (default: ${DEFAULT_VERSION})
 	--arch:			set [arch] (default: $(uname -i))
+	--dist-upgrade:		build VineSeed bootstrap via ${STABLE_VERSION}
 	--target:		build rpms with [target]
 	--with-compat32:	build rpms with compat32 on boostrap
+
+Actions:
 	--clean:		clean boostrap of [version]
 	--build:		build boostrap of [version]
 	--build-rpm:		build [src.rpm] on boostrap
@@ -67,6 +72,16 @@ Msg_NoSupportVERSION_ja(){
     Msg_NoSupportVERSION_C
 }
 
+Msg_NoSupportDistUpgradeVERSION_C(){
+    cat<<EOF
+E: version ${VERSION} does not support --dist-upgrade option
+EOF
+}
+
+Msg_NoSupportDistUpgradeVERSION_ja(){
+    Msg_NoSupportDistUpgradeVERSION_C
+}
+
 Msg_NoSupportTARGET_C(){
     cat<<EOF
 E: rpm build target ${TARGET} is NO support
@@ -93,11 +108,18 @@ setup-vbuilder(){
     [ -d $VBOOTSTRAP_DIR ] || mkdir -p $VBOOTSTRAP_DIR
     VERSION=$DEFAULT_VERSION
 
+    ## current stable relase version
+    STABLE_VERSION=@@VBUILDER_STABLE_VERSION@@
+
     ## set locale
     case $LANG in
 	ja*)  LOCALE=ja ;;
 	*)    LOCALE=C ;;
     esac
+
+    ## set boolian
+    with_setup_vbootstrap=0
+    with_dist_upgrade=0
 }
 
 check-next-parameter(){
@@ -109,10 +131,9 @@ check-next-parameter(){
     done
 }
 
-FLAG_setup_vbootstrap=0
 setup-vbootstrap(){
-    if [ ${FLAG_setup_vbootstrap} -eq 0 ]; then
-	FLAG_setup_vbootstrap=1
+    if [ ${with_setup_vbootstrap} -eq 0 ]; then
+	with_setup_vbootstrap=1
 
 	## check a chroot archtecture
 	if [ ! -z ${VARCH} ]; then
@@ -152,6 +173,14 @@ setup-vbootstrap(){
 	    exit 1
 	fi
 
+	## check ${VERSION} equals VineSeed*, when with_dist_upgrade=1
+	if [ $with_dist_upgrade -eq 1 ]; then
+	    if [ "$(echo ${VERSION} | sed -e "s/\(VineSeed\).*/\1/")" != "VineSeed" ]; then
+		Msg_NoSupportDistUpgradeVERSION_$LOCALE
+		exit 1
+	    fi
+	fi
+
 	## check build target option ${TARGET}
 	if [ ! -z "${TARGET}" ]; then
 	    RPM_TARGET_LIST="$(cat /usr/lib/rpm/rpmrc | grep arch_canon: | sed -e "s/arch_canon:[[:blank:]]*\(.*\):.*/\1/")"
@@ -209,7 +238,18 @@ Clean(){
 Build(){
     setup-vbootstrap
 
-    /usr/sbin/vbootstrap ${VERSION} ${BUILD_ROOT}
+    if [ $with_dist_upgrade -eq 1 ]; then
+	## make bootstrap of ${STABLE_VERSION}
+	/usr/sbin/vbootstrap \
+	    $(echo ${VERSION} | sed -e "s/VineSeed/${STABLE_VERSION}/") \
+	    ${BUILD_ROOT}
+
+	## aim apt-line to VineSeed
+	sed -i "s/apt ${STABLE_VERSION}/apt VineSeed/g" \
+	    ${BUILD_ROOT}/etc/apt/sources.list.d/main.list
+    else
+	/usr/sbin/vbootstrap ${VERSION} ${BUILD_ROOT}
+    fi
 
     # ## mount virtual file systems
     # for dir in /dev /dev/pts /dev/shm /proc /sys; do
@@ -239,8 +279,16 @@ Build(){
 	/bin/sh -c 'apt-get -y install apt-sourceslist-plus && apt-get update'
     /usr/sbin/chroot ${BUILD_ROOT} \
 	/bin/sh -c 'apt-get -y install apt-sourceslist-nonfree && apt-get update'
+
+    if [ $with_dist_upgrade -eq 1 ]; then
+	/usr/sbin/chroot ${BUILD_ROOT} \
+	    /bin/sh -c 'apt-get update && apt-get -y dist-upgrade'
+    fi
+    /usr/sbin/chroot ${BUILD_ROOT} \
+	/bin/sh -c 'apt-get -y install build-essential'
     /usr/sbin/chroot ${BUILD_ROOT} \
-	/bin/sh -c 'apt-get -y install build-essential self-build-setup'
+	/bin/sh -c 'apt-get -y install self-build-setup'
+
     /usr/sbin/chroot ${BUILD_ROOT} \
 	/bin/sh -c 'apt-get -y install etcskel shadow-utils'
 
@@ -341,14 +389,14 @@ setup-vbuilder
 
 [ $# -eq 0 ] && Usage_$LOCALE
 while [ $# -gt 0 ]; do
-    tmpARG="$1"
-    case "$1" in
+    tmpARG=$1
+    case $tmpARG in
 	--version|--arch|--target|--build-rpm|--install-rpm|--remove-rpm)
 	    shift
 	    echo $1 | check-next-parameter
 	    [ $? -eq 1 ] && exit 1
 	    ;;
-	--with-compat32|--build|--clean)
+	--dist-upgrade|--with-compat32|--build|--clean)
 	    ;;
 	*)
 	    Usage_$LOCALE
@@ -356,13 +404,16 @@ while [ $# -gt 0 ]; do
 	    ;;
     esac
 
-    case "$tmpARG" in
+    case $tmpARG in
 	--version)
 	    VERSION=$1
 	    ;;
 	--arch)
 	    VARCH=$1
 	    ;;
+	--dist-upgrade)
+	    with_dist_upgrade=1
+	    ;;
 	--target)
 	    TARGET=$1
 	    RPM_OPTS="${RPM_OPTS} --target $TARGET"
@@ -393,4 +444,3 @@ while [ $# -gt 0 ]; do
 done
 
 exit
-