|
@@ -1,18 +1,11 @@
|
|
#!/bin/bash
|
|
#!/bin/bash
|
|
# -*- coding: utf-8-unix -*-
|
|
# -*- coding: utf-8-unix -*-
|
|
|
|
|
|
-## default settings
|
|
|
|
-VBOOTSTRAP_DIR=/var/local/vbootstrap
|
|
|
|
-[ -d $VBOOTSTRAP_DIR ] || mkdir -p $VBOOTSTRAP_DIR
|
|
|
|
-DEFAULT_VERSION=@@DEFAULT_VERSION@@
|
|
|
|
-VERSION=$DEFAULT_VERSION
|
|
|
|
-
|
|
|
|
Usage_C(){
|
|
Usage_C(){
|
|
cat<<EOF
|
|
cat<<EOF
|
|
-Usage: $(basename $0) {--version [version]} {--arch [arch]} {--with-compat32} {--build-rpm [src.rpm]|--install-rpm [arch.rpm]|--remove-rpm [package]|--build|--clean}
|
|
|
|
|
|
+Usage: $(basename $0) {--version [version]} {--arch [arch]} {--build-rpm [src.rpm]|--install-rpm [arch.rpm]|--remove-rpm [package]|--build|--clean}
|
|
--version: set [version] (default: ${DEFAULT_VERSION})
|
|
--version: set [version] (default: ${DEFAULT_VERSION})
|
|
--arch: set [arch] (default: $(uname -i))
|
|
--arch: set [arch] (default: $(uname -i))
|
|
- --with-compat32: build with compat32 on boostrap
|
|
|
|
--build-rpm: build [src.rpm] on boostrap
|
|
--build-rpm: build [src.rpm] on boostrap
|
|
--install-rpm: install [arch.rpm] on boostrap
|
|
--install-rpm: install [arch.rpm] on boostrap
|
|
--remove-rpm: remove [package] on boostrap
|
|
--remove-rpm: remove [package] on boostrap
|
|
@@ -28,29 +21,76 @@ $(basename $0) --build-rpm [src.rpm]
|
|
$(basename $0) --version 4.2 --clean --build
|
|
$(basename $0) --version 4.2 --clean --build
|
|
* make a i386 chroot on x86_64:
|
|
* make a i386 chroot on x86_64:
|
|
$(basename $0) --arch i386 --clean --build
|
|
$(basename $0) --arch i386 --clean --build
|
|
-* build compat32:
|
|
|
|
-$(basename $0) --arch i386 --with-compat32 --build-rpm [src.rpm]
|
|
|
|
|
|
+$(/usr/sbin/vbootstrap | sed -e s/^Usage:.*// -e s/^E:.*//)
|
|
EOF
|
|
EOF
|
|
-exit 1
|
|
|
|
}
|
|
}
|
|
|
|
|
|
Usage_ja(){
|
|
Usage_ja(){
|
|
Usage_C
|
|
Usage_C
|
|
}
|
|
}
|
|
|
|
|
|
-Msg_NoSupportVARCH_C(){
|
|
|
|
- while read varch; do
|
|
|
|
|
|
+Msg_MissingParameter_C(){
|
|
|
|
+ while read para; do
|
|
cat<<EOF
|
|
cat<<EOF
|
|
-${varch} is NO support on $(uname -i)
|
|
|
|
|
|
+E: Missing some parameter before ${para}
|
|
EOF
|
|
EOF
|
|
done
|
|
done
|
|
- exit 1
|
|
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+Msg_MissingParameter_ja(){
|
|
|
|
+ Msg_MissingParameter_C
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+Msg_NoSupportVARCH_C(){
|
|
|
|
+ cat<<EOF
|
|
|
|
+E: arch ${VARCH} is NO support on $(uname -i)
|
|
|
|
+EOF
|
|
}
|
|
}
|
|
|
|
|
|
Msg_NoSupportVARCH_ja(){
|
|
Msg_NoSupportVARCH_ja(){
|
|
Msg_NoSupportVARCH_C
|
|
Msg_NoSupportVARCH_C
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+Msg_NoSupportVERSION_C(){
|
|
|
|
+ cat<<EOF
|
|
|
|
+E: version ${VERSION} is NO support
|
|
|
|
+EOF
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+Msg_NoSupportVERSION_ja(){
|
|
|
|
+ Msg_NoSupportVERSION_C
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+##############################################################################
|
|
|
|
+
|
|
|
|
+setup-vbuilder(){
|
|
|
|
+ ## load default settings
|
|
|
|
+ if [ -d /etc/vbootstrap/vbuilder.conf ]; then
|
|
|
|
+ . /etc/vbootstrap/vbuilder.conf
|
|
|
|
+ else
|
|
|
|
+ [ -z "${VBOOTSTRAP_DIR}" ] && \
|
|
|
|
+ VBOOTSTRAP_DIR=@@VBUILDER_VBOOTSTRAP_DIR@@
|
|
|
|
+ [ -z "${DEFAULT_VERSION}" ] && \
|
|
|
|
+ DEFAULT_VERSION=@@VBUILDER_DEFAULT_VERSION@@
|
|
|
|
+ fi
|
|
|
|
+ [ -d $VBOOTSTRAP_DIR ] || mkdir -p $VBOOTSTRAP_DIR
|
|
|
|
+ VERSION=$DEFAULT_VERSION
|
|
|
|
+
|
|
|
|
+ ## set locale
|
|
|
|
+ case $LANG in
|
|
|
|
+ ja*) LOCALE=ja ;;
|
|
|
|
+ *) LOCALE=C ;;
|
|
|
|
+ esac
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+check-next-parameter(){
|
|
|
|
+ while read arg; do
|
|
|
|
+ if [ $(echo ${arg} | grep '^-') ]; then
|
|
|
|
+ echo ${arg} | Msg_MissingParameter_$LOCALE
|
|
|
|
+ return 1
|
|
|
|
+ fi
|
|
|
|
+ done
|
|
|
|
+}
|
|
|
|
|
|
FLAG_setup_vbootstrap=0
|
|
FLAG_setup_vbootstrap=0
|
|
setup-vbootstrap(){
|
|
setup-vbootstrap(){
|
|
@@ -58,27 +98,45 @@ setup-vbootstrap(){
|
|
FLAG_setup_vbootstrap=1
|
|
FLAG_setup_vbootstrap=1
|
|
|
|
|
|
## check a chroot archtecture
|
|
## check a chroot archtecture
|
|
- [ ! -z ${VARCH} ] && \
|
|
|
|
|
|
+ if [ ! -z ${VARCH} ]; then
|
|
case "${VARCH}" in
|
|
case "${VARCH}" in
|
|
i386)
|
|
i386)
|
|
[ "$(uname -i)" = "ppc" ] && \
|
|
[ "$(uname -i)" = "ppc" ] && \
|
|
- echo ${VARCH} | Msg_NoSupportVARCH_$LOCALE
|
|
|
|
|
|
+ Msg_NoSupportVARCH_$LOCALE
|
|
|
|
+ [ $? -eq 0 ] && exit 1
|
|
;;
|
|
;;
|
|
x86_64)
|
|
x86_64)
|
|
[ "$(uname -i)" = "ppc" ] && \
|
|
[ "$(uname -i)" = "ppc" ] && \
|
|
- echo ${VARCH} | Msg_NoSupportVARCH_$LOCALE
|
|
|
|
|
|
+ Msg_NoSupportVARCH_$LOCALE
|
|
|
|
+ [ $? -eq 0 ] && exit 1
|
|
;;
|
|
;;
|
|
ppc)
|
|
ppc)
|
|
[ "$(uname -i)" = "i386" -o "$(uname -i)" = "x86_64" ] && \
|
|
[ "$(uname -i)" = "i386" -o "$(uname -i)" = "x86_64" ] && \
|
|
- echo ${VARCH} | Msg_NoSupportVARCH_$LOCALE
|
|
|
|
|
|
+ Msg_NoSupportVARCH_$LOCALE
|
|
|
|
+ [ $? -eq 0 ] && exit 1
|
|
;;
|
|
;;
|
|
esac
|
|
esac
|
|
|
|
+ fi
|
|
|
|
+
|
|
[ -z ${VARCH} ] && VARCH=$(uname -i)
|
|
[ -z ${VARCH} ] && VARCH=$(uname -i)
|
|
|
|
|
|
|
|
+ ##!! IRREGULAR: 4.2 is NO support on x86_64
|
|
|
|
+ if [ "${VERSION}" = "4.2" -a "$(uname -i)" = "x86_64" ]; then
|
|
|
|
+ Msg_NoSupportVERSION_${LOCALE}
|
|
|
|
+ exit 1
|
|
|
|
+ fi
|
|
|
|
+
|
|
## support for i386 chroot on x86_64 below:
|
|
## support for i386 chroot on x86_64 below:
|
|
[ "${VARCH}" != "$(uname -i)" ] && VERSION=${VERSION}_${VARCH}
|
|
[ "${VARCH}" != "$(uname -i)" ] && VERSION=${VERSION}_${VARCH}
|
|
|
|
+
|
|
|
|
+ ## check support ${VERSION}
|
|
|
|
+ if [ -z "$(/usr/sbin/vbootstrap | sed -e s/^Usage:.*// -e s/^E:.*// | grep -m 1 ${VERSION})" ]; then
|
|
|
|
+ Msg_NoSupportVERSION_$LOCALE
|
|
|
|
+ exit 1
|
|
|
|
+ fi
|
|
|
|
+
|
|
fi
|
|
fi
|
|
-
|
|
|
|
|
|
+
|
|
BUILD_ROOT=${VBOOTSTRAP_DIR}/${VERSION}
|
|
BUILD_ROOT=${VBOOTSTRAP_DIR}/${VERSION}
|
|
BUILD_USER=vbuilder
|
|
BUILD_USER=vbuilder
|
|
CACHE_DIR=${VBOOTSTRAP_DIR}/cache/${VERSION}
|
|
CACHE_DIR=${VBOOTSTRAP_DIR}/cache/${VERSION}
|
|
@@ -92,14 +150,21 @@ setup-vbootstrap(){
|
|
Clean(){
|
|
Clean(){
|
|
setup-vbootstrap
|
|
setup-vbootstrap
|
|
|
|
|
|
- umount ${BUILD_ROOT}/proc
|
|
|
|
|
|
+ [ -d ${BUILD_ROOT}/proc ] && \
|
|
|
|
+ umount ${BUILD_ROOT}/proc
|
|
|
|
|
|
if [ -d ${BUILD_ROOT}/var/cache/apt/archives ]; then
|
|
if [ -d ${BUILD_ROOT}/var/cache/apt/archives ]; then
|
|
|
|
+ echo -n "Chaching RPMs in ${CACHE_DIR}/apt/archives ... "
|
|
[ -d ${CACHE_DIR}/apt/archives ] || mkdir -p ${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/
|
|
mv -f ${BUILD_ROOT}/var/cache/apt/archives/*.rpm ${CACHE_DIR}/apt/archives/
|
|
|
|
+ echo "done."
|
|
fi
|
|
fi
|
|
|
|
|
|
- rm -rf $BUILD_ROOT/
|
|
|
|
|
|
+ if [ -d ${BUILD_ROOT} ]; then
|
|
|
|
+ echo -n "Cleaning build root \"${BUILD_ROOT}\" ... "
|
|
|
|
+ rm -rf ${BUILD_ROOT}
|
|
|
|
+ echo "done."
|
|
|
|
+ fi
|
|
}
|
|
}
|
|
|
|
|
|
Build(){
|
|
Build(){
|
|
@@ -110,8 +175,11 @@ Build(){
|
|
[ -d ${BUILD_ROOT}/proc ] || mkdir -p ${BUILD_ROOT}/proc
|
|
[ -d ${BUILD_ROOT}/proc ] || mkdir -p ${BUILD_ROOT}/proc
|
|
mount -t proc proc ${BUILD_ROOT}/proc
|
|
mount -t proc proc ${BUILD_ROOT}/proc
|
|
|
|
|
|
- [ -d ${CACHE_DIR} -a "${VARCH}" = "$(uname -i)" ] && \
|
|
|
|
|
|
+ if [ -d ${CACHE_DIR} ]; then
|
|
|
|
+ echo -n "Copying chached RPMs to ${BUILD_ROOT}/var/cache/apt/archives ... "
|
|
cp -f ${CACHE_DIR}/apt/archives/*.rpm ${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} \
|
|
/usr/sbin/chroot ${BUILD_ROOT} \
|
|
/bin/sh -c 'apt-get update && apt-get -y dist-upgrade'
|
|
/bin/sh -c 'apt-get update && apt-get -y dist-upgrade'
|
|
@@ -130,11 +198,16 @@ Build(){
|
|
|
|
|
|
/usr/sbin/chroot ${BUILD_ROOT} /bin/sh -c '/usr/sbin/pwconv'
|
|
/usr/sbin/chroot ${BUILD_ROOT} /bin/sh -c '/usr/sbin/pwconv'
|
|
/usr/sbin/chroot ${BUILD_ROOT} /bin/sh -c "/usr/sbin/useradd ${BUILD_USER}"
|
|
/usr/sbin/chroot ${BUILD_ROOT} /bin/sh -c "/usr/sbin/useradd ${BUILD_USER}"
|
|
|
|
+
|
|
|
|
+ echo "Making a build farm for ${VERSION} done."
|
|
}
|
|
}
|
|
|
|
|
|
setup-vbootstrap-rpm(){
|
|
setup-vbootstrap-rpm(){
|
|
setup-vbootstrap
|
|
setup-vbootstrap
|
|
|
|
|
|
|
|
+ ## check ${BUILD_ROOT}
|
|
|
|
+ [ -d ${BUILD_ROOT} ] || Build
|
|
|
|
+
|
|
if [ -f $RPM_PKG ]; then
|
|
if [ -f $RPM_PKG ]; then
|
|
BASE_RPM_PKG=$(basename $RPM_PKG)
|
|
BASE_RPM_PKG=$(basename $RPM_PKG)
|
|
cp -f $RPM_PKG $BUILD_ROOT${BUILD_DIR}
|
|
cp -f $RPM_PKG $BUILD_ROOT${BUILD_DIR}
|
|
@@ -179,37 +252,45 @@ RPM_Build(){
|
|
|
|
|
|
##############################################################################
|
|
##############################################################################
|
|
|
|
|
|
-case $LANG in
|
|
|
|
- ja*) LOCALE=ja ;;
|
|
|
|
- *) LOCALE=C ;;
|
|
|
|
-esac
|
|
|
|
|
|
+setup-vbuilder
|
|
|
|
|
|
[ $# -eq 0 ] && Usage_$LOCALE
|
|
[ $# -eq 0 ] && Usage_$LOCALE
|
|
while [ $# -gt 0 ]; do
|
|
while [ $# -gt 0 ]; do
|
|
case "$1" in
|
|
case "$1" in
|
|
--version)
|
|
--version)
|
|
shift;
|
|
shift;
|
|
|
|
+ echo $1 | check-next-parameter
|
|
|
|
+ [ $? -eq 1 ] && exit 1
|
|
VERSION=$1
|
|
VERSION=$1
|
|
;;
|
|
;;
|
|
--arch)
|
|
--arch)
|
|
shift;
|
|
shift;
|
|
|
|
+ echo $1 | check-next-parameter
|
|
|
|
+ [ $? -eq 1 ] && exit 1
|
|
VARCH=$1
|
|
VARCH=$1
|
|
;;
|
|
;;
|
|
|
|
+ ##!! This option is obsolete for 5.0 or above higher version on i386.
|
|
--with-compat32)
|
|
--with-compat32)
|
|
RPM_OPTS="--with compat32"
|
|
RPM_OPTS="--with compat32"
|
|
;;
|
|
;;
|
|
--build-rpm)
|
|
--build-rpm)
|
|
shift;
|
|
shift;
|
|
|
|
+ echo $1 | check-next-parameter
|
|
|
|
+ [ $? -eq 1 ] && exit 1
|
|
RPM_PKG=$1
|
|
RPM_PKG=$1
|
|
RPM_Build
|
|
RPM_Build
|
|
;;
|
|
;;
|
|
--install-rpm)
|
|
--install-rpm)
|
|
shift;
|
|
shift;
|
|
|
|
+ echo $1 | check-next-parameter
|
|
|
|
+ [ $? -eq 1 ] && exit 1
|
|
RPM_PKG=$1
|
|
RPM_PKG=$1
|
|
RPM_Install
|
|
RPM_Install
|
|
;;
|
|
;;
|
|
--remove-rpm)
|
|
--remove-rpm)
|
|
shift;
|
|
shift;
|
|
|
|
+ echo $1 | check-next-parameter
|
|
|
|
+ [ $? -eq 1 ] && exit 1
|
|
RPM_PKG=$1
|
|
RPM_PKG=$1
|
|
RPM_Remove
|
|
RPM_Remove
|
|
;;
|
|
;;
|
|
@@ -220,7 +301,8 @@ while [ $# -gt 0 ]; do
|
|
Clean
|
|
Clean
|
|
;;
|
|
;;
|
|
*)
|
|
*)
|
|
- Usage
|
|
|
|
|
|
+ Usage_$LOCALE
|
|
|
|
+ exit 1
|
|
;;
|
|
;;
|
|
esac
|
|
esac
|
|
shift
|
|
shift
|