xbps_register_pkg: keep stored props in pkgdb on updates.
I noticed that while updating a pkg that is on hold or in repolock mode, does not keep those properties. Always set those props in the new pkg dictionary to respect this behaviour. If there's a pkg on hold and you update it, you want to keep it in this state unless you tell it to change. Added new test case to verify.
This commit is contained in:
parent
9b695433a0
commit
f906f5a83d
@ -1,5 +1,5 @@
|
||||
/*-
|
||||
* Copyright (c) 2008-2014 Juan Romero Pardines.
|
||||
* Copyright (c) 2008-2020 Juan Romero Pardines.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@ -35,7 +35,8 @@ int HIDDEN
|
||||
xbps_register_pkg(struct xbps_handle *xhp, xbps_dictionary_t pkgrd)
|
||||
{
|
||||
xbps_array_t replaces;
|
||||
xbps_dictionary_t pkgd;
|
||||
xbps_dictionary_t pkgd, pkgdbd;
|
||||
xbps_object_t obj;
|
||||
time_t t;
|
||||
struct tm tm;
|
||||
struct tm *tmp;
|
||||
@ -106,15 +107,22 @@ xbps_register_pkg(struct xbps_handle *xhp, xbps_dictionary_t pkgrd)
|
||||
}
|
||||
free(buf);
|
||||
/*
|
||||
* Remove unneeded objs from pkg dictionary.
|
||||
* Keep objects stored in pkgdb (if found).
|
||||
*/
|
||||
xbps_dictionary_remove(pkgd, "download");
|
||||
xbps_dictionary_remove(pkgd, "remove-and-update");
|
||||
xbps_dictionary_remove(pkgd, "transaction");
|
||||
xbps_dictionary_remove(pkgd, "skip-obsoletes");
|
||||
xbps_dictionary_remove(pkgd, "pkgname");
|
||||
xbps_dictionary_remove(pkgd, "version");
|
||||
|
||||
if ((pkgdbd = xbps_pkgdb_get_pkg(xhp, pkgname))) {
|
||||
obj = xbps_dictionary_get(pkgdbd, "hold");
|
||||
if (obj) {
|
||||
xbps_dictionary_set(pkgd, "hold", obj);
|
||||
}
|
||||
obj = xbps_dictionary_get(pkgdbd, "repolock");
|
||||
if (obj) {
|
||||
xbps_dictionary_set(pkgd, "repolock", obj);
|
||||
}
|
||||
obj = xbps_dictionary_get(pkgdbd, "automatic-install");
|
||||
if (obj) {
|
||||
xbps_dictionary_set(pkgd, "automatic-install", obj);
|
||||
}
|
||||
}
|
||||
/*
|
||||
* Remove self replacement when applicable.
|
||||
*/
|
||||
@ -125,6 +133,16 @@ xbps_register_pkg(struct xbps_handle *xhp, xbps_dictionary_t pkgrd)
|
||||
if (!xbps_array_count(replaces))
|
||||
xbps_dictionary_remove(pkgd, "replaces");
|
||||
}
|
||||
/*
|
||||
* Remove unneeded objs from pkg dictionary.
|
||||
*/
|
||||
xbps_dictionary_remove(pkgd, "download");
|
||||
xbps_dictionary_remove(pkgd, "remove-and-update");
|
||||
xbps_dictionary_remove(pkgd, "transaction");
|
||||
xbps_dictionary_remove(pkgd, "skip-obsoletes");
|
||||
xbps_dictionary_remove(pkgd, "pkgname");
|
||||
xbps_dictionary_remove(pkgd, "version");
|
||||
|
||||
if (!xbps_dictionary_set(xhp->pkgdb, pkgname, pkgd)) {
|
||||
xbps_dbg_printf(xhp,
|
||||
"%s: failed to set pkgd for %s\n", __func__, pkgver);
|
||||
|
@ -94,7 +94,42 @@ hold_shlibs_body() {
|
||||
atf_check_equal $? 0
|
||||
}
|
||||
|
||||
atf_test_case keep_on_update
|
||||
|
||||
keep_on_update_head() {
|
||||
atf_set "descr" "Tests for pkgs on hold: keep prop on update"
|
||||
}
|
||||
|
||||
keep_on_update_body() {
|
||||
mkdir -p repo pkg_A
|
||||
cd repo
|
||||
xbps-create -A noarch -n A-1.0_1 -s "A pkg" ../pkg_A
|
||||
atf_check_equal $? 0
|
||||
xbps-rindex -d -a $PWD/*.xbps
|
||||
atf_check_equal $? 0
|
||||
cd ..
|
||||
xbps-install -r root --repository=$PWD/repo -yd A
|
||||
atf_check_equal $? 0
|
||||
xbps-pkgdb -r root -m hold A
|
||||
atf_check_equal $? 0
|
||||
out=$(xbps-query -r root -H)
|
||||
atf_check_equal $out A-1.0_1
|
||||
cd repo
|
||||
xbps-create -A noarch -n A-1.1_1 -s "A pkg" ../pkg_A
|
||||
atf_check_equal $? 0
|
||||
xbps-rindex -d -a $PWD/*.xbps
|
||||
atf_check_equal $? 0
|
||||
cd ..
|
||||
xbps-install -r root --repository=$PWD/repo -yuvd A
|
||||
atf_check_equal $? 0
|
||||
out=$(xbps-query -r root -p pkgver A)
|
||||
atf_check_equal $out A-1.1_1
|
||||
out=$(xbps-query -r root -p hold A)
|
||||
atf_check_equal $out yes
|
||||
}
|
||||
|
||||
atf_init_test_cases() {
|
||||
atf_add_test_case downgrade_hold
|
||||
atf_add_test_case hold_shlibs
|
||||
atf_add_test_case keep_on_update
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user