Skip to content

Commit ba5f8d2

Browse files
committed
lib: don't run post/purge remove scripts for updated packages
This bug was introduced in 1f99a09
1 parent 6a951d0 commit ba5f8d2

File tree

1 file changed

+12
-16
lines changed

1 file changed

+12
-16
lines changed

lib/transaction_commit.c

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,6 @@ run_post_remove_scripts(struct xbps_handle *xhp, xbps_array_t remove_scripts)
6363

6464
for (unsigned int i = 0; i < xbps_array_count(remove_scripts); i++) {
6565
xbps_dictionary_t dict;
66-
bool update = false;
6766
xbps_data_t script = NULL;
6867
const char *pkgver = NULL;
6968
const void *buf;
@@ -75,21 +74,19 @@ run_post_remove_scripts(struct xbps_handle *xhp, xbps_array_t remove_scripts)
7574
xbps_dictionary_get_cstring_nocopy(dict, "pkgver", &pkgver);
7675
assert(pkgver);
7776

78-
xbps_dictionary_get_bool(dict, "update", &update);
79-
8077
script = xbps_dictionary_get(dict, "remove-script");
8178
assert(script);
8279

8380
buf = xbps_data_data_nocopy(script);
8481
buflen = xbps_data_size(script);
85-
rv = xbps_pkg_exec_buffer(xhp, buf, buflen, pkgver, "post", update);
82+
rv = xbps_pkg_exec_buffer(xhp, buf, buflen, pkgver, "post", false);
8683
if (rv != 0) {
8784
xbps_set_cb_state(xhp, XBPS_STATE_TRANS_FAIL, rv, pkgver,
8885
"%s: [trans] REMOVE script failed to execute pre ACTION: %s",
8986
pkgver, strerror(rv));
9087
goto out;
9188
}
92-
rv = xbps_pkg_exec_buffer(xhp, buf, buflen, pkgver, "purge", update);
89+
rv = xbps_pkg_exec_buffer(xhp, buf, buflen, pkgver, "purge", false);
9390
if (rv != 0) {
9491
xbps_set_cb_state(xhp, XBPS_STATE_TRANS_FAIL, rv, pkgver,
9592
"%s: [trans] REMOVE script failed to execute pre ACTION: %s",
@@ -250,6 +247,16 @@ xbps_transaction_commit(struct xbps_handle *xhp)
250247

251248
update = ttype == XBPS_TRANS_UPDATE;
252249

250+
rv = xbps_pkg_exec_script(xhp, pkgdb_pkgd, "remove-script", "pre", update);
251+
if (rv != 0) {
252+
xbps_set_cb_state(xhp, XBPS_STATE_TRANS_FAIL, rv, pkgver,
253+
"%s: [trans] REMOVE script failed to execute pre ACTION: %s",
254+
pkgver, strerror(rv));
255+
goto out;
256+
}
257+
if (update)
258+
continue;
259+
253260
dict = xbps_dictionary_create();
254261
if (dict == NULL) {
255262
rv = errno ? errno : ENOMEM;
@@ -259,10 +266,6 @@ xbps_transaction_commit(struct xbps_handle *xhp)
259266
rv = errno ? errno : ENOMEM;
260267
goto out;
261268
}
262-
if (!xbps_dictionary_set_bool(dict, "update", update)) {
263-
rv = errno ? errno : ENOMEM;
264-
goto out;
265-
}
266269
if (!xbps_dictionary_set(dict, "remove-script", script)) {
267270
rv = errno ? errno : ENOMEM;
268271
goto out;
@@ -272,13 +275,6 @@ xbps_transaction_commit(struct xbps_handle *xhp)
272275
goto out;
273276
}
274277
xbps_object_release(dict);
275-
rv = xbps_pkg_exec_script(xhp, pkgdb_pkgd, "remove-script", "pre", update);
276-
if (rv != 0) {
277-
xbps_set_cb_state(xhp, XBPS_STATE_TRANS_FAIL, rv, pkgver,
278-
"%s: [trans] REMOVE script failed to execute pre ACTION: %s",
279-
pkgver, strerror(rv));
280-
goto out;
281-
}
282278
}
283279
xbps_object_iterator_reset(iter);
284280

0 commit comments

Comments
 (0)