vbuilder.sh.in 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661
  1. #!/bin/bash
  2. # -*- coding: utf-8-unix -*-
  3. Usage_C(){
  4. cat<<EOF
  5. Usage: $(basename $0) {--version [version]} {--arch [arch]} {--dist-upgrade} {--target [target]} {--with-compat32} {clean|build|build-rpm [src.rpm]|install-rpm [arch.rpm|package]|remove-rpm [package]}
  6. Options:
  7. --version: set [version] (default: ${DEFAULT_VERSION})
  8. --arch: set [arch] (default: $(uname -i))
  9. --dist-upgrade: make VineSeed bootstrap via ${STABLE_VERSION}
  10. --unionfs cover a bootstrap with unionfs
  11. --target: build rpms with [target]
  12. --with-compat32: build rpms with compat32 on boostrap
  13. Actions:
  14. clean: clean the boostrap of [version]
  15. build: build a boostrap of [version]
  16. build-rpm: build [src.rpm] on a boostrap
  17. install-rpm: install [arch.rpm|package] on a boostrap
  18. remove-rpm: remove [package] on a boostrap
  19. For example,
  20. * make a clean/plain build environment on the current archtecture:
  21. $(basename $0) --clean --build
  22. * build rpms from the specified source rpm:
  23. $(basename $0) --build-rpm [src.rpm]
  24. * make a plain build environment for Vine Linux 4.2:
  25. $(basename $0) --version 4.2 --clean --build
  26. * make a i386 chroot on x86_64:
  27. $(basename $0) --arch i386 --clean --build
  28. * build a kernel package with target i686
  29. $(basename $0) --target i686 --build-rpm [kernel src.rpm]
  30. * build a compat32 package:
  31. $(basename $0) --arch i386 --with-compat32 --build-rpm [src.rpm]
  32. $(/usr/sbin/vbootstrap | sed -e s/^Usage:.*// -e s/^E:.*//)
  33. EOF
  34. }
  35. Usage_ja(){
  36. Usage_C
  37. }
  38. Msg_MissingParameter_C(){
  39. para=$1
  40. cat<<EOF
  41. E: Missing some parameters after ${para}
  42. EOF
  43. }
  44. Msg_MissingParameter_ja(){
  45. para=$1
  46. cat<<EOF
  47. E: ${para} 以後のいくつかのパラメータに間違いがあります
  48. EOF
  49. }
  50. Msg_NoSupportVARCH_C(){
  51. cat<<EOF
  52. E: arch ${VARCH} is NOT supported on $(uname -i)
  53. EOF
  54. }
  55. Msg_NoSupportVARCH_ja(){
  56. cat<<EOF
  57. E: ${VARCH} アーキテクチャは $(uname -i) 上で非サポートです
  58. EOF
  59. }
  60. Msg_NoSupportVERSION_C(){
  61. cat<<EOF
  62. E: ${VERSION} is NOT supported
  63. EOF
  64. }
  65. Msg_NoSupportVERSION_ja(){
  66. cat<<EOF
  67. E: バージョン ${VERSION} は非サポートです
  68. EOF
  69. }
  70. Msg_NoSupportDistUpgradeVERSION_C(){
  71. cat<<EOF
  72. E: version ${VERSION} does not support --dist-upgrade option
  73. EOF
  74. }
  75. Msg_NoSupportDistUpgradeVERSION_ja(){
  76. cat<<EOF
  77. E: バージョン ${VERSION} では --dist-upgrade オプションはサポートされていません
  78. EOF
  79. }
  80. Msg_NoSupportTARGET_C(){
  81. cat<<EOF
  82. E: rpm build target ${TARGET} is NOT supported
  83. EOF
  84. }
  85. Msg_NoSupportTARGET_ja(){
  86. cat<<EOF
  87. E: rpm ビルドターゲット ${TARGET} はサポートされていません
  88. EOF
  89. }
  90. Msg_NotPackageName_C(){
  91. cat<<EOF
  92. E: $RPM_PKG is not a package name
  93. EOF
  94. }
  95. Msg_NotPackageName_ja(){
  96. cat<<EOF
  97. E: $RPM_PKG はパッケージ名でありません
  98. EOF
  99. }
  100. Msg_NotSourceRPM_C(){
  101. cat<<EOF
  102. E: $RPM_PKG is not a source RPM package
  103. EOF
  104. }
  105. Msg_NotSourceRPM_ja(){
  106. cat<<EOF
  107. E: $RPM_PKG はソース RPM パッケージでありません
  108. EOF
  109. }
  110. ##############################################################################
  111. check-parameter(){
  112. if [ -z "$*" ]; then
  113. Usage_$LOCALE
  114. return 1
  115. fi
  116. while [ ! -z "$*" ]; do
  117. case $1 in
  118. --help)
  119. Usage_$LOCALE
  120. return 1
  121. ;;
  122. --version|--arch|--target|--build-rpm|build-rpm|--install-rpm|install-rpm|--remove-rpm|remove-rpm)
  123. shift
  124. check-next-parameter $1 || return 1
  125. ;;
  126. --dist-upgrade|--unionfs|--with-compat32|--build|build|--clean|clean)
  127. ;;
  128. *)
  129. Msg_MissingParameter_$LOCALE $1
  130. return 1
  131. ;;
  132. esac
  133. shift
  134. done
  135. return 0
  136. }
  137. check-next-parameter(){
  138. arg=$1
  139. if [ -z "${arg}" ]; then
  140. Msg_MissingParameter_$LOCALE ${arg}
  141. return 1
  142. fi
  143. if [ $(echo ${arg} | grep '^-') ]; then
  144. Msg_MissingParameter_$LOCALE ${arg}
  145. return 1
  146. fi
  147. return 0
  148. }
  149. setup-vbuilder(){
  150. ## load default settings
  151. if [ -r /etc/vbootstrap/vbuilder.conf ]; then
  152. . /etc/vbootstrap/vbuilder.conf
  153. fi
  154. [ -z "${VBOOTSTRAP_DIR}" ] && \
  155. VBOOTSTRAP_DIR=@@VBUILDER_VBOOTSTRAP_DIR@@
  156. [ -z "${DEFAULT_VERSION}" ] && \
  157. DEFAULT_VERSION=@@VBUILDER_DEFAULT_VERSION@@
  158. [ -z "${BUILT_RPMS_DIR}" ] && \
  159. BUILT_RPMS_DIR=@@VBUILDER_BUILT_RPMS_DIR@@
  160. [ -d $VBOOTSTRAP_DIR ] || mkdir -p $VBOOTSTRAP_DIR
  161. VERSION=$DEFAULT_VERSION
  162. ## current stable relase version
  163. STABLE_VERSION=@@VBUILDER_STABLE_VERSION@@
  164. ## set locale
  165. case $LANG in
  166. ja*) LOCALE=ja ;;
  167. *) LOCALE=C ;;
  168. esac
  169. ## set boolian
  170. with_setup_vbootstrap=0
  171. with_unionfs=0
  172. with_dist_upgrade=0
  173. }
  174. setup-vbootstrap(){
  175. if [ ${with_setup_vbootstrap} -eq 0 ]; then
  176. with_setup_vbootstrap=1
  177. ## check a chroot archtecture
  178. if [ ! -z ${VARCH} ]; then
  179. case "${VARCH}" in
  180. i386|i686|x86_64)
  181. [ "$(uname -i)" = "ppc" ] && \
  182. Msg_NoSupportVARCH_$LOCALE
  183. [ $? -eq 0 ] && exit 1
  184. ;;
  185. ppc)
  186. [ "$(uname -i)" = "i386" -o "$(uname -i)" = "i686" -o "$(uname -i)" = "x86_64" ] && \
  187. Msg_NoSupportVARCH_$LOCALE
  188. [ $? -eq 0 ] && exit 1
  189. ;;
  190. esac
  191. fi
  192. [ -z ${VARCH} ] && VARCH=$(uname -i)
  193. ##!! 4.2 is NO support on VARCH=x86_64
  194. if [ "${VERSION}" = "4.2" -a "${VARCH}" = "x86_64" ]; then
  195. Msg_NoSupportVERSION_${LOCALE}
  196. exit 1
  197. fi
  198. ## support i386 chroot on x86_64 below:
  199. [ "${VARCH}" != "$(uname -i)" ] && VERSION=${VERSION}_${VARCH}
  200. ## check support ${VERSION}
  201. if [ -z "$(/usr/sbin/vbootstrap | sed -e s/^Usage:.*// -e s/^E:.*// | grep -m 1 ${VERSION})" ]; then
  202. Msg_NoSupportVERSION_$LOCALE
  203. exit 1
  204. fi
  205. ## check ${VERSION} equals VineSeed*, when with_dist_upgrade=1
  206. if [ $with_dist_upgrade -eq 1 ]; then
  207. if [ "$(echo ${VERSION} | sed -e "s/\(VineSeed\).*/\1/")" != "VineSeed" ]; then
  208. Msg_NoSupportDistUpgradeVERSION_$LOCALE
  209. exit 1
  210. fi
  211. fi
  212. ## check build target option ${TARGET}
  213. if [ ! -z "${TARGET}" ]; then
  214. RPM_TARGET_LIST="$(cat /usr/lib/rpm/rpmrc | grep arch_canon: | sed -e "s/arch_canon:[[:blank:]]*\(.*\):.*/\1/")"
  215. if [ -z "$(echo $RPM_TARGET_LIST | grep $TARGET)" ]; then
  216. Msg_NoSupportTARGET_$LOCALE
  217. exit 1
  218. fi
  219. fi
  220. fi
  221. MAJOR_VERSION=$(echo ${VERSION} | sed -e "s/_i[0-9]86//")
  222. BUILD_ROOT=${VBOOTSTRAP_DIR}/${VERSION}
  223. BUILD_USER=vbuilder
  224. BUILD_DIR=/home/${BUILD_USER}/rpm
  225. ARCHIVES_DIR=${BUILD_ROOT}/var/cache/apt/archives
  226. CACHE_DIR=${VBOOTSTRAP_DIR}/cache/${VERSION}/apt/archives
  227. UNIONFS_DIR=${VBOOTSTRAP_DIR}/unionfs/${VERSION}
  228. __chroot_sh="/usr/sbin/chroot ${BUILD_ROOT} /bin/sh -c"
  229. mkdir -p $VBOOTSTRAP_DIR
  230. }
  231. setup-vbootstrap-rpm(){
  232. setup-vbootstrap
  233. ## check ${BUILD_ROOT}
  234. [ -d ${BUILD_ROOT} ] || Build
  235. DIST_RELEASE=$(cat ${BUILD_ROOT}/etc/vine-release | cut -f3 -d" " | cut -f1 -d.)
  236. if [ -f $RPM_PKG ]; then
  237. BASE_RPM_PKG=$(basename $RPM_PKG)
  238. cp -f $RPM_PKG $BUILD_ROOT${BUILD_DIR}
  239. else
  240. BASE_RPM_PKG=$RPM_PKG
  241. fi
  242. }
  243. ## recover apt-get data on host/chroot
  244. apt-get-update(){
  245. case $1 in
  246. --host)
  247. echo -n "apt-get update on host ... "
  248. apt-get -qq update > /dev/null 2>&1
  249. echo "done."
  250. ;;
  251. --chroot)
  252. echo -n "apt-get update on chroot ... "
  253. $__chroot_sh 'apt-get -qq update' > /dev/null 2>&1
  254. echo "done."
  255. ;;
  256. *)
  257. echo apt-get-update: unknown option $1
  258. exit 1
  259. ;;
  260. esac
  261. }
  262. ## mount-chroot {|--umount} [file system|name]
  263. ## support file systems: /home /tmp /sys /proc /dev/shm /dev/pts /dev
  264. ## support name: vfs chache_dir
  265. ## NOTE: /tmp needs for applications which use X
  266. ## vfs is virtual file systems
  267. ## cache_dir is ${CACHE_DIR} to ${ARCHIVES_DIR}
  268. mount-chroot(){
  269. if [ "$1" = "--umount" ]; then
  270. mount-chroot-umount $2 || return 1
  271. else
  272. mount-chroot-mount $1 || return 1
  273. fi
  274. return 0
  275. }
  276. ## mount-chroot-umount [file system|name]
  277. mount-chroot-umount(){
  278. local fs=$1
  279. case $fs in
  280. /home|/tmp|/sys|/proc|/dev/shm|/dev/pts|/dev)
  281. [ -d ${BUILD_ROOT}${fs} ] || return 1
  282. [ -z "$(mount | grep ${BUILD_ROOT}${fs})" ] || \
  283. umount ${BUILD_ROOT}${fs}
  284. return 0
  285. ;;
  286. vfs)
  287. # for dir in /sys /proc /dev/shm /dev/pts /dev; do
  288. # mount-chroot-umount ${dir} || return 1
  289. # done
  290. [ -d ${BUILD_ROOT}/proc ] || return 1
  291. [ -z "$(mount | grep ${BUILD_ROOT}/proc)" ] || \
  292. umount ${BUILD_ROOT}/proc
  293. return 0
  294. ;;
  295. cache_dir)
  296. [ -d ${ARCHIVES_DIR} ] || return 1
  297. [ -z "$(mount | grep ${ARCHIVES_DIR})" ] || \
  298. umount ${ARCHIVES_DIR}
  299. return 0
  300. ;;
  301. unionfs_dir)
  302. [ -d ${BUILD_ROOT} ] || return 1
  303. [ -z "$(mount | grep ${BUILD_ROOT} | grep unionfs)" ] || \
  304. umount ${BUILD_ROOT}
  305. if [ ! -z "$(mount | grep ${BUILD_ROOT} | grep unionfs)" ]; then
  306. echo "Retry lazy unmount ... "
  307. umount -l ${BUILD_ROOT}
  308. echo "done."
  309. fi
  310. return 0
  311. ;;
  312. *)
  313. echo mount-chroot-umount: unknown file system $fs
  314. exit 1
  315. ;;
  316. esac
  317. }
  318. ## mount-chroot-mount [file system|name]
  319. mount-chroot-mount(){
  320. local fs=$1
  321. local mnt_opts=""
  322. case $fs in
  323. /home)
  324. mnt_opts="-o rbind"
  325. ;;
  326. *)
  327. mnt_opts="--bind"
  328. ;;
  329. esac
  330. case $fs in
  331. /home|/tmp|/sys|/proc|/dev/shm|/dev/pts|/dev)
  332. [ -d ${BUILD_ROOT}${fs} ] || mkdir -p ${BUILD_ROOT}${fs}
  333. [ -z "$(mount | grep ${BUILD_ROOT}${fs})" ] && \
  334. mount ${mnt_opts} ${fs} ${BUILD_ROOT}${fs}
  335. return 0
  336. ;;
  337. vfs)
  338. # for dir in /dev /dev/pts /dev/shm /proc /sys; do
  339. # mount-chroot-mount ${dir} || return 1
  340. # done
  341. mount-chroot-mount /proc || return 1
  342. return 0
  343. ;;
  344. cache_dir)
  345. [ -d ${CACHE_DIR} ] || mkdir -p ${CACHE_DIR}
  346. [ -d ${ARCHIVES_DIR} ] || mkdir -p ${ARCHIVES_DIR}
  347. [ -z "$(mount | grep ${ARCHIVES_DIR})" ] && \
  348. mount ${mnt_opts} ${CACHE_DIR} ${ARCHIVES_DIR}
  349. [ -d ${ARCHIVES_DIR}/partial ] || mkdir -p ${ARCHIVES_DIR}/partial
  350. return 0
  351. ;;
  352. unionfs_dir)
  353. if [ $with_unionfs -eq 1 ]; then
  354. [ -d ${UNIONFS_DIR} ] || mkdir -p ${UNIONFS_DIR}
  355. [ -z "$(mount | grep ${BUILD_ROOT})" ] && \
  356. mount -t unionfs -o dirs=${UNIONFS_DIR}=rw:${BUILD_ROOT}=ro unionfs ${BUILD_ROOT}
  357. unionctl ${BUILD_ROOT} --list
  358. fi
  359. return 0
  360. ;;
  361. *)
  362. echo mount-chroot-mount: unknown file system $fs
  363. exit 1
  364. ;;
  365. esac
  366. }
  367. ##############################################################################
  368. Clean(){
  369. setup-vbootstrap
  370. # mount-chroot --umount /home
  371. # mount-chroot --umount /tmp
  372. mount-chroot --umount vfs
  373. mount-chroot --umount cache_dir
  374. mount-chroot --umount unionfs_dir
  375. apt-get-update --host
  376. if [ $with_unionfs -eq 1 ]; then
  377. if [ -d ${UNIONFS_DIR} ]; then
  378. echo -n "Cleaning build root \"${UNIONFS_DIR}\" via unionfs ... "
  379. rm -rf ${UNIONFS_DIR}
  380. echo "done."
  381. fi
  382. else
  383. if [ -d ${BUILD_ROOT} ]; then
  384. echo -n "Cleaning build root \"${BUILD_ROOT}\" ... "
  385. rm -rf ${BUILD_ROOT}
  386. echo "done."
  387. fi
  388. fi
  389. echo "Cleanup a build farm for ${VERSION} done."
  390. }
  391. Build(){
  392. setup-vbootstrap
  393. if [ $with_dist_upgrade -eq 1 ]; then
  394. ## make bootstrap of ${STABLE_VERSION}
  395. /usr/sbin/vbootstrap \
  396. $(echo ${VERSION} | sed -e "s/VineSeed/${STABLE_VERSION}/") \
  397. ${BUILD_ROOT}
  398. ## aim apt-line to VineSeed
  399. sed -i "s/apt ${STABLE_VERSION}/apt VineSeed/g" \
  400. ${BUILD_ROOT}/etc/apt/sources.list.d/main.list
  401. else
  402. /usr/sbin/vbootstrap ${VERSION} ${BUILD_ROOT}
  403. fi
  404. mount-chroot cache_dir
  405. mount-chroot vfs
  406. # mount-chroot /tmp
  407. # mount-chroot /home
  408. $__chroot_sh 'apt-get -qq update && apt-get -qq -y dist-upgrade'
  409. ##!! 4.2 has no apt-sourceslist-{plus,nonfree} packages
  410. if [ "${MAJOR_VERSION}" != "4.2" ]; then
  411. $__chroot_sh 'apt-get -qq update && apt-get -qq -y install apt-sourceslist-plus'
  412. $__chroot_sh 'apt-get -qq update && apt-get -qq -y install apt-sourceslist-nonfree'
  413. fi
  414. if [ $with_dist_upgrade -eq 1 ]; then
  415. $__chroot_sh 'apt-get -qq update && apt-get -qq -y dist-upgrade'
  416. fi
  417. $__chroot_sh 'apt-get -qq -y install build-essential'
  418. $__chroot_sh 'apt-get -qq -y install self-build-setup'
  419. $__chroot_sh 'apt-get -qq -y install etcskel shadow-utils'
  420. $__chroot_sh 'cd /dev && /sbin/MAKEDEV console'
  421. $__chroot_sh 'cd /dev && /sbin/MAKEDEV null'
  422. $__chroot_sh 'cd /dev && /sbin/MAKEDEV zero'
  423. $__chroot_sh '/usr/sbin/pwconv'
  424. $__chroot_sh "/usr/sbin/useradd ${BUILD_USER}"
  425. ##!! for rpm-4.8.0 or higher
  426. ##!! (See http://trac.vinelinux.org/wiki/Vine6/AboutUpdateToolchain)
  427. if [ "$(echo ${VERSION} | sed -e "s/\(VineSeed\).*/\1/")" = "VineSeed" ]; then
  428. $__chroot_sh "sed -i -e 's/^%_topdir/#%_topdir/' /home/${BUILD_USER}/.rpmmacros"
  429. fi
  430. # mount-chroot --umount /home
  431. # mount-chroot --umount /tmp
  432. mount-chroot --umount vfs
  433. mount-chroot --umount cache_dir
  434. apt-get-update --host
  435. echo "Making a build farm for ${VERSION} done."
  436. }
  437. RPM_Remove(){
  438. setup-vbootstrap-rpm
  439. mount-chroot unionfs_dir
  440. mount-chroot cache_dir
  441. mount-chroot vfs
  442. apt-get-update --chroot
  443. if [ -f $RPM_PKG ]; then
  444. Msg_NotPackageName_$LOCALE
  445. exit 1
  446. fi
  447. $__chroot_sh "apt-get -y remove $BASE_RPM_PKG"
  448. mount-chroot --umount vfs
  449. mount-chroot --umount cache_dir
  450. mount-chroot --umount unionfs_dir
  451. apt-get-update --host
  452. }
  453. RPM_Install(){
  454. setup-vbootstrap-rpm
  455. mount-chroot unionfs_dir
  456. mount-chroot cache_dir
  457. mount-chroot vfs
  458. apt-get-update --chroot
  459. $__chroot_sh "cd ${BUILD_DIR} && apt-get -y install $BASE_RPM_PKG"
  460. mount-chroot --umount vfs
  461. mount-chroot --umount cache_dir
  462. mount-chroot --umount unionfs_dir
  463. apt-get-update --host
  464. }
  465. RPM_Build(){
  466. setup-vbootstrap-rpm
  467. mount-chroot unionfs_dir
  468. mount-chroot cache_dir
  469. mount-chroot vfs
  470. apt-get-update --chroot
  471. if [ ! -f $RPM_PKG ]; then
  472. Msg_NotSourceRPM_$LOCALE
  473. exit 1
  474. fi
  475. RPM_PKG_USER=$(stat -c %U $RPM_PKG)
  476. RPM_PKG_GROUP=$(stat -c %G $RPM_PKG)
  477. [ ! -z "${SUDO_UID}" ] && RPM_PKG_USER=${SUDO_UID}
  478. [ ! -z "${SUDO_GID}" ] && RPM_PKG_GROUP=${SUDO_GID}
  479. local __install="install -p -v -o ${RPM_PKG_USER} -g ${RPM_PKG_GROUP}"
  480. RPM_PKG_ARCH_LIST="RPMS/i386 RPMS/i686 RPMS/x86_64 RPMS/ppc RPMS/noarch SRPMS"
  481. [ -z "${TARGET}" ] || \
  482. RPM_PKG_ARCH_LIST="RPMS/${TARGET} ${RPM_PKG_ARCH_LIST}"
  483. ## make src.rpm for $VERSION
  484. $__chroot_sh "cd ${BUILD_DIR} && su ${BUILD_USER} -c 'rpm -ivh $BASE_RPM_PKG'"
  485. $__chroot_sh "cd ${BUILD_DIR} && su ${BUILD_USER} -c 'rpmbuild -bs --nodeps --clean --rmsource --rmspec ${BUILD_DIR}/SPECS/*.spec'"
  486. ## change ${DIST_RELEASE}
  487. BASE_RPM_PKG=$(echo $BASE_RPM_PKG | sed -e "s/vl\([0-9]*\)\./vl${DIST_RELEASE}\./")
  488. ## rebuild $BASE_RPM_PKG on ${DIST_RELEASE}
  489. $__chroot_sh "cd ${BUILD_DIR}/SRPMS && apt-get -y build-dep $BASE_RPM_PKG"
  490. $__chroot_sh "cd ${BUILD_DIR}/SRPMS && su ${BUILD_USER} -c 'rpmbuild --rebuild $RPM_OPTS $BASE_RPM_PKG'"
  491. $__chroot_sh "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')"
  492. ## copy built rpms to ${HOME}/rpm/ for each archtectures
  493. echo "Copying built rpms to ${HOME}/rpm/ for each archtectures ... "
  494. for i in $RPM_PKG_ARCH_LIST; do \
  495. if [ -d $BUILD_ROOT${BUILD_DIR}/${i} ]; then
  496. if [ ! -d ${BUILT_RPMS_DIR}/${MAJOR_VERSION}/${i} ]; then
  497. $__install -d ${BUILT_RPMS_DIR}/${MAJOR_VERSION}/${i}/
  498. chown -R ${RPM_PKG_USER}:${RPM_PKG_GROUP} ${BUILT_RPMS_DIR}
  499. fi
  500. find $BUILD_ROOT${BUILD_DIR}/${i} -type f -regex '.*\.rpm' \
  501. -exec $__install -m0644 {} ${BUILT_RPMS_DIR}/${MAJOR_VERSION}/${i}/ \;
  502. fi
  503. done
  504. mount-chroot --umount vfs
  505. mount-chroot --umount cache_dir
  506. mount-chroot --umount unionfs_dir
  507. apt-get-update --host
  508. echo "done."
  509. }
  510. ##############################################################################
  511. setup-vbuilder
  512. check-parameter $* || exit 1
  513. while [ $# -gt 0 ]; do
  514. tmpARG=$1
  515. case $tmpARG in
  516. --version|--arch|--target|--build-rpm|build-rpm|--install-rpm|install-rpm|--remove-rpm|remove-rpm)
  517. shift
  518. ;;
  519. --dist-upgrade|--unionfs|--with-compat32|--build|build|--clean|clean)
  520. ;;
  521. *)
  522. echo unknown option $1
  523. exit 1
  524. ;;
  525. esac
  526. case $tmpARG in
  527. --version)
  528. VERSION=$1
  529. ;;
  530. --arch)
  531. VARCH=$1
  532. ;;
  533. --dist-upgrade)
  534. with_dist_upgrade=1
  535. ;;
  536. --unionfs)
  537. with_unionfs=1
  538. ;;
  539. --target)
  540. TARGET=$1
  541. RPM_OPTS="${RPM_OPTS} --target $TARGET"
  542. ;;
  543. --with-compat32)
  544. RPM_OPTS="${RPM_OPTS} --with compat32"
  545. ;;
  546. --build-rpm|build-rpm)
  547. RPM_PKG=$1
  548. RPM_Build || exit 1
  549. ;;
  550. --install-rpm|install-rpm)
  551. RPM_PKG=$1
  552. RPM_Install || exit 1
  553. ;;
  554. --remove-rpm|remove-rpm)
  555. RPM_PKG=$1
  556. RPM_Remove || exit 1
  557. ;;
  558. --build|build)
  559. Build
  560. ;;
  561. --clean|clean)
  562. Clean
  563. ;;
  564. esac
  565. shift
  566. done
  567. exit