Browse Source

updated vbuilder: added --debug, --login options; applied vbootstrap-0.0.37-armhack.patch (Thanks to parrot-san)

git-svn-id: http://trac.vinelinux.org/repos/projects/vbootstrap/trunk@2718 ec354946-7b23-47d6-9f5a-488ba84defc7
munepi 11 years ago
parent
commit
d0e18a6b47
7 changed files with 264 additions and 92 deletions
  1. 10 20
      Makefile
  2. 69 23
      libvbuilder.sh.in
  3. 2 0
      vbootstrap-vl.spec
  4. 8 4
      vbuilder-bash-completion.sh
  5. 9 0
      vbuilder.conf.in
  6. 165 44
      vbuilder.sh.in
  7. 1 1
      vchroot.sh.in

+ 10 - 20
Makefile

@@ -15,28 +15,18 @@ DESTDIR=
 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" \
-		vbuilder.conf.in > vbuilder.conf
+	for i in vbuilder.sh.in vbuilder.conf.in libvbuilder.sh.in; do \
+	  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_UNIONFS_DIR@@|${VBUILDER_UNIONFS_DIR}|g" \
+	      -e "s|@@VBUILDER_CACHE_DIR@@|${VBUILDER_CACHE_DIR}|g" \
+	      -e "s|@@VBUILDER_BUILT_RPMS_DIR@@|${VBUILDER_BUILT_RPMS_DIR}|g" \
+		  $$i > `basename $$i .in`; \
+	done
 
 	##!! experimental: vchroot
-	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" \
-		libvbuilder.sh.in > libvbuilder.sh
 	cp -f vchroot.sh.in vchroot.sh
 
 	cd po && make

+ 69 - 23
libvbuilder.sh.in

@@ -13,6 +13,8 @@ setup-vbuilder(){
 	CATEGORIES=@@VBUILDER_CATEGORIES@@
     [ -z "${VBOOTSTRAP_DIR}" ] && \
 	VBOOTSTRAP_DIR=@@VBUILDER_VBOOTSTRAP_DIR@@
+    [ -z "${UNIONFS_DIR}" ] && \
+	UNIONFS_DIR=@@VBUILDER_UNIONFS_DIR@@
     [ -z "${CACHE_DIR}" ] && \
 	CACHE_DIR=@@VBUILDER_CACHE_DIR@@
     [ -z "${BUILT_RPMS_DIR}" ] && \
@@ -24,12 +26,13 @@ setup-vbuilder(){
     ## set current stable relase version
     STABLE_VERSION=@@VBUILDER_STABLE_VERSION@@
 
-    ## set boolian
+    ## set boolian variables
     with_setup_vbootstrap=0
     with_dist_upgrade=0
     with_unionfs=0
     with_sign=0
     with_no_install=0
+    with_debug=0
     with_actions=0
     with_ix86_on_x86_64=0
     with_category_main=0
@@ -46,24 +49,45 @@ setup-vbootstrap(){
     if [ ${with_setup_vbootstrap} -eq 0 ]; then
 	with_setup_vbootstrap=1
 
+	## check debug mode
+	[ ${with_debug} -eq 1 ] && \
+	    set && set -x
+
 	## check some directories
 	## Note: create $BUILT_RPMS_DIR in RPM_Build()
 	[ -d $VBOOTSTRAP_DIR ] || mkdir -p $VBOOTSTRAP_DIR
 	[ -d $CACHE_DIR ] || mkdir -p $CACHE_DIR
 
+	UARCH=$(uname -i)
+	case "${UARCH}" in
+	    arm*)
+		UARCH="arm"
+		;;
+	esac
+
+	case "${VARCH}" in
+	    arm*)
+		VARCH="arm"
+		;;
+	esac
+
 	## check a chroot archtecture
 	if [ -z ${VARCH} ]; then
-	    VARCH=$(uname -i)
+	    VARCH=${UARCH}
 	else
 	    case "${VARCH}" in
 		i386|i686|x86_64)
-		    [ "$(uname -i)" = "ppc" ] && \
+		    [ "$(uname -i)" = "ppc" -o "${UARCH}" = "arm" ] && \
 			echo $"E: arch ${VARCH} is NOT supported on $(uname -i)" && return 1
 		    ;;
 		ppc)
-		    [ "$(uname -i)" = "i386" -o "$(uname -i)" = "i686" -o "$(uname -i)" = "x86_64" ] && \
+		    [ "$(uname -i)" = "i386" -o "$(uname -i)" = "i686" -o "$(uname -i)" = "x86_64" -o "${UARCH}" = "arm" ] && \
 			echo $"E: arch ${VARCH} is NOT supported on $(uname -i)" && return 1
 		    ;;
