Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I got 2 repos locally. One is a copy of Squeeze and another is a custom one, and is managed by reprepro. Are there ready-made tools that would generate a list of duplicate packages between the two?

share|improve this question

You could go along with fdupes which uses md5sum to compare files and allows deletion of duplicates. I don't know enough about Debian repositories though, so you'll probably have to drop those files from some package registry as well (I think there is a file called packages.gz or similar in each repository).

So what you should do:

  1. Use fdupes to generate a list of duplicates
  2. use that list to drop packages from the repository information
  3. delete the actual files
share|improve this answer
Thanks for that. Very useful stuff. Once used it and forgot about it. BTW repoupdate has a command that deletes the package: it will remove both the repo info of that package (packages.gz) and the actual file itself. – Tshepang Sep 25 '10 at 22:30
up vote 0 down vote accepted

Silly me, I've been seating on a script that makes this far faster and easier:


import os
import gzip
import apt_pkg

repo1 = "~/.repo_local/dists/cache/main/binary-i386/Packages.gz"
repo1 = os.path.expanduser(repo1)
repo1 = apt_pkg.TagFile(gzip.open(repo1, "rb"))
repo1 = dict([(pkg["Package"], pkg["Version"]) for pkg in repo1])

repo2 = "~/.repo_bin/dists/squeeze/main/binary-i386/Packages.gz"
repo2 = os.path.expanduser(repo2)
repo2 = apt_pkg.TagFile(gzip.open(repo2, "rb"))
repo2 = dict([(pkg["Package"], pkg["Version"]) for pkg in repo2])

found = False

for pkg in repo1:
    if pkg in repo2:
        vc = apt_pkg.version_compare(repo1[pkg], repo2[pkg])
        if vc == 0:
            print("{:<30}{:<30}({})".format(repo1[pkg], repo2[pkg], pkg))
            found = True

if found:
    print("=" * 90)
    print("{:<30}{:<30}({})".format("custom", "official", "package name"))
    print("nothing matching search criteria found")
share|improve this answer
apt_pkg is from python3-apt. – Tshepang May 1 '11 at 21:59

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.