Improved "xbps auto-updating itself" behaviour.

Always check if there's a new xbps package version available
while *installing* or *updating* in any form.

This fixes the following scenario:

- xbps-0.53_10 is currently installed
- xbps-0.54_1 is available in repo
- xbps-install --update netbsd-wtf || xbps-install new-pkg || xbps-install --update

As expected any of the following scenarios in last cmd will use *this*
transaction to autoupdate xbps and its reverse dependencies.

Another transaction will be necessary to install or update the other unrelated
packages.

Added a new test case to verify this case and improve the other test
cases with more extensive checks.
This commit is contained in:
Juan RP
2019-06-17 12:02:02 +02:00
parent f5f7f6b5a3
commit b672e1a7f2
2 changed files with 188 additions and 61 deletions

View File

@@ -21,7 +21,7 @@ update_xbps_body() {
atf_check_equal $? 0
out=$(xbps-query -r root -p pkgver xbps)
atf_check_equal "$out" "xbps-1.0_1"
atf_check_equal $out xbps-1.0_1
cd repo
xbps-create -A noarch -n xbps-1.1_1 -s "xbps pkg" ../xbps
@@ -34,7 +34,7 @@ update_xbps_body() {
atf_check_equal $? 0
out=$(xbps-query -r root -p pkgver xbps)
atf_check_equal "$out" "xbps-1.1_1"
atf_check_equal $out xbps-1.1_1
}
atf_test_case update_xbps_with_revdeps
@@ -44,8 +44,8 @@ update_xbps_with_revdeps_head() {
}
update_xbps_with_revdeps_body() {
mkdir -p repo xbps xbps-dbg
touch xbps/foo xbps-dbg/foo
mkdir -p repo xbps xbps-dbg baz
touch xbps/foo xbps-dbg/foo baz/blah
cd repo
xbps-create -A noarch -n xbps-1.0_1 -s "xbps pkg" ../xbps
@@ -58,35 +58,53 @@ update_xbps_with_revdeps_body() {
atf_check_equal $? 0
cd repo
xbps-create -A noarch -n xbps-1.1_1 -s "xbps pkg" ../xbps
xbps-create -A noarch -n baz-1.0_1 -s "baz pkg" ../baz
atf_check_equal $? 0
xbps-rindex -d -a $PWD/*.xbps
atf_check_equal $? 0
xbps-create -A noarch -n xbps-dbg-1.0_1 -s "xbps-dbg pkg" --dependencies "xbps-1.0_1" ../xbps-dbg
atf_check_equal $? 0
xbps-rindex -d -a $PWD/*.xbps
atf_check_equal $? 0
cd ..
xbps-install -r root --repository=$PWD/repo -yd xbps-dbg-1.0_1
xbps-install -r root --repository=$PWD/repo -yd xbps-dbg baz
atf_check_equal $? 0
cd repo
xbps-create -A noarch -n xbps-1.1_1 -s "xbps pkg" ../xbps
atf_check_equal $? 0
xbps-create -A noarch -n baz-1.1_1 -s "baz pkg" ../baz
atf_check_equal $? 0
xbps-create -A noarch -n xbps-dbg-1.1_1 -s "xbps-dbg pkg" --dependencies "xbps-1.1_1" ../xbps-dbg
atf_check_equal $? 0
xbps-rindex -d -a $PWD/*.xbps
atf_check_equal $? 0
cd ..
# first time, xbps autoupdates
xbps-install -r root --repository=$PWD/repo -yud
atf_check_equal $? 0
out=$(xbps-query -r root -p pkgver xbps)
atf_check_equal $out "xbps-1.1_1"
atf_check_equal $out xbps-1.1_1
out=$(xbps-query -r root -p pkgver xbps-dbg)
atf_check_equal $out "xbps-dbg-1.1_1"
atf_check_equal $out xbps-dbg-1.1_1
out=$(xbps-query -r root -p pkgver baz)
atf_check_equal $out baz-1.0_1
# second time, updates everything
xbps-install -r root --repository=$PWD/repo -yud
atf_check_equal $? 0
out=$(xbps-query -r root -p pkgver xbps)
atf_check_equal $out xbps-1.1_1
out=$(xbps-query -r root -p pkgver xbps-dbg)
atf_check_equal $out xbps-dbg-1.1_1
out=$(xbps-query -r root -p pkgver baz)
atf_check_equal $out baz-1.1_1
}
atf_test_case update_xbps_with_uptodate_revdeps
@@ -128,14 +146,71 @@ update_xbps_with_uptodate_revdeps_body() {
atf_check_equal $? 0
out=$(xbps-query -r root -p pkgver xbps)
atf_check_equal $out "xbps-1.1_1"
atf_check_equal $out xbps-1.1_1
out=$(xbps-query -r root -p pkgver base-system)
atf_check_equal $out "base-system-1.0_1"
atf_check_equal $out base-system-1.0_1
}
atf_test_case update_xbps_on_any_op
update_xbps_on_any_op_head() {
atf_set "descr" "Tests for pkg updates: xbps autoupdates itself on any operation"
}
update_xbps_on_any_op_body() {
mkdir -p repo xbps foo
touch xbps/foo foo/blah
cd repo
xbps-create -A noarch -n xbps-1.0_1 -s "xbps pkg" ../xbps
atf_check_equal $? 0
xbps-create -A noarch -n foo-1.0_1 -s "foo pkg" ../foo
atf_check_equal $? 0
xbps-rindex -d -a $PWD/*.xbps
atf_check_equal $? 0
cd ..
xbps-install -r root --repository=$PWD/repo -yd xbps foo
atf_check_equal $? 0
out=$(xbps-query -r root -p pkgver xbps)
atf_check_equal $out xbps-1.0_1
out=$(xbps-query -r root -p pkgver foo)
atf_check_equal $out foo-1.0_1
cd repo
xbps-create -A noarch -n xbps-1.1_1 -s "xbps pkg" ../xbps
atf_check_equal $? 0
xbps-create -A noarch -n foo-1.1_1 -s "foo pkg" ../foo
atf_check_equal $? 0
xbps-rindex -d -a $PWD/*.xbps
atf_check_equal $? 0
cd ..
xbps-install -r root --repository=$PWD/repo -yud foo
atf_check_equal $? 0
out=$(xbps-query -r root -p pkgver xbps)
atf_check_equal $out xbps-1.1_1
out=$(xbps-query -r root -p pkgver foo)
atf_check_equal $out foo-1.0_1
xbps-install -r root --repository=$PWD/repo -yud
atf_check_equal $? 0
out=$(xbps-query -r root -p pkgver xbps)
atf_check_equal $out xbps-1.1_1
out=$(xbps-query -r root -p pkgver foo)
atf_check_equal $out foo-1.1_1
}
atf_init_test_cases() {
atf_add_test_case update_xbps
atf_add_test_case update_xbps_with_revdeps
atf_add_test_case update_xbps_with_uptodate_revdeps
atf_add_test_case update_xbps_on_any_op
}