Browse Source

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

git-svn-id: http://trac.vinelinux.org/repos/projects/vbootstrap/trunk@791 ec354946-7b23-47d6-9f5a-488ba84defc7
munepi 14 years ago
parent
commit
6860cd9bed
4 changed files with 111 additions and 25 deletions
  1. 3 0
      Makefile
  2. 9 1
      vbootstrap-vl.spec
  3. 4 0
      vbuilder.conf.in
  4. 95 24
      vbuilder.sh.in

+ 3 - 0
Makefile

@@ -4,6 +4,7 @@ REVISION=$(shell LC_ALL=C svn info 2> /dev/null | grep Revision | cut -d' ' -f2)
 
 VBUILDER_STABLE_VERSION=5.1
 VBUILDER_DEFAULT_VERSION=VineSeed
+VBUILDER_CATEGORIES=main,plus,nonfree
 VBUILDER_VBOOTSTRAP_DIR=/var/local/vbootstrap
 #VBUILDER_CACHE_DIR=$$\{VBOOTSTRAP_DIR\}/cache
 VBUILDER_CACHE_DIR=/var/local/vbootstrap/cache
@@ -15,11 +16,13 @@ all:
 	sed -e "s/@@VBOOTSTRAP_VERSION@@/${VERSION}/g" vbootstrap.sh.in > vbootstrap.sh
 	sed -e "s/@@VBUILDER_STABLE_VERSION@@/${VBUILDER_STABLE_VERSION}/g" \
 	    -e "s/@@VBUILDER_DEFAULT_VERSION@@/${VBUILDER_DEFAULT_VERSION}/g" \
+	    -e "s/@@VBUILDER_CATEGORIES@@/${VBUILDER_CATEGORIES}/g" \
 	    -e "s|@@VBUILDER_VBOOTSTRAP_DIR@@|${VBUILDER_VBOOTSTRAP_DIR}|g" \
 	    -e "s|@@VBUILDER_CACHE_DIR@@|${VBUILDER_CACHE_DIR}|g" \
 	    -e "s|@@VBUILDER_BUILT_RPMS_DIR@@|${VBUILDER_BUILT_RPMS_DIR}|g" \
 		vbuilder.sh.in > vbuilder.sh
 	sed -e "s/@@VBUILDER_DEFAULT_VERSION@@/${VBUILDER_DEFAULT_VERSION}/g" \
+	    -e "s/@@VBUILDER_CATEGORIES@@/${VBUILDER_CATEGORIES}/g" \
 	    -e "s|@@VBUILDER_VBOOTSTRAP_DIR@@|${VBUILDER_VBOOTSTRAP_DIR}|g" \
 	    -e "s|@@VBUILDER_CACHE_DIR@@|${VBUILDER_CACHE_DIR}|g" \
 	    -e "s|@@VBUILDER_BUILT_RPMS_DIR@@|${VBUILDER_BUILT_RPMS_DIR}|g" \

+ 9 - 1
vbootstrap-vl.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.22
+%define version 0.0.23
 
 Summary: bootstrap scripts to create a basic Vine Linux system
 Summary(ja): Vine Linux の基本システムを作成するためのスクリプト
@@ -72,6 +72,14 @@ vbuilder は vbootstrap を利用して chroot 環境の構築し、
 
 
 %changelog
+* Sun Apr 11 2010 Munehiro Yamamoto <munepi@vinelinux.org> 0.0.23-1
+- updated vbootstrap.sh.in (daisuke-san)
+  - changed to cache /var/lib/apt/lists, /var/cache/apt/archives 
+    in bootstrap (not in host)
+  - set Dir::State and Dir::Cache in APT_OPTS
+- updated vbuilder.sh.in
+  - added --category option
+
 * Fri Apr 02 2010 Munehiro Yamamoto <munepi@vinelinux.org> 0.0.22-1
 - updated vbuilder.sh.in: 
   - added --bootstrap-dir, --built-rpms-dir, --cache-dir options

+ 4 - 0
vbuilder.conf.in

@@ -7,6 +7,10 @@
 ## default: DEFAULT_VERSION=@@VBUILDER_DEFAULT_VERSION@@
 DEFAULT_VERSION=@@VBUILDER_DEFAULT_VERSION@@
 
+## Default categories for chroot
+## default: CATEGORIES=@@VBUILDER_CATEGORIES@@
+CATEGORIES=@@VBUILDER_CATEGORIES@@
+
 ## The top dirctory for vbootstrap
 ## default: VBOOTSTRAP_DIR=@@VBUILDER_VBOOTSTRAP_DIR@@
 VBOOTSTRAP_DIR=@@VBUILDER_VBOOTSTRAP_DIR@@

+ 95 - 24
vbuilder.sh.in

