From e5e91efa4cef9291834383ba5a4720e838f7bb1c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Hedin=20Br=C3=B8nner?= Date: Thu, 19 Jul 2018 10:52:59 +0200 Subject: [PATCH] flatpak: Don't hardcode flatpak binary path in launchers The hardcoded flatpak path breaks all installed applications when flatpak is updated. fixes: https://github.com/NixOS/nixpkgs/issues/43581 --- .../development/libraries/flatpak/default.nix | 1 + .../flatpak/use-flatpak-from-path.patch | 48 +++++++++++++++++++ 2 files changed, 49 insertions(+) create mode 100644 pkgs/development/libraries/flatpak/use-flatpak-from-path.patch diff --git a/pkgs/development/libraries/flatpak/default.nix b/pkgs/development/libraries/flatpak/default.nix index e769cb50513..6591b13834e 100644 --- a/pkgs/development/libraries/flatpak/default.nix +++ b/pkgs/development/libraries/flatpak/default.nix @@ -24,6 +24,7 @@ in stdenv.mkDerivation rec { }) # patch taken from gtk_doc ./respect-xml-catalog-files-var.patch + ./use-flatpak-from-path.patch ]; nativeBuildInputs = [ diff --git a/pkgs/development/libraries/flatpak/use-flatpak-from-path.patch b/pkgs/development/libraries/flatpak/use-flatpak-from-path.patch new file mode 100644 index 00000000000..e855902a930 --- /dev/null +++ b/pkgs/development/libraries/flatpak/use-flatpak-from-path.patch @@ -0,0 +1,48 @@ +--- a/common/flatpak-dir.c ++++ b/common/flatpak-dir.c +@@ -5467,7 +5467,7 @@ export_desktop_file (const char *app, + + new_exec = g_string_new (""); + g_string_append_printf (new_exec, +- FLATPAK_BINDIR "/flatpak run --branch=%s --arch=%s", ++ "flatpak run --branch=%s --arch=%s", + escaped_branch, + escaped_arch); + +@@ -6644,8 +6644,8 @@ flatpak_dir_deploy (FlatpakDir *self, + error)) + return FALSE; + +- bin_data = g_strdup_printf ("#!/bin/sh\nexec %s/flatpak run --branch=%s --arch=%s %s \"$@\"\n", +- FLATPAK_BINDIR, escaped_branch, escaped_arch, escaped_app); ++ bin_data = g_strdup_printf ("#!/bin/sh\nexec flatpak run --branch=%s --arch=%s %s \"$@\"\n", ++ escaped_branch, escaped_arch, escaped_app); + if (!g_file_replace_contents (wrapper, bin_data, strlen (bin_data), NULL, FALSE, + G_FILE_CREATE_REPLACE_DESTINATION, NULL, cancellable, error)) + return FALSE; +diff --git a/tests/test-bundle.sh b/tests/test-bundle.sh +index 6937b041..01f8add7 100755 +--- a/tests/test-bundle.sh ++++ b/tests/test-bundle.sh +@@ -59,7 +59,7 @@ assert_has_dir $FL_DIR/app/org.test.Hello/$ARCH/master/active/files + assert_has_dir $FL_DIR/app/org.test.Hello/$ARCH/master/active/export + assert_has_file $FL_DIR/exports/share/applications/org.test.Hello.desktop + # Ensure Exec key is rewritten +-assert_file_has_content $FL_DIR/exports/share/applications/org.test.Hello.desktop "^Exec=.*/flatpak run --branch=master --arch=$ARCH --command=hello.sh org.test.Hello$" ++assert_file_has_content $FL_DIR/exports/share/applications/org.test.Hello.desktop "^Exec=flatpak run --branch=master --arch=$ARCH --command=hello.sh org.test.Hello$" + assert_has_file $FL_DIR/exports/share/icons/hicolor/64x64/apps/org.test.Hello.png + assert_has_file $FL_DIR/exports/share/icons/HighContrast/64x64/apps/org.test.Hello.png + +diff --git a/tests/test-run.sh b/tests/test-run.sh +index 9d83d82e..234e4ec6 100755 +--- a/tests/test-run.sh ++++ b/tests/test-run.sh +@@ -42,7 +42,7 @@ assert_has_dir $FL_DIR/app/org.test.Hello/$ARCH/master/active/files + assert_has_dir $FL_DIR/app/org.test.Hello/$ARCH/master/active/export + assert_has_file $FL_DIR/exports/share/applications/org.test.Hello.desktop + # Ensure Exec key is rewritten +-assert_file_has_content $FL_DIR/exports/share/applications/org.test.Hello.desktop "^Exec=.*/flatpak run --branch=master --arch=$ARCH --command=hello.sh org.test.Hello$" ++assert_file_has_content $FL_DIR/exports/share/applications/org.test.Hello.desktop "^Exec=flatpak run --branch=master --arch=$ARCH --command=hello.sh org.test.Hello$" + assert_has_file $FL_DIR/exports/share/icons/hicolor/64x64/apps/org.test.Hello.png + assert_not_has_file $FL_DIR/exports/share/icons/hicolor/64x64/apps/dont-export.png + assert_has_file $FL_DIR/exports/share/icons/HighContrast/64x64/apps/org.test.Hello.png