Implement support to "preserve" existent on-disk files.
See NEWS for more information. Fix #51
This commit is contained in:
@@ -21,6 +21,7 @@ atf_test_program{name="scripts_test"}
|
||||
atf_test_program{name="incorrect_deps_test"}
|
||||
atf_test_program{name="vpkg_test"}
|
||||
atf_test_program{name="install_test"}
|
||||
atf_test_program{name="preserve_files_test"}
|
||||
|
||||
include('config/Kyuafile')
|
||||
include('find_pkg_orphans/Kyuafile')
|
||||
|
@@ -36,7 +36,6 @@ ATF_TC_BODY(config_include_test, tc)
|
||||
{
|
||||
struct xbps_handle xh;
|
||||
const char *tcsdir;
|
||||
char conffile[XBPS_MAXPATH-1];
|
||||
|
||||
/* get test source dir */
|
||||
tcsdir = atf_tc_get_config_var(tc, "srcdir");
|
||||
@@ -46,9 +45,7 @@ ATF_TC_BODY(config_include_test, tc)
|
||||
memset(&xh, 0, sizeof(xh));
|
||||
strncpy(xh.rootdir, tcsdir, sizeof(xh.rootdir));
|
||||
strncpy(xh.metadir, tcsdir, sizeof(xh.metadir));
|
||||
strncpy(conffile, tcsdir, sizeof(conffile));
|
||||
strncat(conffile, "/xbps.conf", sizeof(conffile)-1);
|
||||
xh.conffile = conffile;
|
||||
snprintf(xh.conffile, sizeof(xh.conffile), "%s/xbps.conf", tcsdir);
|
||||
xh.flags = XBPS_FLAG_DEBUG;
|
||||
ATF_REQUIRE_EQ(xbps_init(&xh), 0);
|
||||
|
||||
@@ -67,7 +64,6 @@ ATF_TC_BODY(config_include_nomatch_test, tc)
|
||||
{
|
||||
struct xbps_handle xh;
|
||||
const char *tcsdir;
|
||||
char conffile[XBPS_MAXPATH-1];
|
||||
|
||||
/* get test source dir */
|
||||
tcsdir = atf_tc_get_config_var(tc, "srcdir");
|
||||
@@ -77,9 +73,7 @@ ATF_TC_BODY(config_include_nomatch_test, tc)
|
||||
memset(&xh, 0, sizeof(xh));
|
||||
strncpy(xh.rootdir, tcsdir, sizeof(xh.rootdir));
|
||||
strncpy(xh.metadir, tcsdir, sizeof(xh.metadir));
|
||||
strncpy(conffile, tcsdir, sizeof(conffile));
|
||||
strncat(conffile, "/xbps_nomatch.conf", sizeof(conffile)-1);
|
||||
xh.conffile = conffile;
|
||||
strncpy(xh.conffile, "/xbps_nomatch.conf", sizeof(xh.conffile));
|
||||
xh.flags = XBPS_FLAG_DEBUG;
|
||||
ATF_REQUIRE_EQ(xbps_init(&xh), 0);
|
||||
|
||||
|
@@ -79,7 +79,7 @@ ATF_TC_BODY(find_pkg_obsoletes_test, tc)
|
||||
|
||||
memset(&xh, 0, sizeof(xh));
|
||||
strncpy(xh.rootdir, tcsdir, sizeof(xh.rootdir));
|
||||
xh.conffile = "/tmp/unexistent.conf";
|
||||
strncpy(xh.conffile, "/tmp/unexistent.conf", sizeof(xh.conffile));
|
||||
ATF_REQUIRE_EQ(xbps_init(&xh), 0);
|
||||
|
||||
d1 = create_dict("files", "/etc/foo.conf");
|
||||
|
@@ -4,7 +4,7 @@ TOPDIR = ../../../..
|
||||
TESTSHELL = conf_files_test issue6_test issue18_test issue20_test remove_test
|
||||
TESTSHELL+= replace_test installmode_test obsoletefiles_test
|
||||
TESTSHELL+= issue31_test scripts_test incorrect_deps_test
|
||||
TESTSHELL+= vpkg_test install_test
|
||||
TESTSHELL+= vpkg_test install_test preserve_files_test
|
||||
|
||||
include ../Makefile.inc
|
||||
include $(TOPDIR)/mk/test.mk
|
||||
|
83
tests/xbps/libxbps/shell/preserve_files_test.sh
Normal file
83
tests/xbps/libxbps/shell/preserve_files_test.sh
Normal file
@@ -0,0 +1,83 @@
|
||||
#!/usr/bin/env atf-sh
|
||||
|
||||
atf_test_case tc1
|
||||
|
||||
tc1_head() {
|
||||
atf_set "descr" "Tests for pkg install/upgrade with preserved files: preserve on-disk files with globs"
|
||||
}
|
||||
|
||||
tc1_body() {
|
||||
mkdir some_repo
|
||||
mkdir -p pkg_A/usr/bin
|
||||
echo "blahblah" > pkg_A/usr/bin/blah
|
||||
echo "foofoo" > pkg_A/usr/bin/foo
|
||||
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
|
||||
cd ..
|
||||
|
||||
mkdir -p root/usr/bin
|
||||
echo "modified blahblah" > root/usr/bin/blah
|
||||
echo "modified foofoo" > root/usr/bin/foo
|
||||
|
||||
echo "preserve=/usr/bin/*" > foo.conf
|
||||
|
||||
xbps-install -C foo.conf -r root --repository=$PWD/some_repo -yd A
|
||||
atf_check_equal $? 0
|
||||
|
||||
rv=1
|
||||
if [ "$(cat root/usr/bin/blah)" = "modified blahblah" -a "$(cat root/usr/bin/foo)" = "modified foofoo" ]; then
|
||||
rv=0
|
||||
fi
|
||||
atf_check_equal $rv 0
|
||||
}
|
||||
|
||||
atf_test_case tc2
|
||||
|
||||
tc2_head() {
|
||||
atf_set "descr" "Tests for pkg install/upgrade with preserved files: preserve on-disk files without globs"
|
||||
}
|
||||
|
||||
tc2_body() {
|
||||
mkdir some_repo
|
||||
mkdir -p pkg_A/usr/bin
|
||||
echo "blahblah" > pkg_A/usr/bin/blah
|
||||
echo "foofoo" > pkg_A/usr/bin/foo
|
||||
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
|
||||
cd ..
|
||||
|
||||
mkdir -p root/usr/bin
|
||||
echo "modified blahblah" > root/usr/bin/blah
|
||||
echo "modified foofoo" > root/usr/bin/foo
|
||||
|
||||
printf "preserve=/usr/bin/blah\npreserve=/usr/bin/foo\n" > foo.conf
|
||||
|
||||
echo "foo.conf" >&2
|
||||
cat foo.conf >&2
|
||||
|
||||
xbps-install -C foo.conf -r root --repository=$PWD/some_repo -yd A
|
||||
atf_check_equal $? 0
|
||||
|
||||
rv=1
|
||||
if [ "$(cat root/usr/bin/blah)" = "modified blahblah" -a "$(cat root/usr/bin/foo)" = "modified foofoo" ]; then
|
||||
rv=0
|
||||
fi
|
||||
|
||||
echo "root/usr/bin/blah" >&2
|
||||
cat root/usr/bin/blah >&2
|
||||
echo "root/usr/bin/foo" >&2
|
||||
cat root/usr/bin/foo >&2
|
||||
|
||||
atf_check_equal $rv 0
|
||||
}
|
||||
|
||||
atf_init_test_cases() {
|
||||
atf_add_test_case tc1
|
||||
atf_add_test_case tc2
|
||||
}
|
@@ -41,7 +41,7 @@ script_nargs_body() {
|
||||
rval=0
|
||||
xbps-reconfigure -C empty.conf -r root -f A 2>out
|
||||
out="$(cat out)"
|
||||
expected="post A 1.0_1 no empty.conf $(uname -m)"
|
||||
expected="post A 1.0_1 no $(pwd)/empty.conf $(uname -m)"
|
||||
if [ "$out" != "$expected" ]; then
|
||||
echo "out: '$out'"
|
||||
echo "expected: '$expected'"
|
||||
@@ -75,7 +75,7 @@ script_arch_body() {
|
||||
rval=0
|
||||
XBPS_ARCH=foo xbps-reconfigure -C empty.conf -r root -f A 2>out
|
||||
out="$(cat out)"
|
||||
expected="post A 1.0_1 no empty.conf foo"
|
||||
expected="post A 1.0_1 no $(pwd)/empty.conf foo"
|
||||
if [ "$out" != "$expected" ]; then
|
||||
echo "out: '$out'"
|
||||
echo "expected: '$expected'"
|
||||
|
Reference in New Issue
Block a user