EXTRA_DIST += data/SPECS/versiontest.spec
EXTRA_DIST += data/SPECS/conflicttest.spec
EXTRA_DIST += data/SPECS/configtest.spec
+EXTRA_DIST += data/SPECS/symlinktest.spec
EXTRA_DIST += data/SOURCES/hello-1.0.tar.gz
EXTRA_DIST += data/RPMS/foo-1.0-1.noarch.rpm
EXTRA_DIST += data/RPMS/hello-1.0-1.i386.rpm
--- /dev/null
+%bcond_with symlink
+
+Name: symlinktest
+Version: 1.0
+Release: %{rel}
+Summary: Testing symlink behavior
+Group: Testing
+License: GPL
+BuildArch: noarch
+
+%description
+%{summary}
+
+%install
+rm -rf $RPM_BUILD_ROOT
+mkdir -p $RPM_BUILD_ROOT/usr/share
+%if %{with symlink}
+mkdir -p $RPM_BUILD_ROOT/usr/lib/%{name}
+echo %{name} > $RPM_BUILD_ROOT/usr/lib/%{name}/README
+ln -s ../lib/%{name} $RPM_BUILD_ROOT/usr/share/%{name}
+%else
+mkdir -p $RPM_BUILD_ROOT/usr/share/%{name}
+echo %{name} > $RPM_BUILD_ROOT/usr/share/%{name}/README
+%endif
+
+%clean
+rm -rf $RPM_BUILD_ROOT
+
+%files
+%defattr(-,root,root,-)
+%if %{with symlink}
+/usr/lib/%{name}
+%endif
+/usr/share/%{name}
[ignore])
AT_CLEANUP
+
+# ------------------------------
+# Replace directory with symlink, this is expected to fail
+AT_SETUP([rpm -U replacing directory with symlink])
+AT_KEYWORDS([install])
+AT_CHECK([
+RPMDB_CLEAR
+rm -rf "${TOPDIR}"
+rm -rf "${RPMTEST}"/usr/{share,lib}/symlinktest*
+
+run rpmbuild --quiet -bb \
+ --define "rel 1" --without symlink ${RPMDATA}/SPECS/symlinktest.spec
+run rpmbuild --quiet -bb \
+ --define "rel 2" --with symlink ${RPMDATA}/SPECS/symlinktest.spec
+
+runroot rpm -U "${TOPDIR}"/RPMS/noarch/symlinktest-1.0-1.noarch.rpm
+runroot rpm -U "${TOPDIR}"/RPMS/noarch/symlinktest-1.0-2.noarch.rpm
+],
+[1],
+[],
+[error: unpacking of archive failed on file /usr/share/symlinktest: cpio: rename failed - Is a directory
+])
+AT_CLEANUP
+
+# ------------------------------
+# Replace symlink with a directory - the upgrade succeeds but leaves an
+# orphan directory that the symlink now points to. Should verify the
+# result more carefully...
+AT_SETUP([rpm -U replacing symlink with directory])
+AT_KEYWORDS([install])
+AT_CHECK([
+RPMDB_CLEAR
+rm -rf "${TOPDIR}"
+rm -rf "${RPMTEST}"/usr/{share,lib}/symlinktest*
+
+run rpmbuild --quiet -bb \
+ --define "rel 1" --with symlink ${RPMDATA}/SPECS/symlinktest.spec
+run rpmbuild --quiet -bb \
+ --define "rel 2" --without symlink ${RPMDATA}/SPECS/symlinktest.spec
+
+runroot rpm -U "${TOPDIR}"/RPMS/noarch/symlinktest-1.0-1.noarch.rpm
+runroot rpm -U "${TOPDIR}"/RPMS/noarch/symlinktest-1.0-2.noarch.rpm
+],
+[0],
+[],
+[])
+AT_CLEANUP