Put the Ubuntu logging functions in the hooks directory.
authorDidier Raboud <odyx@debian.org>
Tue, 15 May 2012 08:56:51 +0000 (10:56 +0200)
committerDidier Raboud <odyx@debian.org>
Tue, 15 May 2012 14:50:08 +0000 (16:50 +0200)
Add the needed maintscript helper to remove the untouched
lsb-base-logging.sh; including Pre-Dependency on recent-enough dpkg.

debian/control
debian/lsb-base.maintscript.Ubuntu [new file with mode: 0644]
debian/rules
init-functions.d/50-ubuntu-logging [new file with mode: 0644]
lsb-base-logging-ubuntu.sh [deleted file]

index fde40a4ecd8601e1156f3e761b6d365d7db66d6c..13333b3517dcb20d9f8f55f74293058e4e6fcd9b 100644 (file)
@@ -301,6 +301,7 @@ Package: lsb-base
 Architecture: all
 Multi-Arch: foreign
 Depends: ${misc:Depends}
+Pre-Depends: ${misc:Pre-Depends}
 Priority: required
 Description: Linux Standard Base 4.1 init script functionality
  The Linux Standard Base (http://www.linuxbase.org/) is a standard
diff --git a/debian/lsb-base.maintscript.Ubuntu b/debian/lsb-base.maintscript.Ubuntu
new file mode 100644 (file)
index 0000000..4a85b2e
--- /dev/null
@@ -0,0 +1 @@
+rm_conffile /etc/lsb-base-logging.sh 4.1+Debian3+ lsb-base
index a465fc4160a9e5e30a64afb70f23431c21f12eb1..04e7065f8ab3ca9e27fd90be74f4e3e309919214 100755 (executable)
@@ -43,6 +43,7 @@ endif
 override_dh_clean:
        dh_clean
        rm -f *.py[co]
+       rm -f debian/lsb-base.maintscript
 
 override_dh_python2:
        dh_python2
@@ -51,7 +52,11 @@ override_dh_python2:
 override_dh_install:
        dh_install
 ifeq ($(derives_from_ubuntu),yes)
-       cp -p lsb-base-logging-ubuntu.sh debian/lsb-base/etc/lsb-base-logging.sh
+       cp -p init-functions.d/50-ubuntu-logging debian/lsb-base/lib/lsb/init-functions.d/
+
+override_dh_installdeb:
+       cp debian/lsb-base.maintscript.Ubuntu debian/lsb-base.maintscript
+       dh_installdeb
 endif
 
 override_dh_gencontrol:
diff --git a/init-functions.d/50-ubuntu-logging b/init-functions.d/50-ubuntu-logging
new file mode 100644 (file)
index 0000000..ac22357
--- /dev/null
@@ -0,0 +1,141 @@
+# Default init script logging functions suitable for Ubuntu.
+# See /lib/lsb/init-functions for usage help.
+LOG_DAEMON_MSG=""
+
+log_use_plymouth () {
+    if [ "${loop:-n}" = y ]; then
+        return 1
+    fi
+    plymouth --ping >/dev/null 2>&1
+}
+
+log_success_msg () {
+    echo " * $@"
+}
+
+log_failure_msg () {
+    if log_use_fancy_output; then
+        RED=`$TPUT setaf 1`
+        NORMAL=`$TPUT op`
+        echo " $RED*$NORMAL $@"
+    else
+        echo " * $@"
+    fi
+}
+
+log_warning_msg () {
+    if log_use_fancy_output; then
+        YELLOW=`$TPUT setaf 3`
+        NORMAL=`$TPUT op`
+        echo " $YELLOW*$NORMAL $@"
+    else
+        echo " * $@"
+    fi
+}
+
+log_begin_msg () {
+    log_daemon_msg "$1"
+}
+
+log_daemon_msg () {
+    if [ -z "$1" ]; then
+        return 1
+    fi
+
+    if log_use_fancy_output && $TPUT xenl >/dev/null 2>&1; then
+        COLS=`$TPUT cols`
+        if [ "$COLS" ] && [ "$COLS" -gt 6 ]; then
+            COL=`$EXPR $COLS - 7`
+        else
+            COLS=80
+            COL=73
+        fi
+
+        if log_use_plymouth; then
+            # If plymouth is running, don't output anything at this time
+            # to avoid buffering problems (LP: #752393)
+            if [ -z "$LOG_DAEMON_MSG" ]; then
+                LOG_DAEMON_MSG=$*
+                return
+            fi
+        fi
+
+        # We leave the cursor `hanging' about-to-wrap (see terminfo(5)
+        # xenl, which is approximately right). That way if the script
+        # prints anything then we will be on the next line and not
+        # overwrite part of the message.
+
+        # Previous versions of this code attempted to colour-code the
+        # asterisk but this can't be done reliably because in practice
+        # init scripts sometimes print messages even when they succeed
+        # and we won't be able to reliably know where the colourful
+        # asterisk ought to go.
+
+        printf " * $*       "
+        # Enough trailing spaces for ` [fail]' to fit in; if the message
+        # is too long it wraps here rather than later, which is what we
+        # want.
+        $TPUT hpa `$EXPR $COLS - 1`
+        printf ' '
+    else
+        echo " * $@"
+        COL=
+    fi
+}
+
+log_progress_msg () {
+    :
+}
+
+log_end_msg () {
+    if [ -z "$1" ]; then
+        return 1
+    fi
+
+    if [ "$COL" ] && [ -x "$TPUT" ]; then
+        # If plymouth is running, print previously stored output
+        # to avoid buffering problems (LP: #752393)
+        if log_use_plymouth; then
+            if [ -n "$LOG_DAEMON_MSG" ]; then
+                log_daemon_msg $LOG_DAEMON_MSG
+                LOG_DAEMON_MSG=""
+            fi
+        fi
+
+        printf "\r"
+        $TPUT hpa $COL
+        if [ "$1" -eq 0 ]; then
+            echo "[ OK ]"
+        else
+            printf '['
+            $TPUT setaf 1 # red
+            printf fail
+            $TPUT op # normal
+            echo ']'
+        fi
+    else
+        if [ "$1" -eq 0 ]; then
+            echo "   ...done."
+        else
+            echo "   ...fail!"
+        fi
+    fi
+    return $1
+}
+
+log_action_msg () {
+    echo " * $@"
+}
+
+log_action_begin_msg () {
+    log_daemon_msg "$@..."
+}
+
+log_action_cont_msg () {
+    log_daemon_msg "$@..."
+}
+
+log_action_end_msg () {
+    # In the future this may do something with $2 as well.
+    log_end_msg "$1" || true
+}
diff --git a/lsb-base-logging-ubuntu.sh b/lsb-base-logging-ubuntu.sh
deleted file mode 100644 (file)
index ac22357..0000000
+++ /dev/null
@@ -1,141 +0,0 @@
-# Default init script logging functions suitable for Ubuntu.
-# See /lib/lsb/init-functions for usage help.
-LOG_DAEMON_MSG=""
-
-log_use_plymouth () {
-    if [ "${loop:-n}" = y ]; then
-        return 1
-    fi
-    plymouth --ping >/dev/null 2>&1
-}
-
-log_success_msg () {
-    echo " * $@"
-}
-
-log_failure_msg () {
-    if log_use_fancy_output; then
-        RED=`$TPUT setaf 1`
-        NORMAL=`$TPUT op`
-        echo " $RED*$NORMAL $@"
-    else
-        echo " * $@"
-    fi
-}
-
-log_warning_msg () {
-    if log_use_fancy_output; then
-        YELLOW=`$TPUT setaf 3`
-        NORMAL=`$TPUT op`
-        echo " $YELLOW*$NORMAL $@"
-    else
-        echo " * $@"
-    fi
-}
-
-log_begin_msg () {
-    log_daemon_msg "$1"
-}
-
-log_daemon_msg () {
-    if [ -z "$1" ]; then
-        return 1
-    fi
-
-    if log_use_fancy_output && $TPUT xenl >/dev/null 2>&1; then
-        COLS=`$TPUT cols`
-        if [ "$COLS" ] && [ "$COLS" -gt 6 ]; then
-            COL=`$EXPR $COLS - 7`
-        else
-            COLS=80
-            COL=73
-        fi
-
-        if log_use_plymouth; then
-            # If plymouth is running, don't output anything at this time
-            # to avoid buffering problems (LP: #752393)
-            if [ -z "$LOG_DAEMON_MSG" ]; then
-                LOG_DAEMON_MSG=$*
-                return
-            fi
-        fi
-
-        # We leave the cursor `hanging' about-to-wrap (see terminfo(5)
-        # xenl, which is approximately right). That way if the script
-        # prints anything then we will be on the next line and not
-        # overwrite part of the message.
-
-        # Previous versions of this code attempted to colour-code the
-        # asterisk but this can't be done reliably because in practice
-        # init scripts sometimes print messages even when they succeed
-        # and we won't be able to reliably know where the colourful
-        # asterisk ought to go.
-
-        printf " * $*       "
-        # Enough trailing spaces for ` [fail]' to fit in; if the message
-        # is too long it wraps here rather than later, which is what we
-        # want.
-        $TPUT hpa `$EXPR $COLS - 1`
-        printf ' '
-    else
-        echo " * $@"
-        COL=
-    fi
-}
-
-log_progress_msg () {
-    :
-}
-
-log_end_msg () {
-    if [ -z "$1" ]; then
-        return 1
-    fi
-
-    if [ "$COL" ] && [ -x "$TPUT" ]; then
-        # If plymouth is running, print previously stored output
-        # to avoid buffering problems (LP: #752393)
-        if log_use_plymouth; then
-            if [ -n "$LOG_DAEMON_MSG" ]; then
-                log_daemon_msg $LOG_DAEMON_MSG
-                LOG_DAEMON_MSG=""
-            fi
-        fi
-
-        printf "\r"
-        $TPUT hpa $COL
-        if [ "$1" -eq 0 ]; then
-            echo "[ OK ]"
-        else
-            printf '['
-            $TPUT setaf 1 # red
-            printf fail
-            $TPUT op # normal
-            echo ']'
-        fi
-    else
-        if [ "$1" -eq 0 ]; then
-            echo "   ...done."
-        else
-            echo "   ...fail!"
-        fi
-    fi
-    return $1
-}
-
-log_action_msg () {
-    echo " * $@"
-}
-
-log_action_begin_msg () {
-    log_daemon_msg "$@..."
-}
-
-log_action_cont_msg () {
-    log_daemon_msg "$@..."
-}
-
-log_action_end_msg () {
-    # In the future this may do something with $2 as well.
-    log_end_msg "$1" || true
-}