+		arm)
+		    [ "${UARCH}" = "i386" -o "${UARCH}" = "i686" -o "${UARCH}" = "x86_64" -o "${UARCH}" = "ppc" ] && \
+			echo $"E: arch ${VARCH} is NOT supported on ${UARCH}" && return 1
+		    ;;
 	    esac
 	fi
 
@@ -73,11 +97,21 @@ setup-vbootstrap(){
 	    return 1
 	fi
 
+        ##!! 4.2 is NO support on VARCH=arm
+	if [ "${VERSION}" = "4.2" -a "${VARCH}" = "arm" ]; then
+	    echo $"E: ${VERSION} is NOT supported"
+	    return 1
+	fi
+
 	## support i386 chroot on x86_64 below: 
-	[ "${VARCH}" != "$(uname -i)" ] && \
+	[ "${VARCH}" != "${UARCH}" ] && \
 	    VERSION=${VERSION}_${VARCH} && \
 	    with_ix86_on_x86_64=1
 
+	## hack arm repository to local
+	[ "${VARCH}" = "arm" ] && \
+	    VERSION=${VERSION}_${VARCH}
+
         ## check support ${VERSION}
 	if [ -z "$(/usr/sbin/vbootstrap | sed -e s/^Usage:.*// -e s/^E:.*// | grep -m 1 ${VERSION})" ]; then
 	    echo $"E: ${VERSION} is NOT supported"
@@ -144,7 +178,7 @@ setup-vbootstrap(){
 	fi
 
 	## set ${RPM_PKG_ARCH_LIST}
-	RPM_PKG_ARCH_LIST="RPMS/i386 RPMS/i686 RPMS/x86_64 RPMS/ppc RPMS/noarch SRPMS"
+	RPM_PKG_ARCH_LIST="RPMS/i386 RPMS/i686 RPMS/x86_64 RPMS/ppc RPMS/noarch RPMS/armv3l RPMS/armv4l RPMS/armv4tl RPMS/armv5tejl RPMS/armv5tel RPMS/armv6l RPMS/armv7l SRPMS"
 	[ -z "${TARGET}" ] || \
 	    RPM_PKG_ARCH_LIST="RPMS/${TARGET} ${RPM_PKG_ARCH_LIST}"
 
@@ -154,7 +188,7 @@ setup-vbootstrap(){
     BUILD_ROOT=${VBOOTSTRAP_DIR}/${VERSION}
     BUILD_USER=vbuilder
     BUILD_DIR=/home/${BUILD_USER}/rpm
-    UNIONFS_DIR=${VBOOTSTRAP_DIR}/unionfs/${VERSION}
+    UNIONFS_ROOT=${UNIONFS_DIR}/${VERSION}
     ARCHIVES_DIR=${BUILD_ROOT}/var/cache/apt/archives
     EXTERNAL_ARCHIVES_DIR=${CACHE_DIR}/${VERSION}/apt/archives
     VBUILDER_LOG=${BUILD_ROOT}/var/log/vbuilder.log
@@ -241,9 +275,6 @@ mount-chroot-umount(){
 	    for dir in /sys /proc /dev/shm /dev/pts /dev; do
 	    	mount-chroot-umount ${dir} || return 1
 	    done
-	    # [ -d ${BUILD_ROOT}/proc ] || return 1
-	    # [ -z "$(mount | grep ${BUILD_ROOT}/proc)" ] || \
-	    # 	umount ${BUILD_ROOT}/proc
 	    ;;
 	archives_dir)
 	    [ -d ${ARCHIVES_DIR} ] || return 1
@@ -271,41 +302,55 @@ mount-chroot-umount(){
 ## mount-chroot-mount [file system|name]
 mount-chroot-mount(){
     local fs=$1
-    local mnt_opts=""
 
     case $fs in
 	/home)
-	    mnt_opts="-o _netdev,rbind"
+	    [ -d ${BUILD_ROOT}${fs} ] || mkdir -p ${BUILD_ROOT}${fs}
+	    [ -z "$(mount | grep ${BUILD_ROOT}${fs})" ] && \
+		mount -o _netdev,rbind ${fs} ${BUILD_ROOT}${fs}
 	    ;;
-	*)
-	    mnt_opts="--bind -o _netdev"
+	/tmp|/dev)
+	    [ -d ${BUILD_ROOT}${fs} ] || mkdir -p ${BUILD_ROOT}${fs}
+	    [ -z "$(mount | grep ${BUILD_ROOT}${fs})" ] && \
+		mount --bind -o _netdev ${fs} ${BUILD_ROOT}${fs}
 	    ;;
-    esac
-
-    case $fs in
-	/home|/tmp|/sys|/proc|/dev/shm|/dev/pts|/dev)
+	/sys)
+	    [ -d ${BUILD_ROOT}${fs} ] || mkdir -p ${BUILD_ROOT}${fs}
+	    [ -z "$(mount | grep ${BUILD_ROOT}${fs})" ] && \
+		mount -o _netdev -t sysfs vbuildersysfs ${BUILD_ROOT}${fs}
+	    ;;
+	/proc)
+	    [ -d ${BUILD_ROOT}${fs} ] || mkdir -p ${BUILD_ROOT}${fs}
+	    [ -z "$(mount | grep ${BUILD_ROOT}${fs})" ] && \
+		mount -o _netdev -t proc vbuilderproc ${BUILD_ROOT}${fs}
+	    ;;
+	/dev/shm)
+	    [ -d ${BUILD_ROOT}${fs} ] || mkdir -p ${BUILD_ROOT}${fs}
+	    [ -z "$(mount | grep ${BUILD_ROOT}${fs})" ] && \
+		mount -o _netdev -t tmpfs vbuildertmpfs ${BUILD_ROOT}${fs}
+	    ;;
+	/dev/pts)
 	    [ -d ${BUILD_ROOT}${fs} ] || mkdir -p ${BUILD_ROOT}${fs}
 	    [ -z "$(mount | grep ${BUILD_ROOT}${fs})" ] && \
