/[smeserver]/builds_bin/update_test_repo
ViewVC logotype

Contents of /builds_bin/update_test_repo

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


Revision 1.2 - (show annotations) (download)
Tue Dec 12 03:54:21 2006 UTC (17 years, 11 months ago) by slords
Branch: MAIN
CVS Tags: HEAD
Changes since 1.1: +0 -0 lines
FILE REMOVED
Move test to dev

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

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