Hello,
I've just found this bug and I must say is a real pain for vendors
which package stuff which installs in /opt.
I also found an easy way to reproduce the bug. See the bottom of this
message for details.
As a test one of the guys at work made /opt a symlink and we observed
that, although other directories were present in /opt, after the
removal of any of the
packages that has files in /opt, the symlink is gone somewhere right
after or during prerm.
I edited the maintainer scripts and added this snippet at the
beginning of each one:
echo ' >>> $0 : $1 : $2 : $3 '
ls -l -d /opt || echo '/opt is missing'
This the trimmed listing:
twix:/tmp# aptitude purge foo
...
>>> /var/lib/dpkg/info/foo.prerm : remove : :
lrwxrwxrwx 1 root root 9 2009-06-17 20:05 /opt -> opt-real/
...
>>> /var/lib/dpkg/info/foo.postrm : remove : :
ls: cannot access /opt: No such file or directory
/opt is missing
Curăț fișierele de configurare pentru foo ...
>>> /var/lib/dpkg/info/foo.postrm : purge : :
ls: cannot access /opt: No such file or directory
/opt is missing
Se procesează declanșatorii pentru man-db ...
...
As a demo I created a modified hello package whose intefdiff is:
0 eddy@twix ~/usr/src/perso/symlinkopt $ interdiff -z hello_2.2-3{,.1}.diff.gz
diff -u hello-2.2/debian/changelog hello-2.2/debian/changelog
--- hello-2.2/debian/changelog
+++ hello-2.2/debian/changelog
@@ -1,3 +1,10 @@
+hello (2.2-3.1) unstable; urgency=low
+
+ * Non-maintainer upload.
+ * put some file in /opt to test a possible bug in dpkg
+
+ -- Eddy Petrișor <eddy.petrisor@gmail.com> Wed, 17 Jun 2009 21:36:53 +0300
+
hello (2.2-3) unstable; urgency=low
* Added debian/watch file. Closes: #489213.
diff -u hello-2.2/debian/rules hello-2.2/debian/rules
--- hello-2.2/debian/rules
+++ hello-2.2/debian/rules
@@ -48,6 +48,9 @@
cp -a NEWS debian/copyright $(docdir)
cp -a debian/changelog $(docdir)/changelog.Debian
cp -a ChangeLog $(docdir)/changelog
+ # put stuff in /opt
+ mkdir -p debian/tmp/opt/hello/share/doc
+ cp -a NEWS debian/copyright debian/tmp/opt/hello/share/doc
cd $(docdir) && gzip -9 changelog changelog.Debian
gzip -r9 debian/tmp/usr/share/man
dpkg-shlibdeps debian/tmp/usr/bin/hello
Steps to reproduce:
1. mv /opt /opt-real && ln -s /opt-real /opt
2. mkdir -p /opt-real/bar && echo 'non-empty' > /opt-real/bar/bar-ish
3. install the attached hello deb (or build one from the attached source package
4. dpkg --remove hello
Result:
/opt symlink was deleted
Expected result:
/opt symlink should have been left as it was since there was also bar in there