This is related to Create meaningful etckeeper commit messages.
I've patched /etc/etckeeper/pre-install.d/50uncommitted-changes as follows (to add support for a "PRECOMMIT" file):
#!/bin/sh
set -e
PRECOMMIT=/root/.etckeeper/pre-install.txt
if etckeeper unclean; then
if [ "$AVOID_COMMIT_BEFORE_INSTALL" = 1 ]; then
echo "" >&2
echo "** etckeeper detected uncommitted changes in /etc prior to $HIGHLEVEL_PACKAGE_MANAGER run" >&2
echo "** Aborting $HIGHLEVEL_PACKAGE_MANAGER run. Manually commit and restart." >&2
echo "" >&2
exit 1
fi
if [ -r "PRECOMMIT" ]; then
MSG=$(cat "$PRECOMMIT")
else
MSG="saving uncommitted changes in /etc prior to $HIGHLEVEL_PACKAGE_MANAGER run"
fi
if ! etckeeper commit "$MSG"; then
echo "warning: etckeeper failed to commit changes in /etc using $VCS" >&2
fi
fi
[ -r "$PRECOMMIT" ] && mv "$PRECOMMIT" "$(basename "$PRECOMMIT" txt).$(date +%Y%m%d.%s)"
And I've written a (Bash) shell function for my /root/bashrc which wraps the apt-get command to create the this "precommit" message (and to rename out of the way).
But I'd prefer to patch the hooks in /etc/apt/apt.conf.d/05etckeeper
My question is: can I capture the apt-get command's arguments from within a DPKG::Pre-Invoke command?