aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog9
-rwxr-xr-xpbuilder31
-rwxr-xr-xpbuilder-buildpackage15
-rw-r--r--pbuilder-buildpackage-funcs2
-rwxr-xr-xpbuilder-createbuildenv11
-rw-r--r--pbuilder-modules18
-rwxr-xr-xpbuilder-updatebuildenv14
-rwxr-xr-xpbuilder-user-mode-linux4
8 files changed, 77 insertions, 27 deletions
diff --git a/ChangeLog b/ChangeLog
index 95ed0ab..9ac2e82 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,14 @@
2007-05-27 Junichi Uekawa <dancer@debian.org>
+ * pbuilder-updatebuildenv:
+ * pbuilder-createbuildenv: exit 0 at end.
+
+ * pbuilder-buildpackage (BUILD_PID): explicitly call trap to
+ untrap unexpected exit cases. Unexpected cases should exit 1,
+ expected exit cases should exit 0.
+
+ * pbuilder-user-mode-linux: change all 'trap' functions to be postfixed with _trap
+
* pbuilder-createbuildenv:
* pbuilder-updatebuildenv: trap sighup as well as exit.
diff --git a/pbuilder b/pbuilder
index a0a49fe..1777c2f 100755
--- a/pbuilder
+++ b/pbuilder
@@ -55,10 +55,10 @@ case "$1" in
. /usr/lib/pbuilder/pbuilder-checkparams
. /usr/lib/pbuilder/pbuilder-runhooks
extractbuildplace
- trap umountproc_cleanbuildplace exit sighup
+ trap umountproc_cleanbuildplace_trap exit sighup
loadhooks
recover_aptcache
- trap saveaptcache_umountproc_cleanbuildplace exit sighup
+ trap saveaptcache_umountproc_cleanbuildplace_trap exit sighup
if [ "${INTERNAL_BUILD_UML}" = "yes" ]; then
echo " -> entering the shell"
@@ -72,21 +72,28 @@ File extracted to: $BUILDPLACE
save_aptcache
- trap umountproc_cleanbuildplace exit sighup
+ trap umountproc_cleanbuildplace_trap exit sighup
# saving the place afterwards
if [ "${SAVE_AFTER_LOGIN}" = "yes" ]; then
if [ "${INTERNAL_BUILD_UML}" = "yes" ]; then
echo "E: Invalid combination of internal-build-uml and save-after-login flags" >&2
+ exit 1
else
echo " -> Saving the results, modifications to this session will persist"
unloadhooks
umountproc
- trap cleanbuildplace exit sighup
+ trap cleanbuildplace_trap exit sighup
${CHROOTEXEC} /usr/bin/apt-get clean || true
create_basetgz
+ cleanbuildplace
+ trap exit sighup
+ exit 0
fi
fi
+ umountproc_cleanbuildplace
+ trap exit sighup
+ exit 0
;;
--execute|execute)
# try to execute arbitrary program.
@@ -101,11 +108,11 @@ File extracted to: $BUILDPLACE
fi;
extractbuildplace
- trap umountproc_cleanbuildplace exit sighup
+ trap umountproc_cleanbuildplace_trap exit sighup
loadhooks
recover_aptcache
- trap saveaptcache_umountproc_cleanbuildplace exit sighup
+ trap saveaptcache_umountproc_cleanbuildplace_trap exit sighup
RUNNAME="$BUILDPLACE/run"
cat "$EXECPROGRAM" > "$RUNNAME"
@@ -115,7 +122,7 @@ File extracted to: $BUILDPLACE
rm -f "$RUNNAME"
save_aptcache
- trap umountproc_cleanbuildplace exit sighup
+ trap umountproc_cleanbuildplace_trap exit sighup
# saving the place afterwards
if [ "${SAVE_AFTER_LOGIN}" = "yes" ]; then
@@ -125,18 +132,24 @@ File extracted to: $BUILDPLACE
echo " -> Saving the results, modifications to this session will persist"
unloadhooks
umountproc
- trap cleanbuildplace exit sighup
+ trap cleanbuildplace_trap exit sighup
${CHROOTEXEC} /usr/bin/apt-get clean || true
create_basetgz
+ cleanbuildplace
+ trap exit sighup
+ exit 0
fi
fi
+ umountproc_cleanbuildplace
+ trap exit sighup
+ exit 0
;;
--dumpconfig|dumpconfig)
shift
. /usr/lib/pbuilder/pbuilder-checkparams
. /usr/lib/pbuilder/pbuilder-runhooks
extractbuildplace
- trap umountproc_cleanbuildplace exit sighup
+ trap umountproc_cleanbuildplace_trap exit sighup
loadhooks
executehooks "F"
echo " -> start dump config"
diff --git a/pbuilder-buildpackage b/pbuilder-buildpackage
index 4121c62..a71ff60 100755
--- a/pbuilder-buildpackage
+++ b/pbuilder-buildpackage
@@ -52,7 +52,7 @@ export HOME="/tmp/buildd"
echobacktime
extractbuildplace
-trap umountproc_cleanbuildplace exit sighup
+trap umountproc_cleanbuildplace_trap exit sighup
loadhooks
if [ ! -d "${BUILDRESULT}" ]; then
@@ -89,10 +89,10 @@ recover_aptcache
createbuilduser
echo "Installing the build-deps"
executehooks "D"
-trap saveaptcache_umountproc_cleanbuildplace exit sighup
+trap saveaptcache_umountproc_cleanbuildplace_trap exit sighup
checkbuilddep "$PACKAGENAME"
save_aptcache
-trap umountproc_cleanbuildplace exit sighup
+trap umountproc_cleanbuildplace_trap exit sighup
echo "Copying source file"
copydsc "$PACKAGENAME" "$BUILDPLACE/tmp/buildd"
@@ -139,7 +139,7 @@ else
fi
if ! wait ${BUILD_PID}; then
- trap umountproc_cleanbuildplace exit sighup
+ trap umountproc_cleanbuildplace_trap exit sighup
eval "${KILL_WAIT_PID}"
echo "pbuilder: Failed autobuilding of package" >&2
executehooks "C"
@@ -149,10 +149,10 @@ else
# build was successful
fi
-trap umountproc_cleanbuildplace exit sighup
+trap umountproc_cleanbuildplace_trap exit sighup
executehooks "B"
save_aptcache
-trap cleanbuildplace exit sighup
+trap cleanbuildplace_trap exit sighup
umountproc
@@ -164,4 +164,7 @@ else
echo "E: BUILDRESULT=[$BUILDRESULT] is not a directory." >&2
fi
+cleanbuildplace
+trap exit sighup
echobacktime
+exit 0
diff --git a/pbuilder-buildpackage-funcs b/pbuilder-buildpackage-funcs
index 9104d27..d220c76 100644
--- a/pbuilder-buildpackage-funcs
+++ b/pbuilder-buildpackage-funcs
@@ -43,7 +43,7 @@ function checkbuilddep () {
# If asked to preserve the build place, and pbuilder-satisfydepends
# didn't taint it, then don't clean it when exiting.
if [ $? -eq 2 -a "${PRESERVE_BUILDPLACE}" = "yes" ]; then
- trap umountproc exit sighup
+ trap umountproc_trap exit sighup
fi
echo "E: pbuilder-satisfydepends failed." >&2
exit 2
diff --git a/pbuilder-createbuildenv b/pbuilder-createbuildenv
index 313d446..8f9c835 100755
--- a/pbuilder-createbuildenv
+++ b/pbuilder-createbuildenv
@@ -81,7 +81,7 @@ executehooks "G"
echo "Refreshing the base.tgz "
echo " -> upgrading packages"
mountproc
-$TRAP umountproc_cleanbuildplace exit sighup
+$TRAP umountproc_cleanbuildplace_trap exit sighup
$CHROOTEXEC /usr/bin/apt-get update
if [ -n "$REMOVEPACKAGES" ]; then
$CHROOTEXEC /usr/bin/dpkg --purge $REMOVEPACKAGES
@@ -95,13 +95,16 @@ executehooks "E"
unloadhooks
umountproc
$CHROOTEXEC /usr/bin/apt-get clean || true
-
-$TRAP cleanbuildplace exit sighup
+$TRAP cleanbuildplace_trap exit sighup
# Internal_build_uml is set when --no-targz is set, this code is actually never called from pbuilder-user-mode-linux
if [ ! "${INTERNAL_BUILD_UML}" = "yes" ]; then
create_basetgz
fi
if [ "${PRESERVE_BUILDPLACE}" = "yes" ]; then
- trap exit sighup
+ :
+else
+ cleanbuildplace
fi
+trap exit sighup
+exit 0
diff --git a/pbuilder-modules b/pbuilder-modules
index 04a97d1..cfa860c 100644
--- a/pbuilder-modules
+++ b/pbuilder-modules
@@ -432,6 +432,24 @@ function create_basetgz() {
)
}
+# all trap hooks that should lead to 'exit'; and error exit.
+function cleanbuildplace_trap () {
+ cleanbuildplace
+ exit 1
+}
+function saveaptcache_umountproc_cleanbuildplace_trap () {
+ saveaptcache_umountproc_cleanbuildplace
+ exit 1
+}
+function umountproc_cleanbuildplace_trap () {
+ umountproc_cleanbuildplace
+ exit 1
+}
+function umountproc_trap () {
+ umountproc
+ exit 1
+}
+
#Setting environmental variables that are really required:
#required for some packages to install...
export LANG=C
diff --git a/pbuilder-updatebuildenv b/pbuilder-updatebuildenv
index d6abe49..fb5bdfd 100755
--- a/pbuilder-updatebuildenv
+++ b/pbuilder-updatebuildenv
@@ -32,7 +32,7 @@ else
fi
extractbuildplace
-$TRAP umountproc_cleanbuildplace exit sighup
+$TRAP umountproc_cleanbuildplace_trap exit sighup
loadhooks
echo "Refreshing the base.tgz "
@@ -43,7 +43,7 @@ if [ -n "$REMOVEPACKAGES" ]; then
fi
recover_aptcache
-$TRAP saveaptcache_umountproc_cleanbuildplace exit sighup
+$TRAP saveaptcache_umountproc_cleanbuildplace_trap exit sighup
$CHROOTEXEC /usr/bin/apt-get -y --force-yes "${FORCE_CONFNEW[@]}" dist-upgrade
$CHROOTEXEC /usr/bin/apt-get -y --force-yes install build-essential dpkg-dev apt $EXTRAPACKAGES
save_aptcache
@@ -62,17 +62,21 @@ if [ "${AUTOCLEANAPTCACHE}" = "yes" -a -n "$APTCACHE" ]; then
done
fi
-$TRAP umountproc_cleanbuildplace exit sighup
+$TRAP umountproc_cleanbuildplace_trap exit sighup
executehooks "E"
unloadhooks
umountproc
$CHROOTEXEC /usr/bin/apt-get clean || true
-$TRAP cleanbuildplace exit sighup
+$TRAP cleanbuildplace_trap exit sighup
if [ ! "${INTERNAL_BUILD_UML}" = "yes" ]; then
create_basetgz
fi
if [ "${PRESERVE_BUILDPLACE}" = "yes" ]; then
- trap exit sighup
+ :
+else
+ cleanbuildplace
fi
+trap exit sighup
+exit 0
diff --git a/pbuilder-user-mode-linux b/pbuilder-user-mode-linux
index ca1a1a4..485b1a8 100755
--- a/pbuilder-user-mode-linux
+++ b/pbuilder-user-mode-linux
@@ -21,7 +21,7 @@
set -e
-function cleanup_function () {
+function cleanup_function_trap () {
rm -f ${INSIDE_PBUILDER}
${EXTRACLEANUP}
}
@@ -51,7 +51,7 @@ function operate_uml () {
# opeartes on UML, and runs pbuilder $1
# use this script file to bootstrap the pbuilder inside the UML
INSIDE_PBUILDER=$(tempfile)
- trap cleanup_function exit sighup
+ trap cleanup_function_trap exit sighup
UML_CHROOT_MOUNTPOINT=/var/cache/pbuilder/pbuilder-mnt
UML_CHROOT_BUILDRESULTMOUNTDIR=/var/cache/pbuilder/pbuilder-umlresult
#The following script is ran inside UML as soon as it is started.