#! /bin/bash #========================================================================== # Execute any hooks required for this segment # # Title: pbuilder-runhooks # Description User hooks for pbuilder package # Programmed by: Dale Amon # Date: $Date$ # Version: $Revision$ # # $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 muxt be named in the format: # . 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. # # HISTORY: # $Log$ # Revision 1.7 2001/09/27 11:04:54 dancer # removing comment # # Revision 1.6 2001/09/27 11:03:56 dancer # removing pushd and popd. # # Revision 1.5 2001/09/27 09:16:34 dancer # fixing some serious typos . # # Revision 1.4 2001/09/27 08:20:58 dancer # changing little bits to my liking, and hopefully removing any potentially dangerous bits. # # Revision 1.3 2001/09/27 07:13:04 dancer # and even more reindentation. # # Revision 1.2 2001/09/27 07:12:51 dancer # reindent etc. # # Revision 1.1 2001/09/27 07:10:47 dancer # new file from dale amon. # # 20010925 Dale Amon # Created. # Thanks to Jens Ruehmkorf # # for discussions and ideas. # # 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 [ -d "$BUILDPLACE/$hooks" ]; then rm -rf "$BUILDPLACE/$hooks" fi if [ -d "$HOOKDIR" ]; then cp -a "$HOOKDIR" "$BUILDPLACE/tmp/" fi } #-------------------------------------------------------------------------- # Tidy up after ourselves. (Anything we leave behind ends up in base.tgz) # function unloadhooks () { if [ -d "$BUILDPLACE/$hooks" ]; then rm -rf "$BUILDPLACE/$hooks" else echo "E: Logic failure." fi } #-------------------------------------------------------------------------- # 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" for fn in "$BUILDPLACE/$hooks/$prefix"[0-9][0-9]* ; do case "$fn" in *~) echo "E: skipping an editor backup file $fn" ;; *.bak) echo "E: skipping a backup file $fn" ;; *) if [ -x $fn ]; then $CHROOTEXEC "$hooks/"$(basename "$fn") echo " -> user script $fn finished" else filetype=$(readlink -f $(basename "$fn" ) ) echo "E: execute priv not set on file $filetype" fi ;; esac done } #--------------------------------------------------------------------------