On Sun, Aug 22, 2021 at 12:17:59PM +0800, Paul Wise wrote: > I think this approach is pretty convoluted, personally I would just > make the files in /etc either not exist when disabled, or symlinks into > /usr/share when enabled.
I don't disagree, but /e/p.d/* can't be symlinks to /u/s. However, please consider new, simplified, patch below, applying to current Salsa HEAD (4ff688068d05a82039f7cbf88ae99e4d6a4bc327, 0.186-1). Thanks, наб
From 868e5606b4c22ac84fafeff2028a1c74f710728f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=BD=D0=B0=D0=B1?= <nabijaczlew...@nabijaczleweli.xyz> Date: Mon, 17 Jan 2022 18:26:42 +0100 Subject: [PATCH] d/libdebuginfod-common.post{inst,rm}: install conffiles 644, use /bin/sh shebang, remove /e/p.d/dd.*sh if libdebuginfod/usedebiandebuginfod unset --- debian/libdebuginfod-common.postinst | 115 +++++---------------------- debian/libdebuginfod-common.postrm | 31 ++++---- 2 files changed, 35 insertions(+), 111 deletions(-) diff --git a/debian/libdebuginfod-common.postinst b/debian/libdebuginfod-common.postinst index a482967..93f5fa3 100644 --- a/debian/libdebuginfod-common.postinst +++ b/debian/libdebuginfod-common.postinst @@ -1,4 +1,4 @@ -#!/bin/bash +#!/bin/sh set -e @@ -6,101 +6,28 @@ set -e 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 + for ext in sh csh; do + [ -f "${CONFTEMPLATEPATH}/debuginfod.${ext}" ] || continue + + if [ "$GOT_DEBCONF_ANSWER" -eq 0 ]; then + grep -qFx "ID=debian" /etc/os-release && db_get libdebuginfod/usedebiandebuginfod || RET="false" + GOT_DEBCONF_ANSWER=1 + fi + + if [ "$RET" = "true" ]; then + UCF_FORCE_CONFFMISS=1 ucf --three-way --debconf-ok "${CONFTEMPLATEPATH}/debuginfod.${ext}" "/etc/profile.d/debuginfod.${ext}" + if [ "$(stat -c%a "/etc/profile.d/debuginfod.${ext}")" = 600 ]; then + chmod 644 "/etc/profile.d/debuginfod.${ext}" # Correct permissions created by previous versions (<=0.186-1) + fi + else + rm -f "/etc/profile.d/debuginfod.${ext}" + fi + ucfr libdebuginfod-common "/etc/profile.d/debuginfod.${ext}" + done + rm -rf "${tmpdir}" ;; abort-upgrade|abort-remove|abort-deconfigure) diff --git a/debian/libdebuginfod-common.postrm b/debian/libdebuginfod-common.postrm index 62a92ca..250ab6c 100644 --- a/debian/libdebuginfod-common.postrm +++ b/debian/libdebuginfod-common.postrm @@ -1,27 +1,24 @@ -#!/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) - : - ;; - - upgrade|failed-upgrade|abort-install|abort-upgrade|disappear) + remove|upgrade|failed-upgrade|abort-install|abort-upgrade|disappear) ;; *) -- 2.34.1
signature.asc
Description: PGP signature