Bläddra i källkod

vbuilder.sh.in: extended to store built rpms on chroot env. in each arch. of home rpm dir.

git-svn-id: http://trac.vinelinux.org/repos/projects/vbootstrap/trunk@370 ec354946-7b23-47d6-9f5a-488ba84defc7
munepi 15 år sedan
förälder
incheckning
526cb97ab6
4 ändrade filer med 39 tillägg och 6 borttagningar
  1. 4 1
      Makefile
  2. 3 2
      vbootstrap.spec
  3. 4 0
      vbuilder.conf.in
  4. 28 3
      vbuilder.sh.in

+ 4 - 1
Makefile

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

+ 3 - 2
vbootstrap.spec

@@ -59,8 +59,9 @@ make DESTDIR=$RPM_BUILD_ROOT install
 
 
 %changelog
-* Xxx Xxx XX 2009 Munehiro Yamamoto <munepi@vinelinux.org> 0.0.5-1
-- updated vbuilder.sh.in
+* Sat Oct 31 2009 Munehiro Yamamoto <munepi@vinelinux.org> 0.0.5-1
+- updated vbuilder.sh.in and vbuilder.conf.in
+  - extended to store built rpms on chroot env. in each arch. of home rpm dir.
 
 * Sun Sep 13 2009 Munehiro Yamamoto <munepi@vinelinux.org> 0.0.4-1
 - added vine-release in BASE_PKGS of scripts/*

+ 4 - 0
vbuilder.conf.in

@@ -11,4 +11,8 @@ VBOOTSTRAP_DIR=@@VBUILDER_VBOOTSTRAP_DIR@@
 ## default: DEFAULT_VERSION=@@VBUILDER_DEFAULT_VERSION@@
 DEFAULT_VERSION=@@VBUILDER_DEFAULT_VERSION@@
 
+## Default directory to store built rpms
+## default: BUILT_RPMS_DIR=@@VBUILDER_BUILT_RPMS_DIR@@
+BUILT_RPMS_DIR=@@VBUILDER_BUILT_RPMS_DIR@@
+
 ## end of file

+ 28 - 3
vbuilder.sh.in

@@ -75,6 +75,8 @@ setup-vbuilder(){
 	VBOOTSTRAP_DIR=@@VBUILDER_VBOOTSTRAP_DIR@@
     [ -z "${DEFAULT_VERSION}" ] && \
 	DEFAULT_VERSION=@@VBUILDER_DEFAULT_VERSION@@
+    [ -z "${BUILT_RPMS_DIR}" ] && \
+	BUILT_RPMS_DIR=@@VBUILDER_BUILT_RPMS_DIR@@
     [ -d $VBOOTSTRAP_DIR ] || mkdir -p $VBOOTSTRAP_DIR
     VERSION=$DEFAULT_VERSION
 
@@ -246,12 +248,35 @@ RPM_Build(){
 	echo "$RPM_PKG: not source RPM package."
 	exit 1
     fi
+    
+    RPM_PKG_USER=$(stat -c %U $RPM_PKG)
+    local __install="install -p -v -o ${RPM_PKG_USER} -g ${RPM_PKG_USER}"
+    RPM_PKG_ARCH_LIST="RPMS/i386 RPMS/x86_64 RPMS/ppc RPMS/noarch SRPMS"
+
     /usr/sbin/chroot ${BUILD_ROOT} \
-	/bin/sh -c "cd ${BUILD_DIR} && apt-get -y build-dep $BASE_RPM_PKG"
+    	/bin/sh -c "cd ${BUILD_DIR} && apt-get -y build-dep $BASE_RPM_PKG"
     /usr/sbin/chroot ${BUILD_ROOT} \
-	/bin/sh -c "cd ${BUILD_DIR} && su ${BUILD_USER} -c 'rpmbuild --rebuild $RPM_OPTS $BASE_RPM_PKG'"
+    	/bin/sh -c "cd ${BUILD_DIR} && su ${BUILD_USER} -c 'rpmbuild --rebuild $RPM_OPTS $BASE_RPM_PKG'"
+    /usr/sbin/chroot ${BUILD_ROOT} \
+	/bin/sh -c "cd ${BUILD_DIR} && apt-get -y install $(find $BUILD_ROOT${BUILD_DIR}/RPMS -type f -regex '.*\.rpm' | sed -e s@${BUILD_ROOT}@@g -e 's|.*\/compat32-.*||g' -e 's|.*\/.*\.src\.rpm||g' -e 's/$/ \\/g')"
+
+    ## make src.rpm for $VERSION
     /usr/sbin/chroot ${BUILD_ROOT} \
-	/bin/sh -c "cd ${BUILD_DIR} && apt-get -y install $(find $BUILD_ROOT${BUILD_DIR}/RPMS -type f -regex '.*\.rpm' | sed -e s@${BUILD_ROOT}@@g -e 's|.*\/compat32-.*||g' -e 's/$/ \\/g')"
+    	/bin/sh -c "cd ${BUILD_DIR} && su ${BUILD_USER} -c 'rpm -ivh $BASE_RPM_PKG'"
+    /usr/sbin/chroot ${BUILD_ROOT} \
+	/bin/sh -c "cd ${BUILD_DIR} && su ${BUILD_USER} -c 'rpmbuild -bs --nodeps --clean --rmsource --rmspec ${BUILD_DIR}/SPECS/*.spec'"
+
+    ## copy built rpms to ${HOME}/rpm/ for each archtectures
+    echo "Copying built rpms to ${HOME}/rpm/ for each archtectures ... "
+    for i in $RPM_PKG_ARCH_LIST; do \
+	if [ -d $BUILD_ROOT${BUILD_DIR}/${i} ]; then
+	    [ -d ${BUILT_RPMS_DIR}/${i} ] || \
+		$__install -d ${BUILT_RPMS_DIR}/${i}/
+	    find $BUILD_ROOT${BUILD_DIR}/${i} -type f -regex '.*\.rpm' \
+		-exec $__install -m0644 {} ${BUILT_RPMS_DIR}/${i}/ \;
+	fi
+    done
+    echo "done."
 }