unpack: make sure to remove only on-disk files if file type does not match.
Added another ATF test-case to make sure it works properly.
This commit is contained in:
parent
efdb0eb5a4
commit
6d9bb47fba
@ -371,10 +371,11 @@ unpack_archive(struct xbps_handle *xhp,
|
||||
if (lstat(entry_pname, &st) == 0)
|
||||
file_exists = true;
|
||||
/*
|
||||
* If file to be extracted does not match the mode_t of
|
||||
* If file to be extracted does not match the file type of
|
||||
* file currently stored on disk, remove file on disk.
|
||||
*/
|
||||
if (file_exists && (entry_statp->st_mode != st.st_mode))
|
||||
if (file_exists &&
|
||||
((entry_statp->st_mode & S_IFMT) != (st.st_mode & S_IFMT)))
|
||||
remove(entry_pname);
|
||||
|
||||
if (!force && (entry_type == AE_IFREG)) {
|
||||
|
@ -52,6 +52,7 @@ tc2_body() {
|
||||
cd repo
|
||||
mkdir pkg_a
|
||||
echo "fooblah" > pkg_a/cf1.conf
|
||||
chmod 755 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
|
||||
@ -61,8 +62,10 @@ tc2_body() {
|
||||
atf_check_equal $? 0
|
||||
|
||||
sed -e 's,fooblah,blahfoo,' -i rootdir/cf1.conf
|
||||
chmod 644 rootdir/cf1.conf
|
||||
mkdir pkg_a
|
||||
echo "bazbar" > pkg_a/cf1.conf
|
||||
chmod 755 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
|
||||
@ -83,7 +86,50 @@ tc2_body() {
|
||||
atf_check_equal $rval 0
|
||||
}
|
||||
|
||||
# 3rd test: modified configuration file on disk, unmodified on upgrade.
|
||||
# result: keep file on disk as is.
|
||||
atf_test_case tc3
|
||||
|
||||
tc3_head() {
|
||||
atf_set "descr" "Tests for configuration file handling: on-disk modified, upgrade unmodified"
|
||||
}
|
||||
|
||||
tc3_body() {
|
||||
mkdir repo
|
||||
cd repo
|
||||
mkdir pkg_a
|
||||
echo "fooblah" > pkg_a/cf1.conf
|
||||
chmod 755 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
|
||||
chmod 644 rootdir/cf1.conf
|
||||
mkdir pkg_a
|
||||
echo "fooblah" > pkg_a/cf1.conf
|
||||
chmod 755 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
|
||||
}
|
||||
|
||||
atf_init_test_cases() {
|
||||
atf_add_test_case tc1
|
||||
atf_add_test_case tc2
|
||||
atf_add_test_case tc3
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user