/[smeserver]/builds_bin/update_dev_repo
ViewVC logotype

Contents of /builds_bin/update_dev_repo

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


Revision 1.4 - (show annotations) (download)
Mon Jan 22 16:37:25 2007 UTC (17 years, 10 months ago) by slords
Branch: MAIN
Changes since 1.3: +0 -1 lines
Update tools

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 $test_repo = '/releases/7/smedev';
11 my $releases = 2;
12
13 my $rpm_flags = RPM2->vsf_nodsa;
14 my @repositories = qw(
15 /releases/7/smeos/i386/CentOS/RPMS/
16 /releases/7/smeupdates/i386/RPMS/
17 /releases/7/smeupdates-testing/i386/RPMS/
18 /releases/7/smeextras/i386/RPMS/
19 /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 my $changed = 0;
59 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 $changed++;
71 }
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 if ($changed) {
84 system(qw(/builds/bin/linksource -s), "$test_repo/i386/RPMS", '-d', "$test_repo/SRPMS");
85 system(qw(createrepo), "$test_repo/i386");
86 system(qw(repoview), "$test_repo/i386");
87 system(qw(yum-arch), "$test_repo/i386");
88 }
89
90 sub compare($$) {
91 my ($a, $b) = @_;
92 return $a->tag("NAME") cmp $b->tag("NAME") || $a cmp $b;
93 }

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