diff options
author | Pascal Terjan <pterjan@gmail.com> | 2016-01-23 17:20:45 +0000 |
---|---|---|
committer | Pascal Terjan <pterjan@gmail.com> | 2016-01-23 17:20:45 +0000 |
commit | 98b77841287ee8662d3c7e1e4bcfbfdb95fe2591 (patch) | |
tree | 627aa58db0329181c00808da35ea045eb67c26bf /emi | |
parent | 63cae2848d59440b480f6f2d343edc7946c5cf62 (diff) | |
download | iurt-98b77841287ee8662d3c7e1e4bcfbfdb95fe2591.tar iurt-98b77841287ee8662d3c7e1e4bcfbfdb95fe2591.tar.gz iurt-98b77841287ee8662d3c7e1e4bcfbfdb95fe2591.tar.bz2 iurt-98b77841287ee8662d3c7e1e4bcfbfdb95fe2591.tar.xz iurt-98b77841287ee8662d3c7e1e4bcfbfdb95fe2591.zip |
Rename section into media to have same $pkg_tree structure than ulri
Diffstat (limited to 'emi')
-rwxr-xr-x | emi | 94 |
1 files changed, 47 insertions, 47 deletions
@@ -128,7 +128,7 @@ my %pkg_tree; sub done_func { my ($_todo, $_f, $m, $s, $r) = @_; - my $section = "$m/$s"; + my $media = "$m/$s"; if ($r =~ /^(\d{14}\.\w+\.\w+\.\d+)([_.].+)$/) { my ($prefix, $suffix) = ($1, $2); @@ -136,17 +136,17 @@ sub done_func { my ($arch, $result) = ($1, $2); if ($result eq 'done') { plog('DEBUG', "found .done ($prefix) for $arch"); - $pkg_tree{$prefix}{section}{$section}{arch}{$arch} = 1; + $pkg_tree{$prefix}{media}{$media}{arch}{$arch} = 1; } elsif ($result eq 'excluded') { $arch = $config->{arch_translation}{$arch} if $config->{arch_translation}{$arch}; plog('DEBUG', "found .excluded ($prefix) for $arch"); - $pkg_tree{$prefix}{section}{$section}{excluded_arch}{$arch} = 1; + $pkg_tree{$prefix}{media}{$media}{excluded_arch}{$arch} = 1; } } elsif ($suffix =~ /^\.(\w+)$/) { my ($action) = $1; if ($action eq 'upload') { plog('DEBUG', "found already uploaded ($prefix)"); - $pkg_tree{$prefix}{section}{$section}{uploaded} = 1; + $pkg_tree{$prefix}{media}{$media}{uploaded} = 1; } } } @@ -154,18 +154,18 @@ sub done_func { sub done_post { my ($_todo, $f, $m, $s, $r) = @_; - my $section = "$m/$s"; + my $media = "$m/$s"; if ($r =~ /(\d{14}\.\w+\.\w+\.\d+)_(.*\.([^.]+)\.rpm)$/) { my ($prefix, $rpm, $arch) = ($1, $2, $3); $arch = $config->{arch_translation}{$arch} if $config->{arch_translation}{$arch}; - plog('DEBUG', "found rpm $rpm ($prefix) for section $section"); + plog('DEBUG', "found rpm $rpm ($prefix) for media $media"); $pkg_tree{$prefix}{target} = $f; - $pkg_tree{$prefix}{section}{$section}{path} = "/$f/$m/$s"; + $pkg_tree{$prefix}{media}{$media}{path} = "/$f/$m/$s"; if ($arch eq 'src') { - push @{$pkg_tree{$prefix}{section}{$section}{srpms}}, $rpm; - $pkg_tree{$prefix}{section}{$section}{arch}{src} = 1; + push @{$pkg_tree{$prefix}{media}{$media}{srpms}}, $rpm; + $pkg_tree{$prefix}{media}{$media}{arch}{src} = 1; } - push @{$pkg_tree{$prefix}{section}{$section}{rpms}} , $rpm; + push @{$pkg_tree{$prefix}{media}{$media}{rpms}} , $rpm; } } @@ -187,8 +187,8 @@ check_upload_tree($todo, \&todo_func); # Decide what should be uploaded # -# $targets{$target}{$section}{arch_finisher}{$arch}: prefix on which we need to actions to get this arch updated -# $targets{$target}{$section}{to_upload}: list of prefixes to upload +# $targets{$target}{$media}{arch_finisher}{$arch}: prefix on which we need to actions to get this arch updated +# $targets{$target}{$media}{to_upload}: list of prefixes to upload my %targets; foreach my $prefix (sort keys %pkg_tree) { @@ -199,22 +199,22 @@ foreach my $prefix (sort keys %pkg_tree) { my $ok = 1; - foreach my $section (keys %{$pkg_tree{$prefix}{section}}) { - my @wanted_archs = defined($pkg_tree{$prefix}{section}{$section}{arch}{noarch}) ? 'noarch' : @$mandatory_arch; - my $path = $pkg_tree{$prefix}{section}{$section}{path}; + foreach my $media (keys %{$pkg_tree{$prefix}{media}}) { + my @wanted_archs = defined($pkg_tree{$prefix}{media}{$media}{arch}{noarch}) ? 'noarch' : @$mandatory_arch; + my $path = $pkg_tree{$prefix}{media}{$media}{path}; my %missing; plog('DEBUG', "... in $path"); - if ($pkg_tree{$prefix}{section}{$section}{uploaded}) { + if ($pkg_tree{$prefix}{media}{$media}{uploaded}) { plog('INFO', "package already uploaded for mandatory arches, proceeding"); next; } foreach my $m (@wanted_archs, 'src') { - $pkg_tree{$prefix}{section}{$section}{excluded_arch}{$m} and next; + $pkg_tree{$prefix}{media}{$media}{excluded_arch}{$m} and next; my $x = "yes"; - if (!$pkg_tree{$prefix}{section}{$section}{arch}{$m}) { + if (!$pkg_tree{$prefix}{media}{$media}{arch}{$m}) { $missing{$m} = 1; $x = "no"; $ok = 0; @@ -224,7 +224,7 @@ foreach my $prefix (sort keys %pkg_tree) { unless ($ok) { plog('INFO', "mandatory arch", join(' ', keys %missing), - "missing for $section, waiting"); + "missing for $media, waiting"); next; } } @@ -233,46 +233,46 @@ foreach my $prefix (sort keys %pkg_tree) { # # All mandatory archs found, mark for upload # - foreach my $section (keys %{$pkg_tree{$prefix}{section}}) { - $targets{$target}{$section} ||= { 'arch_finisher' => {}, 'is_finisher' => {}, 'to_upload' => [] }; + foreach my $media (keys %{$pkg_tree{$prefix}{media}}) { + $targets{$target}{$media} ||= { 'arch_finisher' => {}, 'is_finisher' => {}, 'to_upload' => [] }; - push @{$targets{$target}{$section}{to_upload}}, $prefix; + push @{$targets{$target}{$media}{to_upload}}, $prefix; - # We already have found universal finisher in that section, we're fine - next if exists $targets{$target}{$section}{arch_finisher}{noarch}; + # We already have found universal finisher in that media, we're fine + next if exists $targets{$target}{$media}{arch_finisher}{noarch}; - if ($pkg_tree{$prefix}{section}{$section}{arch}{noarch}) { + if ($pkg_tree{$prefix}{media}{$media}{arch}{noarch}) { # This package is noarch, genhdlist for it will touch all archs - $targets{$target}{$section}{arch_finisher} = { 'noarch' => $prefix }; + $targets{$target}{$media}{arch_finisher} = { 'noarch' => $prefix }; } else { - my $has_new_arch = scalar(difference2([ keys %{$pkg_tree{$prefix}{section}{$section}{arch}} ], [ keys %{$targets{$target}{$section}{arch_finisher}} ])); + my $has_new_arch = scalar(difference2([ keys %{$pkg_tree{$prefix}{media}{$media}{arch}} ], [ keys %{$targets{$target}{$media}{arch_finisher}} ])); if ($has_new_arch) { # We need this package to cover the new arch # Set it for all, it may allow getting rid of some others - foreach (keys %{$pkg_tree{$prefix}{section}{$section}{arch}}) { - $targets{$target}{$section}{arch_finisher}{$_} = $prefix; + foreach (keys %{$pkg_tree{$prefix}{media}{$media}{arch}}) { + $targets{$target}{$media}{arch_finisher}{$_} = $prefix; } } } } } -sub upload_prefix_in_section { - my ($prefix, $section, $o_finish) = @_; +sub upload_prefix_in_media { + my ($prefix, $media, $o_finish) = @_; my (@packages, @duplicate_packages); my ($user) = $prefix =~ /\d{14}\.(\w+)\.\w+\.\d+$/; my $target = $pkg_tree{$prefix}{target}; my $youri_file = "$prefix.youri"; - if ($pkg_tree{$prefix}{section}{$section}{uploaded}) { + if ($pkg_tree{$prefix}{media}{$media}{uploaded}) { $youri_file .= "." . time(); } - my $path = $pkg_tree{$prefix}{section}{$section}{path}; + my $path = $pkg_tree{$prefix}{media}{$media}{path}; plog('OK', "all mandatory archs done: $prefix"); - foreach my $rpm (@{$pkg_tree{$prefix}{section}{$section}{rpms}}) { + foreach my $rpm (@{$pkg_tree{$prefix}{media}{$media}{rpms}}) { my $rpmpath = "$done/$path/${prefix}_$rpm"; - if ($pkg_tree{$prefix}{section}{$section}{uploaded}) { + if ($pkg_tree{$prefix}{media}{$media}{uploaded}) { # if already uploaded for mandatory arches, do not try to upload again src or noarch packages # but still remember these duplicate files for removal if (my ($type) = $rpm =~ /\.(noarch|src)\.rpm$/) { @@ -288,7 +288,7 @@ sub upload_prefix_in_section { $user ||= $config->{upload_user}; # FIXME we want to skip all post, we should not hardcode them here my $skip = $o_finish ? "" : "--skip-post genhdlist2 --skip-post mirror --skip-post clean_rpmsrate"; - my $command = "/usr/bin/perl -I/usr/share/mga-youri-submit/lib /usr/share/mga-youri-submit/bin/youri-submit --verbose --config /etc/youri/submit-upload.conf --define user=$user --define prefix=$prefix --define section=$section $skip $target @packages &> $done/$path/$youri_file"; + my $command = "/usr/bin/perl -I/usr/share/mga-youri-submit/lib /usr/share/mga-youri-submit/bin/youri-submit --verbose --config /etc/youri/submit-upload.conf --define user=$user --define prefix=$prefix --define section=$media $skip $target @packages &> $done/$path/$youri_file"; plog('DEBUG', "running $command"); if (!system($command)) { @@ -297,14 +297,14 @@ sub upload_prefix_in_section { # should send a mail or something plog('ERROR', "upload failed ($!), rejecting files in $reject/$path/"); make_path("$reject/$path"); - foreach my $rpm (@{$pkg_tree{$prefix}{section}{$section}{rpms}}) { + foreach my $rpm (@{$pkg_tree{$prefix}{media}{$media}{rpms}}) { link("$done/$path/${prefix}_$rpm", "$reject/$path/${prefix}_$rpm") or plog('ERROR', "ERROR: link of $rpm failed ($!)"); } link("$done/$path/$youri_file", "$reject/$path/$youri_file"); my ($user) = $prefix =~ /\d{14}\.(\w+)\.\w+\.\d+/; if ($user) { - my @pkgs = grep { !/src\.rpm$/ } @{$pkg_tree{$prefix}{section}{$section}{rpms}}; + my @pkgs = grep { !/src\.rpm$/ } @{$pkg_tree{$prefix}{media}{$media}{rpms}}; my $text = join("\n", qq(The upload of the following packages failed:\n), map { "- $_" } @pkgs) . "\n"; my $rpms = join(' ', @pkgs, undef); my $to = get_author_email($user) || "Unknown <$config->{admin}>"; @@ -321,13 +321,13 @@ sub upload_prefix_in_section { # unlink the sources rpm unless some non mandatory arch still need to be done my $all_done = 1; - if (!defined($pkg_tree{$prefix}{section}{$section}{arch}{noarch})) { + if (!defined($pkg_tree{$prefix}{media}{$media}{arch}{noarch})) { my $arch_list = find { ref($_) eq 'ARRAY' } $config->{arch}, (ref($config->{arch}) eq 'HASH' ? ($config->{arch}{$target}, $config->{arch}{default}) : ()); my @arch_list = $arch_list ? @$arch_list : keys %{$config->{bot}}; # If we are here, mandatory arches are done, no need to check them my $mandatory_arch = get_mandatory_arch($config, $target); foreach my $arch (difference2(\@arch_list, $mandatory_arch)) { - next if $pkg_tree{$prefix}{section}{$section}{arch}{$arch}; + next if $pkg_tree{$prefix}{media}{$media}{arch}{$arch}; $all_done = 0; } } @@ -340,24 +340,24 @@ sub upload_prefix_in_section { } foreach my $target (keys %targets) { - foreach my $section (keys %{$targets{$target}}) { + foreach my $media (keys %{$targets{$target}}) { my %is_finisher; - foreach (values %{$targets{$target}{$section}{arch_finisher}}) { + foreach (values %{$targets{$target}{$media}{arch_finisher}}) { $is_finisher{$_} = 1; } - foreach my $prefix (@{$targets{$target}{$section}{to_upload}}) { + foreach my $prefix (@{$targets{$target}{$media}{to_upload}}) { next if $is_finisher{$prefix}; - upload_prefix_in_section($prefix, $section); + upload_prefix_in_media($prefix, $media); } foreach my $prefix (keys %is_finisher) { - upload_prefix_in_section($prefix, $section, 1); + upload_prefix_in_media($prefix, $media, 1); } - foreach my $prefix (@{$targets{$target}{$section}{to_upload}}) { - my $path = $pkg_tree{$prefix}{section}{$section}{path}; + foreach my $prefix (@{$targets{$target}{$media}{to_upload}}) { + my $path = $pkg_tree{$prefix}{media}{$media}{path}; touch("$done/$path/$prefix.upload") unless -f "$reject/$path/$prefix.youri"; } } |