Hackery to get rpm install tests to "work" with fakechroot
authorPanu Matilainen <pmatilai@redhat.com>
Fri, 21 Nov 2008 15:48:27 +0000 (17:48 +0200)
committerPanu Matilainen <pmatilai@redhat.com>
Fri, 21 Nov 2008 15:59:49 +0000 (17:59 +0200)
- fakechroot throws it's own curveballs into the already mixed up thing,
  copy things to the test dir and set chroot base to that to avoid
  confusion with cwd and such
- klunky and ugly but at least the tests pass now when running non-root

tests/atlocal.in
tests/rpmdb.at
tests/rpmquery.at

index 484a621..4e4e30e 100644 (file)
@@ -3,12 +3,15 @@ export LD_LIBRARY_PATH
 PATH="${abs_builddir}/testing@rpmbindir@:${abs_builddir}/testing@usrbindir@:$PATH"
 export PATH
 
+RPMTEST="${abs_builddir}/testing"
+RPMDATA="${abs_srcdir}/data/"
+
 # Popt looks into $HOME
-HOME="${abs_builddir}/testing"
+HOME="${RPMTEST}"
 export HOME
 
-RPMRC="${abs_builddir}/testing@RPMCONFIGDIR@/rpmrc"
-TOPDIR="${abs_builddir}/testing/build"
+RPMRC="${RPMTEST}@RPMCONFIGDIR@/rpmrc"
+TOPDIR="${RPMTEST}/build"
 
 RPM_XFAIL=${RPM_XFAIL-1}
 
@@ -16,5 +19,15 @@ function run()
 {
     cmd="$1"
     shift
-    "${cmd}" --rcfile="${RPMRC}" --define "_topdir ${TOPDIR}" $*
+    "${cmd}" --rcfile="${RPMRC}" --define "_topdir ${TOPDIR}" $@
+}
+
+function runroot()
+{
+    cmd="$1"
+    shift
+    (cd ${RPMTEST} && \
+     mkdir -p etc && touch etc/mtab &&
+     FAKECHROOT_BASE="${RPMTEST}" fakechroot "${cmd}" --rcfile="${RPMRC}" --define "_topdir ${TOPDIR}" $@
+    )
 }
index d95d017..9da741b 100644 (file)
@@ -35,8 +35,7 @@ AT_SETUP([rpm -qa])
 AT_CHECK([
 RPMDB_CLEAR
 RPMDB_INIT
-run rpm \
-  --root="${abs_builddir}"/testing \
+runroot rpm \
   -qa
 ],
 [0])
@@ -52,9 +51,11 @@ AT_CHECK([
 RPMDB_CLEAR
 RPMDB_INIT
 
-run rpm -i \
-  --root="${abs_builddir}"/testing \
-  "${abs_srcdir}"/data/RPMS/foo-1.0-1.noarch.rpm
+tpkg="foo-1.0-1.noarch.rpm"
+cp "${RPMDATA}/RPMS/${tpkg}" "${RPMTEST}"
+
+runroot rpm -i \
+  "${tpkg}"
 ],
 [0])
 
@@ -70,10 +71,12 @@ AT_CHECK([
 RPMDB_CLEAR
 RPMDB_INIT
 
-run rpm -i \
-  --root="${abs_builddir}"/testing \
-  --nodeps --ignorearch --relocate=/usr="${abs_builddir}"/testing/check \
-  "${abs_srcdir}"/data/RPMS/hello-1.0-1.i386.rpm
+tpkg="hello-1.0-1.i386.rpm"
+cp "${RPMDATA}/RPMS/${tpkg}" "${RPMTEST}"
+
+runroot rpm -i \
+  --noscripts --nodeps --ignorearch --relocate=/usr="${abs_builddir}"/testing/check \
+  "${tpkg}"
 ],
 [0])
 
@@ -89,10 +92,12 @@ AT_CHECK([
 RPMDB_CLEAR
 RPMDB_INIT
 
-run rpm -i \
-  --root="${abs_builddir}"/testing \
-  --nodeps --ignorearch --relocate=/usr="${abs_builddir}"/testing/check \
-  "${abs_srcdir}"/data/RPMS/hello-1.0-1.ppc64.rpm
+tpkg="hello-1.0-1.ppc64.rpm"
+cp "${RPMDATA}/RPMS/${tpkg}" "${RPMTEST}"
+
+runroot rpm -i \
+  --noscripts --nodeps --ignorearch --relocate=/usr="${abs_builddir}"/testing/check \
+  "${tpkg}"
 ],
 [0],
 [ignore],
index 9fbddea..f450f1c 100644 (file)
@@ -101,15 +101,17 @@ AT_CHECK([
 RPMDB_CLEAR
 RPMDB_INIT
 
-run rpm \
-  --nodeps --ignorearch --relocate=/usr="${abs_builddir}"/testing/check \
-  -i "${abs_srcdir}"/data/RPMS/hello-1.0-1.ppc64.rpm
+tpkg="hello-1.0-1.ppc64.rpm"
+cp "${RPMDATA}/RPMS/$tpkg" "${RPMTEST}"
+
+runroot rpm \
+  --noscripts --nodeps --ignorearch --relocate=/usr="${abs_builddir}"/testing/check \
+  -i "${tpkg}"
 ],
 [0])
 
 AT_CHECK([
-run rpm \
-  --root="${abs_builddir}"/testing \
+runroot rpm \
   -q hello
 ],
 [0],
@@ -124,8 +126,7 @@ ${abs_builddir}/testing/check/share/doc/hello-1.0/FAQ
 _ATEOF
 
 AT_CHECK([
-rpm \
-  --root="${abs_builddir}"/testing \
+runroot rpm \
   -ql hello
 ],
 [0],