From 3342c8f479233a71b1c7309b0d101d25c58da747 Mon Sep 17 00:00:00 2001 From: Chris Lawrence Date: Mon, 17 Jan 2011 14:24:35 -0600 Subject: [PATCH] lsb 3.2-27 Debian release. --- debian/changelog | 15 ++++++++++ debian/prerm | 2 +- init-functions | 77 +++++++++++++++++++++++++++++------------------- 3 files changed, 62 insertions(+), 32 deletions(-) diff --git a/debian/changelog b/debian/changelog index ec0e145..b68e64d 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,18 @@ +lsb (3.2-27) unstable; urgency=low + + * Track down another use of dpkg --print-installation-architecture. + (Closes: #610049) + * Various cleanups to init-functions, courtesy of Jari Aalto: + + Use /bin/echo when using options throughout. (Closes: #602038) + + Use $() command substitution. (Closes: #602035) + + Use && and || instead of -a and -o. (Closes: #602037) + + Break long lines. (Closes: #602039) + + Cleanup use of local. (Closes: #602042) + + Use single-line statements. (Closes: #602044) + + Use self-documenting values of variables. (Closes: #602048) + + -- Chris Lawrence Mon, 17 Jan 2011 14:24:35 -0600 + lsb (3.2-26) unstable; urgency=low * Fix reversed assignment in compare_release. (Closes: #540208) diff --git a/debian/prerm b/debian/prerm index 278be5b..fb33522 100644 --- a/debian/prerm +++ b/debian/prerm @@ -1,7 +1,7 @@ #!/bin/sh -e remove_ldso_symlink () { - ARCH=`dpkg --print-installation-architecture` + ARCH=`dpkg --print-architecture` case "$ARCH" in s390|ia64|ppc64|sparc|sparc64|alpha|hppa|m68k|mipsel) rm -f /lib/ld-lsb-$ARCH.so.[123] diff --git a/init-functions b/init-functions index 57444b8..8b14cf7 100644 --- a/init-functions +++ b/init-functions @@ -28,15 +28,15 @@ #EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. start_daemon () { - local force nice pidfile exec i args - force=0 + local force nice pidfile exec args + force="" nice=0 pidfile=/dev/null OPTIND=1 while getopts fn:p: opt ; do case "$opt" in - f) force=1;; + f) force="force";; n) nice="$OPTARG";; p) pidfile="$OPTARG";; esac @@ -50,24 +50,28 @@ start_daemon () { exec="$1"; shift args="--start --nicelevel $nice --quiet --oknodo" - if [ $force = 1 ]; then - /sbin/start-stop-daemon $args --chdir "$PWD" --startas $exec --pidfile /dev/null -- "$@" + if [ "$force" ]; then + /sbin/start-stop-daemon $args \ + --chdir "$PWD" --startas $exec --pidfile /dev/null -- "$@" elif [ $pidfile ]; then - /sbin/start-stop-daemon $args --chdir "$PWD" --exec $exec --oknodo --pidfile "$pidfile" -- "$@" + /sbin/start-stop-daemon $args \ + --chdir "$PWD" --exec $exec --oknodo --pidfile "$pidfile" -- "$@" else /sbin/start-stop-daemon $args --chdir "$PWD" --exec $exec -- "$@" fi } pidofproc () { - local pidfile line i pids= status specified pid + local pidfile line status specified pid pidfile= specified= OPTIND=1 while getopts p: opt ; do case "$opt" in - p) pidfile="$OPTARG"; specified=1;; + p) pidfile="$OPTARG" + specified="specified" + ;; esac done shift $(($OPTIND - 1)) @@ -77,7 +81,7 @@ pidofproc () { pidfile="/var/run/$base.pid" fi - if [ -n "${pidfile:-}" -a -r "$pidfile" ]; then + if [ -n "${pidfile:-}" ] && [ -r "$pidfile" ]; then read pid < "$pidfile" if [ -n "${pid:-}" ]; then if $(kill -0 "${pid:-}" 2> /dev/null); then @@ -91,7 +95,7 @@ pidofproc () { fi fi fi - if [ -x /bin/pidof -a ! "$specified" ]; then + if [ -x /bin/pidof ] && [ ! "$specified" ]; then status="0" /bin/pidof -o %PPID -x $1 || status="$?" if [ "$status" = 1 ]; then @@ -107,10 +111,10 @@ pidofproc () { # start-stop-daemon uses the same algorithm as "pidofproc" above. killproc () { - local pidfile sig status base i name_param is_term_sig + local pidfile sig status base name_param is_term_sig pidfile= name_param= - is_term_sig=no + is_term_sig= OPTIND=1 while getopts p: opt ; do @@ -129,18 +133,21 @@ killproc () { sig=$(echo ${2:-} | sed -e 's/^-\(.*\)/\1/') sig=$(echo $sig | sed -e 's/^SIG\(.*\)/\1/') - if [ -z "$sig" -o "$sig" = 15 -o "$sig" = TERM ]; then - is_term_sig=yes + if [ -z "$sig" ] || [ "$sig" = 15 ] || [ "$sig" = TERM ]; then + is_term_sig="terminate_signal" fi status=0 - if [ ! "$is_term_sig" = yes ]; then + if [ ! "$is_term_sig" ]; then if [ -n "$sig" ]; then - /sbin/start-stop-daemon --stop --signal "$sig" --quiet $name_param || status="$?" + /sbin/start-stop-daemon --stop --signal "$sig" \ + --quiet $name_param || status="$?" else - /sbin/start-stop-daemon --stop --quiet $name_param || status="$?" + /sbin/start-stop-daemon --stop \ + --quiet $name_param || status="$?" fi else - /sbin/start-stop-daemon --stop --quiet --oknodo $name_param || status="$?" + /sbin/start-stop-daemon --stop --quiet \ + --oknodo $name_param || status="$?" fi if [ "$status" = 1 ]; then if [ -n "$sig" ]; then @@ -149,7 +156,7 @@ killproc () { return 3 # program is not running fi - if [ "$status" = 0 -a "$is_term_sig" = yes -a "$pidfile" ]; then + if [ "$status" = 0 ] && [ "$is_term_sig" ] && [ "$pidfile" ]; then pidofproc -p "$pidfile" "$1" >/dev/null || rm -f "$pidfile" fi return 0 @@ -191,7 +198,13 @@ status_of_proc () { log_use_fancy_output () { TPUT=/usr/bin/tput EXPR=/usr/bin/expr - if [ -t 1 ] && [ "x${TERM:-}" != "x" ] && [ "x${TERM:-}" != "xdumb" ] && [ -x $TPUT ] && [ -x $EXPR ] && $TPUT hpa 60 >/dev/null 2>&1 && $TPUT setaf 1 >/dev/null 2>&1; then + if [ -t 1 ] && + [ "x${TERM:-}" != "x" ] && + [ "x${TERM:-}" != "xdumb" ] && + [ -x $TPUT ] && [ -x $EXPR ] && + $TPUT hpa 60 >/dev/null 2>&1 && + $TPUT setaf 1 >/dev/null 2>&1 + then [ -z $FANCYTTY ] && FANCYTTY=1 || true else FANCYTTY=0 @@ -241,7 +254,7 @@ log_begin_msg () { if [ -z "${1:-}" ]; then return 1 fi - echo -n "$@" + /bin/echo -n "$@" } # Sample usage: @@ -265,11 +278,11 @@ log_daemon_msg () { log_daemon_msg_pre "$@" if [ -z "${2:-}" ]; then - echo -n "$1:" + /bin/echo -n "$1:" return fi - echo -n "$1: $2" + /bin/echo -n "$1: $2" log_daemon_msg_post "$@" } @@ -292,7 +305,7 @@ log_progress_msg () { if [ -z "${1:-}" ]; then return 1 fi - echo -n " $@" + /bin/echo -n " $@" } @@ -303,6 +316,7 @@ log_end_msg () { return 1 fi + local retval retval=$1 log_end_msg_pre "$@" @@ -310,9 +324,9 @@ log_end_msg () { # Only do the fancy stuff if we have an appropriate terminal # and if /usr is already mounted if log_use_fancy_output; then - RED=`$TPUT setaf 1` - YELLOW=`$TPUT setaf 3` - NORMAL=`$TPUT op` + RED=$( $TPUT setaf 1) + YELLOW=$( $TPUT setaf 3) + NORMAL=$( $TPUT op) else RED='' YELLOW='' @@ -335,14 +349,15 @@ log_action_msg () { } log_action_begin_msg () { - echo -n "$@..." + /bin/echo -n "$@..." } log_action_cont_msg () { - echo -n "$@..." + /bin/echo -n "$@..." } log_action_end_msg () { + local end log_action_end_msg_pre "$@" if [ -z "${2:-}" ]; then end="." @@ -354,8 +369,8 @@ log_action_end_msg () { echo "done${end}" else if log_use_fancy_output; then - RED=`$TPUT setaf 1` - NORMAL=`$TPUT op` + RED=$( $TPUT setaf 1) + NORMAL=$( $TPUT op) /bin/echo -e "${RED}failed${end}${NORMAL}" else echo "failed${end}" -- 2.30.2