Hi!

Here's a debdiff, which:
  1. installs the conffiles 644
  2. simplifies on/off toggling
  3. => doesn't pollute the environment with an empty DEBUGINFOD_URLS
     when off
  4. fixes debuginfod.csh on the csh from current sid
     (it failed with invalid variable name on that line
          if DEBUGINFOD_URLS was already set)
  5. fixes /bin/bash shebangs(?!) in post{inst,rm}

So:
-- >8 --
$ debconf-show libdebuginfod-common
* libdebuginfod/usedebiandebuginfod: true
if ("true" == "true" && "https://debuginfod.debian.net"; != "") then
        if ($?DEBUGINFOD_URLS) then
                if ("$DEBUGINFOD_URLS" != "") then
                        setenv DEBUGINFOD_URLS "$DEBUGINFOD_URLS 
https://debuginfod.debian.net";
                else
                        setenv DEBUGINFOD_URLS "https://debuginfod.debian.net";
                endif
        else
                setenv DEBUGINFOD_URLS "https://debuginfod.debian.net";
        endif
endif
if [ "true" = "true" ] && [ -n "https://debuginfod.debian.net"; ]; then
        DEBUGINFOD_URLS="${DEBUGINFOD_URLS-}${DEBUGINFOD_URLS:+ 
}https://debuginfod.debian.net";
        export DEBUGINFOD_URLS
fi
$ csh -c 'source /etc/profile.d/debuginfod.csh; printenv | grep DEBUGI'
DEBUGINFOD_URLS=https://debuginfod.debian.net
$ sh -c '. /etc/profile.d/debuginfod.sh; printenv | grep DEBUGI'
DEBUGINFOD_URLS=https://debuginfod.debian.net

$ debconf-show libdebuginfod-common
* libdebuginfod/usedebiandebuginfod: false
$ cat /etc/profile.d/debuginfod.*
if ("false" == "true" && "https://debuginfod.debian.net"; != "") then
        if ($?DEBUGINFOD_URLS) then
                if ("$DEBUGINFOD_URLS" != "") then
                        setenv DEBUGINFOD_URLS "$DEBUGINFOD_URLS 
https://debuginfod.debian.net";
                else
                        setenv DEBUGINFOD_URLS "https://debuginfod.debian.net";
                endif
        else
                setenv DEBUGINFOD_URLS "https://debuginfod.debian.net";
        endif
endif
if [ "false" = "true" ] && [ -n "https://debuginfod.debian.net"; ]; then
        DEBUGINFOD_URLS="${DEBUGINFOD_URLS-}${DEBUGINFOD_URLS:+ 
}https://debuginfod.debian.net";
        export DEBUGINFOD_URLS
fi
$ csh -c 'source /etc/profile.d/debuginfod.csh; printenv | grep DEBUGI'
$ sh -c '. /etc/profile.d/debuginfod.sh; printenv | grep DEBUGI'
-- >8 --

Please consider it.

наб
diff -Nru elfutils-0.185/debian/changelog elfutils-0.185/debian/changelog
--- elfutils-0.185/debian/changelog     2021-08-15 18:27:02.000000000 +0200
+++ elfutils-0.185/debian/changelog     2021-08-16 16:20:52.000000000 +0200
@@ -1,3 +1,14 @@
+elfutils (0.185-3) UNRELEASED; urgency=medium
+
+  * d/libdebuginfod-common.postinst: install conffiles 644
+  * d/libdebuginfod-common.postinst, new d/p/toggleable-profile.diff:
+    don't pollute environment with empty DEBUGINFOD_URLS when off,
+    simplify disabling, fix invalid name in csh with DEBUGINFOD_URLS set
+  * d/libdebuginfod-common.post{inst,rm}:
+    fix indentation, shebang to /bin/sh from /bin/bash(!)
+
+ -- наб <nabijaczlew...@nabijaczleweli.xyz>  Mon, 16 Aug 2021 16:20:52 +0200
+
 elfutils (0.185-2) unstable; urgency=medium
 
   * Upload to unstable.
diff -Nru elfutils-0.185/debian/libdebuginfod-common.postinst 
elfutils-0.185/debian/libdebuginfod-common.postinst
--- elfutils-0.185/debian/libdebuginfod-common.postinst 2021-04-15 
17:14:24.000000000 +0200
+++ elfutils-0.185/debian/libdebuginfod-common.postinst 2021-08-16 
16:17:46.000000000 +0200
@@ -6,101 +6,26 @@
 
 CONFTEMPLATEPATH="/usr/share/libdebuginfod-common"
 
