apt is confused, trying to install packages that are already installed
DebianThis forum is for the discussion of Debian Linux.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
apt is confused, trying to install packages that are already installed
Hi all,
In a fit of absolute stupidity this morning I wiped pretty much all the files in my /var directory by typing /var instead of /var/log. After a few hours of panicing, I noticed 4 days ago I had backed up /var and /etc (testing a simple python program), so I replaced the files in /var with those from my backup. Now, apt-get wants to install/upgrade a load of packages that have already been upgraded. Will it be safe just to do an apt-get upgrade even old packages will have already been replaced with new ones, or am I going to need to have to tell/trick apt into realising the files have already been upgraded.
Nope, still wants to upgrade all the packages again. Will it be safe to just type yes? Also, before I replaced /var, I ran dpkg -l > installed_packages. Could I use this file to tell dpkg what is installed already?
Hmm, I don't think it worked... Now I'm getting this error whenever I invoke apt to upgrade or install etc.
Code:
# apt-get upgrade
Reading Package Lists... Done
Building Dependency Tree... Done
The following packages have been kept back:
x-window-system-core x-window-system-dev xlibmesa-gl xlibmesa-gl-dbg xlibmesa-gl-dev xlibosmesa-dev xlibosmesa4
xlibosmesa4-dbg
The following packages will be upgraded:
xlibs
1 upgraded, 0 newly installed, 0 to remove and 8 not upgraded.
116 not fully installed or removed.
Need to get 0B/479kB of archives.
After unpacking 430kB of additional disk space will be used.
Do you want to continue? [Y/n] y
Selecting previously deselected package xlibs.
(Reading database ... 143825 files and directories currently installed.)
Preparing to replace xlibs 4.3.0.dfsg.1-14 (using .../xlibs_6.8.2.dfsg.1-6_all.deb) ...
cp: `/etc/X11/xkb/rules/xfree86' and `/etc/X11/xkb/rules/xorg' are the same file
dpkg: error processing /var/cache/apt/archives/xlibs_6.8.2.dfsg.1-6_all.deb (--unpack):
subprocess pre-installation script returned error exit status 1
/var/lib/dpkg/tmp.ci/postrm: line 886: replace_conffile_with_symlink_rollback: command not found
dpkg: error while cleaning up:
subprocess post-removal script returned error exit status 127
Errors were encountered while processing:
/var/cache/apt/archives/xlibs_6.8.2.dfsg.1-6_all.deb
E: Sub-process /usr/bin/dpkg returned an error code (1)
I remembered having seen this problem before, so I did some searching.
I found a link via Google that shows how to rebuild a Debian package database (that thing in /var) using a script. This is the link.
However, read the comments in that script carefully before you run it. I think you need a /var that is completely empty to be able to run this script. Also I would recommend to back-up your important data.
I don't know if it works, I don't know if it can destroy your system, I haven't tried it myself, but you can give it a go. The worst thing that can happen is that you have to completely reinstall your system
And an advice for the feature, don't accidently delete the /var directory again
I moved everything from /var to /var2 for the time being, and tried the script but it kept exiting saying /var/log exists even though nothing existed there! It was strange though, I copied and pasted the shell script, and then saved it, chmod a+x, and then invoked it ./dpkg.sh and it just echo the contents of the file as it was working which was a little strange...
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.