-		mount ${mnt_opts} ${fs} ${BUILD_ROOT}${fs}
+		mount -o gid=5,mode=620,_netdev -t devpts vbuilderdevpts ${BUILD_ROOT}${fs}
 	    ;;
 	vfs)
 	    for dir in /dev /dev/pts /dev/shm /proc /sys; do
 	    	mount-chroot-mount ${dir} || return 1
 	    done
-	    # mount-chroot-mount /proc || return 1
 	    ;;
 	archives_dir)
 	    [ -d ${EXTERNAL_ARCHIVES_DIR} ] || mkdir -p ${EXTERNAL_ARCHIVES_DIR}
 	    [ -d ${ARCHIVES_DIR} ] || mkdir -p ${ARCHIVES_DIR}
 	    [ -z "$(mount | grep ${ARCHIVES_DIR})" ] && \
-		mount ${mnt_opts} ${EXTERNAL_ARCHIVES_DIR} ${ARCHIVES_DIR}
+		mount --bind -o _netdev ${EXTERNAL_ARCHIVES_DIR} ${ARCHIVES_DIR}
 	    [ -d ${ARCHIVES_DIR}/partial ] || mkdir -p ${ARCHIVES_DIR}/partial
 	    ;;
 	unionfs_dir)
 	    if [ $with_unionfs -eq 1 ]; then
-		[ -d ${UNIONFS_DIR} ] || mkdir -p ${UNIONFS_DIR}
+		[ -d ${UNIONFS_ROOT} ] || mkdir -p ${UNIONFS_ROOT}
 		[ -z "$(mount | grep ${BUILD_ROOT})" ] && \
-		    mount -t unionfs -o dirs=${UNIONFS_DIR}=rw:${BUILD_ROOT}=ro unionfs ${BUILD_ROOT}
+		    mount -t unionfs -o dirs=${UNIONFS_ROOT}=rw:${BUILD_ROOT}=ro unionfs ${BUILD_ROOT}
 		unionctl ${BUILD_ROOT} --list
 	    fi
 	    ;;
@@ -338,6 +383,7 @@ $(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}
+--unionfs-dir: ${UNIONFS_DIR}
 --cache-dir: ${CACHE_DIR}
 --built-rpms-dir: ${BUILT_RPMS_DIR}
 ${HRULE}

+ 2 - 0
vbootstrap-vl.spec

@@ -83,6 +83,8 @@ vbuilder は vbootstrap を利用して chroot 環境の構築し、
 * Fri Feb 18 2011 Munehiro Yamamoto <munepi@vinelinux.org> 0.0.38-1
 - updated vbuilder.sh.in
   - added $$UNIONFS_DIR
+  - added --debug, --login options
+  - applied vbootstrap-0.0.37-armhack.patch (Thanks to parrot-san)
 
 * Wed Feb 09 2011 Munehiro Yamamoto <munepi@vinelinux.org> 0.0.37-1
 - fixed a little mistake of vbuilder.sh.in

+ 8 - 4
vbuilder-bash-completion.sh

@@ -22,14 +22,12 @@ _vbuilder()
     first="${COMP_WORDS[1]}"
 
     ## The basic options we'll complete.
