/[smeserver]/builds_bin/linksource
ViewVC logotype

Annotation of /builds_bin/linksource

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.8 - (hide annotations) (download)
Fri Apr 27 21:41:16 2007 UTC (17 years, 7 months ago) by slords
Branch: MAIN
CVS Tags: HEAD
Changes since 1.7: +0 -0 lines
FILE REMOVED
Remove old broken tools

1 gordonr 1.1 #!/usr/bin/perl
2    
3     use strict;
4     use warnings;
5     use RPM2;
6     use File::Copy;
7 slords 1.4 use Getopt::Std;
8    
9     my %opts;
10     getopts( "s:d:", \%opts );
11     my $src = $opts{s} || '/builds/RPMS';
12     my $dest = $opts{d} || '/builds/SRPMS';
13 gordonr 1.1
14     my $rpm_flags = RPM2->vsf_nodsa;
15     my @repositories = qw(
16 slords 1.3 /mirrors/centos/4/fasttrack/SRPMS
17     /mirrors/centos/4/updates/SRPMS
18     /mirrors/centos/4/os/SRPMS
19     /mirrors/centos/4/extras/SRPMS
20     /mirrors/rpmforge/dag/source/
21     /mirrors/atrpms/src/el4-i386/atrpms/stable/
22     /mirrors/fedora-legacy/fedora/3/updates/SRPMS/
23     /mirrors/fedora-legacy/fedora/3/os/SRPMS/
24     /builds/rpms/SRPMS/
25     );
26 gordonr 1.1
27 slords 1.4 opendir RPMS, "$src" or die "Couldn't opendir $src";
28 slords 1.5 my @rpms = map { RPM2->open_package("$src/$_", $rpm_flags) } grep { /\.rpm$/ } readdir RPMS;
29 gordonr 1.1 closedir RPMS;
30    
31 slords 1.6 opendir SRPMS, "$dest" or die "Couldn't opendir $dest";
32     my %srpms = map { $_ => 0 } grep { /\.rpm$/ } readdir SRPMS;
33     closedir SRPMS;
34    
35 gordonr 1.1 my %repos;
36     foreach my $repo (reverse @repositories)
37     {
38     my %temp_repo = map { $_ => $repo } grep { /\.rpm$/ } readdir RPMS if ( opendir RPMS, $repo );
39     closedir RPMS;
40    
41     %repos = (%repos, %temp_repo);
42     }
43    
44 slords 1.5 foreach my $rpm ( sort @rpms )
45 gordonr 1.1 {
46     my (@headers, $header);
47    
48     my $rpmfix = $rpm;
49     $rpmfix =~ s@\+@\\+@g;
50    
51     my @sources;
52 slords 1.5 my $src = $rpm->tag('SOURCERPM');
53 gordonr 1.1 push @sources, $src;
54     push @sources, $src if ($src =~ s/\.2\.el4\.rf\./\.rf\./);
55 gordonr 1.2 push @sources, $src if ($src =~ s/\.el4\.rf\./\.rf\./);
56 slords 1.3 push @sources, $src if ($src =~ s/\.el4\.at\./\.at\./);
57 gordonr 1.1 push @sources, $src if ($src =~ s/\.rf\./\.dag\./);
58    
59     my $found = 0;
60     foreach my $source ( @sources )
61     {
62 slords 1.4 if( -f "$dest/$source" )
63 gordonr 1.1 {
64     $found = 1;
65 slords 1.6 $srpms{$source}++;
66 gordonr 1.1 last;
67     } else {
68     if ($repos{$source})
69     {
70     my $fromfile = $repos{$source} . "/$source";
71     $fromfile =~ s#//#/#g;
72 slords 1.6 print "copying $source\n";
73     system(qw(cp --preserve=timestamps), $fromfile, "$dest/");
74 gordonr 1.1 $found = 1;
75 slords 1.6 $srpms{$source}++;
76 gordonr 1.1 last;
77     }
78    
79     }
80     }
81 slords 1.7 print "can't find SRPM ($sources[0]) for ", $rpm->as_nvre(), "\n" unless $found;
82 gordonr 1.1 }
83 slords 1.6
84     foreach my $srpm ( grep { $srpms{$_} == 0 } keys %srpms ) {
85     print "removing unused SRPM ($srpm)\n";
86     unlink "$dest/$srpm";
87     }

admin@koozali.org
ViewVC Help
Powered by ViewVC 1.2.1 RSS 2.0 feed