Installing default-jdk, uninstalling it, doing apt-get autoremove, and reinstalling it leaves you without /usr/bin/javac ?

Bug #1285791 reported by Dan Kegel
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
java-common (Ubuntu)
New
Undecided
Unassigned

Bug Description

To reproduce:

$ sudo lxc-create -t ubuntu -n testbot01-ubu1004-test -- -r lucid
$ sudo lxc-start -n testbot01-ubu1004-test
(log in)
$ sudo apt-get install default-jdk
$ which javac
/usr/bin/javac
$ sudo apt-get remove default-jdk
$ which javac
/usr/bin/javac
$ sudo apt-get autoremove -y
$ which javac
$ sudo apt-get install default-jdk
$ which javac
$ update-java-alternatives -l
java-1.6.0-openjdk 1061 /usr/lib/jvm/java-1.6.0-openjdk
$ sudo update-java-alternatives -a
update-alternatives: error: no alternatives for appletviewer.
update-alternatives: error: no alternatives for extcheck.
...
$ apt-cache policy default-jdk
default-jdk:
  Installed: 1.6-34
  Candidate: 1.6-34
  Version table:
 *** 1.6-34 0
        500 http://archive.ubuntu.com/ubuntu/ lucid/main Packages
        100 /var/lib/dpkg/status

If you save a log on the two 'apt-get install default-jdk' lines, diffing the two shows:

 Setting up openjdk-6-jre-headless (6b27-1.12.6-1ubuntu0.10.04.4) ...
-update-alternatives: using /usr/lib/jvm/java-6-openjdk/jre/bin/java to provide /usr/bin/java (java) in auto mode.
...
 Setting up openjdk-6-jdk (6b27-1.12.6-1ubuntu0.10.04.4) ...
-update-alternatives: using /usr/lib/jvm/java-6-openjdk/bin/appletviewer to provide /usr/bin/appletviewer (appletviewer) in auto mode.

So evidently there's some sort of postinst / postrm problem that only shows up on the second install?

Revision history for this message
Dan Kegel (dank) wrote :

Oh, and the host OS was Ubuntu 12.04.4 LTS, if that matters.

Revision history for this message
Dan Kegel (dank) wrote :

The postinst script for openjdk-6-jdk_6b27-1.12.6-1ubuntu0.10.04.4_amd64.deb says:

case "$1" in
configure)
    # obsolete tool
    if update-alternatives --list apt 2>/dev/null; then
        update-alternatives --remove-all apt || true
    fi

    if [ -z "$2" ]; then
        update_alternatives=y
    fi

...

https://www.debian.org/doc/debian-policy/ch-maintainerscripts.html says $2 is " most-recently-configured-version".

Thus it looks like a thinko ... the author of the postinst script thought $2 meant something else, or forgot that the postrm script removed the alternatives?

The same test appears to be present in ubuntu 12.04's openjdk-7-jdk_7u51-2.4.4-0ubuntu0.12.04.2_amd64.deb,
but I haven't verified yet whether the problem occurs there as well.

Revision history for this message
Dan Kegel (dank) wrote :

Running 'apt-get purge openjdk-6-jdk' instead of (or after) removing openjdk-6-jdk appears to work around
the problem; the next install does put /usr/bin/javac in place.

Revision history for this message
Dan Kegel (dank) wrote :

Correction: apt-get purge openjdk-6-jdk *after* uninstalling it does not work around it (it refuses to purge
because the package isn't installed).
The correct workaround if you know the package is uninstalled is sudo dpkg --purge openjdk-6-jdk.

The problem is present if the package is not installed but is configured, e.g. if you see:

$ dpkg-query -l openjdk-6-jdk
Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Inst/Cfg-files/Unpacked/Failed-cfg/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
||/ Name Version Description
+++-=========================-=========================-==================================================================
rc openjdk-6-jdk 6b27-1.12.6-1ubuntu0.10.0 OpenJDK Development Kit (JDK)

instead of

$ dpkg-query -l openjdk-6-jdk
Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Inst/Cfg-files/Unpacked/Failed-cfg/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
||/ Name Version Description
+++-=========================-=========================-==================================================================
un openjdk-6-jdk <none> (no description available)

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.