-    options="--version --arch --category --dist-upgrade --unionfs --target --with-compat32 --rpmbuild-define --rpmbuild-with --rpmbuild-without --sign --no-install --bootstrap-dir --cache-dir --built-rpms-dir"
+    options="--version --arch --category --dist-upgrade --unionfs --target --with-compat32 --rpmbuild-define --rpmbuild-with --rpmbuild-without --sign --no-install --bootstrap-dir --unionfs-dir --cache-dir --built-rpms-dir --debug"
     actions="clean build build-rpm install-rpm remove-rpm show-info"
     opts="$options $actions"
 
     _arch=$(rpm --eval %_arch)
 
-    in_options=0
-
     ## Complete the arguments to some of the basic commands.
     case "${prev}" in
 	--version)
@@ -42,7 +40,7 @@ _vbuilder()
 	    ;;
 
 	--arch)
-	    local running="i386 ppc x86_64"
+	    local running="i386 ppc x86_64 arm"
 	    COMPREPLY=( $(compgen -W "${running}" -- "${cur}") )
 	    ;;
 
@@ -56,6 +54,12 @@ _vbuilder()
 	    COMPREPLY=( $(compgen -W "${running}" -- "${cur}") )
 	    ;;
 
+	--bootstrap-dir|--unionfs-dir|--cache-dir|--built-rpms-dir)
+	    if [ $COMP_CWORD -eq 1 -o "${COMPREPLY+set}" != "set" ]; then
+		_filedir ''
+	    fi
+	    ;;
+
 	--build-rpm|build-rpm)
 	    if [ $COMP_CWORD -eq 1 -o "${COMPREPLY+set}" != "set" ]; then
 		_filedir 'src.rpm'

+ 9 - 0
vbuilder.conf.in

@@ -13,10 +13,19 @@ CATEGORIES=@@VBUILDER_CATEGORIES@@
 
 ## The top dirctory for vbootstrap
 ## default: VBOOTSTRAP_DIR=@@VBUILDER_VBOOTSTRAP_DIR@@
+## If the memory size of your system is enough large (about 4GB or larger), 
+## you may give VBOOTSTRAP_DIR to a directory on tmpfs
+## For example, VBOOTSTRAP_DIR=/dev/shm/vbootstrap
 VBOOTSTRAP_DIR=@@VBUILDER_VBOOTSTRAP_DIR@@
 
 ## Default directory to store unionfs images of vbootstrap
 ## default: CACHE_DIR=@@VBUILDER_UNIONFS_DIR@@
+## If the memory size of your system is enough large (about 4GB or larger), 
+## you may give UNIONFS_DIR to a directory on tmpfs
+## For example, UNIONFS_DIR=/dev/shm/vbootstrap/unionfs
+## 
+## We remark that you may better assign either VBOOTSTRAP_DIR or UNIONFS_DIR 
+## if you make a bootstrap on tmpfs. 
 UNIONFS_DIR=@@VBUILDER_UNIONFS_DIR@@
 
 ## Default directory to cache rpms of /var/cache/apt/archives in chroot

+ 165 - 44
vbuilder.sh.in

@@ -5,12 +5,19 @@ TEXTDOMAIN=vbootstrap
 TEXTDOMAINDIR=/usr/share/locale
 
 Usage(){
+    UARCH=$(uname -i)
+    case "${UARCH}" in
+	arm*)
+	    UARCH="arm"
+	    ;;
+    esac
+
     cat<<EOF
-Usage:	$(basename $0) {--version [version]} {--arch [arch]} {--category [categories]} {--dist-upgrade} {--target [target]} {--with-compat32} {--rpmbuild-define [macro_expr]} {--rpmbuild-with [bcond_with]} {--rpmbuild-without [bcond_with]} {--sign} {--no-install} {--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} {--rpmbuild-define [macro_expr]} {--rpmbuild-with [bcond_with]} {--rpmbuild-without [bcond_with]} {--sign} {--no-install} {--debug} {--help} {--bootstrap-dir [directory]} {--unionfs-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))
+	--arch:			set [arch] (default: ${UARCH})
 	--category:		set [categories] (default: ${CATEGORIES})
 	--dist-upgrade:		make VineSeed bootstrap via ${STABLE_VERSION}
 	--unionfs:		cover a bootstrap with unionfs
@@ -21,10 +28,13 @@ Options:
 	--rpmbuild-without:	give a option --without [bcond_with] to rpmbuild
 	--sign:			sign built rpms
 	--no-install:		build only a source rpm - do NOT install a built rpm
+	--login:		login in chroot as root user
 	--bootstrap-dir:	set a bootstrap directory (default: ${VBOOTSTRAP_DIR})
 	--unionfs-dir:		set a directory to store unionfs images of vbootstrap (default: ${UNIONFS_DIR})
 	--cache-dir:		set a directory to cache rpms (default: ${CACHE_DIR})
 	--built-rpms-dir:	set a directory to store built rpms in chroot (default: ${BUILT_RPMS_DIR})
