aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorPascal Terjan <pterjan@mageia.org>2022-04-26 13:25:56 +0000
committerPascal Terjan <pterjan@mageia.org>2022-04-26 15:22:14 +0000
commitc5778711ae16c34ba16e3ba87e1fff5e79587efc (patch)
treeae55c3974d6289dd20d46047ac6753dcf88f0951 /lib
parentd8254dd4754100edff0269cac433faa2168be3fc (diff)
downloadiurt-c5778711ae16c34ba16e3ba87e1fff5e79587efc.tar
iurt-c5778711ae16c34ba16e3ba87e1fff5e79587efc.tar.gz
iurt-c5778711ae16c34ba16e3ba87e1fff5e79587efc.tar.bz2
iurt-c5778711ae16c34ba16e3ba87e1fff5e79587efc.tar.xz
iurt-c5778711ae16c34ba16e3ba87e1fff5e79587efc.zip
ulri: Remove duplication on loading lock file
Diffstat (limited to 'lib')
-rw-r--r--lib/Iurt/Queue.pm62
1 files changed, 40 insertions, 22 deletions
diff --git a/lib/Iurt/Queue.pm b/lib/Iurt/Queue.pm
index 541bbff..2f1e968 100644
--- a/lib/Iurt/Queue.pm
+++ b/lib/Iurt/Queue.pm
@@ -14,6 +14,8 @@ our @EXPORT = qw(
cleanup_failed_build
check_if_all_archs_processed
check_if_mandatory_arch_failed
+ load_lock_file_data
+ remove_bot_from_package
);
sub apply_to_upload_tree {
@@ -145,6 +147,42 @@ sub cleanup_failed_build {
}
}
+sub load_lock_file_data {
+ my ($ent, $lock_path, $media, $config) = @_;
+ if ($lock_path !~ /\/(\d{14}\.\w+\.\w+\.\d+)_([\w-]+)\.(\w+)\.([\w-]+)\.(\d{14})\.(\d+)\.lock$/) {
+ plog('ERROR', "invalid lock file name: $lock_path");
+ return;
+ }
+ my ($prefix, $arch, $bot, $host, $date, $pid) = ($1, $2, $3, $4, $5, $6);
+
+ $arch = $config->{arch_translation}{$arch} if $config->{arch_translation}{$arch};
+ plog('DEBUG', "found lock on $host/$arch for $prefix");
+
+ if ($arch =~ /noarch/) {
+ plog('DEBUG', "... and $prefix is noarch");
+ $ent->{media}{$media}{arch}{noarch} = 1;
+ $arch =~ s/-.*//;
+ }
+
+ $ent->{media}{$media}{arch}{$arch} = 1;
+
+ my $time = read_line($lock_path);
+ $time = (split ' ', $time)[2];
+ push @{$ent->{media}{$media}{bot}}, {
+ bot => $bot,
+ host => $host,
+ date => $date,
+ pid => $pid,
+ 'arch' => $arch,
+ 'time' => $time
+ };
+}
+
+sub remove_bot_from_package {
+ my ($ent, $media, $host, $pid) = @_;
+ @{$ent->{media}{$media}{bot}} = grep { $_->{host} ne $host || $_->{pid} != $pid} @{$ent->{media}{$media}{bot}};
+}
+
sub get_upload_tree_state {
our ($config) = @_;
@@ -171,32 +209,12 @@ sub get_upload_tree_state {
}
if ($r =~ /(\d{14}\.\w+\.\w+\.\d+)_([\w-]+)\.(\w+)\.([\w-]+)\.(\d{14})\.(\d+)\.lock$/) {
- my ($prefix, $arch, $bot, $host, $date, $pid) = ($1, $2, $3, $4, $5, $6);
+ my $prefix = $1;
# Set path here too has we may have a lock without the src.rpm
$pkg_tree{$prefix}{media}{$media}{path} = "/$f/$m/$s";
- $arch = $config->{arch_translation}{$arch} if $config->{arch_translation}{$arch};
- plog('DEBUG', "found lock on $host/$arch for $prefix");
-
- if ($arch =~ /noarch/) {
- plog('DEBUG', "... and $prefix is noarch");
- $pkg_tree{$prefix}{media}{$media}{arch}{noarch} = 1;
- $arch =~ s/-.*//;
- }
-
- $pkg_tree{$prefix}{media}{$media}{arch}{$arch} = 1;
-
- my $time = read_line("$todo/$f/$m/$s/$r");
- $time = (split ' ', $time)[2];
- push @{$pkg_tree{$prefix}{media}{$media}{bot}}, {
- bot => $bot,
- host => $host,
- date => $date,
- pid => $pid,
- 'arch' => $arch,
- 'time' => $time
- };
+ load_lock_file_data(\%{$pkg_tree{$prefix}}, "$todo/$f/$m/$s/$r", $media, $config);
}
if ($r =~ /(\d{14}\.\w+\.\w+\.\d+)_.*\.deps$/) {