@@ -3,13 +3,14 @@
 
 Usage_C(){
     cat<<EOF
-Usage:	$(basename $0) {--version [version]} {--arch [arch]} {--dist-upgrade} {--target [target]} {--with-compat32} {--bootstrap-dir [directory]} {--cache-dir [directory]} {--built-rpms-dir [directory]} {clean|build|build-rpm [src.rpm]|install-rpm [arch.rpm|package]|remove-rpm [package]|show-info}
+Usage:	$(basename $0) {--version [version]} {--arch [arch]} {--category [categories]} {--dist-upgrade} {--target [target]} {--with-compat32} {--bootstrap-dir [directory]} {--cache-dir [directory]} {--built-rpms-dir [directory]} {clean|build|build-rpm [src.rpm]|install-rpm [arch.rpm|package]|remove-rpm [package]|show-info}
 
 Options:
 	--version:		set [version] (default: ${DEFAULT_VERSION})
 	--arch:			set [arch] (default: $(uname -i))
+	--category:		set [categories] (default: ${CATEGORIES})
 	--dist-upgrade:		make VineSeed bootstrap via ${STABLE_VERSION}
-	--unionfs		cover a bootstrap with unionfs
+	--unionfs:		cover a bootstrap with unionfs
 	--target:		build rpms with [target]
 	--with-compat32:	build rpms with compat32 on boostrap
 	--bootstrap-dir:	set a bootstrap directory (default: ${VBOOTSTRAP_DIR})
@@ -59,6 +60,20 @@ E: ${para} 以後のいくつかの引数に間違いがあります
 EOF
 }
 
+Msg_NoSuchCategoryExists_C(){
+    local para=$1
+    cat<<EOF
+E: No such category exists: $para
+EOF
+}
+
+Msg_NoSuchCategoryExists_ja(){
+    local para=$1
+    cat<<EOF
+E: そのようなカテゴリは存在しません: $para
+EOF
+}
+
 Msg_GiveMoreOptions_C(){
     cat<<EOF
 E: You can give no more options after actions
@@ -170,7 +185,7 @@ check-parameter(){
 		Usage_$LOCALE
 		return 1
 		;;
-	    --version|--arch|--target|--bootstrap-dir|--cache-dir|--built-rpms-dir)
+	    --version|--arch|--category|--target|--bootstrap-dir|--cache-dir|--built-rpms-dir)
 		[ $with_actions -eq 1 ] && \
 		    Msg_GiveNoMoreOptions_$LOCALE && return 1
 		shift
@@ -219,6 +234,8 @@ setup-vbuilder(){
     fi
     [ -z "${DEFAULT_VERSION}" ] && \
 	DEFAULT_VERSION=@@VBUILDER_DEFAULT_VERSION@@
+    [ -z "${CATEGORIES}" ] && \
+	CATEGORIES=@@VBUILDER_CATEGORIES@@
     [ -z "${VBOOTSTRAP_DIR}" ] && \
 	VBOOTSTRAP_DIR=@@VBUILDER_VBOOTSTRAP_DIR@@
     [ -z "${CACHE_DIR}" ] && \
@@ -243,6 +260,10 @@ setup-vbuilder(){
     with_unionfs=0
     with_dist_upgrade=0
     with_actions=0
+    with_category_main=0
+    with_category_plus=0
+    with_category_nonfree=0
+    with_category_proposed_updates=0
 }
 
 setup-vbootstrap(){
@@ -290,6 +311,36 @@ setup-vbootstrap(){
 	    fi
 	fi
 
+	## set ${MAJOR_VERSION}
+	MAJOR_VERSION=$(echo ${VERSION} | sed -e "s/_i[0-9]86//")
+
+	## check apt categories
+	## The main category main is unconditionally permited
+	with_category_main=1
+	for cat in $(echo ${CATEGORIES} | sed -e "s/,/ /"g); do
+	    case $cat in
+		main)
+		    with_category_main=1
+		    ;;
+		plus)
+		    with_category_plus=1
+		    ;;
+		nonfree)
+		    with_category_nonfree=1
+		    ;;
+		proposed-updates)
+                    ##!! 4.2 has no apt-sourceslist-proposed-updates packages
+		    [ "${MAJOR_VERSION}" = "4.2" ] && \
+			Msg_NoSuchCategoryExists_$LOCALE ${cat} && exit 1
+
+		    with_category_proposed_updates=1
+		    ;;
+		*)
+		    Msg_NoSuchCategoryExists_$LOCALE ${cat} && exit 1
+		    ;;
+	    esac
+	done
+
 	## 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/")"