+	--debug:		enable debug mode
+	--help:			show this help
 
 Actions:
 	clean:			clean the boostrap of [version]
@@ -69,7 +79,7 @@ check-parameter(){
 		shift
 		check-next-parameter $1 || return 1
 		;;
-	    --dist-upgrade|--unionfs|--with-compat32|--sign|--no-install)
+	    --dist-upgrade|--unionfs|--with-compat32|--sign|--no-install|--login|--debug)
 		[ $with_actions -eq 1 ] && \
 		    echo $"E: You can give no more options after actions" && \
 		    return 1
@@ -131,12 +141,14 @@ setup-vbuilder(){
     ## set current stable relase version
     STABLE_VERSION=@@VBUILDER_STABLE_VERSION@@
 
-    ## set boolian
+    ## set boolian variables
     with_setup_vbootstrap=0
     with_dist_upgrade=0
     with_unionfs=0
     with_sign=0
     with_no_install=0
+    with_login=0
+    with_debug=0
     with_actions=0
     with_ix86_on_x86_64=0
     with_category_main=0
@@ -153,24 +165,45 @@ setup-vbootstrap(){
     if [ ${with_setup_vbootstrap} -eq 0 ]; then
 	with_setup_vbootstrap=1
 
+	## check debug mode
+	[ ${with_debug} -eq 1 ] && \
+	    set && set -x
+
 	## check some directories
 	## Note: create $BUILT_RPMS_DIR in RPM_Build()
 	[ -d $VBOOTSTRAP_DIR ] || mkdir -p $VBOOTSTRAP_DIR
 	[ -d $CACHE_DIR ] || mkdir -p $CACHE_DIR
 
+	UARCH=$(uname -i)
+	case "${UARCH}" in
+	    arm*)
+		UARCH="arm"
+		;;
+	esac
+
+	case "${VARCH}" in
+	    arm*)
+		VARCH="arm"
+		;;
+	esac
+
 	## check a chroot archtecture
 	if [ -z ${VARCH} ]; then
-	    VARCH=$(uname -i)
+	    VARCH=${UARCH}
 	else
 	    case "${VARCH}" in
 		i386|i686|x86_64)
-		    [ "$(uname -i)" = "ppc" ] && \
+		    [ "$(uname -i)" = "ppc" -o "${UARCH}" = "arm" ] && \
 			echo $"E: arch ${VARCH} is NOT supported on $(uname -i)" && return 1
 		    ;;
 		ppc)
-		    [ "$(uname -i)" = "i386" -o "$(uname -i)" = "i686" -o "$(uname -i)" = "x86_64" ] && \
+		    [ "$(uname -i)" = "i386" -o "$(uname -i)" = "i686" -o "$(uname -i)" = "x86_64" -o "${UARCH}" = "arm" ] && \
 			echo $"E: arch ${VARCH} is NOT supported on $(uname -i)" && return 1
 		    ;;
+		arm)
+		    [ "${UARCH}" = "i386" -o "${UARCH}" = "i686" -o "${UARCH}" = "x86_64" -o "${UARCH}" = "ppc" ] && \
+			echo $"E: arch ${VARCH} is NOT supported on ${UARCH}" && return 1
+		    ;;
 	    esac
 	fi
 
