2

Short of rebuilding the whole server from the ground up (which I'm working on anyway), any ideas how to fix this problem on an old debian etch box? Its annoying to not be able to apt-get things...

# apt-get install dpkg
<<snip>>
Preparing to replace dpkg 1.13.25 (using .../archives/dpkg_1.13.26_i386.deb) ...
dpkg: error processing /var/cache/apt/archives/dpkg_1.13.26_i386.deb (--unpack):
 unable to install updated status of `dpkg': No such file or directory
<< hangs here - need to ctrl-c >>


# dpkg -C
The following packages are in a mess due to serious problems during
installation.  They must be reinstalled for them (and any packages
that depend on them) to function properly:
 dpkg                 package maintenance system for Debian
gnarf
  • 713
  • 3
  • 8
  • 21

3 Answers3

2

Okay, this is going to be fun. Your box is fairly screwed, so the worst problem is that you screw it harder, but I take no responsibility for you doing that following this advice. The problem is either that the dpkg package didn't install correctly, or the metadata is corrupt.

Let's deal with the first problem. Debian packages are just an ar file of two tar files. You can extract them by hand if you really need to. Try the following:

# cd /tmp
# ar x /var/cache/apt/archives/dpkg_1.13.26_i386.deb
# cd /
# tar -xzvf /tmp/data.tar.gz

This should extract the files from the package and install them on the system. We should probably tell dpkg that the package is installed. Find the /var/lib/dpkg/status file, and find a line that says:

Package: dpkg

Then edit the Status line to say:

Status: install ok installed

and change the version to say:

Version: 1.13.26

Hopefully now, dpkg should be working. If it is, I would reinstall dpkg, so dpkg knows what files the dpkg package has installed.

# dpkg -i /var/cache/apt/archives/dpkg_1.13.26_i386.deb

If it's a metadata file that's become corrupt, they're just plain text files, so you can edit them. I would suggest using dpkg in debug more or strace to see if you can find out which file in particular is broken.

# dpkg --debug=2001 -i /var/cache/apt/archives/dpkg_1.13.26_i386.deb
# strace -efile -f dpkg -i /var/cache/apt/archives/dpkg_1.13.26_i386.deb

(Check out dpkg --debug=help to find out what 2001 means)

If the status file is corrupt, there is a status-old file you could use as a backup.

David Pashley
  • 23,151
  • 2
  • 41
  • 71
1

I suspect I might try manually re-downloading the dpkg deb using something like wget or curl and then manually extracting the contents of the package onto your filesystem.

It would be wise to have a backup of your system before you try this.

Zoredache
  • 128,755
  • 40
  • 271
  • 413
  • Thank you for two very useful links. The problem still exists though - dpkg seems to be segfaulting on installing anything... I'm working on rebuilding the server anyway... Still curious if anyone has any ideas. – gnarf Sep 29 '09 at 05:05
0

apt-get depends on dpkg for operation...thus if your dpkg is messed up, apt-get will not be able to install anything (including dpkg itself).

davr
  • 1,729
  • 3
  • 14
  • 24