-# Change a "generic" shell file according to enable/disable
-# DEBUGINFOD_URLS according.
-#
-# - $1 is the shell file name
-#
-# - $2 is the pattern that we will look for when changing the file.
-#   This pattern will also be used to perform the substitution.
-#
-# - $3 is the action we will perform: set the DEBUGINFOD_URLS
-#   variable, or unset it.
-#
-# By the end of it, the specified shell file will have an extra line
-# which either sets DEBUGINFOD_URLS to have its own value, or sets
-# DEBUGINFOD_URLS to be empty (i.e., unsets any value).
-change_shell_file ()
-{
-    file="$1"
-    pattern="$2"
-
-    if [ "$3" = "set" ]; then
-       finalvar='$DEBUGINFOD_URLS'
-    else
-       finalvar=""
-    fi
-
-    # Check whether the last line of the file already starts with
-    # ${pattern}.  If it does, then we will perform a sed to replace
-    # it according to the action specified.  Otherwise, we will append
-    # a last line containing the set/unset.
-    if tail -n1 "$file" | grep -q "^$pattern"; then
-       sed -i "\$s@${pattern}.*@${pattern}\"${finalvar}\"@" "${file}"
-    else
-       echo "${pattern}\"${finalvar}\"" >> "${file}"
-    fi
-}
-
-# Change the .sh file according to an action specified by $1.  It can
-# be either "set" (meaning that we will be setting DEBUGINFOD_URLS to
-# a valid value), or "unset" (which means that DEBUGINFOD_URLS will be
-# empty).
-change_sh_file ()
-{
-    shfile="$1"
-    shaction="$2"
-
-    change_shell_file \
-       "$shfile" \
-       "export DEBUGINFOD_URLS=" \
-       "$shaction"
-}
-
-# Change the .csh file according to an action specified by $1.  The
-# explanation for change_sh_file also applies here.
-change_csh_file ()
-{
-    cshfile="$1"
-    cshaction="$2"
-
-    change_shell_file \
-       "$cshfile" \
-       "setenv DEBUGINFOD_URLS " \
-       "$cshaction"
-}
-
 case "$1" in
     configure)
-       GOT_DEBCONF_ANSWER=0
-
-       for ext in sh csh; do
-           if [ -f "${CONFTEMPLATEPATH}"/debuginfod."${ext}" ]; then
-               if [ "$GOT_DEBCONF_ANSWER" -eq 0 ]; then
-                   RET="false"
-                   if grep -qFx "ID=debian" /etc/os-release; then
-                       db_get libdebuginfod/usedebiandebuginfod || RET="false"
-                   fi
-
-                   if [ "$RET" = "true" ]; then
-                       action="set"
-                   else
-                       action="unset"
-                   fi
-                   GOT_DEBCONF_ANSWER=1
-               fi
-
-               tmpfile=$(mktemp)
-               cat "${CONFTEMPLATEPATH}"/debuginfod."${ext}" > "$tmpfile"
-               change_"${ext}"_file "$tmpfile" "$action"
-
-               ucf --three-way --debconf-ok \
-                   "$tmpfile" \
-                   /etc/profile.d/debuginfod."${ext}"
-               ucfr libdebuginfod-common /etc/profile.d/debuginfod."${ext}"
-               rm -f "${tmpfile}"
-           fi
-       done
+               GOT_DEBCONF_ANSWER=0
+               tmpdir="$(mktemp -d)"
+               for ext in sh csh; do
+                       [ -f "${CONFTEMPLATEPATH}/debuginfod.${ext}" ] || 
continue
+
+                       if [ "$GOT_DEBCONF_ANSWER" -eq 0 ]; then
+                               RET="false"
+                       if grep -qFx "ID=debian" /etc/os-release; then
+                                       db_get 
libdebuginfod/usedebiandebuginfod || RET="false"
+                               fi
+                               GOT_DEBCONF_ANSWER=1
+                       fi
+
+                       sed "s/#DEBUGINFOD_ON#/$RET/" 
"${CONFTEMPLATEPATH}/debuginfod.${ext}" > "${tmpdir}/debuginfod.${ext}"
+                       ucf --three-way --debconf-ok 
"${tmpdir}/debuginfod.${ext}" "/etc/profile.d/debuginfod.${ext}"
+                       ucfr libdebuginfod-common 
"/etc/profile.d/debuginfod.${ext}"
+               done
+               rm -rf "${tmpdir}"
        ;;
 
     abort-upgrade|abort-remove|abort-deconfigure)
