aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThierry Vignaud <thierry.vignaud@gmail.com>2015-02-23 10:58:56 +0100
committerThierry Vignaud <thierry.vignaud@gmail.com>2015-02-26 19:02:12 +0100
commitb0cd1853933d8c68610c9e173721525c6a17e8ce (patch)
tree0791961522b6af3060b4a75fe88800ec144cd2b7
parente1143e85b339f28c00f2682c326a1ff8d92a91e7 (diff)
downloadperl-URPM-b0cd1853933d8c68610c9e173721525c6a17e8ce.tar
perl-URPM-b0cd1853933d8c68610c9e173721525c6a17e8ce.tar.gz
perl-URPM-b0cd1853933d8c68610c9e173721525c6a17e8ce.tar.bz2
perl-URPM-b0cd1853933d8c68610c9e173721525c6a17e8ce.tar.xz
perl-URPM-b0cd1853933d8c68610c9e173721525c6a17e8ce.zip
callbacks now get pkg name instead of just pkg id
thus fixing unknown package name on erases (mga#15032)
-rw-r--r--NEWS3
-rw-r--r--URPM.pm6
-rw-r--r--URPM.xs8
3 files changed, 12 insertions, 5 deletions
diff --git a/NEWS b/NEWS
index cf0aaa2..c6fe11c 100644
--- a/NEWS
+++ b/NEWS
@@ -1,3 +1,6 @@
+- callbacks now get pkg name instead of just pkg id
+ thus fixing unknown package name on erases (mga#15032)
+
Version 5.03 - 14 November 2014
- add a missing PUTBACK in traverse_tag_find()
diff --git a/URPM.pm b/URPM.pm
index 2ed0572..2236551 100644
--- a/URPM.pm
+++ b/URPM.pm
@@ -885,13 +885,13 @@ Recognized options are:
They roughly correspond to command-line options to rpm(1).
-'callback_open' signature is (C<$data>, C<$cb_type>, C<$pkg_id>). It _must_ return a file handler for the asked package.
+'callback_open' signature is (C<$data>, C<$cb_type>, C<$pkg_id>, C<pkg_name>). It _must_ return a file handler for the asked package.
-'callback_close' signature is (C<$data>, C<$cb_type>, C<$pkg_id>). It is called just before URPM close the fd for the installed package.
+'callback_close' signature is (C<$data>, C<$cb_type>, C<$pkg_id>, C<pkg_name>). It is called just before URPM close the fd for the installed package.
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>)
+Other Callbacks signature is callback(C<$data>, C<$cb_type>, C<$pkg_id>, C<$subtype>, C<$amout>, C<$total>, C<pkg_name>)
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'.
diff --git a/URPM.xs b/URPM.xs
index 14327e8..f4ac459 100644
--- a/URPM.xs
+++ b/URPM.xs
@@ -1199,7 +1199,7 @@ ts_nosignature(rpmts ts) {
return rpmtsSetVSFlags(ts, _RPMVSF_NODIGESTS | _RPMVSF_NOSIGNATURES);
}
-static void *rpmRunTransactions_callback(__attribute__((unused)) const void *h,
+static void *rpmRunTransactions_callback(const void *arg,
const rpmCallbackType what,
const rpm_loff_t amount,
const rpm_loff_t total,
@@ -1214,6 +1214,7 @@ static void *rpmRunTransactions_callback(__attribute__((unused)) const void *h,
SV *callback = NULL;
char *callback_type = NULL;
char *callback_subtype = NULL;
+ Header h = (Header) arg;
if (!td)
return NULL;
@@ -1303,7 +1304,7 @@ static void *rpmRunTransactions_callback(__attribute__((unused)) const void *h,
ENTER;
SAVETMPS;
PUSHMARK(SP);
- EXTEND(SP, callback_subtype == NULL ? 2 : 5);
+ EXTEND(SP, callback_subtype == NULL ? 3 : 6);
PUSHs(td->data);
mPUSHs(newSVpv(callback_type, 0));
PUSHs(pkgKey != NULL ? sv_2mortal(newSViv((long)pkgKey - 1)) : &PL_sv_undef);
@@ -1312,6 +1313,9 @@ static void *rpmRunTransactions_callback(__attribute__((unused)) const void *h,
mPUSHs(newSViv(amount));
mPUSHs(newSViv(total));
}
+ // for erasures, the key provided by librpm is always 0, so let's add another parameter (fullname):
+ char *s = headerGetAsString(h, RPMTAG_NVR);
+ mPUSHs(newSVpv(s, 0));
PUTBACK;
i = call_sv(callback, callback == td->callback_open ? G_SCALAR : G_DISCARD);
SPAGAIN;