Make sure that configuration files are properly kept or unpacked.
Added two new test cases to verify it works as advertised.
This commit is contained in:
parent
41baf01cd1
commit
8f36f8e638
@ -159,6 +159,7 @@ unpack_archive(struct xbps_handle *xhp,
|
|||||||
xbps_dictionary_t propsd, filesd, old_filesd;
|
xbps_dictionary_t propsd, filesd, old_filesd;
|
||||||
xbps_array_t array, obsoletes;
|
xbps_array_t array, obsoletes;
|
||||||
xbps_object_t obj;
|
xbps_object_t obj;
|
||||||
|
const struct stat *entry_statp;
|
||||||
void *instbuf = NULL, *rembuf = NULL;
|
void *instbuf = NULL, *rembuf = NULL;
|
||||||
struct stat st;
|
struct stat st;
|
||||||
struct xbps_unpack_cb_data xucd;
|
struct xbps_unpack_cb_data xucd;
|
||||||
@ -232,6 +233,7 @@ unpack_archive(struct xbps_handle *xhp,
|
|||||||
entry_pname = archive_entry_pathname(entry);
|
entry_pname = archive_entry_pathname(entry);
|
||||||
entry_size = archive_entry_size(entry);
|
entry_size = archive_entry_size(entry);
|
||||||
entry_type = archive_entry_filetype(entry);
|
entry_type = archive_entry_filetype(entry);
|
||||||
|
entry_statp = archive_entry_stat(entry);
|
||||||
/*
|
/*
|
||||||
* Ignore directories from archive.
|
* Ignore directories from archive.
|
||||||
*/
|
*/
|
||||||
@ -369,10 +371,10 @@ unpack_archive(struct xbps_handle *xhp,
|
|||||||
if (lstat(entry_pname, &st) == 0)
|
if (lstat(entry_pname, &st) == 0)
|
||||||
file_exists = true;
|
file_exists = true;
|
||||||
/*
|
/*
|
||||||
* If file to be extracted does not match the file type of
|
* If file to be extracted does not match the mode_t of
|
||||||
* file currently stored on disk, remove file on disk.
|
* file currently stored on disk, remove file on disk.
|
||||||
*/
|
*/
|
||||||
if (file_exists && (entry_type != (int)st.st_mode))
|
if (file_exists && (entry_statp->st_mode != st.st_mode))
|
||||||
remove(entry_pname);
|
remove(entry_pname);
|
||||||
|
|
||||||
if (!force && (entry_type == AE_IFREG)) {
|
if (!force && (entry_type == AE_IFREG)) {
|
||||||
|
@ -13,5 +13,6 @@ SUBDIRS += pkgdb
|
|||||||
SUBDIRS += issue6
|
SUBDIRS += issue6
|
||||||
SUBDIRS += issue18
|
SUBDIRS += issue18
|
||||||
SUBDIRS += issue20
|
SUBDIRS += issue20
|
||||||
|
SUBDIRS += conf_files
|
||||||
|
|
||||||
include ../../../mk/subdir.mk
|
include ../../../mk/subdir.mk
|
||||||
|
@ -11,5 +11,6 @@ atf_test_program{name="find_pkg_obsoletes_test"}
|
|||||||
atf_test_program{name="issue6_test"}
|
atf_test_program{name="issue6_test"}
|
||||||
atf_test_program{name="issue18_test"}
|
atf_test_program{name="issue18_test"}
|
||||||
atf_test_program{name="issue20_test"}
|
atf_test_program{name="issue20_test"}
|
||||||
|
atf_test_program{name="conf_files_test"}
|
||||||
include('find_pkg_orphans/Kyuafile')
|
include('find_pkg_orphans/Kyuafile')
|
||||||
include('pkgdb/Kyuafile')
|
include('pkgdb/Kyuafile')
|
||||||
|
7
tests/xbps/libxbps/conf_files/Makefile
Normal file
7
tests/xbps/libxbps/conf_files/Makefile
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
TOPDIR = ../../../..
|
||||||
|
-include $(TOPDIR)/config.mk
|
||||||
|
|
||||||
|
TEST = conf_files_test
|
||||||
|
|
||||||
|
include ../Makefile.inc
|
||||||
|
include $(TOPDIR)/mk/test-shell.mk
|
89
tests/xbps/libxbps/conf_files/conf_files_test.sh
Normal file
89
tests/xbps/libxbps/conf_files/conf_files_test.sh
Normal file
@ -0,0 +1,89 @@
|
|||||||
|
#! /usr/bin/env atf-sh
|
||||||
|
|
||||||
|
# 1st test: modified configuration file on disk, unmodified on upgrade.
|
||||||
|
# result: keep file as is on disk.
|
||||||
|
atf_test_case tc1
|
||||||
|
|
||||||
|
tc1_head() {
|
||||||
|
atf_set "descr" "Tests for configuration file handling: on-disk modified, upgrade unmodified"
|
||||||
|
}
|
||||||
|
|
||||||
|
tc1_body() {
|
||||||
|
mkdir repo
|
||||||
|
cd repo
|
||||||
|
mkdir pkg_a
|
||||||
|
echo "fooblah" > pkg_a/cf1.conf
|
||||||
|
xbps-create -A noarch -n a-0.1_1 -s "pkg a" --config-files "/cf1.conf" pkg_a
|
||||||
|
atf_check_equal $? 0
|
||||||
|
rm -rf pkg_a
|
||||||
|
xbps-rindex -a *.xbps
|
||||||
|
atf_check_equal $? 0
|
||||||
|
xbps-install -r rootdir --repository=$PWD -y a
|
||||||
|
atf_check_equal $? 0
|
||||||
|
|
||||||
|
sed -e 's,fooblah,blahfoo,' -i rootdir/cf1.conf
|
||||||
|
mkdir pkg_a
|
||||||
|
echo "fooblah" > pkg_a/cf1.conf
|
||||||
|
xbps-create -A noarch -n a-0.2_1 -s "pkg a" --config-files "/cf1.conf" pkg_a
|
||||||
|
atf_check_equal $? 0
|
||||||
|
xbps-rindex -a *.xbps
|
||||||
|
rm -rf pkg_a
|
||||||
|
atf_check_equal $? 0
|
||||||
|
xbps-install -r rootdir --repository=$PWD -yu
|
||||||
|
atf_check_equal $? 0
|
||||||
|
result="$(cat rootdir/cf1.conf)"
|
||||||
|
rval=1
|
||||||
|
if [ "${result}" = "blahfoo" ]; then
|
||||||
|
rval=0
|
||||||
|
fi
|
||||||
|
atf_check_equal $rval 0
|
||||||
|
}
|
||||||
|
|
||||||
|
# 2nd test: modified configuration file on disk, modified on upgrade.
|
||||||
|
# result: install new file as "<conf_file>.new-<version>".
|
||||||
|
atf_test_case tc2
|
||||||
|
|
||||||
|
tc2_head() {
|
||||||
|
atf_set "descr" "Tests for configuration file handling: on-disk modified, upgrade modified"
|
||||||
|
}
|
||||||
|
|
||||||
|
tc2_body() {
|
||||||
|
mkdir repo
|
||||||
|
cd repo
|
||||||
|
mkdir pkg_a
|
||||||
|
echo "fooblah" > pkg_a/cf1.conf
|
||||||
|
xbps-create -A noarch -n a-0.1_1 -s "pkg a" --config-files "/cf1.conf" pkg_a
|
||||||
|
atf_check_equal $? 0
|
||||||
|
rm -rf pkg_a
|
||||||
|
xbps-rindex -a *.xbps
|
||||||
|
atf_check_equal $? 0
|
||||||
|
xbps-install -r rootdir --repository=$PWD -y a
|
||||||
|
atf_check_equal $? 0
|
||||||
|
|
||||||
|
sed -e 's,fooblah,blahfoo,' -i rootdir/cf1.conf
|
||||||
|
mkdir pkg_a
|
||||||
|
echo "bazbar" > pkg_a/cf1.conf
|
||||||
|
xbps-create -A noarch -n a-0.2_1 -s "pkg a" --config-files "/cf1.conf" pkg_a
|
||||||
|
atf_check_equal $? 0
|
||||||
|
xbps-rindex -a *.xbps
|
||||||
|
rm -rf pkg_a
|
||||||
|
atf_check_equal $? 0
|
||||||
|
xbps-install -r rootdir --repository=$PWD -yu
|
||||||
|
atf_check_equal $? 0
|
||||||
|
result="$(cat rootdir/cf1.conf)"
|
||||||
|
rval=1
|
||||||
|
if [ "${result}" = "blahfoo" ]; then
|
||||||
|
rval=0
|
||||||
|
fi
|
||||||
|
atf_check_equal $rval 0
|
||||||
|
rval=1
|
||||||
|
if [ -s rootdir/cf1.conf.new-0.2_1 ]; then
|
||||||
|
rval=0
|
||||||
|
fi
|
||||||
|
atf_check_equal $rval 0
|
||||||
|
}
|
||||||
|
|
||||||
|
atf_init_test_cases() {
|
||||||
|
atf_add_test_case tc1
|
||||||
|
atf_add_test_case tc2
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user