Package: checkinstall
Version: 1.6.2-4ubuntu1
Severity: normal

Dear Maintainer,

(I noticed this problem on Linux Mint initially, later found it on
Debian Stretch as well.)

I added `--addso=yes` to `checkinstall` and made a DEB package.
The package looks good, except for the `postinstall` script.

The script generated for my package is:
```sh
#!/bin/sh
#
# postinstall script, created by checkinstall-1.6.2
#
echo
if ! egrep "^//usr/local/lib *$" /etc/ld.so.conf &> /dev/null; then
   echo "Adding "//usr/local/lib" to /etc/ld.so.conf"
   echo //usr/local/lib >> /etc/ld.so.conf
fi
ldconfig
```

The shebang on line 1 requires '/bin/sh', but the redirection of both
stdout and stderr on line 6 (the `&>` syntax) is specific to bash. So
the condition after the `!` operator will always exit with an error
thus yields `false`, and the `if` condition yields true after the
negation. This results a new line appended to '/etc/ld.so.conf' every
time this package is installed, which I have to clean up periodically.


This patch fixes the problem:
```diff
--- checkinstall.orig   2018-03-15 16:00:29.997552520 +0800
+++ /usr/bin/checkinstall       2018-03-15 15:12:18.232830708 +0800
@@ -1975,7 +1975,7 @@

  cat ${TMP_DIR}/libdirs | while read libdir; do
    (
-    echo "if ! egrep \"^/${libdir} *$\" /etc/ld.so.conf &> /dev/null; then"
+    echo "if ! egrep \"^/${libdir} *$\" /etc/ld.so.conf >/dev/null
2>&1; then"
     echo "   echo \"Adding \"/$libdir\" to /etc/ld.so.conf\""
     echo "   echo /$libdir >> /etc/ld.so.conf"
     echo fi
```

-- System Information:
Debian Release: stretch/sid
  APT prefers xenial-updates
  APT policy: (500, 'xenial-updates'), (500, 'xenial-security'), (500,
'xenial-backports'), (500, 'xenial')
Architecture: amd64 (x86_64)
Foreign Architectures: i386

Kernel: Linux 4.13.0-37-generic (SMP w/8 CPU cores)
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash
Init: systemd (via /run/systemd/system)

Versions of packages checkinstall depends on:
ii  dpkg-dev  1.18.4ubuntu1.3
ii  file      1:5.25-2ubuntu1
ii  libc6     2.23-0ubuntu10

Versions of packages checkinstall recommends:
ii  make  4.1-6

Versions of packages checkinstall suggests:
ii  gettext  0.19.7-2ubuntu3

-- no debconf information

--- checkinstall.orig	2018-03-15 16:00:29.997552520 +0800
+++ /usr/bin/checkinstall	2018-03-15 15:12:18.232830708 +0800
@@ -1975,7 +1975,7 @@
 
  cat ${TMP_DIR}/libdirs | while read libdir; do
    (
-    echo "if ! egrep \"^/${libdir} *$\" /etc/ld.so.conf &> /dev/null; then"
+    echo "if ! egrep \"^/${libdir} *$\" /etc/ld.so.conf >/dev/null 2>&1; then"
     echo "   echo \"Adding \"/$libdir\" to /etc/ld.so.conf\"" 
     echo "   echo /$libdir >> /etc/ld.so.conf"
     echo fi

Reply via email to