vbuilder.sh.in 16 KB

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