Package: ucf
Version: 3.0043
Severity: important

Dear Maintainer,

ucfr aborts during an unattended upgrade of dovecot when a diverted
configuration file is present:

> Replacing config file /etc/dovecot/dovecot.conf.mypackage with new
version
> ucfr: Attempt from package dovecot-core  to take
/etc/dovecot/dovecot.conf.mypackage away from package mypackage
> ucfr: Aborting.

ucf fails when trying to complete the installation (via another
invocation of apt install):

> Setting up dovecot-core (1:2.2.33.2-1ubuntu4.7) ...
> /usr/bin/ucf: 444: [: missing ]
> grep: ]: No such file or directory
> /usr/bin/ucf: 444: [: missing ]
> grep: ]: No such file or directory

The patch below
* makes ucfr respect diverted configuration files,
* fixes the syntax error in ucf and
* makes ucf correctly detect 'local' diversions, bringing it in line
  with stable dpkg-divert output as provided by '--listpackage'.

The patch has been tested successfully with ucf/3.0043 backported to
Ubuntu 18.04.

*** usr/bin/ucf~        2020-06-16 07:37:53.000000000 +0200
--- usr/bin/ucf 2021-01-05 16:36:12.097133824 +0100
***************
*** 439,454 ****
  fi

  # Follow dpkg-divert as though we are installed as part of
$opt_package
! divert_line=$(dpkg-divert --list "$dest_file")
  if [ -n "$divert_line" ]; then
!    if [ echo "$divert_line" | grep "^local" ]; then
!        # local diversion; pick something not in the package namespace
!        divert_package="LOCAL"
!    else
!        # extract the name of the diverted package.
!        # The fact that this requires output parsing is bug #485012
!        divert_package=$(dpkg-divert --listpackage "$dest_file")
!    fi

     if [ "$divert_package" != "$opt_package" ]; then
         dest_file=$(dpkg-divert --truename "$dest_file")
--- 439,448 ----
  fi

  # Follow dpkg-divert as though we are installed as part of
$opt_package
! divert_line=$(dpkg-divert --listpackage "$dest_file")
  if [ -n "$divert_line" ]; then
!    # name of the package or 'LOCAL' for a local diversion
!    divert_package="$divert_line"

     if [ "$divert_package" != "$opt_package" ]; then
         dest_file=$(dpkg-divert --truename "$dest_file")
*** usr/bin/ucfr~       2020-06-16 07:37:53.000000000 +0200
--- usr/bin/ucfr        2021-01-05 16:39:06.592853096 +0100
***************
*** 112,121 ****
              awk '{print $1;}' );

          if [ "$pkg" != "$old_pkg" ]; then
!             if [ "X$FORCE" = "X" ]; then
!                 echo >&2 "$progname: Attempt from package $pkg  to
take ${real_conf_file} away from package $old_pkg";
!                 echo >&2 "ucfr: Aborting.";
!                 exit 4;
              fi
          else
              if [ "X$VERBOSE" != "X" ]; then
--- 112,129 ----
              awk '{print $1;}' );

          if [ "$pkg" != "$old_pkg" ]; then
!             divert_package=$(dpkg-divert --listpackage "$conf_file")
!             if [ -n "$divert_package" ]; then
!                 if [ "X$VERBOSE" != "X" ]; then
!                     echo >&2 "$progname: Package $pkg will not take
away diverted ${conf_file} from package $divert_package";
!                 fi
!                 exit 0;
!             else
!                 if [ "X$FORCE" = "X" ]; then
!                     echo >&2 "$progname: Attempt from package
$pkg  to take ${real_conf_file} away from package $old_pkg";
!                     echo >&2 "ucfr: Aborting.";
!                     exit 4;
!                 fi
              fi
          else
              if [ "X$VERBOSE" != "X" ]; then

Reply via email to