Add testcase for %ghost %config behavior
authorPanu Matilainen <pmatilai@redhat.com>
Wed, 30 Jan 2013 11:46:45 +0000 (13:46 +0200)
committerPanu Matilainen <pmatilai@redhat.com>
Wed, 30 Jan 2013 12:32:57 +0000 (14:32 +0200)
- Further parametrize configtest.spec to allow for different attributes
- Verify pre-existing %ghost %config is preserved on install,
  that it survives upgrades and gets removed on erase.
  This fails now because it IS broken due to commit
  a712252392eca75443ca45c10a72873cabec7963.
(cherry picked from commit 5121ea2151f13e58740b7b4e7dc20cff5f2475fb)

tests/data/SPECS/configtest.spec
tests/rpmconfig.at

index e9b72c0..5f15c34 100644 (file)
@@ -32,4 +32,4 @@ rm -rf $RPM_BUILD_ROOT
 
 %files
 %defattr(-,root,root,-)
-%{!?noconfig:%config%{?noreplace:(noreplace)}} %{_sysconfdir}/my.conf
+%{?fileattr} %{!?noconfig:%config%{?noreplace:(noreplace)}} %{_sysconfdir}/my.conf
index 6bdbf39..80323bc 100644 (file)
@@ -790,3 +790,55 @@ foo-2.0
 ],
 [])
 AT_CLEANUP
+
+---------
+# Test pre-existing and post-install config ghost survival and erasure
+AT_SETUP([install/upgrade/erase ghost config])
+AT_KEYWORDS([install])
+AT_CHECK([
+RPMDB_CLEAR
+RPMDB_INIT
+cf="${RPMTEST}"/etc/my.conf
+rm -rf "${cf}" "${cf}".rpm*
+rm -rf "${TOPDIR}"
+
+for v in 1.0 2.0; do
+    runroot rpmbuild --quiet -bb \
+        --define "ver ${v}" \
+        --define "filetype file" \
+        --define "filedata buster" \
+        --define "fileattr %ghost" \
+          /data/SPECS/configtest.spec
+done
+
+# pre-existing config, install, erase
+test ! -f "${cf}" && echo OK1
+echo "keaton" > "${cf}"
+cat "${cf}"
+runroot rpm -U "${TOPDIR}"/RPMS/noarch/configtest-1.0-1.noarch.rpm
+cat "${cf}"
+runroot rpm -e configtest
+test ! -f "${cf}" && echo OK1
+
+# post-install config, upgrade, erase
+runroot rpm -U "${TOPDIR}"/RPMS/noarch/configtest-1.0-1.noarch.rpm
+test ! -f "${cf}" && echo OK2
+echo "buster" > "${cf}"
+cat "${cf}"
+runroot rpm -U "${TOPDIR}"/RPMS/noarch/configtest-2.0-1.noarch.rpm
+cat "${cf}"
+runroot rpm -e configtest
+test ! -f "${cf}" && echo OK2
+],
+[],
+[OK1
+keaton
+keaton
+OK1
+OK2
+buster
+buster
+OK2
+],
+[])
+AT_CLEANUP