summaryrefslogtreecommitdiffstats
path: root/src/vfs/extfs/helpers/rpms+.in
blob: 9a8e7de8bbfe43b7382c747253828660c35d881f (plain)
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#! @PERL@
#
# Written by Balazs Nagy (julian7@kva.hu) 1998
# locale bugfix by Michal Svec (rebel@penguin.cz) 2000
# (C) 1998 The Free Software Foundation.
#
#

# override any locale for dates
delete $ENV{"LC_ALL"};
$ENV{"LC_TIME"}="C";

#print $ENV{"LC_ALL"};
#exit 0;

sub gd
{
    my ($dt) = @_;
    $dt =~ tr/ //s;
    $dt =~ s/^\w+ (\w+) (\d+) (\d+:\d+):\d+ .+\n?$/$1 $2 $3/;
    return $dt;
}

$DATE=gd(`date`);

sub list
{
    my (@rpms, %files, $i, $fn, $dn, $sz, $bt);
#    @rpms = `rpm -qa --qf "\%{NAME}-\%{VERSION}-\%{RELEASE}:\%{GROUP}:\%{SIZE}:\%{BUILDTIME:date}\n"`;
    @rpms = `rpm -qa --qf "\%{NAME}-\%{VERSION}:\%{GROUP}:\%{SIZE}:\%{BUILDTIME:date}\n"`;
    print @trpms;
    %files = ();
    %sizes = ();
    %dates = ();
    for $i (@rpms) {
	if ($i =~ /^([^:]+):([^:]+):([^:]+):(.+)$/) {
	    ($fn, $dn, $sz, $bt) = ($1, $2, $3, $4);
	    $dn =~ s/ /_/g;
	    if (defined $files{$dn}) {
		push(@{$files{$dn}}, $fn);
	    } else {
		@{$files{$dn}} = ($fn);
	    }
	    $sizes{$fn} = $sz;
	    $dates{$fn} = gd($bt);
	}
    }
    for $i (sort keys %files) {
	print "dr-xr-xr-x 1 root root 0 $DATE $i/\n";
	for $fn (sort @{$files{$i}}) {
	    print "-r--r--r-- 1 root root $sizes{$fn} $dates{$fn} $i/$fn.trpm\n";
	}
    }
}

#open O, ">>/tmp/tt";
#print O "RPMS: ";
#for $i (@ARGV) {
#    print O "$i ";
#}
#print O "\n";
#close O;

if ($ARGV[0] eq "list") { list(); exit(0); }
elsif ($ARGV[0] eq "copyout") { open O, ">$ARGV[3]"; print O $ARGV[2], "\n"; close O; exit(0); }
exit(1);