diff -Nru elfutils-0.185/debian/libdebuginfod-common.postrm 
elfutils-0.185/debian/libdebuginfod-common.postrm
--- elfutils-0.185/debian/libdebuginfod-common.postrm   2021-04-15 
17:14:24.000000000 +0200
+++ elfutils-0.185/debian/libdebuginfod-common.postrm   2021-08-16 
16:20:52.000000000 +0200
@@ -1,20 +1,20 @@
-#!/bin/bash
+#!/bin/sh
 
 set -e
 
 case "$1" in
     purge)
-       for ext in sh csh; do
-           if [ -f /etc/profile.d/debuginfod."${ext}" ]; then
-               if which ucf > /dev/null; then
-                   ucf --purge /etc/profile.d/debuginfod."${ext}"
-               fi
-               if which ucfr > /dev/null; then
-                   ucfr --purge libdebuginfod-common 
/etc/profile.d/debuginfod."${ext}"
-               fi
-               rm -f /etc/profile.d/debuginfod."${ext}"
-           fi
-       done
+               for ext in sh csh; do
+                       [ -f /etc/profile.d/debuginfod."${ext}" ] || continue
+
+                       if command -v ucf > /dev/null; then
+                           ucf --purge /etc/profile.d/debuginfod."${ext}"
+                       fi
+                       if command -v ucfr > /dev/null; then
+                           ucfr --purge libdebuginfod-common 
/etc/profile.d/debuginfod."${ext}"
+                       fi
+                       rm -f /etc/profile.d/debuginfod."${ext}"
+               done
        ;;
 
     remove)
diff -Nru elfutils-0.185/debian/patches/series 
elfutils-0.185/debian/patches/series
--- elfutils-0.185/debian/patches/series        2021-03-09 20:09:18.000000000 
+0100
+++ elfutils-0.185/debian/patches/series        2021-08-16 16:20:52.000000000 
+0200
@@ -17,3 +17,4 @@
 kfreebsd-debuginfod
 kfreebsd-mremap-stub
 hurd-hacks.diff
+toggleable-profile.diff
diff -Nru elfutils-0.185/debian/patches/toggleable-profile.diff 
elfutils-0.185/debian/patches/toggleable-profile.diff
--- elfutils-0.185/debian/patches/toggleable-profile.diff       1970-01-01 
01:00:00.000000000 +0100
+++ elfutils-0.185/debian/patches/toggleable-profile.diff       2021-08-16 
16:20:52.000000000 +0200
@@ -0,0 +1,19 @@
+--- elfutils-0.185.orig/config/profile.csh.in
++++ elfutils-0.185/config/profile.csh.in
+@@ -1,6 +1,6 @@
+-if ("@DEBUGINFOD_URLS@" != "") then
++if ("#DEBUGINFOD_ON#" == "true" && "@DEBUGINFOD_URLS@" != "") then
+       if ($?DEBUGINFOD_URLS) then
+-              if ($%DEBUGINFOD_URLS) then
++              if ("$DEBUGINFOD_URLS" != "") then
+                       setenv DEBUGINFOD_URLS "$DEBUGINFOD_URLS 
@DEBUGINFOD_URLS@"
+               else
+                       setenv DEBUGINFOD_URLS "@DEBUGINFOD_URLS@"
+--- elfutils-0.185.orig/config/profile.sh.in
++++ elfutils-0.185/config/profile.sh.in
+@@ -1,4 +1,4 @@
+-if [ -n "@DEBUGINFOD_URLS@" ]; then
++if [ "#DEBUGINFOD_ON#" = "true" ] && [ -n "@DEBUGINFOD_URLS@" ]; then
+       DEBUGINFOD_URLS="${DEBUGINFOD_URLS-}${DEBUGINFOD_URLS:+ 
}@DEBUGINFOD_URLS@"
+       export DEBUGINFOD_URLS
+ fi

Attachment: signature.asc
Description: PGP signature

Reply via email to