aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThierry Vignaud <tv@mageia.org>2013-01-29 17:56:18 +0000
committerThierry Vignaud <tv@mageia.org>2013-01-29 17:56:18 +0000
commit31f847ff80562e1a47f4bc87565325243e1e2e3b (patch)
tree0c8dce244b23f4ef16f438d593cb5a1f06256e37
parent3fd6b485cbafd6a89a79d6227ec442544827a973 (diff)
downloadperl-URPM-31f847ff80562e1a47f4bc87565325243e1e2e3b.tar
perl-URPM-31f847ff80562e1a47f4bc87565325243e1e2e3b.tar.gz
perl-URPM-31f847ff80562e1a47f4bc87565325243e1e2e3b.tar.bz2
perl-URPM-31f847ff80562e1a47f4bc87565325243e1e2e3b.tar.xz
perl-URPM-31f847ff80562e1a47f4bc87565325243e1e2e3b.zip
add support for callback_error
-rw-r--r--NEWS1
-rw-r--r--URPM.pm4
-rw-r--r--URPM.xs25
3 files changed, 28 insertions, 2 deletions
diff --git a/NEWS b/NEWS
index 6966129..e15495b 100644
--- a/NEWS
+++ b/NEWS
@@ -1,4 +1,5 @@
- enhanced doc
+- enable to report script & I/O errors
Version 4.23 - 20 January 2012
diff --git a/URPM.pm b/URPM.pm
index 2be89b1..cdcf4f2 100644
--- a/URPM.pm
+++ b/URPM.pm
@@ -779,6 +779,7 @@ It's usually the $urpm object.
Recognized options are:
callback_close => sub { ... }
+ callback_error => sub { ... }
callback_inst => sub { ... }
callback_open => sub { ... }
callback_trans => sub { ... }
@@ -803,7 +804,8 @@ C<$cb_type> is one of 'open' or 'close'.
Other Callbacks signature is callback(C<$data>, C<$cb_type>, C<$pkg_id>, C<$subtype>, C<$amout>, C<$total>)
-C<$cb_type> is one of 'inst', 'trans' or 'uninst'. C<$subtype> can be 'start', 'progress' or 'stop'.
+C<$cb_type> is one of 'error', 'inst', 'trans' or 'uninst'. C<$subtype> can be 'start', 'progress' or 'stop'.
+For 'error', it can be 'cpio', 'script' or 'unpack'.
The purpose of those callbacks is to report progress (the two last parameters (C<$amount> & C<$total>) enable to compute progress percentage).
diff --git a/URPM.xs b/URPM.xs
index 59258ab..c6baa8a 100644
--- a/URPM.xs
+++ b/URPM.xs
@@ -70,6 +70,7 @@ struct s_TransactionData {
SV* callback_trans;
SV* callback_uninst;
SV* callback_inst;
+ SV* callback_error;
long min_delta;
SV *data; /* chain with another data user provided */
};
@@ -1243,6 +1244,17 @@ static void *rpmRunTransactions_callback(__attribute__((unused)) const void *h,
callback = td->callback_inst;
callback_type = "inst";
break;
+ case RPMCALLBACK_SCRIPT_START:
+ case RPMCALLBACK_SCRIPT_STOP:
+ callback = td->callback_inst;
+ callback_type = "script";
+ break;
+ case RPMCALLBACK_CPIO_ERROR:
+ case RPMCALLBACK_SCRIPT_ERROR:
+ case RPMCALLBACK_UNPACK_ERROR:
+ callback = td->callback_error;
+ callback_type = "error";
+ break;
default:
break;
}
@@ -1270,6 +1282,15 @@ static void *rpmRunTransactions_callback(__attribute__((unused)) const void *h,
case RPMCALLBACK_UNINST_STOP:
callback_subtype = "stop";
break;
+ case RPMCALLBACK_CPIO_ERROR:
+ callback_subtype = "cpio";
+ break;
+ case RPMCALLBACK_SCRIPT_ERROR:
+ callback_subtype = "script";
+ break;
+ case RPMCALLBACK_UNPACK_ERROR:
+ callback_subtype = "unpack";
+ break;
default:
break;
}
@@ -2661,7 +2682,7 @@ Trans_run(trans, data, ...)
URPM::Transaction trans
SV *data
PREINIT:
- struct s_TransactionData td = { NULL, NULL, NULL, NULL, NULL, 100000, data };
+ struct s_TransactionData td = { NULL, NULL, NULL, NULL, NULL, NULL, 100000, data };
rpmtransFlags transFlags = RPMTRANS_FLAG_NONE;
int probFilter = 0;
int translate_message = 0, raw_message = 0;
@@ -2716,6 +2737,8 @@ Trans_run(trans, data, ...)
if (SvROK(ST(i+1))) td.callback_uninst = ST(i+1);
} else if (len == 9+4 && !memcmp(s+9, "inst", 4)) {
if (SvROK(ST(i+1))) td.callback_inst = ST(i+1);
+ } else if (len == 9+4 && !memcmp(s+9, "errror", 6)) {
+ if (SvROK(ST(i+1))) td.callback_error = ST(i+1);
}
}
}