From 4c147854808b45b900cf3c5ef3b497a5c4313e59 Mon Sep 17 00:00:00 2001 From: Juan RP Date: Sat, 23 Aug 2014 08:02:40 +0200 Subject: [PATCH] Fix #53 (xbps-install with multiple arguments shouldn't fail if one is already installed). --- bin/xbps-install/main.c | 4 ++- tests/xbps/Makefile | 2 +- tests/xbps/common/Kyuafile | 1 + tests/xbps/xbps-install/Kyuafile | 4 +++ tests/xbps/xbps-install/Makefile | 8 ++++++ tests/xbps/xbps-install/behaviour_tests.sh | 33 ++++++++++++++++++++++ 6 files changed, 50 insertions(+), 2 deletions(-) create mode 100644 tests/xbps/xbps-install/Kyuafile create mode 100644 tests/xbps/xbps-install/Makefile create mode 100644 tests/xbps/xbps-install/behaviour_tests.sh diff --git a/bin/xbps-install/main.c b/bin/xbps-install/main.c index b11fa272..b8aa47cf 100644 --- a/bin/xbps-install/main.c +++ b/bin/xbps-install/main.c @@ -238,7 +238,9 @@ main(int argc, char **argv) /* Install target packages */ for (i = optind; i < argc; i++) { rv = install_new_pkg(&xh, argv[i], reinstall); - if (rv != 0) { + if (optind >= 2 && rv == EEXIST) { + rv = 0; + } else if (rv != 0) { xbps_pkgdb_unlock(&xh); exit(rv); } diff --git a/tests/xbps/Makefile b/tests/xbps/Makefile index cfecace2..50096e4a 100644 --- a/tests/xbps/Makefile +++ b/tests/xbps/Makefile @@ -1,5 +1,5 @@ -include ../../config.mk -SUBDIRS = common libxbps xbps-query xbps-rindex +SUBDIRS = common libxbps xbps-install xbps-query xbps-rindex include ../../mk/subdir.mk diff --git a/tests/xbps/common/Kyuafile b/tests/xbps/common/Kyuafile index 2108b192..6a9ca533 100644 --- a/tests/xbps/common/Kyuafile +++ b/tests/xbps/common/Kyuafile @@ -3,5 +3,6 @@ syntax("kyuafile", 1) test_suite("xbps") include('libxbps/Kyuafile') +include('xbps-install/Kyuafile') include('xbps-query/Kyuafile') include('xbps-rindex/Kyuafile') diff --git a/tests/xbps/xbps-install/Kyuafile b/tests/xbps/xbps-install/Kyuafile new file mode 100644 index 00000000..e15dd06c --- /dev/null +++ b/tests/xbps/xbps-install/Kyuafile @@ -0,0 +1,4 @@ +syntax("kyuafile", 1) + +test_suite("xbps-install") +atf_test_program{name="behaviour_tests"} diff --git a/tests/xbps/xbps-install/Makefile b/tests/xbps/xbps-install/Makefile new file mode 100644 index 00000000..c465c561 --- /dev/null +++ b/tests/xbps/xbps-install/Makefile @@ -0,0 +1,8 @@ +TOPDIR = ../../.. +-include $(TOPDIR)/config.mk + +TESTSHELL = behaviour_tests +TESTSSUBDIR = xbps/xbps-install +EXTRA_FILES = Kyuafile + +include $(TOPDIR)/mk/test.mk diff --git a/tests/xbps/xbps-install/behaviour_tests.sh b/tests/xbps/xbps-install/behaviour_tests.sh new file mode 100644 index 00000000..0c71f86d --- /dev/null +++ b/tests/xbps/xbps-install/behaviour_tests.sh @@ -0,0 +1,33 @@ +#! /usr/bin/env atf-sh + +atf_test_case install_existent + +install_existent_head() { + atf_set "descr" "xbps-install(8): install multiple existent pkgs (issue #53)" +} + +install_existent_body() { + mkdir -p some_repo pkg_A pkg_B + touch pkg_A/file00 + touch pkg_B/file00 + cd some_repo + xbps-create -A noarch -n A-1.0_1 -s "A pkg" ../pkg_A + atf_check_equal $? 0 + xbps-rindex -a *.xbps + atf_check_equal $? 0 + xbps-create -A noarch -n B-1.1_1 -s "B pkg" ../pkg_B + atf_check_equal $? 0 + xbps-rindex -a *.xbps + atf_check_equal $? 0 + cd .. + xbps-install -r root -C empty.conf --repository=$PWD/some_repo -y A + atf_check_equal $? 0 + xbps-install -r root -C empty.conf --repository=$PWD/some_repo -yn A B + atf_check_equal $? 0 + xbps-install -r root -C empty.conf --repository=$PWD/some_repo -yn B A + atf_check_equal $? 0 +} + +atf_init_test_cases() { + atf_add_test_case install_existent +}