1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
#!/usr/bin/perl
use warnings;
use strict;
use Data::Dumper;
my $repodir="/srv/http/sites/bluewind/repo";
my @arches=("i686", "x86_64", "any");
my $pkgname=$ARGV[0];
my @pkgs;
for my $arch (@arches) {
@pkgs = ();
for my $pkg (glob("$repodir/$arch/$pkgname-*")) {
# check the pkgname
$pkg =~ m/^.*\/(.+)-.*?-.*?-.*?\.pkg\.tar\..*$/;
next unless ($1 eq $pkgname);
my $mtime = (stat($pkg))[9];
push @pkgs, {path => $pkg, time => $mtime};
}
@pkgs = sort {$b->{time} cmp $a->{time} } @pkgs;
# ignore the latest file
shift @pkgs;
for my $pkg (@pkgs) {
print "removing $pkg->{path}\n";
unlink $pkg->{path};
}
}
|