@@ -180,11 +213,21 @@ setup-vbootstrap(){
 	    return 1
 	fi
 
+        ##!! 4.2 is NO support on VARCH=arm
+	if [ "${VERSION}" = "4.2" -a "${VARCH}" = "arm" ]; then
+	    echo $"E: ${VERSION} is NOT supported"
+	    return 1
+	fi
+
 	## support i386 chroot on x86_64 below: 
-	[ "${VARCH}" != "$(uname -i)" ] && \
+	[ "${VARCH}" != "${UARCH}" ] && \
 	    VERSION=${VERSION}_${VARCH} && \
 	    with_ix86_on_x86_64=1
 
+	## hack arm repository to local
+	[ "${VARCH}" = "arm" ] && \
+	    VERSION=${VERSION}_${VARCH}
+
         ## check support ${VERSION}
 	if [ -z "$(/usr/sbin/vbootstrap | sed -e s/^Usage:.*// -e s/^E:.*// | grep -m 1 ${VERSION})" ]; then
 	    echo $"E: ${VERSION} is NOT supported"
@@ -251,7 +294,7 @@ setup-vbootstrap(){
 	fi
 
 	## set ${RPM_PKG_ARCH_LIST}
-	RPM_PKG_ARCH_LIST="RPMS/i386 RPMS/i686 RPMS/x86_64 RPMS/ppc RPMS/noarch SRPMS"
+	RPM_PKG_ARCH_LIST="RPMS/i386 RPMS/i686 RPMS/x86_64 RPMS/ppc RPMS/noarch RPMS/armv3l RPMS/armv4l RPMS/armv4tl RPMS/armv5tejl RPMS/armv5tel RPMS/armv6l RPMS/armv7l SRPMS"
 	[ -z "${TARGET}" ] || \
 	    RPM_PKG_ARCH_LIST="RPMS/${TARGET} ${RPM_PKG_ARCH_LIST}"
 
@@ -345,12 +388,9 @@ mount-chroot-umount(){
 	    fi
 	    ;;
 	vfs)
-	    # for dir in /sys /proc /dev/shm /dev/pts /dev; do
-	    # 	mount-chroot-umount ${dir} || return 1
-	    # done
-	    [ -d ${BUILD_ROOT}/proc ] || return 1
-	    [ -z "$(mount | grep ${BUILD_ROOT}/proc)" ] || \
-	    	umount ${BUILD_ROOT}/proc
+	    for dir in /sys /proc /dev/shm /dev/pts /dev; do
+	    	mount-chroot-umount ${dir} || return 1
+	    done
 	    ;;
 	archives_dir)
 	    [ -d ${ARCHIVES_DIR} ] || return 1
@@ -378,34 +418,48 @@ mount-chroot-umount(){
 ## mount-chroot-mount [file system|name]
 mount-chroot-mount(){
     local fs=$1
-    local mnt_opts=""
 
     case $fs in
 	/home)
-	    mnt_opts="-o _netdev,rbind"
+	    [ -d ${BUILD_ROOT}${fs} ] || mkdir -p ${BUILD_ROOT}${fs}
+	    [ -z "$(mount | grep ${BUILD_ROOT}${fs})" ] && \
+		mount -o _netdev,rbind ${fs} ${BUILD_ROOT}${fs}
 	    ;;
-	*)
-	    mnt_opts="--bind -o _netdev"
+	/tmp|/dev)
+	    [ -d ${BUILD_ROOT}${fs} ] || mkdir -p ${BUILD_ROOT}${fs}
+	    [ -z "$(mount | grep ${BUILD_ROOT}${fs})" ] && \
+		mount --bind -o _netdev ${fs} ${BUILD_ROOT}${fs}
 	    ;;
-    esac
-
-    case $fs in
-	/home|/tmp|/sys|/proc|/dev/shm|/dev/pts|/dev)
+	/sys)
+	    [ -d ${BUILD_ROOT}${fs} ] || mkdir -p ${BUILD_ROOT}${fs}
+	    [ -z "$(mount | grep ${BUILD_ROOT}${fs})" ] && \
+		mount -o _netdev -t sysfs vbuildersysfs ${BUILD_ROOT}${fs}
+	    ;;
+	/proc)
+	    [ -d ${BUILD_ROOT}${fs} ] || mkdir -p ${BUILD_ROOT}${fs}
+	    [ -z "$(mount | grep ${BUILD_ROOT}${fs})" ] && \
+		mount -o _netdev -t proc vbuilderproc ${BUILD_ROOT}${fs}
+	    ;;
+	/dev/shm)
 	    [ -d ${BUILD_ROOT}${fs} ] || mkdir -p ${BUILD_ROOT}${fs}
 	    [ -z "$(mount | grep ${BUILD_ROOT}${fs})" ] && \
-		mount ${mnt_opts} ${fs} ${BUILD_ROOT}${fs}
+		mount -o _netdev -t tmpfs vbuildertmpfs ${BUILD_ROOT}${fs}
+	    ;;
+	/dev/pts)
+	    [ -d ${BUILD_ROOT}${fs} ] || mkdir -p ${BUILD_ROOT}${fs}
+	    [ -z "$(mount | grep ${BUILD_ROOT}${fs})" ] && \
+		mount -o gid=5,mode=620,_netdev -t devpts vbuilderdevpts ${BUILD_ROOT}${fs}
 	    ;;
 	vfs)
-	    # for dir in /dev /dev/pts /dev/shm /proc /sys; do
-	    # 	mount-chroot-mount ${dir} || return 1
-	    # done
-	    mount-chroot-mount /proc || return 1
+	    for dir in /dev /dev/pts /dev/shm /proc /sys; do
+	    	mount-chroot-mount ${dir} || return 1
+	    done
 	    ;;
 	archives_dir)
 	    [ -d ${EXTERNAL_ARCHIVES_DIR} ] || mkdir -p ${EXTERNAL_ARCHIVES_DIR}
 	    [ -d ${ARCHIVES_DIR} ] || mkdir -p ${ARCHIVES_DIR}
 	    [ -z "$(mount | grep ${ARCHIVES_DIR})" ] && \
