yaobin.wen

Yaobin's Blog

View on GitHub
21 February 2022

Recover Reprepro Corrupted/Broken `.db` Files

by yaobin.wen

reprepro(1) is a tool to manage a repository of Debian packages. For future reference, here is a list of the documents I’ve collected about this tool:

This article talks about how to recover the corrupted/broken .db files under the db folder, using [5.2] as the main reference because it briefly talks about this process but doesn’t give a detailed list of steps.

As [4] points out, a Reprepro repository has the following basic sub-directories in its base directory:

In my work, I’m maintaining two distributions: edge and stable. When everything is fine, I could run reprepro list edge/stable to list all the packages in the specified distribution. One day, however, when I was publishing updated packages to edge, I accidentally corrupted the repository and started to get errors like “some .deb files are missing” errors. Having not found a way to fix that (since I had many missing .deb files), I moved the repository base directory away by appending .bak to its name and let reprepro recreate them with the distribution edge.

The problem was the newly created repository didn’t have the previously existing distribution stable. In other words, my partially recovered repository had the following parts:

As a result, when I ran reprepro list stable, I got the error of “Cannot find definition of distribution ‘stable’!”.

So I did the following steps to partially fix it:

Now I had the backup repository directory and the newly created repository directory almost synchronized. Running reprepro list stable wouldn’t report any error but it didn’t list any packages of stable, either, because the .db files in the newly created repository directory still didn’t have the information of those packages.

[5.2] teaches a way to recover the directory db:

If you have still an uncorrupted “dists/” directory around, (e.g. you just deleted db/ accidentally), it can be reconstructed by moving your dists/ directory to some other place, moving the packages.db file (if still existent) away, and set every distribution in conf/distributions a “Update: localreadd” with localreadd in conf/updates like:

Name: localreadd
Suite: *
Method: copy:/<otherplace>

with otherplace being the place you moved the dists/ directory too.

But the description is a bit vague without specific instructions. After some experimenting, I figured the following detailed steps to recover my db directory:

ssb:-:4096:1:851F38D2609E665D:1567703050::::::s:::+:::23:
fpr:::::::::A788F5525815CBC6DF91A36E851F38D2609E665D:
grp:::::::::2D08AB585A479D3A674BD9969EAB96F0A6286564:
Origin: Yaobin Wen <robin.wyb@gmail.com>
Codename: edge
Architectures: amd64
Components: comp1 comp2
SignWith: 0xA788F5525815CBC6DF91A36E851F38D2609E665D
Update: localreadd
Name: localreadd
Suite: *
VerifyRelease: 851F38D2609E665D
Method: copy:/srv/www/apt/debian/bionic/tmp

Now the db directory is re-constructed. Running reprepro list edge/stable should print the packages of the distributions.

Tags: Tech