nixpkgs/pkgs/development/libraries/flatpak/fix-test-paths.patch

124 lines
4.5 KiB
Diff
Raw Normal View History

2017-10-02 13:40:26 +00:00
--- a/tests/libtest.sh
+++ b/tests/libtest.sh
2018-09-06 09:38:09 +00:00
@@ -296,7 +296,7 @@
2017-10-02 13:40:26 +00:00
# running installed-tests: assume we know what we're doing
:
elif ! "$FLATPAK_BWRAP" --unshare-ipc --unshare-net --unshare-pid \
- --ro-bind / / /bin/true > bwrap-result 2>&1; then
+ --ro-bind / / @coreutils@/bin/true > bwrap-result 2>&1; then
sed -e 's/^/# /' < bwrap-result
echo "1..0 # SKIP Cannot run bwrap"
exit 0
2018-09-06 09:38:09 +00:00
@@ -309,12 +309,12 @@
2017-10-02 13:40:26 +00:00
export DBUS_SESSION_BUS_ADDRESS="$(cat dbus-session-bus-address)"
DBUS_SESSION_BUS_PID="$(cat dbus-session-bus-pid)"
-if ! /bin/kill -0 "$DBUS_SESSION_BUS_PID"; then
+if ! @coreutils@/bin/kill -0 "$DBUS_SESSION_BUS_PID"; then
assert_not_reached "Failed to start dbus-daemon"
fi
cleanup () {
2018-06-13 16:09:33 +00:00
- /bin/kill -9 $DBUS_SESSION_BUS_PID ${FLATPAK_HTTP_PID:-}
+ @coreutils@/bin/kill -9 $DBUS_SESSION_BUS_PID ${FLATPAK_HTTP_PID:-}
2017-10-02 13:40:26 +00:00
gpg-connect-agent --homedir "${FL_GPG_HOMEDIR}" killagent /bye || true
fusermount -u $XDG_RUNTIME_DIR/doc || :
if test -n "${TEST_SKIP_CLEANUP:-}"; then
2018-02-13 16:52:49 +00:00
--- a/tests/make-test-runtime.sh
+++ b/tests/make-test-runtime.sh
2018-06-13 16:09:33 +00:00
@@ -26,6 +26,7 @@
PATH="$PATH:/usr/sbin:/sbin"
2018-02-13 16:52:49 +00:00
# Add bash and dependencies
+mkdir -p ${DIR}/nix/store
mkdir -p ${DIR}/usr/bin
mkdir -p ${DIR}/usr/lib
ln -s ../lib ${DIR}/usr/lib64
2018-09-06 09:38:09 +00:00
@@ -35,48 +36,27 @@
2018-02-13 16:52:49 +00:00
else
cp `which ldconfig` ${DIR}/usr/bin
fi
2018-06-13 16:09:33 +00:00
-LIBS=`mktemp`
-BINS=`mktemp`
-
-add_bin() {
- local f=$1
- shift
-
- if grep -qFe "${f}" $BINS; then
- # Already handled
- return 0
- fi
-
- echo $f >> $BINS
-
- # Add library dependencies
- (ldd "${f}" | sed "s/.* => //" | awk '{ print $1}' | grep ^/ | sort -u -o $LIBS $LIBS -) || true
-
- local shebang=$(sed -n '1s/^#!\([^ ]*\).*/\1/p' "${f}")
- if [ x$shebang != x ]; then
- add_bin "$shebang"
- fi
-}
-
for i in $@; do
2018-02-13 16:52:49 +00:00
- I=`which $i`
2018-06-13 16:09:33 +00:00
- add_bin $I
2018-02-13 16:52:49 +00:00
-done
2018-06-13 16:09:33 +00:00
-for i in `cat $BINS`; do
- echo Adding binary $i 1>&2
- cp "$i" ${DIR}/usr/bin/
-done
-for i in `cat $LIBS`; do
- echo Adding library $i 1>&2
2018-02-13 16:52:49 +00:00
- cp "$i" ${DIR}/usr/lib/
+ I=$(readlink -f $(which $i))
+ requisites=$(nix-store --query --requisites "$I")
+ for r in $requisites; do
+ # a single store item can be needed by multiple paths, no need to copy it again
+ if [ ! -e ${DIR}/$r ]; then
+ cp -r $r ${DIR}/$r
+ fi
+ done
+ ln -s $I ${DIR}/usr/bin/$i
done
2018-06-13 16:09:33 +00:00
ln -s bash ${DIR}/usr/bin/sh
2018-02-13 16:52:49 +00:00
-# We copy the C.UTF8 locale and call it en_US. Its a bit of a lie, but
-# the real en_US locale is often not available, because its in the
-# local archive.
+mv ${DIR}/nix/store ${DIR}/usr/store # files outside /usr are not permitted, we will have to replace /nix/store with /usr/store
+chmod -R u+w ${DIR} # nix store has read-only directories which would cause problems during clean-up, files need to be writable for sed
+find ${DIR} -type f -print0 | xargs -0 sed -i 's~/nix/store/~/usr/store/~g' # replace hardcoded paths
+find ${DIR} -type l | xargs -I '{}' sh -c 'tg="$(readlink "$1")"; newtg="${tg#/nix/store/}"; if [ "$tg" != "$newtg" ]; then ln -fs "/usr/store/$newtg" "$1"; fi' -- '{}' # replace symlink targets
+
+# We copy the whole locale archive because we do not have C.UTF8 locale
mkdir -p ${DIR}/usr/lib/locale/
-cp -r /usr/lib/locale/C.* ${DIR}/usr/lib/locale/en_US
+cp @glibcLocales@/lib/locale/locale-archive ${DIR}/usr/lib/locale/locale-archive
if [ x$COLLECTION_ID != x ]; then
collection_args=--collection-id=${COLLECTION_ID}
2017-10-02 13:40:26 +00:00
--- a/tests/testlibrary.c
+++ b/tests/testlibrary.c
2018-07-15 17:12:14 +00:00
@@ -584,7 +584,7 @@
2017-10-02 13:40:26 +00:00
{
gint exit_code = 0;
2018-07-15 17:12:14 +00:00
char *argv[] = { (char *) bwrap, "--unshare-ipc", "--unshare-net",
- "--unshare-pid", "--ro-bind", "/", "/", "/bin/true", NULL };
+ "--unshare-pid", "--ro-bind", "/", "/", "@coreutils@/bin/true", NULL };
2017-10-02 13:40:26 +00:00
g_autofree char *argv_str = g_strjoinv (" ", argv);
g_test_message ("Spawning %s", argv_str);
g_spawn_sync (NULL, argv, NULL, G_SPAWN_SEARCH_PATH, NULL, NULL, NULL, NULL, &exit_code, &error);
2018-02-13 16:52:49 +00:00
--- a/triggers/gtk-icon-cache.trigger
+++ b/triggers/gtk-icon-cache.trigger
@@ -1,7 +1,7 @@
#!/bin/sh
if test \( -x "$(which gtk-update-icon-cache 2>/dev/null)" \) -a \( -d $1/exports/share/icons/hicolor \); then
- cp /usr/share/icons/hicolor/index.theme $1/exports/share/icons/hicolor/
+ cp @hicolorIconTheme@/share/icons/hicolor/index.theme $1/exports/share/icons/hicolor/
for dir in $1/exports/share/icons/*; do
if test -f $dir/index.theme; then
if ! gtk-update-icon-cache --quiet $dir; then