Package: ccache Version: 3.1.5-2 Severity: normal Tags: patch Hello,
when I install gcc/g++ before ccache the symlinks to /usr/bin/cc and /usr/bin/c++ aren't updated. This is what happens (see below what's wrong) in a clean chroot: root@nemesis:/# apt-get install ccache [snip] Setting up ccache (3.1.5-2) ... Updating symlinks in /usr/lib/ccache ... root@nemesis:/# apt-get install gcc g++ [snip] Selecting previously deselected package gcc. Unpacking gcc (from .../gcc_4%3a4.6.0-6_amd64.deb) ... [snip] Selecting previously deselected package g++-4.6. Unpacking g++-4.6 (from .../g++-4.6_4.6.1-1_amd64.deb) ... Selecting previously deselected package g++. Unpacking g++ (from .../g++_4%3a4.6.0-6_amd64.deb) ... [snip] Processing triggers for ccache ... Updating symlinks in /usr/lib/ccache ... [snip] Setting up gcc (4:4.6.0-6) ... [snip] Setting up g++ (4:4.6.0-6) ... update-alternatives: using /usr/bin/g++ to provide /usr/bin/c++ (c++) in auto mode. root@nemesis:/# ls -la /usr/lib/ccache/ total 8 drwxr-xr-x 2 root root 4096 Jul 5 20:34 . drwxr-xr-x 25 root root 4096 Jul 5 20:34 .. lrwxrwxrwx 1 root root 16 Jul 5 20:34 c89-gcc -> ../../bin/ccache lrwxrwxrwx 1 root root 16 Jul 5 20:34 c99-gcc -> ../../bin/ccache lrwxrwxrwx 1 root root 16 Jul 5 20:34 g++ -> ../../bin/ccache lrwxrwxrwx 1 root root 16 Jul 5 20:34 g++-4.6 -> ../../bin/ccache lrwxrwxrwx 1 root root 16 Jul 5 20:34 gcc -> ../../bin/ccache lrwxrwxrwx 1 root root 16 Jul 5 20:34 gcc-4.6 -> ../../bin/ccache lrwxrwxrwx 1 root root 16 Jul 5 20:34 x86_64-linux-gnu-g++ -> ../../bin/ccache lrwxrwxrwx 1 root root 16 Jul 5 20:34 x86_64-linux-gnu-g++-4.6 -> ../../bin/ccache lrwxrwxrwx 1 root root 16 Jul 5 20:34 x86_64-linux-gnu-gcc -> ../../bin/ccache lrwxrwxrwx 1 root root 16 Jul 5 20:34 x86_64-linux-gnu-gcc-4.6 -> ../../bin/ccache root@nemesis:/# update-ccache-symlinks root@nemesis:/# ls -la /usr/lib/ccache/ total 8 drwxr-xr-x 2 root root 4096 Jul 5 20:36 . drwxr-xr-x 25 root root 4096 Jul 5 20:34 .. lrwxrwxrwx 1 root root 16 Jul 5 20:36 c++ -> ../../bin/ccache lrwxrwxrwx 1 root root 16 Jul 5 20:34 c89-gcc -> ../../bin/ccache lrwxrwxrwx 1 root root 16 Jul 5 20:34 c99-gcc -> ../../bin/ccache lrwxrwxrwx 1 root root 16 Jul 5 20:36 cc -> ../../bin/ccache lrwxrwxrwx 1 root root 16 Jul 5 20:34 g++ -> ../../bin/ccache lrwxrwxrwx 1 root root 16 Jul 5 20:34 g++-4.6 -> ../../bin/ccache lrwxrwxrwx 1 root root 16 Jul 5 20:34 gcc -> ../../bin/ccache lrwxrwxrwx 1 root root 16 Jul 5 20:34 gcc-4.6 -> ../../bin/ccache lrwxrwxrwx 1 root root 16 Jul 5 20:34 x86_64-linux-gnu-g++ -> ../../bin/ccache lrwxrwxrwx 1 root root 16 Jul 5 20:34 x86_64-linux-gnu-g++-4.6 -> ../../bin/ccache lrwxrwxrwx 1 root root 16 Jul 5 20:34 x86_64-linux-gnu-gcc -> ../../bin/ccache lrwxrwxrwx 1 root root 16 Jul 5 20:34 x86_64-linux-gnu-gcc-4.6 -> ../../bin/ccache As you can see in the first ls, both cc and c++ symlinks are missing in /usr/lib/ccache/. The problem is the following: both /usr/bin/cc and /usr/bin/c++ are alternatives installed while executing gcc and g++ postinst scripts respectively. The dpkg triggers for ccache are activated in the gcc/g++ configuring stage, before /usr/bin/cc and /usr/bin/c++ exist in the hard disk, therefore they aren't considered by update-ccache-symlinks. How to solve it? The first thing I tought was that adding a couple of file triggers for /usr/bin/cc and /usr/bin/c++ to ccache would do the trick, but unfortunately there's a problem with this; quoting from "File triggers" section of /usr/share/doc/dpkg-dev/triggers.txt.gz >File triggers have names of the form > /path/to/directory/or/file >and are activated when the specified filesystem object, or any object >under the specified subdirectory, is created, updated or deleted by >dpkg during package unpack or removal. So file triggers can't be activated in the postinst, only during upack or removal. Therefore the solution is making the triggers explicit, calling them from some maintainer scripts in gcc-defaults. I'm attaching a couple of patches implementing this solution. So ... if the gcc maintainers accept the gcc-defaults patch, would you accept the ccache one? If yes, I would open a new bug report against src:gcc-defaults with the patch and mark this one as blocked. A reply just saying "go ahead" is enough, thanks for your time.
Sólo en new/ccache-3.1.5/debian/: ccache.triggers diff -ur orig/ccache-3.1.5/debian//ccache.triggers.in new/ccache-3.1.5/debian//ccache.triggers.in --- orig/ccache-3.1.5/debian//ccache.triggers.in 2011-06-25 23:54:41.000000000 +0200 +++ new/ccache-3.1.5/debian//ccache.triggers.in 2011-07-05 02:04:11.000000000 +0200 @@ -1,2 +1,4 @@ +interest /usr/bin/cc +interest /usr/bin/c++ interest /usr/lib/gcc interest /usr/lib/%DEB_HOST_MULTIARCH%/gcc diff -ur orig/ccache-3.1.5/debian//changelog new/ccache-3.1.5/debian//changelog --- orig/ccache-3.1.5/debian//changelog 2011-06-25 23:54:41.000000000 +0200 +++ new/ccache-3.1.5/debian//changelog 2011-07-05 02:05:24.000000000 +0200 @@ -1,3 +1,9 @@ +ccache (3.1.5-2+santa1) UNRELEASED; urgency=low + + * Add triggers for /usr/bin/cc and /usr/bin/c++. + + -- José Manuel Santamaría Lema <panfa...@gmail.com> Tue, 05 Jul 2011 02:04:30 +0200 + ccache (3.1.5-2) unstable; urgency=low * Update dpkg triggers and update-ccache-symlinks to find compilers at
diff -ur orig/gcc-defaults-1.105/debian//changelog new/gcc-defaults-1.105+nmu0~santa2/debian//changelog --- orig/gcc-defaults-1.105/debian//changelog 2011-06-16 23:53:08.000000000 +0200 +++ new/gcc-defaults-1.105+nmu0~santa2/debian//changelog 2011-07-05 23:27:05.324000747 +0200 @@ -1,3 +1,10 @@ +gcc-defaults (1.105+nmu0~santa2) UNRELEASED; urgency=low + + * Activate triggers for /usr/bin/cc and /usr/bin/c++ in gcc and g++ + postinst/prerm scripts respectively. + + -- José Manuel Santamaría Lema <panfa...@gmail.com> Tue, 05 Jul 2011 03:16:21 +0200 + gcc-defaults (1.105) unstable; urgency=low * Build libgcj-bc for multiarch. Closes: #630417. diff -ur orig/gcc-defaults-1.105/debian//gcc.postinst.in new/gcc-defaults-1.105+nmu0~santa2/debian//gcc.postinst.in --- orig/gcc-defaults-1.105/debian//gcc.postinst.in 2006-08-19 14:57:11.000000000 +0200 +++ new/gcc-defaults-1.105+nmu0~santa2/debian//gcc.postinst.in 2011-07-05 23:34:25.492000813 +0200 @@ -19,6 +19,8 @@ --install /usr/bin/c99 c99 /usr/bin/c99-gcc 20 \ --slave /usr/share/man/man1/c99.1.gz c99.1.gz /usr/share/man/man1/c99-gcc.1.gz +dpkg-trigger /usr/bin/cc + # remove f77 alternative left over from an old egcs version ... if [ -h /etc/alternatives/f77 -a ! -e /etc/alternatives/f77 ]; then rm -f /etc/alternatives/f77 diff -ur orig/gcc-defaults-1.105/debian//gcc.prerm new/gcc-defaults-1.105+nmu0~santa2/debian//gcc.prerm --- orig/gcc-defaults-1.105/debian//gcc.prerm 2006-05-07 11:32:50.000000000 +0200 +++ new/gcc-defaults-1.105+nmu0~santa2/debian//gcc.prerm 2011-07-05 23:29:54.856000771 +0200 @@ -6,6 +6,8 @@ update-alternatives --quiet --remove c99 /usr/bin/c99-gcc fi +dpkg-trigger /usr/bin/cc + #DEBHELPER# exit 0 diff -ur orig/gcc-defaults-1.105/debian//g++.postinst.in new/gcc-defaults-1.105+nmu0~santa2/debian//g++.postinst.in --- orig/gcc-defaults-1.105/debian//g++.postinst.in 2006-08-19 15:09:21.000000000 +0200 +++ new/gcc-defaults-1.105+nmu0~santa2/debian//g++.postinst.in 2011-07-05 03:14:38.000000000 +0200 @@ -32,6 +32,8 @@ --install /usr/bin/c++ c++ /usr/bin/g++ 20 \ @GFDL@--slave /usr/share/man/man1/c++.1.gz c++.1.gz /usr/share/man/man1/g++.1.gz +dpkg-trigger /usr/bin/c++ + #DEBHELPER# exit 0 diff -ur orig/gcc-defaults-1.105/debian//g++.prerm new/gcc-defaults-1.105+nmu0~santa2/debian//g++.prerm --- orig/gcc-defaults-1.105/debian//g++.prerm 2001-02-27 02:28:32.000000000 +0100 +++ new/gcc-defaults-1.105+nmu0~santa2/debian//g++.prerm 2011-07-05 23:28:20.356000759 +0200 @@ -4,6 +4,8 @@ update-alternatives --remove c++ /usr/bin/g++ fi +dpkg-trigger /usr/bin/c++ + #DEBHELPER# exit 0 diff -ur orig/gcc-defaults-1.105/debian//README.Debian new/gcc-defaults-1.105+nmu0~santa2/debian//README.Debian --- orig/gcc-defaults-1.105/debian//README.Debian 2011-04-29 17:10:27.000000000 +0200 +++ new/gcc-defaults-1.105+nmu0~santa2/debian//README.Debian 2011-07-05 23:34:52.752000817 +0200 @@ -45,7 +45,7 @@ architecture. To use the other compiler, simply set CC=gcc-4.1, or similar. -The default compiler versions for Debian GNU/Linux on i386 are +The default compiler versions for Debian GNU/Linux on amd64 are (minor version numbers omitted): cpp : cpp-4.6