[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: How to handle config file that has changed names

On Sun, Sep 21, 2003 at 03:16:32PM +0100, Peter Karlsson wrote:
> A new version of a package that I maintain has changed the name of the
> default configuration file. I want to propagate this name change, but
> how do I handle it properly? AFAICT, I'm not allowed to touch conffiles
> in the maintainer scripts, but this would mean that the old
> configuration would just be replaced by the new one...

You could conditionally move the existing configuration file in the
preinst to the new location.

case "$1" in
    if dpkg --compare-versions "$2" le "1.2-3" && \
       [ -e /etc/old.file ] && [ ! -e /etc/blah/new.location ] ; then
         [ ! -e /etc/blah ] && mkdir /etc/blah
         echo "Moving configfile to new location" 1>&2
         mv /etc/old.file /etc/blah/new.location

Afaict this is ok with policy, there is just one flaw: Anybody who has
edited /etc/old.file will get dpkg's updated conffile dialogue
even if /etc/old.file in 1.2-3 and /etc/blah/new.location in
1.2-4 are identical in the deb.

However the alternative, just orphaning /etc/old.file and installing a
new vanilla /etc/blah/new.location is much worse, as it actually
abandons the users configuration.

You can also do this in postinst:
if [ "$1" = "configure" ] && \
  dpkg --compare-versions "$2" le-nl "1.2-3" && \

which has essentially the same flaw the other way round: If you
changed the default /etc/old.file in between 1.2-1 and 1.2-2 and the
user has edited the file and is upgrading directly from 1.2-1 to 1.2-4
he _won't_ get dpkg's updated conffile dialogue although the default
conffile has changed between 1.2-1 and 1.2-4.  You should know what is
better for your package.

Please triplecheck with a dummy-package, all code in this mail is
           cu andreas
"See, I told you they'd listen to Reason," [SPOILER] Svfurlr fnlf,
fuhggvat qbja gur juveyvat tha.
Neal Stephenson in "Snow Crash"

Reply to: