Hi Kristian,

On Wed, Aug 22, 2007 at 02:17:06PM -0400, Kristian Erik Hermansen wrote:
> On 8/22/07, Ben Collins <[EMAIL PROTECTED]> wrote:
> > sudo apt-get --reinstall install `dpkg --get-selections | grep 
> > '[[:space:]]install' | cut -f1`
> >
> > This _might_ work. There is no silver bullet to fix your problem other
> > than file backups.
> 
> I like your kung-fu, but how is this any different than...
> 
> $ sudo aptitude reinstall ~i

Perhaps extracting the needed files directly from the .deb archives will
do the trick?  Try this insanity, with sudo.  I have no idea if it will
work, YMMV, etc etc, but I think this is generally what's needed to get
all your dpkg info files back in place....

#!/bin/bash
set -e

# Clean out /var/cache/apt/archives
apt-get clean
# Fill it with all the .debs we need
apt-get --reinstall -dy install $(dpkg --get-selections | grep 
'[[:space:]]install' | cut -f1)

DIR=$(mktemp -d -t info-XXXXXX)
for deb in /var/cache/apt/archives/*.deb
do
        # Move to working directory
        cd "$DIR"
        # Create DEBIAN directory
        mkdir -p DEBIAN
        # Extract control files
        dpkg-deb -e "$deb"
        # Extract file list, fixing up the leading ./ and turning / into /.
        dpkg-deb -c "$deb" | awk '{print $NF}' | cut -c2- | sed -e 
's/^\/$/\/./' > DEBIAN/list
        # Figure out binary package name
        DEB=$(basename "$deb" | cut -d_ -f1)
        # Copy each control file into place
        cd DEBIAN
        for file in *
        do
                cp -a "$file" /var/lib/dpkg/info/"$DEB"."$file"
        done
        # Clean up
        cd ..
        rm -rf DEBIAN
done
rmdir "$DIR"

-- 
Kees Cook

Attachment: signature.asc
Description: Digital signature

-- 
ubuntu-server mailing list
[email protected]
https://lists.ubuntu.com/mailman/listinfo/ubuntu-server
More info: https://wiki.ubuntu.com/ServerTeam

Reply via email to