Here is a quick way to fix half installed packages under Debian / Ubuntu Linux.
If you see an error while removing or installing debian / ubuntu package that read as follows:
(Reading database ... 147148 files and directories currently installed.)
Preparing to replace octopussy 0.9.6.2 (using octopussy_0.9.6.2_all.deb) ...
Unpacking replacement octopussy ...
dpkg: warning - old post-removal script returned error exit status 10
dpkg - trying script from the new package instead ...
dpkg: error processing octopussy_0.9.6.2_all.deb (--install):
subprocess new post-removal script returned error exit status 10
dpkg: error while cleaning up:
subprocess post-removal script returned error exit status 10
Errors were encountered while processing:
In above octopussy package is not getting removed because of script error. Mostly these are shell script written using /bin/sh. These scripts called with -e option which means if not interactive, exit immediately if any untested command fails. The exit status of a command is considered to be explicitly tested if the command is used to control an if, elif, while, or until; or if the command is the left hand operand of an && or || operator. In short shell scripts will abort with an error if something fails. To fix this problem visit /var/lib/dpkg/info directory
# cd /var/lib/dpkg/info
Now find out files in following format:
$ ls octopussy.*
Now open each file and find out line that read as follows:
Save and close all the files. Now run apt-get / dpkg command again to remove package:
# apt-get --purge remove octopussy
# dpkg -r octopussy
I install many packages for Debian / Ubuntu Linux from both stable/testing environment but some time I need to find out installed package is from stable or testing environment. I can use dpkg status file to get this information. But Debian comes with perl script called apt-show-versions which lists available package versions with distribution.
apt-show-versions parses the dpkg status file and the APT lists for the installed and available package versions and distribution and shows upgrade options within the specific distribution of the selected package. apt-show-versions uses caching for the status information of installed and available packages. If you run apt-show-versions as root the cache is updated as needed. If you run as non-root uses the newest available information, but can’t update the cache. If you run as root with the option -i the cache is initialized or updated only.
This is really useful if you have a mixed stable/testing environment and want to list all packages which are from testing and can be upgraded in testing.
Type the following command at shell prompt:
$ sudo apt-get install apt-show-versions
Just type command apt-show-versions:
java-common/testing uptodate 0.23
libperl5.8/testing upgradeable from 5.8.7-10 to 5.8.8-2
sysutils/testing upgradeable from 2.0.0-1 to 2.0.1
autoconf/unstable uptodate 2.59a-8
To upgrade all packages in testing you can type command:
# apt-get install $(apt-show-versions -u -b | fgrep testing)
Find out a list of all available versions of postgresql database server:
$ apt-show-versions -a -p postgresql
oth Debian and Ubuntu Linux provides a number of package management tools. This article summaries package management command along with it usage and examples for you. [click to continue…]