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

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


Aaron Haviland wrote, on Aug 22, 2007 at 15:16 EDT:
> Kristian Erik Hermansen wrote, on Aug 22, 2007 at 13:37 EDT:
> > Hey guys,
> > 
> > I did something dumb.  I was playing around with some debs and hacking
> > some control files, when I accidentally removed /var/lib/dpkg/info !!!
> >  Now, if I even try to do 'aptitude reinstall ~i', I am greeted with
> > "Writing extended state information... Error!".  dpkg --list still
> > shows all the currently installed packages, but I am unable to
> > reinstall.  Does anyone have a good idea on how to recover from
> > this???  Ideally, I think it would be easiest to reinstall all the
> > packages, since they are all from the repositories and none are
> > non-standard.
> > 
> > Let me just state that I do not want to do any file recovery, even
> > though I know quite well how to do that.  This should be able to be
> > reversed with some apt/dpkg kung-fu...
> 
> Should be able to be reversed quite easily, in fact, except that you'll
> need to re-download the debs.
> 
> the stuff in /v/l/d/info/ is just control info from the debs, nothing
> specific to your system.
> 
> here's some psdeudo script (i'm getting ready for work, can't spend time
> perfecting it)
> 
> for i in $INSTALLED_PACKAGE_LIST (think dpkg --list | grep ^ii); do
>    #fetch .deb
>    apt-get -d install --reinstall $i
>    DEBNAME="/var/cache/apt/archives/$i_*deb"
>    dpkg-deb -e $DEBNAME $TMPDIR
>    # extracts .control, .md5sums, .post and .pre inst/rm scripts
>    
>    #dpkg doesn't keep control
>    rm $TMPDIR/control
>    
>    #now we just need the .list
>    dpkg-deb --contents $DEBNAME | cut -f2- -d'.' | while read i; do echo "${i%*/}"; done > $TMPDIR/list
>    # that bashism wipes the rootdir line, but every package contains it,
>    # so put it back. It was in the wrong format before, anyway: "./"
>    echo "/." >> $TMPDIR/list
>    
>    for j in $(cd $TMPDIR && *); do
>    	mv $TMPDIR/$j /var/lib/dpkg/info/$i.$j
> 	# $i.$j = packagename.postinst, for example
>    done
> 
>    # wipe the fetched deb. save space
>    apt-get clean
> done
> 
> 
> err... something like that. throw in a bunch of echos and test things
> first! :)
>    
> -- 
> Aaron Haviland

Uhm, you'll be needing to wipe $TMPDIR somewhere towards the end as
well.

-- 
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/c5de40f5/attachment.pgp 


More information about the Ubuntu-us-ma mailing list