-		mount ${mnt_opts} ${EXTERNAL_ARCHIVES_DIR} ${ARCHIVES_DIR}
+		mount --bind -o _netdev ${EXTERNAL_ARCHIVES_DIR} ${ARCHIVES_DIR}
 	    [ -d ${ARCHIVES_DIR}/partial ] || mkdir -p ${ARCHIVES_DIR}/partial
 	    ;;
 	unionfs_dir)
@@ -485,15 +539,13 @@ user_from_uid () {
 Clean(){
     setup-vbootstrap || return 1
 
-    # # output end-of-line in $VBUILDER_LOG
-    # [ -f $VBUILDER_LOG ] && write-vbuilder-log ${HRULE}
-    # Show-Info
-
     # mount-chroot --umount /home
-    # mount-chroot --umount /tmp
-    mount-chroot --umount vfs
+    mount-chroot --umount /tmp
+    mount-chroot --umount /dev/shm
+    mount-chroot --umount /dev/pts
     mount-chroot --umount archives_dir
     mount-chroot --umount unionfs_dir
+    mount-chroot --umount /proc
     apt-get-update --host
 
     if [ $with_unionfs -eq 1 ]; then
@@ -530,8 +582,10 @@ Build(){
 	/usr/sbin/vbootstrap ${VERSION} ${BUILD_ROOT}
     fi
 
+    mount-chroot /proc
     mount-chroot archives_dir
-    mount-chroot vfs
+    mount-chroot /dev/pts
+    mount-chroot /dev/shm
     # mount-chroot /tmp
     # mount-chroot /home
 
@@ -575,10 +629,13 @@ Build(){
     $__chroot_sh 'apt-get -qq -y install etcskel shadow-utils'
 
     $__chroot_sh 'cd /dev && /sbin/MAKEDEV console'
+    $__chroot_sh 'cd /dev && /sbin/MAKEDEV ptmx'
     $__chroot_sh 'cd /dev && /sbin/MAKEDEV null'
     $__chroot_sh 'cd /dev && /sbin/MAKEDEV zero'
     $__chroot_sh 'cd /dev && /sbin/MAKEDEV random'
     $__chroot_sh 'cd /dev && /sbin/MAKEDEV urandom'
+    $__chroot_sh 'cd /dev && mkdir -p shm && chmod 777 shm'
+    $__chroot_sh 'cd /dev && mkdir -p pts && chmod 755 pts'
 
     $__chroot_sh '/usr/sbin/pwconv'
     $__chroot_sh "/usr/sbin/useradd ${BUILD_USER}"
@@ -595,8 +652,10 @@ Build(){
 
     # mount-chroot --umount /home
     # mount-chroot --umount /tmp
-    mount-chroot --umount vfs
+    mount-chroot --umount /dev/shm
+    mount-chroot --umount /dev/pts
     mount-chroot --umount archives_dir
+    mount-chroot --umount /proc
     apt-get-update --host
 
     echo $"Making a build farm for ${VERSION} done."
@@ -613,9 +672,11 @@ Show-Info(){
 
 RPM_Remove(){
     setup-vbootstrap-rpm || return 1
+    mount-chroot /proc
     mount-chroot unionfs_dir
     mount-chroot archives_dir
-    mount-chroot vfs
+    mount-chroot /dev/pts
+    mount-chroot /dev/shm
     apt-get-update --chroot
 
     [ -f $RPM_PKG ] && \
@@ -624,9 +685,11 @@ RPM_Remove(){
 
     write-vbuilder-log "remove-rpm $RPM_PKG"
 
-    mount-chroot --umount vfs
+    mount-chroot --umount /dev/shm
+    mount-chroot --umount /dev/pts
     mount-chroot --umount archives_dir
     mount-chroot --umount unionfs_dir
+    mount-chroot --umount /proc
     apt-get-update --host
 
     return 0
@@ -634,18 +697,23 @@ RPM_Remove(){
 
 RPM_Install(){
     setup-vbootstrap-rpm || return 1
+    mount-chroot /proc
     mount-chroot unionfs_dir
     mount-chroot archives_dir
-    mount-chroot vfs
+    mount-chroot /dev/pts
+    mount-chroot /dev/shm
+
     apt-get-update --chroot
 
     $__chroot_sh "cd ${BUILD_DIR} && apt-get -y install $BASE_RPM_PKG"
 
     write-vbuilder-log "install-rpm $RPM_PKG"
 
-    mount-chroot --umount vfs
+    mount-chroot --umount /dev/shm
+    mount-chroot --umount /dev/pts
     mount-chroot --umount archives_dir
     mount-chroot --umount unionfs_dir
+    mount-chroot --umount /proc
     apt-get-update --host
 
     return 0
@@ -653,9 +721,11 @@ RPM_Install(){
 
 RPM_Build(){
     setup-vbootstrap-rpm || return 1
+    mount-chroot /proc
     mount-chroot unionfs_dir
     mount-chroot archives_dir
-    mount-chroot vfs
+    mount-chroot /dev/pts
+    mount-chroot /dev/shm
     apt-get-update --chroot
 
     [ ! -f $RPM_PKG ] && \
@@ -696,9 +766,11 @@ RPM_Build(){
 
     write-vbuilder-log "build-rpm $RPM_PKG"
 
-    mount-chroot --umount vfs
+    mount-chroot --umount /dev/shm
+    mount-chroot --umount /dev/pts
     mount-chroot --umount archives_dir
     mount-chroot --umount unionfs_dir
+    mount-chroot --umount /proc
     apt-get-update --host
 
     echo $"done."
@@ -732,6 +804,47 @@ RPM_Sign(){
     return 0
 }
 
+Login_Chroot(){
+    [ $with_login -eq 1 ] || return 1
+
+    setup-vbootstrap || return 1
+
+    __chroot="/usr/sbin/chroot ${BUILD_ROOT}"
+    ## setarch ix86 if ix86 chroot on x86_64 host
+    [ $with_ix86_on_x86_64 -eq 1 ] && \
+	__chroot="/usr/sbin/chroot ${BUILD_ROOT} setarch ${VARCH}"
+
+
+    mount-chroot /proc
+    mount-chroot unionfs_dir
+    mount-chroot archives_dir
+    mount-chroot /dev/pts
+    mount-chroot /dev/shm
+    mount-chroot /tmp
+    # mount-chroot /home
+    apt-get-update --chroot
+
+    ## copy host's configurations of /etc
+    #passwd shadow group gshadow
+    for i in resolv.conf hosts; do
+	cp -pf /etc/${i} ${BUILD_ROOT}/etc
+    done
+    cp -Ppf /etc/localtime ${BUILD_ROOT}/etc
+
+    $__chroot /bin/bash || return 1
+
+    # mount-chroot  --umount /home
+    mount-chroot  --umount /tmp
+    mount-chroot --umount /dev/shm
+    mount-chroot --umount /dev/pts
+    mount-chroot --umount archives_dir
+    mount-chroot --umount unionfs_dir
+    mount-chroot --umount /proc
+    apt-get-update --host
+
+    return 0
+}
+
 
 ##############################################################################
 
@@ -745,7 +858,7 @@ while [ $# -gt 0 ]; do
 	--version|--arch|--category|--target|--rpmbuild-define|--rpmbuild-with|--rpmbuild-without|--bootstrap-dir|--unionfs-dir|--cache-dir|--built-rpms-dir)
 	    shift
 	    ;;
-	--dist-upgrade|--unionfs|--with-compat32|--sign|--no-install)
+	--dist-upgrade|--unionfs|--with-compat32|--sign|--no-install|--login|--debug)
 	    ;;
 	--build-rpm|build-rpm|--install-rpm|install-rpm|--remove-rpm|remove-rpm)
 	    shift
@@ -796,6 +909,9 @@ while [ $# -gt 0 ]; do
 	--no-install)
 	    with_no_install=1
 	    ;;
+	--login)
+	    with_login=1
+	    ;;
 	--bootstrap-dir)
 	    VBOOTSTRAP_DIR=$1
 	    ;;
@@ -808,6 +924,9 @@ while [ $# -gt 0 ]; do
 	--built-rpms-dir)
 	    BUILT_RPMS_DIR=$1
 	    ;;
+	--debug)
+	    with_debug=1
+	    ;;
 	--build-rpm|build-rpm)
 	    RPM_PKG=$1
 	    RPM_Build || exit 1
@@ -835,4 +954,6 @@ done
 
 RPM_Sign
 
+Login_Chroot
+
 exit

+ 1 - 1
vchroot.sh.in

@@ -78,7 +78,7 @@ main(){
     for i in resolv.conf hosts; do
 	[ ! -f ${BUILD_ROOT}/etc/${i}.orig ] && \
 	    cp -pf ${BUILD_ROOT}/etc/${i} ${BUILD_ROOT}/etc/${i}.orig && \
-	    cp -pf ${i} ${BUILD_ROOT}/etc
+	    cp -pf /etc/${i} ${BUILD_ROOT}/etc
     done
     cp -Ppf /etc/localtime ${BUILD_ROOT}/etc