[Piuparts-commits] [piuparts] 01/01: Add log-alternatives custom script (Closes: #850917)

Holger Levsen holger at layer-acht.org
Sun Feb 26 15:33:55 UTC 2017


This is an automated email from the git hooks/post-receive script.

holger pushed a commit to branch develop
in repository piuparts.

commit 285e9811cbed6d736a6beacc7d445b150f1452bc
Author: Michael Stapelberg <stapelberg at debian.org>
Date:   Sun Jan 22 18:58:55 2017 +0100

    Add log-alternatives custom script (Closes: #850917)
    
    This script replaces /usr/bin/update-alternatives with a wrapper script
    that logs its invocations, generating output like the following:
    
        LOG-ALTERNATIVES: dpkg=vim: piuparts=vim: /usr/bin/update-alternatives --install /usr/bin/vi vi /usr/bin/vim.basic 30 --slave /usr/share/man/fr/man1/vi.1.gz vi.fr.1.gz /usr/share/man/fr/man1/vim.1.gz --slave /usr/share/man/it/man1/vi.1.gz vi.it.1.gz /usr/share/man/it/man1/vim.1.gz --slave /usr/share/man/pl/man1/vi.1.gz vi.pl.1.gz /usr/share/man/pl/man1/vim.1.gz --slave /usr/share/man/ru/man1/vi.1.gz vi.ru.1.gz /usr/share/man/ru/man1/vim.1.gz --slave /usr/share/man/ja/man1/vi.1.gz  [...]
    
    Closes: #850917
    
    Signed-off-by: Holger Levsen <holger at layer-acht.org>
---
 .../scripts-log-alternatives/post_install_log_alternatives  |  7 +++++++
 .../scripts-log-alternatives/pre_install_log_alternatives   | 13 +++++++++++++
 debian/changelog                                            |  4 ++++
 3 files changed, 24 insertions(+)

diff --git a/custom-scripts/scripts-log-alternatives/post_install_log_alternatives b/custom-scripts/scripts-log-alternatives/post_install_log_alternatives
new file mode 100755
index 0000000..be99f18
--- /dev/null
+++ b/custom-scripts/scripts-log-alternatives/post_install_log_alternatives
@@ -0,0 +1,7 @@
+#!/bin/sh
+
+[ ! -e /usr/bin/update-alternatives.orig ] && exit 0
+rm /usr/bin/update-alternatives
+dpkg-divert --rename --remove /usr/bin/update-alternatives
+cat /tmp/log-alternatives.log
+rm /tmp/log-alternatives.log
diff --git a/custom-scripts/scripts-log-alternatives/pre_install_log_alternatives b/custom-scripts/scripts-log-alternatives/pre_install_log_alternatives
new file mode 100755
index 0000000..0dcf6a2
--- /dev/null
+++ b/custom-scripts/scripts-log-alternatives/pre_install_log_alternatives
@@ -0,0 +1,13 @@
+#!/bin/sh
+
+# Do nothing if the script already ran.
+# The pre_install step can be run multiple times.
+[ -e /usr/bin/update-alternatives.orig ] && exit 0
+
+dpkg-divert --divert /usr/bin/update-alternatives.orig --rename /usr/bin/update-alternatives
+cat >/usr/bin/update-alternatives <<'EOT'
+#!/bin/sh
+echo "LOG-ALTERNATIVES: dpkg=${DPKG_MAINTSCRIPT_PACKAGE}: piuparts=${PIUPARTS_OBJECTS}: $0 $@" >>/tmp/log-alternatives.log
+exec /usr/bin/update-alternatives.orig "$@"
+EOT
+chmod +x /usr/bin/update-alternatives
diff --git a/debian/changelog b/debian/changelog
index 9ec842a..6b569f2 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -32,6 +32,10 @@ piuparts (0.76) UNRELEASED; urgency=medium
     - Announce 2nd piuparts-slave and explain this is a three host setup now.
     - Make "contribute" a link.
 
+  [ Michael Stapelberg ]
+  * Add support for logging update-alternatives calls using optional
+    custom-scripts/scripts-log-alternatives/  (Closes: #850917)
+
  -- Andreas Beckmann <anbe at debian.org>  Mon, 06 Feb 2017 01:11:27 +0100
 
 piuparts (0.75) unstable; urgency=medium

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/piuparts/piuparts.git



More information about the Piuparts-commits mailing list