Bug#506100: Hint?

2010-01-30 Thread Tanguy Ortolo
Le jeudi 28 janvier 2010, Tanguy Ortolo a écrit :
> I may suggest not to rename /usr/share/dokuwiki/.htaccess.dist, to
> rename its friends /var/lib/dokuwiki/data/.htaccess and company by
> adding them a .inst suffix, and to rewrite the ucf calls accordingly.
> I shall test that and submit a patch in a few days.

So, here is my patch, against the debian/ directory of the source
package. Basically, this is what it does:
* debian/rules install:
  name the .htaccess files .htaccess.inst in the package;
* debian/postinst configure:
  call ucf .htaccess.inst .htaccess, so that ucf does not manage files
  that are part of the package itself any more;
* debian/postrm purge:
  remove the ucf files.

With only this modification, there was a problem on upgrading: the
.htaccess files were removed, as part of the old version but not of the
new one, before debian/postinst configure was called. Then, ucf found
the target configuration files, already managed since the old
debian/postinst configure, were not here. It assumed they were removed
by the user and did not install them!

So I also added some modifications for this transition:
* debian/preinst upgrade:
  if needed, backup the configuration files with names
  .htaccess.upgrade;
* debian/postrm abort-upgrade:
  remove these backups;
* debian/postinst configure:
  if the configuration files are not found, and the backups are found,
  resore these backups before calling ucf.

As a bonus, I also added ucfr commands to register the configuration
files, as it is recommended in ucf(1). And commands to unregister them
on purge, of course.

I tested my modifications on upgrading from the previous version, on
reinstalling from my version to my version and on removing my version
and installing it again: the .htaccess files are correctly preserved. On
downgrading, and on removing previous version and installing mine, they
are overwritten.

-- 
Tanguy Ortolo


debian.patch.gz
Description: Binary data


signature.asc
Description: Digital signature


Bug#506100: Hint?

2010-01-28 Thread Tanguy Ortolo
Hello,

I was affected by this bug too, so I looked inside dokuwiki's package to
find what could be wrong. According to the Debian changelog, one of
adn's first changes when he became the maintainer was to put
/usr/share/dokuwiki/.htaccess under ucf, to solve #414006.

Indeed, here is the debian/postinst related extract:
> if [ $1 = "configure" ]; then
>[…]
>ucf /usr/share/dokuwiki/.htaccess /usr/share/dokuwiki/.htaccess

This /usr/share/dokuwiki/.htaccess is dh_installed from the source
package's .htaccess.dist, according to debian/install:
> .htaccess.dist /usr/share/dokuwiki/
and debian/rules:
> install: build
>   […]
>   dh_install
>   […]
>   mv $(DESTDIR)/usr/share/dokuwiki/.htaccess.dist 
> $(DESTDIR)/usr/share/dokuwiki/.htaccess

To sum up, if I understand all this correctly, here is the detail of
that .htaccess.dist life over the package life:
1. Package building, install step:
   1.1 dh_installed from .htaccess.dist to /usr/share/dokuwiki/;
   1.2 renamed from .htaccess.dist to .htaccess.
2. Package installation:
   2.1 unpacked to /usr/share/dokuwiki/.htaccess;
   2.2 postinst: put under ucf.
3. Package upgrade:
   3.1 unpacked to /usr/share/dokuwiki/.htaccess, overwriting the
   previous version;
   3.2 postinst: nothing, as it is not called with "configure".

So, I think the problem is that this .htaccess – and all its friends,
that are affected by this bug too, as I just checked it – is given its
definitive name before ucf is called. It is not a problem when
installing, but when upgrading or reinstalling, as they are overwritten
by the new files that are not given a temporary name.

I may suggest not to rename /usr/share/dokuwiki/.htaccess.dist, to
rename its friends /var/lib/dokuwiki/data/.htaccess and company by
adding them a .inst suffix, and to rewrite the ucf calls accordingly.
I shall test that and submit a patch in a few days.

Freely, librement,

-- 
 _   ,
( \ /⋅>   Tanguy Ortolo
 ) / |/
 \_\_)_


signature.asc
Description: Digital signature