dpkg-scanpackages patched for obsolete package removal
13 Apr 2007 Creating private Debian packages in a repository has a lot of advantages. But when this repository gets large enough (and contains very oldI maintain a repository of selfcreated Debian and Ubuntu packages. The packages I create get tweaked alot during testing, so that several versions of each package exists in the repository. After some time, these obsolete packages slow down dpkg-scanpackages alot and I've often wished to clean them up.
After looking around a bit, I though apt-move would provide a solution. But this tool (like many other) seems to assume that I only have a cache repository in /var/apt/cache or where-ever. This is not the case.
So I looked at the source of the problem: dpkg-scanpackages. This tool detects the old versions (when reporting them) and is written in perl.
So I created this patch for /usr/bin/dpkg-scanpackages:
--- /usr/bin/dpkg-scanpackages 2005-05-26 19:42:35.000000000 +0200
+++ /tmp/dpkg-scanpackages 2007-04-13 10:45:59.211260520 +0200
@@ -109,15 +109,17 @@
if (defined($p1{$p})) {
if (&vercmp($tv{'Version'}, $pv{$p,'Version'})) {
+ if ($ENV{"DEBDELETE"} and -e $pfilename{$p}) { $str=" [DELETED]"; system "mv $pfilename{$p} /tmp/"; } else { $str=""; }
print(STDERR " ! Package $p (filename $fn) is repeat but newer version;\n".
- " used that one and ignored data from $pfilename{$p} !\n")
+ " used that one and ignored data from $pfilename{$p}$str!\n")
|| die $!;
delete $p1{$p};
for $k (keys %k1) {
delete $pv{$p,$k};
}
} else {
- print(STDERR " ! Package $p (filename $fn) is repeat;\n".
+ if ($ENV{"DEBDELETE"} and -e $fn) { $str=" [DELETED]"; system "mv $fn /tmp/"; } else { $str=""; }
+ print(STDERR " ! Package $p (filename $fn$str) is repeat;\n".
" ignored that one and using data from $pfilename{$p} !\n")
|| die $!;
next;
To delete the obsolete (old) versions of packages found in the repository, just define the "DEBDELETE" environment variable and run dpkg-scanpackages.
Example:
(root/aclb3) /home/deepstar/repository# DEBDELETE=1 /tmp/dpkg-scanpackages ubuntu/ /dev/null|gzip -9c > ubuntu/Packages.gz
! Package singularity-encfs (filename ubuntu//singularity-encfs-1176454666.deb) is repeat but newer version;
used that one and ignored data from ubuntu//singularity-encfs-1176453995.deb [DELETED]!
** Packages in archive but missing from override file: **
singularity-backup-client singularity-backup-server singularity-
encfs singularity-icons singularity-versioning
Wrote 5 entries to output Packages file.
(root/aclb3) /home/deepstar/repository#