Re: Need advice wrt #295306
Pierre Habouzit <pierre.habouzit@m4x.org> wrotee:
> The only way is to do some hackish things in the <new-preinst> since
> it's the only script that will be called before the buggy <old-postrm>
>
> until here, it's OK. but I readlly dunno which hack I have to implement
> int the preinst. I have (at least) two choices, but I don't like any of
> them :
> (1) rm -f /var/lib/dpkg/info/uw-imapd.postrm (with the appropriate
> version check)
> - : this is truely horrible, moreover, postrm files may live elsewhere
Where should they live?
> - : this removes a dpkg file during it runs ... dpkg cannot be blamed
> if he fails after such a thing
> + : this is small, and easy to understand
I would never do such things.
> (2) parse /etc/inetd.conf and put the entries I don't want to loose
> somewhere in /var/cache for a moment
> and then use it in the postinst to feed inetd.conf
> + : this is really cleaner than the previous
> - : this is really not trivial : inetd.conf is sorted by categories,
> and it will be really difficult to put the entries at the right
> place in the postinst
> - : this fix will use quite a big amount of code, touch to many
> scripts, and thereof may lead to new bugs, really more easily than
> the previous "solution"
>
> I can't see any (3) that isn't a new instance of (1) or (2), so any
> advice is welcome.
I still think that (2) is the way to go. I also do not see that it is
_so_ difficult. This is what I would do:
1. Grep only non-comment, non-empty lines from inetd.conf
2. grep for the lines that uw-imapd is going to handle in its postinst.
3. For each line you got, add a comment line after it to inetd.conf:
tempfile=`mktemp`
sed -e "/^$service/ a #uw-imapd preinst: $original_line_as_grepped" \
/etc/inetd.conf > $tempfile
chmod --reference /etc/inetd.conf $tempfile
chown --reference /etc/inetd.conf $tempfile
mv $tempfile /etc/inetd.conf # you might need "-f"
(alternatively, you can use in-place-editing, but I am quite sure
woody's sed can't do that, and you don't want a pre-depends. woody's
Perl probably can do it.)
As far as I can see, nobody will touch these lines between your preinst
and your postinst, because the buggy postrm will only act on lines
matching ^$service.
In postinst, do the following:
sed -e 's@^#uw-imapd preinst: @@'
The only pitfall I see is that you must make sure that no char from the
original line as grepped prematurely ends your "a" command to sed. Maybe
Perl is safer here.
Regards, Frank
--
Frank Küster
Inst. f. Biochemie der Univ. Zürich
Debian Developer
Reply to: