/[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.11 by slords, Sun Jun 3 04:13:57 2007 UTC Revision 1.18 by slords, Thu Jul 19 19:59:15 2007 UTC
# Line 19  my $arch = `uname -i`; Line 19  my $arch = `uname -i`;
19  chomp $arch;  chomp $arch;
20    
21  my @repos = (  my @repos = (
               "$releasedir/$smerel/smeos/$arch/CentOS/RPMS",  
               "$releasedir/$smerel/smeos/$arch/SME/RPMS",  
               "$releasedir/$smerel/smeos/$arch/RPMS",  
22                "$releasedir/$smerel/smeos/$arch/SME",                "$releasedir/$smerel/smeos/$arch/SME",
23                  "$releasedir/$smerel/smeos/$arch/SME/RPMS",
24                  "$releasedir/$smerel/smeos/$arch/CentOS/RPMS",
25                "$releasedir/$smerel/smeupdates/$arch/RPMS",                "$releasedir/$smerel/smeupdates/$arch/RPMS",
26                "$releasedir/$smerel/smeupdates-testing/$arch/RPMS",                "$releasedir/$smerel/smeupdates-testing/$arch/RPMS",
27                "$releasedir/$smerel/smeextras/$arch/RPMS",                "$releasedir/$smerel/smeextras/$arch/RPMS",
28                "$releasedir/$smerel/smeaddons/$arch/RPMS",                "$releasedir/$smerel/smeaddons/$arch/RPMS",
29                  "$releasedir/$smerel/smecontribs/$arch/RPMS",
30                "$releasedir/$smerel/smetest/$arch/RPMS",                "$releasedir/$smerel/smetest/$arch/RPMS",
31                "$releasedir/$smerel/smedev/$arch/RPMS",                "$releasedir/$smerel/smedev/$arch/RPMS",
32                "$builds/RPMS/$arch",                "$builds/RPMS/$arch",
33                "$builds/RPMS/i586",                "$builds/RPMS/i586",
34                "$builds/RPMS/i686",                "$builds/RPMS/i686",
35                "$builds/RPMS/noarch",                "$builds/RPMS/noarch",
36                "$stagedir/RPMS",                "$stagedir/RPMS-$arch",
37              );              );
38    
39  my @srcrepos = (  my @srcrepos = (
# Line 43  my @srcrepos = ( Line 43  my @srcrepos = (
43                   "/mirrors/centos/$centosrel/extras/SRPMS",                   "/mirrors/centos/$centosrel/extras/SRPMS",
44                   "/mirrors/rpmforge/dag/source",                   "/mirrors/rpmforge/dag/source",
45                   "/mirrors/atrpms/src/el$centosrel-$arch/atrpms/stable",                   "/mirrors/atrpms/src/el$centosrel-$arch/atrpms/stable",
46                     "/mirrors/atrpms/src/el$centosrel-$arch/atrpms/testing",
47                   "/mirrors/fedora/epel/$centosrel/SRPMS",                   "/mirrors/fedora/epel/$centosrel/SRPMS",
48                   "/mirrors/fedora/core/updates/$fedorarel/SRPMS",                   "/mirrors/fedora/core/updates/$fedorarel/SRPMS",
49                   "/mirrors/fedora/core/$fedorarel/source/SRPMS",                   "/mirrors/fedora/core/$fedorarel/source/SRPMS",
# Line 58  my %sources; Line 59  my %sources;
59  my %changed;  my %changed;
60  my %copy;  my %copy;
61    
62    print "\nReading repos...\n";
63  foreach my $repo ( @repos ) {  foreach my $repo ( @repos ) {
64          my $r = $repo;          my $r = $repo;
65          if ( $repo =~ m{$stagedir/RPMS} ) {          if ( $repo =~ m{$stagedir/RPMS} ) {
# Line 68  foreach my $repo ( @repos ) { Line 70  foreach my $repo ( @repos ) {
70                  $r = $1;                  $r = $1;
71          }          }
72    
73          if ( $r ne 'builds' ) {          if ( $r eq $stagedir ) {
74                    opendir SRPMS, "$r/SRPMS-$arch" or next;
75                    foreach my $srpm ( grep { /\.rpm$/ } readdir SRPMS ) {
76                            $srpms{$r}{$srpm} = 0;
77                            $sources{$srpm} = "$r/SRPMS-$arch";
78                    }
79                    closedir SRPMS;
80            } elsif ( $r ne 'builds' ) {
81                  opendir SRPMS, "$r/SRPMS" or next;                  opendir SRPMS, "$r/SRPMS" or next;
82                  foreach my $srpm ( grep { /\.rpm$/ } readdir SRPMS ) {                  foreach my $srpm ( grep { /\.rpm$/ } readdir SRPMS ) {
83                          $srpms{$r}{$srpm} = 0;                          $srpms{$r}{$srpm} = 0;
# Line 78  foreach my $repo ( @repos ) { Line 87  foreach my $repo ( @repos ) {
87          }          }
88    
89          opendir RPMS, $repo or next;          opendir RPMS, $repo or next;
90            print " - $repo\n";
91          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 ) {
92                  my $rpm = { name => $pkg->tag("NAME"),                  my $rpm = { name => $pkg->tag("NAME"),
93                                  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 111  foreach my $repo ( @repos ) {
111          closedir RPMS;          closedir RPMS;
112  }  }
113    
114    print "\nReading source repos...\n";
115  foreach my $repo ( reverse @srcrepos ) {  foreach my $repo ( reverse @srcrepos ) {
116          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 );
117          closedir SRPMS;          closedir SRPMS;
# Line 108  foreach my $repo ( reverse @srcrepos ) { Line 119  foreach my $repo ( reverse @srcrepos ) {
119          %sources = (%sources, %temp_repo);          %sources = (%sources, %temp_repo);
120  }  }
121    
122    print "\nFinding latest packages...\n";
123  my @latest;  my @latest;
124  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 )  {
125          unless ( grep { $_->{name} eq $rpm->{name} && $_->{rpm} gt $rpm->{rpm} } @latest ) {          unless ( grep { $_->{name} eq $rpm->{name} && $_->{rpm} gt $rpm->{rpm} } @latest ) {
126                  push @latest, $rpm;                  push @latest, $rpm;
127                  unless ( grep { $_->{repo} eq $stagedir && $_->{filename} eq $rpm->{filename} } @rpms ) {                  unless ( grep { $_->{repo} eq $stagedir && $_->{filename} eq $rpm->{filename} } @rpms ) {
128                          push @{$copy{"$stagedir/RPMS"}}, $rpm->{rpm}->filename;                          push @{$copy{"$stagedir/RPMS-$arch"}}, $rpm->{rpm}->filename;
129                          push @rpms, { name => $rpm->{name},                          push @rpms, { name => $rpm->{name},
130                                        filename => $rpm->{filename},                                        filename => $rpm->{filename},
131                                        version => $rpm->{version},                                        version => $rpm->{version},
# Line 130  foreach my $rpm ( grep { $_->{repo} eq $ Line 142  foreach my $rpm ( grep { $_->{repo} eq $
142          $rpm->{repo} = 'deleted' unless grep { $_->{filename} eq $rpm->{filename} } @latest;          $rpm->{repo} = 'deleted' unless grep { $_->{filename} eq $rpm->{filename} } @latest;
143  }  }
144    
145    foreach my $rpm ( reverse grep { $_->{repo} =~ m{^$releasedir/$smerel/} && $_->{repo} =~ m{/sme(addons|contribs|extras)$} } @rpms )  {
146            unless ( grep { $_->{name} eq $rpm->{name} && $_->{rpm} gt $rpm->{rpm} } @latest ) {
147                    push @latest, $rpm;
148            }
149    }
150    
151    print "\nFinding development packages...\n";
152  my @devel;  my @devel;
153  my %versions;  my %versions;
154  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 177  foreach my $rpm ( grep { $_->{repo} =~ m
177          $rpm->{repo} = 'deleted' unless grep { $_->{filename} eq $rpm->{filename} } @devel;          $rpm->{repo} = 'deleted' unless grep { $_->{filename} eq $rpm->{filename} } @devel;
178  }  }
179    
180  print "\n";  print "\nFinding source packages...\n";
181  foreach my $rpm ( grep { $_->{repo} !~ m{^(builds|deleted)$} } @rpms ) {  foreach my $rpm ( grep { $_->{repo} !~ m{^(builds|deleted)$} } @rpms ) {
182          my $src;          my $src;
183          my $srpm = $rpm->{rpm}->tag("SOURCERPM");          my $srpm = $rpm->{rpm}->tag("SOURCERPM");
# Line 176  foreach my $rpm ( grep { $_->{repo} !~ m Line 195  foreach my $rpm ( grep { $_->{repo} !~ m
195          my $repo = $rpm->{repo};          my $repo = $rpm->{repo};
196          foreach my $source ( @sources ) {          foreach my $source ( @sources ) {
197                  if ( $sources{$source} ) {                  if ( $sources{$source} ) {
198                          unless ( -f "$repo/SRPMS/$source" ) {                          if ($repo eq $stagedir) {
199                                  push @{$copy{"$repo/SRPMS"}}, "$sources{$source}/$source";                                  push @{$copy{"$repo/SRPMS-$arch"}}, "$sources{$source}/$source" unless -f "$repo/SRPMS-$arch/$source";
200                                  $changed{$repo}++ unless $repo eq $stagedir;                          } else {
201                                    unless ( -f "$repo/SRPMS/$source" ) {
202                                            push @{$copy{"$repo/SRPMS"}}, "$sources{$source}/$source";
203                                            $changed{$repo}++;
204                                    }
205                          }                          }
206                          $srpms{$repo}{$source}++;                          $srpms{$repo}{$source}++;
207                          $found++;                          $found++;
# Line 192  my @remove; Line 215  my @remove;
215  foreach my $repo ( keys %srpms ) {  foreach my $repo ( keys %srpms ) {
216          foreach my $rpm ( keys %{$srpms{$repo}} ) {          foreach my $rpm ( keys %{$srpms{$repo}} ) {
217                  unless ( $srpms{$repo}{$rpm} ) {                  unless ( $srpms{$repo}{$rpm} ) {
218                          push @remove, "$repo/SRPMS/$rpm";                          if ($repo eq $stagedir) {
219                          $changed{$repo}++ unless $repo eq $stagedir;                                  push @remove, "$repo/SRPMS-$arch/$rpm";
220                            } else {
221                                    push @remove, "$repo/SRPMS/$rpm";
222                                    $changed{$repo}++;
223                            }
224                  }                  }
225          }          }
226  }  }
227    
228  print "\n";  print "\n";
229  foreach my $repo ( sort keys %copy ) {  foreach my $repo ( sort keys %copy ) {
230          foreach my $rpm ( @{$copy{$repo}} ) {          foreach my $rpm ( keys %{{ map { $_ => 1 } @{$copy{$repo}} }} ) {
231                  print "copying $rpm to $repo/\n";                  print "copying $rpm to $repo/\n";
232                    mkdir "$repo" unless -d "$repo";
233                  system(qw(cp --preserve=timestamps), $rpm, "$repo/");                  system(qw(cp --preserve=timestamps), $rpm, "$repo/");
234          }          }
235  }  }
236    
237  print "\n";  print "\n";
238  foreach my $rpm ( @remove, map { $_->{rpm}->filename } grep { $_->{repo} eq 'deleted' } @rpms ) {  foreach my $rpm ( keys %{{ map { $_ => 1 } (@remove, map { $_->{rpm}->filename } grep { $_->{repo} eq 'deleted' } @rpms) }} ) {
239          print "removing $rpm\n";          print "removing $rpm\n";
240          unlink $rpm;          unlink $rpm;
241  }  }
# Line 218  foreach my $repo ( sort keys %changed ) Line 246  foreach my $repo ( sort keys %changed )
246          chomp $dir;          chomp $dir;
247          print "rebuilding $dir...\n";          print "rebuilding $dir...\n";
248          system(qw(createrepo), "$dir");          system(qw(createrepo), "$dir");
249            system(qw(rm -rf), "$dir/.olddata") if -d "$dir/.olddata";
250          system(qw(repoview), "$dir");          system(qw(repoview), "$dir");
251            system(qw(rm -rf), "$dir/.repodata") if "$dir/.repodata";
252  }  }


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