@@ -300,8 +351,6 @@ setup-vbootstrap(){
 
     fi
 
-    MAJOR_VERSION=$(echo ${VERSION} | sed -e "s/_i[0-9]86//")
-
     BUILD_ROOT=${VBOOTSTRAP_DIR}/${VERSION}
     BUILD_USER=vbuilder
     BUILD_DIR=/home/${BUILD_USER}/rpm
@@ -462,26 +511,29 @@ mount-chroot-mount(){
 }
 
 write-vbuilder-log(){
+    HRULE="======================================================================"
+
     [ -d ${BUILD_ROOT} ] || return 1
 
     if [ ! -f $VBUILDER_LOG ]; then
 	cat<<EOF > $VBUILDER_LOG
-======================================================================
+${HRULE}
 VBUILDER REPORT
 DATE:		$(LANG=C date)
 HOSTNAME:	$(hostname)
 OS:		$(echo $($__chroot_sh "cat /etc/vine-release"))
 %_arch:		$(echo $($__chroot_sh "rpm --eval %_arch"))
 
---version:	${VERSION}
-$(echo $([ -z "${VARCH}" ] || echo "--arch:		${VARCH}"))
+--version: ${VERSION}
+$(echo $([ -z "${VARCH}" ] || echo "--arch: ${VARCH}"))
+$(echo $([ -z "${CATEGORIES}" ] || echo "--category: ${CATEGORIES}"))
 $(echo $([ $with_dist_upgrade -eq 1 ] && echo "--dist-upgrade"))
 $(echo $([ $with_unionfs -eq 1 ] && echo "--unionfs"))
-$(echo $([ -z "${TARGET}" ] || echo "--target:		${TARGET}"))
---bootstrap-dir:	${VBOOTSTRAP_DIR}
---cache-dir:		${CACHE_DIR}
---built-rpms-dir:	${BUILT_RPMS_DIR}
-======================================================================
+$(echo $([ -z "${TARGET}" ] || echo "--target: ${TARGET}"))
+--bootstrap-dir: ${VBOOTSTRAP_DIR}
+--cache-dir: ${CACHE_DIR}
+--built-rpms-dir: ${BUILT_RPMS_DIR}
+${HRULE}
 
 [$VBUILDER_CONF]
 $(cat $VBUILDER_CONF)
@@ -501,8 +553,7 @@ Clean(){
     setup-vbootstrap
 
     # output end-of-line in $VBUILDER_LOG
-    [ -f $VBUILDER_LOG ] && \
-	write-vbuilder-log "======================================================================"
+    [ -f $VBUILDER_LOG ] && write-vbuilder-log ${HRULE}
     Show-Info
 
     # mount-chroot --umount /home
@@ -552,17 +603,34 @@ Build(){
 
     $__chroot_sh 'apt-get -qq update && apt-get -qq -y dist-upgrade'
 
-    ##!! 4.2 has no apt-sourceslist-{plus,nonfree} packages
-    if [ "${MAJOR_VERSION}" != "4.2" ]; then
-	$__chroot_sh 'apt-get -qq update && apt-get -qq -y install apt-sourceslist-plus'
-	$__chroot_sh 'apt-get -qq update && apt-get -qq -y install apt-sourceslist-nonfree'
-    fi
+    ##!! 4.2 has no apt-sourceslist-{plus,nonfree,proposed-updates} packages
+    case ${MAJOR_VERSION} in
+	4.2)
+	    $__chroot_sh "sed -i -e 's/main plus updates nonfree *$/$(echo ${CATEGORIES} | sed -e "s/,/ /"g) updates/g' /etc/apt/sources.list"
+	    ;;
+	@@VBUILDER_STABLE_VERSION@@)
+	    [ $with_category_plus -eq 1 ] && \
+		$__chroot_sh 'apt-get -qq update && apt-get -qq -y install apt-sourceslist-plus'
+	    [ $with_category_nonfree -eq 1 ] && \
+		$__chroot_sh 'apt-get -qq update && apt-get -qq -y install apt-sourceslist-nonfree'
+	    [ $with_category_proposed_updates -eq 1 ] && \
+		$__chroot_sh 'apt-get -qq update && apt-get -qq -y install apt-sourceslist-proposed-updates'
+	    ;;
+	VineSeed)
+	    [ $with_category_plus -eq 1 ] && \
+		$__chroot_sh 'apt-get -qq update && apt-get -qq -y install apt-sourceslist-plus'
+	    [ $with_category_nonfree -eq 1 ] && \
+		$__chroot_sh 'apt-get -qq update && apt-get -qq -y install apt-sourceslist-nonfree'
+	    ;;
+    esac
 
-    if [ $with_dist_upgrade -eq 1 ]; then
+    [ $with_dist_upgrade -eq 1 ] && \
 	$__chroot_sh 'apt-get -qq update && apt-get -qq -y dist-upgrade'
-    fi
+
     $__chroot_sh 'apt-get -qq -y install build-essential'
-    $__chroot_sh 'apt-get -qq -y install self-build-setup'
+
+    [ $with_category_nonfree -eq 1 ] && \
+	$__chroot_sh 'apt-get -qq -y install self-build-setup'
 
     $__chroot_sh 'apt-get -qq -y install etcskel shadow-utils'
 
@@ -697,7 +765,7 @@ check-parameter $* || exit 1
 while [ $# -gt 0 ]; do
     tmpARG=$1
     case $tmpARG in
-	--version|--arch|--target|--bootstrap-dir|--cache-dir|--built-rpms-dir)
+	--version|--arch|--category|--target|--bootstrap-dir|--cache-dir|--built-rpms-dir)
 	    shift
 	    ;;
 	--dist-upgrade|--unionfs|--with-compat32)
@@ -720,6 +788,9 @@ while [ $# -gt 0 ]; do
 	--arch)
 	    VARCH=$1
 	    ;;
+	--category)
+	    CATEGORIES=$1
+	    ;;
 	--dist-upgrade)
 	    with_dist_upgrade=1
 	    ;;