Hi Andreas,

Thanks for reporting this issue.

Sorry again, for the delay. As I was saying I didn't see your email when I
got back from my new year vacations.
I added Roopa to the conversation.

You always want to install the diversion - it's a no-op if it is already
> there.
>

Ack. I thought I just needed to divert existing/installed files. See patch
bellow.

diff --git a/debian/ifupdown2.preinst b/debian/ifupdown2.preinst
index 07fc073..eddf429 100644
--- a/debian/ifupdown2.preinst
+++ b/debian/ifupdown2.preinst
@@ -3,7 +3,7 @@
 MYNAME="${0##*/}"

 report() { echo "${MYNAME}: $*" ; }
-report_err() { report "Error: $*" >&2 ; }
+report_err() { report "Error: $*" >&2 ; exit 1; }

 preinst_divert()
 {
@@ -12,13 +12,7 @@ preinst_divert()
     then
         report_err "existing diversion for $1"
     else
-        if [ -e "$1" ] || [ -L "$1" ];
-        then
-            if [ $(dpkg-query -L ifupdown2 | grep "^$1$" | wc -l) -eq 0 ];
-            then
-                dpkg-divert --add --package ifupdown2 --rename --divert
"$1.disabled" "$1"
-            fi
-        fi
+        dpkg-divert --add --package ifupdown2 --rename --divert
"$1.disabled" "$1"
     fi
 }

On Mon, Jan 2, 2017 at 5:21 PM, Andreas Beckmann <a...@debian.org> wrote:

> Control: found -1 1.0~git20161221-1
>
> Hi,
>
> most of the issues are fixed, but one is remaining:
>
> On 2016-11-11 21:09, Julien Fortin wrote:
> >> 2. unconditionally install the diversions, installing bash-completion
> >> after ifupdown2 breaks right now with a file overwrite error since the
> >> diversions are not in place (this is how I noticed the problems)
> >>
> >
> > I tried to reinstall bash-completion, didn't see any issue.
> > Then remove + install, didn't see any issues.
> > Can you please provide me the steps you are following?
>
> remove bash-completion
> install ifupdown2
> install bash-completion
>
> (best test this in a fresh minimal chroot)
>
>
> looking at ifupdown.preinst, I marked the wrong (i.e. superfluous) lines
> with #!!:
>
> preinst_divert()
> {
>     diversions=$(dpkg-divert --list | grep "$1" | grep -v 'by ifupdown2$'
> | wc -l 2> /dev/null)
>     if [ "$diversions" -gt 0 ];
>     then
>         report_err "existing diversion for $1"
>     else
> #!!        if [ -e "$1" ] || [ -L "$1" ];
> #!!        then
> #!!            if [ $(dpkg-query -L ifupdown2 | grep "^$1$" | wc -l) -eq 0
> ];
> #!!            then
>                 dpkg-divert --add --package ifupdown2 --rename --divert
> "$1.disabled" "$1"
> #!!            fi
> #!!        fi
> #!!    fi
> }
>
> You always want to install the diversion - it's a no-op if it is already
> there.
> You don't want to install the diversion only if a conflicting file is
> already present,
> but also to take care for the conflicting file to be installed later.
>
> And I'm pretty sure that you are missing an 'exit 1' in the
> report_err function - there is no point in continuing the
> installation if the system is in a broken state.
>
>
> Andreas
>

Reply via email to