aboutsummaryrefslogtreecommitdiffstats
path: root/bin/youri-submit.in
diff options
context:
space:
mode:
authorFlorent Villard <warly@mandriva.com>2006-10-24 11:07:00 +0000
committerFlorent Villard <warly@mandriva.com>2006-10-24 11:07:00 +0000
commitbecd3cb20324e8c17931b2418cd37bdf63b3cba4 (patch)
tree8d4d50309351be6e6075bd5e94980e9379cbdbe0 /bin/youri-submit.in
parent0acec4125e2e51cfb61c1151e99383cc6cd72b41 (diff)
downloadmga-youri-submit-becd3cb20324e8c17931b2418cd37bdf63b3cba4.tar
mga-youri-submit-becd3cb20324e8c17931b2418cd37bdf63b3cba4.tar.gz
mga-youri-submit-becd3cb20324e8c17931b2418cd37bdf63b3cba4.tar.bz2
mga-youri-submit-becd3cb20324e8c17931b2418cd37bdf63b3cba4.tar.xz
mga-youri-submit-becd3cb20324e8c17931b2418cd37bdf63b3cba4.zip
exit with an error code if an error occured in one group; s/Upload/Submit/; use new structure name from upstream
Diffstat (limited to 'bin/youri-submit.in')
-rwxr-xr-xbin/youri-submit.in112
1 files changed, 66 insertions, 46 deletions
diff --git a/bin/youri-submit.in b/bin/youri-submit.in
index 07118f1..002849a 100755
--- a/bin/youri-submit.in
+++ b/bin/youri-submit.in
@@ -107,7 +107,7 @@ Configuration is read from the first file found among:
=item * $HOME/.youri/submit.conf
-=item * @sysconfdir@/youri/submit.conf
+=item * /usr/local/etc/youri/submit.conf
=back
@@ -176,7 +176,7 @@ my $config = Youri::Config->new(
'verbose' => '|v!',
'clean' => '!',
'test' => '|t!',
- 'list' => '|l!'
+ 'list' => '|l!',
'config' => '=s',
'skip-prei' => '=s@',
'skip-post' => '=s@',
@@ -284,28 +284,36 @@ eval {
die "Failed to create repository: $@\n" if $@;
# perfrom pre action
-my %skip_pres = map { $_ => 1 } @{$config->get('skip-pre')};
-my $pre_packages = [];
my $ok = 1;
-foreach my $id (@{$target_conf->{pre}}) {
+my $pre_packages = [];
+my $skip_pres = $config->get_arg('skip-pre');
+my %skip_pres = $skip_pres ? map { $_ => 1 } @{$skip_pres} : ();
+foreach my $id (@{$target_conf->{pres}}) {
next if $skip_pres{$id};
print "Creating pre $id\n" if $verbose;
my $pre;
+ my $pre_conf = $config->get_param('pres')->{$id};
+
+ if (!$pre_conf) {
+ print STDERR "No such pre $id, skipping\n";
+ next;
+ }
eval {
- $pre = create_instance(
- 'Youri::Upload::Pre',
+ $pre = create_instance(
+ 'Youri::Submit::Pre',
+ $pre_conf,
{
id => $id,
test => $test,
verbose => $verbose > 0 ? $verbose - 1 : 0,
}
- );
+ );
};
if ($@) {
print STDERR "Failed to create pre $id: $@\n";
} else {
print "running pre $id\n" if $verbose;
- unless ($pre->run($pre_packages, $repository, $target, $config->get('define'))) {
+ unless ($pre->run($pre_packages, $repository, $target, $config->get_param('define'))) {
print STDERR "Error: " . $pre->get_error() . "\n";
$ok = 0;
}
@@ -315,6 +323,7 @@ exit(1) unless $ok;
# create packages group
my @packages_group;
+my $group_error;
foreach my $group ((map { [ { section => "", file => $_ } ] } @ARGV), @$pre_packages) {
my @packages;
foreach my $opt (@$group) {
@@ -341,10 +350,10 @@ foreach my $group ((map { [ { section => "", file => $_ } ] } @ARGV), @$pre_pac
my %skip_check = $skip_check ? map { $_ => 1 } @{$skip_check} : ();
my @error;
foreach my $id (@{$target_conf->{checks}}) {
- next if $skip_checks{$id};
+ next if $skip_check{$id};
print "Creating check $id\n" if $verbose;
my $check;
- my $check_conf = $config->get_param('checks')->{$id};
+ my $check_conf = $config->get_param('checks')->{$id};
if (!$check_conf) {
print STDERR "No such check $id, skipping\n";
@@ -352,7 +361,7 @@ foreach my $group ((map { [ { section => "", file => $_ } ] } @ARGV), @$pre_pac
}
eval {
$check = create_instance(
- 'Youri::Upload::Check',
+ 'Youri::Submit::Check',
$check_conf,
{
id => $id,
@@ -366,14 +375,15 @@ foreach my $group ((map { [ { section => "", file => $_ } ] } @ARGV), @$pre_pac
} else {
foreach my $package (@packages) {
print "running check $id on package $package\n" if $verbose;
- my @errors = $check->run(
- $package,
- $repository,
- $target,
- $config->get_arg('define')
- );
- push(@{$errors{$package}}, @errors) if @errors;
- }
+ my @errors = $check->run(
+ $package,
+ $repository,
+ $target,
+ $config->get_arg('define')
+ );
+ push(@{$errors{$package}}, @errors) if $errors[0];
+ }
+ }
}
if (%errors) {
print "Submission errors, aborting:\n";
@@ -386,14 +396,19 @@ foreach my $group ((map { [ { section => "", file => $_ } ] } @ARGV), @$pre_pac
# reject the packages
my $skip_rejects = $config->get_arg('skip-reject');
my %skip_rejects = $skip_rejects ? map { $_ => 1 } @{$skip_rejects} : ();
- foreach my $id (@{$target_conf{rejects}}) {
+ foreach my $id (@{$target_conf->{rejects}}) {
next if $skip_rejects{$id};
print "Creating reject $id\n" if $verbose;
my $reject;
my $reject_conf = $config->get_param('rejects')->{$id};
+
+ if (!$reject_conf) {
+ print STDERR "No such reject $id, skipping\n";
+ next;
+ }
eval {
$reject = create_instance(
- 'Youri::Upload::Reject',
+ 'Youri::Submit::Reject',
$reject_conf,
{
id => $id,
@@ -416,6 +431,7 @@ foreach my $group ((map { [ { section => "", file => $_ } ] } @ARGV), @$pre_pac
}
}
}
+ $group_error = 1;
next
}
@@ -423,7 +439,7 @@ foreach my $group ((map { [ { section => "", file => $_ } ] } @ARGV), @$pre_pac
my $skip_action = $config->get_arg('skip-action');
my %skip_action = $skip_action ? map { $_ => 1 } @{$skip_action} : ();
foreach my $id (@{$target_conf->{actions}}) {
- next if $skip_actions{$id};
+ next if $skip_action{$id};
print "Creating action $id\n" if $verbose;
my $action;
my $action_conf = $config->get_param('actions')->{$id};
@@ -434,7 +450,7 @@ foreach my $group ((map { [ { section => "", file => $_ } ] } @ARGV), @$pre_pac
}
eval {
$action = create_instance(
- 'Youri::Upload::Action',
+ 'Youri::Submit::Action',
$action_conf,
{
id => $id,
@@ -446,22 +462,31 @@ foreach my $group ((map { [ { section => "", file => $_ } ] } @ARGV), @$pre_pac
if ($@) {
print STDERR "Failed to create action $id: $@\n";
} else {
- foreach my $package (@packages) {
- print "running action $id on package $package\n" if $verbose;
- eval {
- $action->run(
- $package,
- $repository,
- $target,
- $config->get_arg('define')
- );
- };
- if ($@) {
- print STDERR "Failed to run action $id on package $package: $@\n";
- }
- }
+ foreach my $package (@packages) {
+ print "running action $id on package $package\n" if $verbose;
+ eval {
+ $action->run(
+ $package,
+ $repository,
+ $target,
+ $config->get_arg('define')
+ );
+ };
+ if ($@) {
+ print STDERR "Failed to run action $id on package $package: $@\n";
+ }
+ }
+ }
+ }
+
+ if ($config->get_arg('clean')) {
+ foreach my $package (@packages) {
+ print "cleaning file $package\n" if $verbose;
+ unlink $package->as_file();
+ }
}
}
+
# perfrom post action
my $skip_post = $config->get_arg('skip-post');
my %skip_post = $skip_post ? map { $_ => 1 } @{$skip_post} : ();
@@ -472,12 +497,12 @@ foreach my $id (@{$target_conf->{post}}) {
my $post_conf = $config->get_param('posts')->{$id};
if (!$post_conf) {
- print STDERR "No such action $id, skipping\n";
+ print STDERR "No such post $id, skipping\n";
next;
}
eval {
$post = create_instance(
- 'Youri::Upload::Post',
+ 'Youri::Submit::Post',
$post_conf,
{
id => $id,
@@ -496,9 +521,4 @@ foreach my $id (@{$target_conf->{post}}) {
}
}
-if ($config->get('clean')) {
- foreach my $package (@packages) {
- print "cleaning file $package\n" if $verbose;
- unlink $package->as_file();
- }
-}
+exit(1) if $group_error;