I've tried to install oracle-java7-installer package from custom repository onto Ubuntu 12. It was failed during executing some post-installation script. So. I want just to rollback it and proceed with another solutions (to install java 7 jdk). I've tried to make

UPDATED with set -x

 >  sudo aptitude remove oracle-java7-installer
The following packages will be REMOVED:
0 packages upgraded, 0 newly installed, 1 to remove and 47 not upgraded.
Need to get 0 B of archives. After unpacking 82.9 kB will be freed.
(Reading database ... 61748 files and directories currently installed.)
Removing oracle-java7-installer ...
+ uname -m
+ arch=amd64
+ dld=x64
+ J_INSTALL_DIR=/usr/lib/jvm/java-7-oracle
+ [ remove = remove ]
+ [ -d /usr/lib/jvm/java-7-oracle/man/man1 ]
+ basename /usr/lib/jvm/java-7-oracle/bin/*
+ name=*
+ [ ! -f /usr/bin/* -o -L /usr/bin/* ]
+ update-alternatives --remove bin boot dev etc home initrd.img lib lib64 lost+found media mnt opt proc raid root run sbin selinux srv sys tmp usr var vmlinuz /usr/lib/jvm/java-7-oracle/bin/*
update-alternatives: error: unknown argument `dev'
dpkg: error processing oracle-java7-installer (--remove):
 subprocess installed pre-removal script returned error exit status 2
No apport report written because MaxReports is reached already
--2012-10-24 17:53:33--  http://download.oracle.com/otn-pub/java/jdk/7u3-b04/jdk-7u3-linux-x64.tar.gz
Resolving download.oracle.com (download.oracle.com)...,
Connecting to download.oracle.com (download.oracle.com)||:80... connected.
HTTP request sent, awaiting response... 302 Moved Temporarily
Location: https://edelivery.oracle.com/otn-pub/java/jdk/7u3-b04/jdk-7u3-linux-x64.tar.gz [following]
--2012-10-24 17:53:33--  https://edelivery.oracle.com/otn-pub/java/jdk/7u3-b04/jdk-7u3-linux-x64.tar.gz
Resolving edelivery.oracle.com (edelivery.oracle.com)...
Connecting to edelivery.oracle.com (edelivery.oracle.com)||:443... connected.
HTTP request sent, awaiting response... 302 Moved Temporarily
Location: http://download.oracle.com/errors/download-fail-1505220.html [following]
--2012-10-24 17:53:33--  http://download.oracle.com/errors/download-fail-1505220.html
Connecting to download.oracle.com (download.oracle.com)||:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 5307 (5.2K) [text/html]
Saving to: `./jdk-7u3-linux-x64.tar.gz'

     0K .....                                                 100%  466M=0s

2012-10-24 17:53:33 (466 MB/s) - `./jdk-7u3-linux-x64.tar.gz' saved [5307/5307]

Download done.
sha256sum mismatch jdk-7u3-linux-x64.tar.gz
Oracle JDK 7 is NOT installed.
dpkg: error while cleaning up:
 subprocess installed post-installation script returned error exit status 1
Errors were encountered while processing:
E: Sub-process /usr/bin/dpkg returned an error code (1)
A package failed to install.  Trying to recover:
> sudo aptitude search oracle-java7-installer
   Cd  oracle-java7-installer                                                 - Sun Java(TM) Development Kit (JDK) 7

What I can do with that? Is it possible to rollback to the previous state without trying to deinstall broken package??

So. I understand from output that scripts inside package are wrong. they failed to download tar.gz from Oracle site and failed to install due to that. Also it does not handle properly remove commande and trying to install it again when I want to remove package. The basic question - is it possible to just rollback that package without running scripts? F.e. like in windows "System restore"? Or I should do this manually?


lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 12.04.1 LTS
Release: 12.04
Codename: precise


sh -x /var/lib/dpkg/info/oracle-java7-installer.prerm
+ set -e
+ uname -m
+ arch=amd64
+ dld=x64
+ J_INSTALL_DIR=/usr/lib/jvm/java-7-oracle
+ [ = remove ]
+ [ = deconfigure ]
+ exit 0

  • Run the following (as root) and provide the output so we can see why prerm is failing: sh -x /var/lib/dpkg/info/oracle-java7-installer.prerm
    – jordanm
    Oct 24, 2012 at 15:31
  • It looks like the error won't occur unless the remove or deconfigure condition is met. Edit the file, and add set -x under set -e. Run the aptitude remove again and update the output in your question.
    – jordanm
    Oct 24, 2012 at 15:37
  • @jordanm updated
    – denys
    Oct 24, 2012 at 16:01

1 Answer 1


That package appears to be buggy and of poor quality. The way to work around the buggy code in the maintainer scripts is to simply replace them with a noop script that will return true.

Replace /var/lib/dpkg/info/oracle-java7-installer.prerm and /var/lib/dpkg/info/oracle-java7-installer.postrm with the following:

exit 0

You should be able to remove the packages once the buggy maintainer scripts are replaced.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .