Comment 13 for bug 14308

Revision history for this message
Debian Bug Importer (debzilla) wrote :

Message-ID: <email address hidden>
Date: Fri, 25 Mar 2005 14:19:23 +1100
From: Herbert Xu <email address hidden>
To: <email address hidden>, <email address hidden>, <email address hidden>,
 adconrad@0c3.net
Subject: Re: Bug#300703: autofs: Upgrade fails

--ReaqsoxgOBHFXBhH
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline

I just saw the same problem upgrading to sarge. I had a look around and
it looks like the script simply wasn't written to be run under set -e.

When a script uses $? liberally to explicitly test success/failure of
commands, you can't just enable -e and expect it to work. You have
to carefully inspect it to make sure that all failure cases are handled
so that they don't cause the script to bomb out when it shouldn't.

I made an attempt to do this here. No guarantees that this catches
all the problems but it does let me finish configuring the package.
--
Visit Openswan at http://www.openswan.org/
Email: Herbert Xu ~{PmV>HI~} <email address hidden>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt

--ReaqsoxgOBHFXBhH
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename="autofs.patch"

--- autofs.old 2005-03-25 14:09:01.000000000 +1100
+++ autofs 2005-03-25 14:18:43.000000000 +1100
@@ -448,11 +448,11 @@
   echo ""
   echo -n $"Unmounting loopback filesystem $match: "
   loopdev=`LC_ALL=C grep $l /proc/mounts | awk '{print $1}'`
- umount -d $match
- if [ $? -eq 0 ]; then
+ if umount -d $match; then
       echo "done"
   else
       echo "failed ($?)"
+ exit 1
   fi
      fi
  done
@@ -470,11 +470,11 @@
      if [ -n "$match" ]; then
   echo ""
   echo -n $"Unmounting loopback filesystem $match: "
- umount -d $match
- if [ $? -eq 0 ]; then
+ if umount -d $match; then
       echo "done"
   else
       echo "failed ($?)"
+ exit 1
   fi
      fi
  done
@@ -629,13 +629,12 @@
   mnt=`echo $rest | sed 's/^.* \(\/[^ ]*\) [A-Za-z].*$/\1/'`
   pidfile=/var/run/autofs/`echo $mnt | sed 's,/,_,g'`.pid

- start-stop-daemon --start --pidfile $pidfile --quiet \
+ if ! start-stop-daemon --start --pidfile $pidfile --quiet \
      --exec $DAEMON -- --pid-file=$pidfile $rest
-
- if [ $? -ne 0 ]
   then
    echo
    echo " failed to start automount point $mnt"
+ exit 1
   fi
  done

@@ -658,8 +657,8 @@

    start-stop-daemon --stop --quiet \
      --retry USR2/$DAEMON_EXIT_WAIT \
- --pidfile $file --exec $DAEMON
- ret=$?
+ --pidfile $file --exec $DAEMON ||
+ ret=$?

    case $ret in
    0)
@@ -675,7 +674,7 @@
     ;;
    *)
     echo -n -e \
- "\n Strange start-stop-daemon exit status: $?"
+ "\n Strange start-stop-daemon exit status: $ret"
     ;;
    esac
   fi
@@ -718,12 +717,12 @@
    mnt=`echo $rest | sed 's/^.* \(\/[^ ]*\) [A-Za-z].*$/\1/'`
    pidfile=/var/run/autofs/`echo $mnt | sed 's,/,_,g'`.pid

- start-stop-daemon --start --pidfile $pidfile --quiet \
+ if ! start-stop-daemon --start --pidfile $pidfile --quiet \
     --exec $DAEMON -- --pid-file=$pidfile $rest
-
- if [ $? -ne 0 ]; then
+ then
     echo
     echo " failed to start automount point $mnt"
+ exit 1
    else
     echo "Started automounter: $mnt"
    fi

--ReaqsoxgOBHFXBhH--