/[smeserver]/builds_bin/update_repos
ViewVC logotype

Diff of /builds_bin/update_repos

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

Revision 1.12 by slords, Sun Jun 3 16:00:54 2007 UTC Revision 1.19 by slords, Tue Oct 16 21:36:23 2007 UTC
# Line 17  my $builds = '/builds/rpms'; Line 17  my $builds = '/builds/rpms';
17  my $stagedir = '/builds';  my $stagedir = '/builds';
18  my $arch = `uname -i`;  my $arch = `uname -i`;
19  chomp $arch;  chomp $arch;
20    #$arch = 'x86_64';
21    
22  my @repos = (  my @repos = (
               "$releasedir/$smerel/smeos/$arch/CentOS/RPMS",  
               "$releasedir/$smerel/smeos/$arch/SME/RPMS",  
               "$releasedir/$smerel/smeos/$arch/RPMS",  
23                "$releasedir/$smerel/smeos/$arch/SME",                "$releasedir/$smerel/smeos/$arch/SME",
24                  "$releasedir/$smerel/smeos/$arch/SME/RPMS",
25                  "$releasedir/$smerel/smeos/$arch/CentOS/RPMS",
26                "$releasedir/$smerel/smeupdates/$arch/RPMS",                "$releasedir/$smerel/smeupdates/$arch/RPMS",
27                "$releasedir/$smerel/smeupdates-testing/$arch/RPMS",                "$releasedir/$smerel/smeupdates-testing/$arch/RPMS",
28                "$releasedir/$smerel/smeextras/$arch/RPMS",                "$releasedir/$smerel/smeextras/$arch/RPMS",
29                "$releasedir/$smerel/smeaddons/$arch/RPMS",                "$releasedir/$smerel/smeaddons/$arch/RPMS",
30                  "$releasedir/$smerel/smecontribs/$arch/RPMS",
31                "$releasedir/$smerel/smetest/$arch/RPMS",                "$releasedir/$smerel/smetest/$arch/RPMS",
32                "$releasedir/$smerel/smedev/$arch/RPMS",                "$releasedir/$smerel/smedev/$arch/RPMS",
33                "$builds/RPMS/$arch",                "$builds/RPMS/$arch",
34                "$builds/RPMS/i586",                "$builds/RPMS/i586",
35                "$builds/RPMS/i686",                "$builds/RPMS/i686",
36                "$builds/RPMS/noarch",                "$builds/RPMS/noarch",
37                "$stagedir/RPMS",                "$stagedir/RPMS-$arch",
38              );              );
39    @repos = grep { ! m{/i[56]86$} } @repos if $arch eq 'x86_64';
40    
41  my @srcrepos = (  my @srcrepos = (
42                   "/mirrors/centos/$centosrel/fasttrack/SRPMS",                   "/mirrors/centos/$centosrel/fasttrack/SRPMS",
# Line 43  my @srcrepos = ( Line 45  my @srcrepos = (
45                   "/mirrors/centos/$centosrel/extras/SRPMS",                   "/mirrors/centos/$centosrel/extras/SRPMS",
46                   "/mirrors/rpmforge/dag/source",                   "/mirrors/rpmforge/dag/source",
47                   "/mirrors/atrpms/src/el$centosrel-$arch/atrpms/stable",                   "/mirrors/atrpms/src/el$centosrel-$arch/atrpms/stable",
48                     "/mirrors/atrpms/src/el$centosrel-$arch/atrpms/testing",
49                   "/mirrors/fedora/epel/$centosrel/SRPMS",                   "/mirrors/fedora/epel/$centosrel/SRPMS",
50                     "/mirrors/fedora/epel/testing/$centosrel/SRPMS",
51                   "/mirrors/fedora/core/updates/$fedorarel/SRPMS",                   "/mirrors/fedora/core/updates/$fedorarel/SRPMS",
52                   "/mirrors/fedora/core/$fedorarel/source/SRPMS",                   "/mirrors/fedora/core/$fedorarel/source/SRPMS",
53                   "/mirrors/fedora/extras/$fedorarel/SRPMS",                   "/mirrors/fedora/extras/$fedorarel/SRPMS",
# Line 58  my %sources; Line 62  my %sources;
62  my %changed;  my %changed;
63  my %copy;  my %copy;
64    
65    print "\nReading repos...\n";
66  foreach my $repo ( @repos ) {  foreach my $repo ( @repos ) {
67          my $r = $repo;          my $r = $repo;
68          if ( $repo =~ m{$stagedir/RPMS} ) {          if ( $repo =~ m{$stagedir/RPMS} ) {
# Line 68  foreach my $repo ( @repos ) { Line 73  foreach my $repo ( @repos ) {
73                  $r = $1;                  $r = $1;
74          }          }
75    
76          if ( $r ne 'builds' ) {          if ( $r eq $stagedir ) {
77                    opendir SRPMS, "$r/SRPMS-$arch" or next;
78                    foreach my $srpm ( grep { /\.rpm$/ } readdir SRPMS ) {
79                            $srpms{$r}{$srpm} = 0;
80                            $sources{$srpm} = "$r/SRPMS-$arch";
81                    }
82                    closedir SRPMS;
83            } elsif ( $r ne 'builds' ) {
84                  opendir SRPMS, "$r/SRPMS" or next;                  opendir SRPMS, "$r/SRPMS" or next;
85                  foreach my $srpm ( grep { /\.rpm$/ } readdir SRPMS ) {                  foreach my $srpm ( grep { /\.rpm$/ } readdir SRPMS ) {
86                          $srpms{$r}{$srpm} = 0;                          $srpms{$r}{$srpm} = 0;
# Line 78  foreach my $repo ( @repos ) { Line 90  foreach my $repo ( @repos ) {
90          }          }
91    
92          opendir RPMS, $repo or next;          opendir RPMS, $repo or next;
93            print " - $repo\n";
94          foreach my $pkg ( reverse sort map { RPM2->open_package("$repo/$_", $rpm_flags); } grep { /\.rpm$/ } readdir RPMS ) {          foreach my $pkg ( reverse sort map { RPM2->open_package("$repo/$_", $rpm_flags); } grep { /\.rpm$/ } readdir RPMS ) {
95                  my $rpm = { name => $pkg->tag("NAME"),                  my $rpm = { name => $pkg->tag("NAME"),
96                                  filename => join("-", map { $pkg->tag($_) } qw/name version release/) . "." . $pkg->tag("ARCH"),                                  filename => join("-", map { $pkg->tag($_) } qw/name version release/) . "." . $pkg->tag("ARCH"),
# Line 101  foreach my $repo ( @repos ) { Line 114  foreach my $repo ( @repos ) {
114          closedir RPMS;          closedir RPMS;
115  }  }
116    
117    print "\nReading source repos...\n";
118  foreach my $repo ( reverse @srcrepos ) {  foreach my $repo ( reverse @srcrepos ) {
119          my %temp_repo = map { $_ => $repo } grep { /\.rpm$/ } readdir SRPMS if ( opendir SRPMS, $repo );          my %temp_repo = map { $_ => $repo } grep { /\.rpm$/ } readdir SRPMS if ( opendir SRPMS, $repo );
120          closedir SRPMS;          closedir SRPMS;
# Line 108  foreach my $repo ( reverse @srcrepos ) { Line 122  foreach my $repo ( reverse @srcrepos ) {
122          %sources = (%sources, %temp_repo);          %sources = (%sources, %temp_repo);
123  }  }
124    
125    print "\nFinding latest packages...\n";
126  my @latest;  my @latest;
127  foreach my $rpm ( reverse grep { $_->{repo} =~ m{^$releasedir/$smerel/} && $_->{repo} !~ m{/smedev$} } @rpms )  {  foreach my $rpm ( reverse grep { $_->{repo} =~ m{^$releasedir/$smerel/} && $_->{repo} !~ m{/sme(addons|contribs|dev|extras)$} } @rpms )  {
128          unless ( grep { $_->{name} eq $rpm->{name} && $_->{rpm} gt $rpm->{rpm} } @latest ) {          unless ( grep { $_->{name} eq $rpm->{name} && $_->{rpm} gt $rpm->{rpm} } @latest ) {
129                  push @latest, $rpm;                  push @latest, $rpm;
130                  unless ( grep { $_->{repo} eq $stagedir && $_->{filename} eq $rpm->{filename} } @rpms ) {                  unless ( grep { $_->{repo} eq $stagedir && $_->{filename} eq $rpm->{filename} } @rpms ) {
131                          push @{$copy{"$stagedir/RPMS"}}, $rpm->{rpm}->filename;                          push @{$copy{"$stagedir/RPMS-$arch"}}, $rpm->{rpm}->filename;
132                          push @rpms, { name => $rpm->{name},                          push @rpms, { name => $rpm->{name},
133                                        filename => $rpm->{filename},                                        filename => $rpm->{filename},
134                                        version => $rpm->{version},                                        version => $rpm->{version},
# Line 130  foreach my $rpm ( grep { $_->{repo} eq $ Line 145  foreach my $rpm ( grep { $_->{repo} eq $
145          $rpm->{repo} = 'deleted' unless grep { $_->{filename} eq $rpm->{filename} } @latest;          $rpm->{repo} = 'deleted' unless grep { $_->{filename} eq $rpm->{filename} } @latest;
146  }  }
147    
148    foreach my $rpm ( reverse grep { $_->{repo} =~ m{^$releasedir/$smerel/} && $_->{repo} =~ m{/sme(addons|contribs|extras)$} } @rpms )  {
149            unless ( grep { $_->{name} eq $rpm->{name} && $_->{rpm} gt $rpm->{rpm} } @latest ) {
150                    push @latest, $rpm;
151            }
152    }
153    
154    print "\nFinding development packages...\n";
155  my @devel;  my @devel;
156  my %versions;  my %versions;
157  foreach my $rpm ( grep { $_->{repo} eq 'builds' } @rpms )  {  foreach my $rpm ( grep { $_->{repo} eq 'builds' } @rpms )  {
# Line 158  foreach my $rpm ( grep { $_->{repo} =~ m Line 180  foreach my $rpm ( grep { $_->{repo} =~ m
180          $rpm->{repo} = 'deleted' unless grep { $_->{filename} eq $rpm->{filename} } @devel;          $rpm->{repo} = 'deleted' unless grep { $_->{filename} eq $rpm->{filename} } @devel;
181  }  }
182    
183  print "\n";  print "\nFinding source packages...\n";
184  foreach my $rpm ( grep { $_->{repo} !~ m{^(builds|deleted)$} } @rpms ) {  foreach my $rpm ( grep { $_->{repo} !~ m{^(builds|deleted)$} } @rpms ) {
185          my $src;          my $src;
186          my $srpm = $rpm->{rpm}->tag("SOURCERPM");          my $srpm = $rpm->{rpm}->tag("SOURCERPM");
# Line 176  foreach my $rpm ( grep { $_->{repo} !~ m Line 198  foreach my $rpm ( grep { $_->{repo} !~ m
198          my $repo = $rpm->{repo};          my $repo = $rpm->{repo};
199          foreach my $source ( @sources ) {          foreach my $source ( @sources ) {
200                  if ( $sources{$source} ) {                  if ( $sources{$source} ) {
201                          unless ( -f "$repo/SRPMS/$source" ) {                          if ($repo eq $stagedir) {
202                                  push @{$copy{"$repo/SRPMS"}}, "$sources{$source}/$source";                                  push @{$copy{"$repo/SRPMS-$arch"}}, "$sources{$source}/$source" unless -f "$repo/SRPMS-$arch/$source";
203                                  $changed{$repo}++ unless $repo eq $stagedir;                          } else {
204                                    unless ( -f "$repo/SRPMS/$source" ) {
205                                            push @{$copy{"$repo/SRPMS"}}, "$sources{$source}/$source";
206                                            $changed{$repo}++;
207                                    }
208                          }                          }
209                          $srpms{$repo}{$source}++;                          $srpms{$repo}{$source}++;
210                          $found++;                          $found++;
# Line 192  my @remove; Line 218  my @remove;
218  foreach my $repo ( keys %srpms ) {  foreach my $repo ( keys %srpms ) {
219          foreach my $rpm ( keys %{$srpms{$repo}} ) {          foreach my $rpm ( keys %{$srpms{$repo}} ) {
220                  unless ( $srpms{$repo}{$rpm} ) {                  unless ( $srpms{$repo}{$rpm} ) {
221                          push @remove, "$repo/SRPMS/$rpm";                          if ($repo eq $stagedir) {
222                          $changed{$repo}++ unless $repo eq $stagedir;                                  push @remove, "$repo/SRPMS-$arch/$rpm";
223                            } else {
224                                    push @remove, "$repo/SRPMS/$rpm";
225                                    $changed{$repo}++;
226                            }
227                  }                  }
228          }          }
229  }  }
# Line 202  print "\n"; Line 232  print "\n";
232  foreach my $repo ( sort keys %copy ) {  foreach my $repo ( sort keys %copy ) {
233          foreach my $rpm ( keys %{{ map { $_ => 1 } @{$copy{$repo}} }} ) {          foreach my $rpm ( keys %{{ map { $_ => 1 } @{$copy{$repo}} }} ) {
234                  print "copying $rpm to $repo/\n";                  print "copying $rpm to $repo/\n";
235                    mkdir "$repo" unless -d "$repo";
236                  system(qw(cp --preserve=timestamps), $rpm, "$repo/");                  system(qw(cp --preserve=timestamps), $rpm, "$repo/");
237          }          }
238  }  }
# Line 218  foreach my $repo ( sort keys %changed ) Line 249  foreach my $repo ( sort keys %changed )
249          chomp $dir;          chomp $dir;
250          print "rebuilding $dir...\n";          print "rebuilding $dir...\n";
251          system(qw(createrepo), "$dir");          system(qw(createrepo), "$dir");
252            system(qw(rm -rf), "$dir/.olddata") if -d "$dir/.olddata";
253          system(qw(repoview), "$dir");          system(qw(repoview), "$dir");
254            system(qw(rm -rf), "$dir/.repodata") if "$dir/.repodata";
255  }  }


Legend:
Removed lines/characters  
Changed lines/characters
  Added lines/characters

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