Package: dpkg
Version: 1.21.22
Severity: wishlist
Tags: patch

Hi,

dpkg postinst fails to create the start-stop-daemon compatibility
symlink if /usr does not exist:

    ln: failed to create symbolic link '/sbin/start-stop-daemon': No such file 
or directory

Getting into this situation requires some creativity. Here is an example:

    $ mmdebstrap --variant=custom 
--include=dpkg,dash,diffutils,coreutils,libc-bin,sed unstable /dev/null

Here are two patches that fix this problem by just not creating the
compatibility symlink in this situation:

--- a/debian/dpkg.postinst
+++ b/debian/dpkg.postinst
@@ -59,7 +59,8 @@ setup_aliases()
 
   # Add a backward compatibility symlink alias for s-s-d, which is now
   # installed in its canonical location.
-  if [ ! -f "$DPKG_ROOT/sbin/$prog" ]; then
+  # Skip creation of the compat symlink if /sbin is not an existing directory
+  if [ ! -f "$DPKG_ROOT/sbin/$prog" ] && [ -d "$DPKG_ROOT/sbin" ]; then
     ln -s "/usr/sbin/$prog" "$DPKG_ROOT/sbin/$prog"
   fi
 }

--- a/debian/dpkg.postinst
+++ b/debian/dpkg.postinst
@@ -59,8 +59,10 @@ setup_aliases()
 
   # Add a backward compatibility symlink alias for s-s-d, which is now
   # installed in its canonical location.
+  # Failure to create the compat symlink (for example if /usr does not
+  # exist) is non-fatal.
   if [ ! -f "$DPKG_ROOT/sbin/$prog" ]; then
-    ln -s "/usr/sbin/$prog" "$DPKG_ROOT/sbin/$prog"
+    ln -s "/usr/sbin/$prog" "$DPKG_ROOT/sbin/$prog" || true
   fi
 }
 

The second patch has the advantage, that the user will receive the error
message from ln about its inability to create the symlink together with the
reason for the failure.

I'm working around this issue in the mmdebstrap test suite by creating /sbin
manually in a hook. I'm filing this bug to not loose track of the situation
and to be able to add a bugnumber to the hook.

Thanks!

cheers, josch

Reply via email to