diff options
author | Pascal Terjan <pterjan@gmail.com> | 2016-01-23 18:47:25 +0000 |
---|---|---|
committer | Pascal Terjan <pterjan@gmail.com> | 2016-01-23 23:24:53 +0000 |
commit | 90dae21c83006471b2123e0ba138f260d6224466 (patch) | |
tree | dc7199347fbcbf2f26c986bb30c0e96e13db3616 /emi | |
parent | 84174a38a9b094c3a5cbef07a48b84b9c65d5bf8 (diff) | |
download | iurt-90dae21c83006471b2123e0ba138f260d6224466.tar iurt-90dae21c83006471b2123e0ba138f260d6224466.tar.gz iurt-90dae21c83006471b2123e0ba138f260d6224466.tar.bz2 iurt-90dae21c83006471b2123e0ba138f260d6224466.tar.xz iurt-90dae21c83006471b2123e0ba138f260d6224466.zip |
Use a shared function to load the state of upload tree
Diffstat (limited to 'emi')
-rwxr-xr-x | emi | 67 |
1 files changed, 2 insertions, 65 deletions
@@ -32,7 +32,7 @@ use File::Path qw(make_path); use Iurt::Config qw(config_usage config_init get_author_email get_mandatory_arch); use Iurt::Process qw(check_pid); use Iurt::Mail qw(sendmail); -use Iurt::File qw(check_upload_tree); +use Iurt::File qw(get_upload_tree_state); use Iurt::Util qw(plog_init plog); use Data::Dumper; use MDK::Common qw(cat_ if_ find touch); @@ -118,70 +118,7 @@ my $todo = "$config->{queue}/todo"; my $done = "$config->{queue}/done"; my $reject = "$config->{queue}/rejected"; -my %pkg_tree; - - -# -# Gather data from upload tree -# - -sub done_func { - my ($_todo, $_f, $m, $s, $r) = @_; - - my $media = "$m/$s"; - - if ($r =~ /^(\d{14}\.\w+\.\w+\.\d+)([_.].+)$/) { - my ($prefix, $suffix) = ($1, $2); - if ($suffix =~ /^_(\w+)\.(\w+)$/) { - my ($arch, $result) = ($1, $2); - if ($result eq 'done') { - plog('DEBUG', "found .done ($prefix) for $arch"); - $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}{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}{media}{$media}{uploaded} = 1; - } - } - } -} - -sub done_post { - my ($_todo, $f, $m, $s, $r) = @_; - 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 media $media"); - $pkg_tree{$prefix}{target} = $f; - $pkg_tree{$prefix}{media}{$media}{path} = "/$f/$m/$s"; - if ($arch eq 'src') { - push @{$pkg_tree{$prefix}{media}{$media}{srpms}}, $rpm; - $pkg_tree{$prefix}{media}{$media}{arch}{src} = 1; - } - push @{$pkg_tree{$prefix}{media}{$media}{rpms}} , $rpm; - } -} - -sub todo_func { - my ($_todo, $_f, $_m, $_s, $r) = @_; - - if ($r =~ /(\d{14}\.\w+\.\w+\.\d+)_(.*\.([^.]+)\.rpm)$/) { - my ($prefix, $rpm) = ($1, $2); - plog('DEBUG', "found todo rpm $rpm ($prefix)"); - push @{$pkg_tree{$prefix}{srpms}}, $rpm; - } -} - -check_upload_tree($done, \&done_func, \&done_post); -check_upload_tree($todo, \&todo_func); - +my %pkg_tree = get_upload_tree_state($config); # # Decide what should be uploaded |