recovery from "rm -rf /var/lib/dpkg/info" ?

Aaron Haviland orion at parsed.net
Wed Aug 22 20:36:11 BST 2007


Aaron Haviland wrote, on Aug 22, 2007 at 15:20 EDT:
> Uhm, you'll be needing to wipe $TMPDIR somewhere towards the end as
> well.
> 

Actually, you won't. I just finished debugging it.
I'll leave it up to you to create the TMPDIR or change the path in the
script

#!/bin/bash

TMPDIR="/tmp/x"
DPKGINFO="/var/lib/dpkg/info"

for i in $(dpkg --list | grep ^ii | cut -f3 -d' '); do
        echo "Now rebuilding package: ${i}" 
        sudo apt-get -d install --reinstall $i -qqy
        DEBNAME="/var/cache/apt/archives/${i}_*.deb"

        # extract control information
        dpkg-deb -e $DEBNAME $TMPDIR

        # we don't actually need the control file itself
        rm $TMPDIR/control

        # but we do need a file list
        dpkg-deb --contents $DEBNAME | cut -f2- -d'.' | while read k; do echo "${k%*/}"; done > $TMPDIR/list
        echo "/." >> $TMPDIR/list
    
        for j in $(cd $TMPDIR && echo *); do
                mv $TMPDIR/$j $DPKGINFO/$i.$j
                # $i.$j = packagename.postinst, for example
        done

        #wipe clean, save space
        sudo apt-get clean
done

-- 
Aaron Haviland
34 Wayne Ave, Dudley, MA                       home:  [508] 943 - 7974
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
Url : https://lists.ubuntu.com/archives/ubuntu-us-ma/attachments/20070822/a30957ac/attachment.pgp 


More information about the Ubuntu-us-ma mailing list