31 Oct 2010 hulten   » (Apprentice)

I had accidentally deleted /var/lib/dpkg/info/ from one of my Debian GNU/Linux systems, with the consequence that APT misses relevant metadata. I vaguely remember having done this before and I might do it stupidly again. Therefore I wrote a script which seems to fix this.

# Repare dpkg database in /var/lib/dpkg/info/ from /var/lib/dpkg/status.
echo File ${STATUS} will be used to read which packages you have 
echo New info/* files will be moved into ${INFO}/.
mkdir ${INFO}
for PACKAGE in `grep ^Package ${STATUS} | awk '{print $2}'`; do
    echo Processing ${PACKAGE}...
    aptitude download ${PACKAGE} || continue
    dpkg-deb -e `ls ${PACKAGE}*.deb` || continue
    for CTRLFILE in *; do mv ${CTRLFILE} 
../${INFO}/${PACKAGE}.${CTRLFILE}; done
    cd ${BASEDIR}/
    rm ${PACKAGE}*.deb

This can be ran as a normal user. If you then move all files from dpkg-info/ to /var/lib/dpkg/info/ APT should work well again. You should change the script if you already have a large amount of deb files in /var/cache/apt/archives/.

Do whatever you want with the script. The script is as-is, without any waranties.

Update: This method does not restore the *.list files, thus leaving me without all necessary dpkg metadata.

Latest blog entries     Older blog entries

New Advogato Features

New HTML Parser: The long-awaited libxml2 based HTML parser code is live. It needs further work but already handles most markup better than the original parser.

Keep up with the latest Advogato features by reading the Advogato status blog.

If you're a C programmer with some spare time, take a look at the mod_virgule project page and help us with one of the tasks on the ToDo list!