/[smeserver]/builds_bin/update_dev_repo
ViewVC logotype

Annotation of /builds_bin/update_dev_repo

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


Revision 1.3 - (hide annotations) (download)
Tue Jan 16 18:18:19 2007 UTC (17 years, 10 months ago) by slords
Branch: MAIN
Changes since 1.2: +12 -5 lines
Update tools

1 slords 1.1 #!/usr/bin/perl
2    
3     use strict;
4     use warnings;
5     use RPM2;
6     use Data::Dumper;
7    
8     sub compare($$);
9    
10 slords 1.3 my $test_repo = '/releases/7/smedev';
11 slords 1.1 my $releases = 2;
12    
13     my $rpm_flags = RPM2->vsf_nodsa;
14     my @repositories = qw(
15 slords 1.3 /releases/7/smeos/i386/CentOS/RPMS/
16 slords 1.1 /releases/7/smeupdates/i386/RPMS/
17     /releases/7/smeupdates-testing/i386/RPMS/
18 slords 1.3 /releases/7/smeextras/i386/RPMS/
19 slords 1.1 /builds/rpms/RPMS/i386/
20     /builds/rpms/RPMS/i586/
21     /builds/rpms/RPMS/i686/
22     /builds/rpms/RPMS/noarch/
23     );
24    
25     my %repos;
26     foreach my $repo (@repositories) {
27     opendir RPMS, $repo;
28     foreach my $rpm (grep { m#\.rpm# } readdir RPMS)
29     {
30     my $header = RPM2->open_package("$repo/$rpm", $rpm_flags);
31     if ($repo =~ m#^/releases/7/sme#) {
32     push @{$repos{$header->tag("NAME").".".$header->tag("ARCH")}{releases}}, $header;
33     } else {
34     push @{$repos{$header->tag("NAME")."-".$header->tag("VERSION").".".$header->tag("ARCH")}{builds}}, $header;
35     }
36     }
37     closedir RPMS;
38     }
39    
40     my @testing = map { RPM2->open_package("$test_repo/i386/RPMS/$_", $rpm_flags) } grep { m#\.rpm# } readdir RPMS if opendir RPMS, "$test_repo/i386/RPMS";
41     closedir RPMS;
42    
43     my %pushed;
44     foreach my $rpm (keys %repos) {
45     next unless $repos{$rpm}{builds};
46    
47     my @builds = reverse sort compare @{$repos{$rpm}{builds}};
48     my $cnt = $#builds > $releases-1 ? $releases-1 : $#builds;
49    
50     if ($repos{$builds[0]->tag("NAME").".".$builds[0]->tag("ARCH")}{releases}) {
51     my @released = reverse sort compare @{$repos{$builds[0]->tag("NAME").".".$builds[0]->tag("ARCH")}{releases}};
52     push @{$pushed{$builds[0]->tag("NAME").".".$builds[0]->tag("ARCH")}}, grep { $_ gt $released[0] } @builds[0..$cnt];
53     } else {
54     push @{$pushed{$builds[0]->tag("NAME").".".$builds[0]->tag("ARCH")}}, @builds[0..$cnt];
55     }
56     }
57    
58 slords 1.3 my $changed = 0;
59 slords 1.1 my @pushed;
60     foreach my $package (sort keys %pushed)
61     {
62     my @push = reverse sort compare @{$pushed{$package}};
63     my $cnt = $#push > $releases*2-1 ? $releases*2-1 : $#push;
64    
65     foreach my $rpm (@push[0..$cnt]) {
66     push @pushed, $rpm;
67     unless (grep { ! compare($_, $rpm) } @testing) {
68     print "adding ".$rpm->filename."\n";
69     system(qw(cp -a), $rpm->filename, "$test_repo/i386/RPMS/");
70 slords 1.3 $changed++;
71 slords 1.1 }
72     }
73     }
74    
75     foreach my $rpm (sort compare @testing)
76     {
77     unless (grep { ! compare($_,$rpm) } @pushed) {
78     print "removing ".$rpm->filename."\n";
79     unlink $rpm->filename;
80     }
81     }
82    
83 slords 1.3 if ($changed) {
84     system(qw(/builds/bin/linksource -s), "$test_repo/i386/RPMS", '-d', "$test_repo/SRPMS");
85     system(qw(rm -rf), "$test_repo/i386/headers", "$test_repo/i386/repodata");
86     system(qw(createrepo), "$test_repo/i386");
87     system(qw(repoview), "$test_repo/i386");
88     system(qw(yum-arch), "$test_repo/i386");
89     }
90 slords 1.1
91     sub compare($$) {
92     my ($a, $b) = @_;
93     return $a->tag("NAME") cmp $b->tag("NAME") || $a cmp $b;
94     }

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