Comment 26 for bug 1473691

Revision history for this message
Steve Langasek (vorlon) wrote :

if test -d /etc/squid3 && dpkg --compare-versions "$2" lt '3.5'; then
       #
       # handle the case where we have /etc/squid3 but the init script is
       # named squid.
       #
       service=squid3
       if ! test -e /etc/init.d/$service ; then
               service=squid
       fi
       invoke-rc.d $service stop
       invoke-rc.d $service start
else
       invoke-rc.d squid restart
fi

I had to look very carefully at the packages in trusty and wily to try to figure out what this code is supposed to do, and I'm still not sure. At first I believed it was buggy, then I came to believe it was just pointless, now I'm convinced again that it's buggy.

The trusty version of the squid3 package ships an /etc/init/squid3.conf upstart job and no init script.
The wily version of the squid3 package ships both an /etc/init/squid3.conf upstart job, and an /etc/init.d/squid3 init script.

You are first looking for a script named /etc/init.d/squid3, and if it's absent, you are stopping and starting the 'squid' service. But if it's *present*, you are stopping and starting the squid3 service, which is certainly wrong.

So on upgrade from trusty, you will have removed /etc/init/squid3.conf in the preinst of squid, and the old version of the squid3 package will have stopped the squid3 service in its prerm because squid Conflicts: old squid3 package and is being removed. Then squid postinst stops squid (unnecessary because not previously started), then starts squid. So the code to get there is convoluted but this will work.

But on upgrade from wily, the old version of the squid3 package will have stopped the squid3 service in its prerm because squid Conflicts: old squid3 package and is being removed; and the new squid preinst will have removed /etc/init/squid3.conf; but /etc/init.d/squid3, which is a conffile, will still be on disk, so your code now tries to stop and then start the old squid3 service, instead of stopping squid3 (which, again, is redundant) and starting squid.

As far as I can see, the entire versioned code block here is wrong, and you should *only* be restarting squid.