clone 366995 -1
reassign -1 ucf
retitle -1 ucf: noninteractive upgrade fails when package uses debconf
tags -1 - unreproducible
found -1 2.0012
thanks bts

Zed Pobre wrote:
> I had a custom apache.conf required for supporting multiple parallel
> wikis in /etc/phpwiki/apache.conf.  This file was replaced with a
> default file on a noninteractive upgrade, and no .dpkg-old version was
> created (fortunately, it was very simple to rewrite).  Looking at your
> postinst, I don't see anything immediately wrong, but there may be
> some oddity involved with ucf when there is no attached tty.

There was a bug in my postinst, I was invoking ucf with redirections to
and from /dev/tty which isn't always available during a non-interactive
upgrade. However this should cause dpkg to exit with an error like the
following and wouldn't result in any configuration loss.

Setting up phpwiki (1.3.12p2-1) ...
/var/lib/dpkg/info/phpwiki.postinst: line 135: /dev/tty: No such device
or address
dpkg: error processing phpwiki (--configure):
 subprocess post-installation script returned error exit status 1

How did you invoke the non-interactive upgrade?

However, in fixing the bug in phpwiki's postinst I've stumbled across
another similar bug that appears to be inside ucf itself. It still can't
reproduce your exact situation (loss of old configuration file) but the
bug does prevent noninteractive upgrades where the configuration file
has been modified.


The remainder of this mail is for the new bug report I've just cloned
and assigned to ucf.

The problem occurs when upgrading a package containing a new
configuration file managed by ucf where the new configuration file is
different to both the original file installed by the previous package
and the current version of the file on disk. Additionally the postinst
script must be using debconf for the bug to occur.

When these four conditions are satisified ucf attempts to prompt the
user as to what it should do with the file on disk, however it attempts
to read the answer from /dev/tty which may not exist during a
non-interactive installation. The full upgrade log (ucf debug and
verbose flags turned on) including the error is shown below:

(Reading database ... 34584 files and directories currently installed.)
Preparing to replace foo 1 (using foo_2_amd64.deb) ...
Unpacking replacement foo ...
Setting up foo (2) ...
ucf: The Source directory is /usr/share/foo
ucf: The State directory is /var/lib/ucf
The hash file exists
egrep [[:space:]]\/etc\/foo\.conf$ /var/lib/ucf/hashfile
60ce0a64962adb638065b6c0e3f3f0a8  /etc/foo.conf
The new start file is      `/usr/share/foo/configuration\'
The destination is         `/etc/foo.conf\' (`\/etc\/foo\.conf\')
The history is kept under  \'/usr/share/foo\'
The file may be cached at \'/var/lib/ucf/cache/:etc:foo.conf\'
The destination file exists, and has md5sum:
8e9beae8f0aed324944f37224f6be2b9  /etc/foo.conf
The old md5sum exists, and is:
60ce0a64962adb638065b6c0e3f3f0a8
The new file exists, and has md5sum:
0a6e31644d037c2959dc6e6ab50f9ebd  /usr/share/foo/configuration
Historical md5sums are not available
Configuration file `/etc/foo.conf'
 ==> File on system created by you or by a script.
 ==> File also in package provided by package maintainer.
   What would you like to do about it ?  Your options are:
    Y or I  : install the package maintainer's version
    N or O  : keep your currently-installed version
      D     : show the differences between the versions
      S     : show the side-by-side differences between the versions
      Z     : start a new shell to examine the situation
 The default action is to keep your current version.
***  foo.conf  (Y/I/N/O/D/Z) [default=N] ?/usr/bin/ucf: line 855:
/dev/tty: No such device or address
dpkg: error processing foo (--install):
 subprocess post-installation script returned error exit status 1
Errors were encountered while processing:
 foo

The expected behaviour of ucf in this case is to leave the configuration
file as is, and install the new configuration file at
/etc/foo.conf.ucf-dist. This expected behaviour occurs correctly if
debconf is removed from the package's postinst script.

Steps to reproduce:

I have built two versions of a very basic test package (foo) to help
diagnose / test this error case. The package installs a single
configuration file /etc/foo.conf from /usr/share/foo/configuration using
stripped down versions of the example maintainer scripts shipped with ucf.

1. Obtain packages from http://www.mattb.net.nz/debian/misc/ucf/
2. Install version 1
3. Edit /etc/foo.conf so it differs from the installed version
4. Perform a non-interactive upgrade to version 2 via the following command
 echo DEBIAN_FRONTEND=noninteractive dpkg -i foo_2_amd64.deb | at now +
1 min
5. Observe breakage and error output as shown above

Please let me know if there is any further information you need to track
down the cause of this bug.

Cheers

-- 
Matt Brown
[EMAIL PROTECTED]
Mob +64 21 611 544 www.mattb.net.nz

Attachment: signature.asc
Description: OpenPGP digital signature

Reply via email to