#! /bin/bash # pbuilder -- personal Debian package builder # Copyright (C) 2001-2007 Junichi Uekawa # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA # pbuilder by Junichi Uekawa 2001 Aug 25 set -e # export this so that programs know which command line # operation is currently done export PBCURRENTCOMMANDLINEOPERATION="$1" umask 0022 case "$1" in --create|create) shift; /usr/lib/pbuilder/pbuilder-createbuildenv "$@" ;; --update|update) shift ; /usr/lib/pbuilder/pbuilder-updatebuildenv "$@" ;; --build|build) shift ; /usr/lib/pbuilder/pbuilder-buildpackage "$@" ;; --clean|clean) shift; . /usr/lib/pbuilder/pbuilder-checkparams if [ -n "$BASEBUILDPLACE" ]; then log.i "Cleaning [$BASEBUILDPLACE]" clean_subdirectories "$BASEBUILDPLACE" || true fi if [ -n "$APTCACHE" ]; then log.i "Cleaning [$APTCACHE]" rm -f "$APTCACHE"/* || true fi ;; --login|login) shift . /usr/lib/pbuilder/pbuilder-checkparams extractbuildplace trap umountproc_cleanbuildplace_trap exit sighup copyinputfile "${BUILDPLACE}$BUILDDIR" recover_aptcache trap saveaptcache_umountproc_cleanbuildplace_trap exit sighup if [ "${INTERNAL_BUILD_UML}" = "yes" ]; then log.i "entering the shell" else log.i "entering the shell File extracted to: $BUILDPLACE " fi executehooks "F" (${CHROOTEXEC} bin/bash -c 'exec -a -bash bin/bash') RET=$? save_aptcache trap umountproc_cleanbuildplace_trap exit sighup # saving the place afterwards if [ "${SAVE_AFTER_LOGIN}" = "yes" ]; then if [ "${INTERNAL_BUILD_UML}" = "yes" ]; then log.e "Invalid combination of internal-build-uml and save-after-login flags" exit 1 else log.i "Saving the results, modifications to this session will persist" umountproc trap cleanbuildplace_trap exit sighup ${CHROOTEXEC} /usr/bin/apt-get clean || true create_basetgz cleanbuildplace trap - exit sighup exit $RET fi fi umountproc_cleanbuildplace trap - exit sighup exit $RET ;; --execute|execute) # try to execute arbitrary program. shift . /usr/lib/pbuilder/pbuilder-checkparams EXECPROGRAM="$1" shift if [ ! -f "${EXECPROGRAM}" ]; then log.e "Command line parameter [$EXECPROGRAM] does not exist" exit 1; fi; extractbuildplace trap umountproc_cleanbuildplace_trap exit sighup copyinputfile "${BUILDPLACE}$BUILDDIR" recover_aptcache trap saveaptcache_umountproc_cleanbuildplace_trap exit sighup RUNNAME="$BUILDPLACE/runscript" cat "$EXECPROGRAM" > "$RUNNAME" chmod a+x "$RUNNAME" executehooks "F" ( ${CHROOTEXEC} /runscript "$@" ) RET=$? rm -f "$RUNNAME" save_aptcache trap umountproc_cleanbuildplace_trap exit sighup # saving the place afterwards if [ "${SAVE_AFTER_LOGIN}" = "yes" ]; then if [ "${INTERNAL_BUILD_UML}" = "yes" ]; then log.e "Invalid combination of internal-build-uml and save-after-login flags" else log.i "Saving the results, modifications to this session will persist" umountproc trap cleanbuildplace_trap exit sighup ${CHROOTEXEC} /usr/bin/apt-get clean || true create_basetgz cleanbuildplace trap - exit sighup exit $RET fi fi umountproc_cleanbuildplace trap - exit sighup exit $RET ;; --dumpconfig|dumpconfig) shift . /usr/lib/pbuilder/pbuilder-checkparams extractbuildplace trap umountproc_cleanbuildplace_trap exit sighup executehooks "F" log.i "start dump config" log.i "set" set; log.i "env" env; log.i "end dump config" ;; --debuild|debuild) shift "$0" execute "$@" /usr/lib/pbuilder/pdebuild-internal ;; --help|help) . /usr/lib/pbuilder/pbuilder-modules showhelp exit 0 ;; *) . /usr/lib/pbuilder/pbuilder-modules showhelp exit 1 ;; esac