aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--pbuilder-modules73
-rw-r--r--pbuilder-runhooks109
2 files changed, 78 insertions, 104 deletions
diff --git a/pbuilder-modules b/pbuilder-modules
index 6c2836f..88d38e5 100644
--- a/pbuilder-modules
+++ b/pbuilder-modules
@@ -17,7 +17,7 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
-. "${BASH_SOURCE%/*}/pbuilder-runhooks"
+hooks=tmp/hooks
function showhelp () {
cat <<EOF
@@ -690,6 +690,77 @@ function add_additional_aptkeyrings() {
}
+#==========================================================================
+# hooks stuff
+
+function loadhooks () {
+ if [ -z "$HOOKDIR" ]; then
+ return ;
+ fi
+ if [ -d "$BUILDPLACE/$hooks" ]; then
+ rm -rf "$BUILDPLACE/$hooks"
+ fi
+ if [ -d "$HOOKDIR" ]; then
+ mkdir -p "$BUILDPLACE/$hooks"
+ if ! cp -aL "$HOOKDIR/"* "$BUILDPLACE/$hooks"; then
+ log.w "no hooks found in the hookdir '$HOOKDIR'"
+ fi
+ else
+ log.w "hookdir $HOOKDIR does not exist, skipping"
+ fi
+}
+
+function unloadhooks () {
+ if [ -z "$HOOKDIR" ]; then
+ return ;
+ fi
+ rm -rf "$BUILDPLACE/$hooks"
+}
+
+function executehooks () {
+ # Execute every script found in the chroot'd target directory.
+ # We only test whether a file is executable since we have no idea what
+ # the user had put in their chroots. If they want PL/1 and ADA on the
+ # chroot or they have decided to use emacslisp for everything, it's their
+ # problem.
+ local prefix="$1"
+ if [ -z "$HOOKDIR" ]; then
+ return
+ fi
+ for fn in "$BUILDPLACE/$hooks/$prefix"[0-9][0-9]* ; do
+ case "$fn" in
+ "$BUILDPLACE/$hooks/$prefix"'[0-9][0-9]*')
+ log.w "no hooks of type ${prefix} found -- ignoring"
+ ;;
+ *~)
+ log.w "skipping an editor backup file $fn"
+ ;;
+ *.bak)
+ log.w "skipping a backup file $fn"
+ ;;
+ *)
+ if [ -x "$fn" ]; then
+ log.i "user script $fn starting"
+ BUILDDIR="$BUILDDIR" \
+ $CHROOTEXEC "/$hooks/$(basename "$fn")"
+ log.i "user script $fn finished"
+ else
+ if [ -f "$fn" ]; then
+ filetype=$(basename "$fn" )
+ log.w "execute priv not set on file $filetype, not executing."
+ else
+ # Should it reach here ? This case should be caught in the above case.
+ log.w "no hooks of type ${prefix} found -- internal error in logic"
+ fi
+ fi
+ ;;
+ esac
+ done
+}
+
+#==========================================================================
+
+
#Setting environmental variables that are really required:
#required for some packages to install...
export LANG=C
diff --git a/pbuilder-runhooks b/pbuilder-runhooks
index 8e96e95..5776f47 100644
--- a/pbuilder-runhooks
+++ b/pbuilder-runhooks
@@ -1,106 +1,9 @@
#! /bin/bash
-#==========================================================================
-# Execute any hooks required for this segment
-#
-# Title: pbuilder-runhooks
-# Description User hooks for pbuilder package
-# Programmed by: Dale Amon <amon@vnl.com>
-# $HOOKDIR is set in /etc/pbuilderrc and contains a list of executable
-# programs or scripts. The type is only limited by what you expect will
-# be available in your chrooted environment after debootstrap has done
-# an initial install. The functions must be named in the format:
-# <prefex><digit><digit><descriptive name>. Currently only X is defined;
-# scripts prefixed with X will be run just before the chroot environment
-# is exited and the base.tgz file is created or updated.
+# This file was merged with pbuilder-modules.
+# We can't delete it since it's referenced in pdebuild-internal, and since we
+# can't assure the same pbuilder version outside and inside the chroot we have
+# to be backward-compatible.
+# Otherwise running an old pbuilder with a newer chroot would break badly.
-# $BUILDPLACE is as used in pbuilder. When already inside chroot, this
-# routine can be called with $BUILDPLACE='' (from pdebuild-internal)
-
-# TODO: * Are there any other executable backup types we should
-# filtered besides *~ and *.bak?
-#
-#==========================================================================
-
-hooks=tmp/hooks
-
-#==========================================================================
-# Set up fresh chroot'd hooks tmp script directory
-#
-
-function loadhooks () {
- if [ -z "$HOOKDIR" ]; then
- return ;
- fi
- if [ -d "$BUILDPLACE/$hooks" ]; then
- rm -rf "$BUILDPLACE/$hooks"
- fi
- if [ -d "$HOOKDIR" ]; then
- mkdir -p "$BUILDPLACE/$hooks"
- if ! cp -aL "$HOOKDIR/"* "$BUILDPLACE/$hooks"; then
- log.w "no hooks found in the hookdir '$HOOKDIR'"
- fi
- else
- log.w "hookdir $HOOKDIR does not exist, skipping"
- fi
-}
-
-#--------------------------------------------------------------------------
-# Tidy up after ourselves. (Anything we leave behind ends up in base.tgz)
-#
-
-function unloadhooks () {
- if [ -z "$HOOKDIR" ]; then
- return ;
- fi
- rm -rf "$BUILDPLACE/$hooks"
-}
-
-#--------------------------------------------------------------------------
-# Execute every script found in the chroot'd target directory. We only
-# test for whether a file is executable because we have no idea what
-# the user had put in their dist. If they want PL/1 and ADA on the base
-# dist or have decided to use emacslisp for everything, it's their
-# problem.
-#
-# Args: Required prefix on hook fn name
-# Returns: none
-#
-
-function executehooks () {
- local prefix="$1"
- if [ -z "$HOOKDIR" ]; then
- return
- fi
- for fn in "$BUILDPLACE/$hooks/$prefix"[0-9][0-9]* ; do
- case "$fn" in
- "$BUILDPLACE/$hooks/$prefix"'[0-9][0-9]*')
- log.w "no hooks of type ${prefix} found -- ignoring"
- ;;
- *~)
- log.w "skipping an editor backup file $fn"
- ;;
- *.bak)
- log.w "skipping a backup file $fn"
- ;;
- *)
- if [ -x "$fn" ]; then
- log.i "user script $fn starting"
- BUILDDIR="$BUILDDIR" \
- $CHROOTEXEC "/$hooks/$(basename "$fn")"
- log.i "user script $fn finished"
- else
- if [ -f "$fn" ]; then
- filetype=$(basename "$fn" )
- log.w "execute priv not set on file $filetype, not executing."
- else
- # Should it reach here ? This case should be caught in the above case.
- log.w "no hooks of type ${prefix} found -- internal error in logic"
- fi
- fi
- ;;
- esac
- done
-}
-
-#--------------------------------------------------------------------------
+. "${BASH_SOURCE%/*}/pbuilder-modules"