From 3e6ae42d56b6482f399653bf8629eb54486f1216 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sandro=20J=C3=A4ckel?= Date: Tue, 5 Dec 2023 22:16:52 +0100 Subject: [PATCH] =?UTF-8?q?libproxy:=200.4.18=20=E2=86=92=200.5.3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit https://github.com/libproxy/libproxy/releases/tag/libproxy-0.5.0 https://github.com/libproxy/libproxy/releases/tag/0.5.1 https://github.com/libproxy/libproxy/releases/tag/0.5.2 https://github.com/libproxy/libproxy/releases/tag/0.5.3 Complete rewrite of the project, reduces runtime closure significantly. Co-authored-by: Jan Tojnar --- .../libraries/libproxy/default.nix | 137 +++++++++++------ .../libproxy/hardcode-gsettings.patch | 140 ++++++++++++++++++ .../libproxy/skip-gsettings-detection.patch | 29 ++++ pkgs/top-level/all-packages.nix | 4 +- 4 files changed, 258 insertions(+), 52 deletions(-) create mode 100644 pkgs/development/libraries/libproxy/hardcode-gsettings.patch create mode 100644 pkgs/development/libraries/libproxy/skip-gsettings-detection.patch diff --git a/pkgs/development/libraries/libproxy/default.nix b/pkgs/development/libraries/libproxy/default.nix index 076e4c33b964..01cb395ea992 100644 --- a/pkgs/development/libraries/libproxy/default.nix +++ b/pkgs/development/libraries/libproxy/default.nix @@ -1,83 +1,122 @@ { lib -, stdenv +, _experimental-update-script-combinators +, curl +, darwin +, duktape , fetchFromGitHub , fetchpatch -, pkg-config -, cmake -, zlib -, dbus -, networkmanager -, enableJavaScript ? stdenv.isDarwin || lib.meta.availableOn stdenv.hostPlatform duktape -, duktape -, pcre -, gsettings-desktop-schemas +, gi-docgen +, gitUpdater , glib -, makeWrapper -, python3 -, SystemConfiguration -, CoreFoundation -, JavaScriptCore +, gobject-introspection +, gsettings-desktop-schemas +, makeHardcodeGsettingsPatch +, meson +, ninja +, pkg-config +, stdenv +, substituteAll +, vala }: -stdenv.mkDerivation rec { +stdenv.mkDerivation (finalAttrs: { pname = "libproxy"; - version = "0.4.18"; + version = "0.5.3"; + + outputs = [ "out" "dev" "devdoc" ]; src = fetchFromGitHub { owner = "libproxy"; repo = "libproxy"; - rev = version; - hash = "sha256-pqj1LwRdOK2CUu3hYIsogQIXxWzShDuKEbDTbtWkgnQ="; + rev = finalAttrs.version; + hash = "sha256-qdYB6HJkgboS8kkTvTqLy6Z3JYY5SOJsRl6nZM0iuvw="; }; - patches = lib.optionals stdenv.isDarwin [ - # https://github.com/libproxy/libproxy/pull/189 + patches = [ + # Minor refactoring. Allows the following patches to apply without rebasing. (fetchpatch { - url = "https://github.com/libproxy/libproxy/commit/4331b9db427ce2c25ff5eeb597bec4bc35ed1a0b.patch"; - sha256 = "sha256-uTh3rYVvEke1iWVHsT3Zj2H1F+gyLrffcmyt0JEKaCA="; + url = "https://github.com/libproxy/libproxy/commit/397f4dc72607cc1bb3b584ffd3de49f8ba80491a.patch"; + hash = "sha256-iUMBMpcVOLG+NxEj8Nd7JtKZFmoGXn0t6A2r2ayiteg="; + includes = [ + "src/backend/plugins/config-gnome/config-gnome.c" + ]; + }) + + # Disable schema presence detection, it would fail because it cannot be autopatched, + # and it will be hardcoded by the next patch anyway. + ./skip-gsettings-detection.patch + + # Hardcode path to Settings schemas for GNOME & related desktops. + # Otherwise every app using libproxy would need to be wrapped individually. + (substituteAll { + src = ./hardcode-gsettings.patch; + gds = glib.getSchemaPath gsettings-desktop-schemas; }) ]; - outputs = [ "out" "dev" "py3" ]; - nativeBuildInputs = [ + gi-docgen + gobject-introspection + meson + ninja pkg-config - cmake - makeWrapper + vala ]; buildInputs = [ - pcre - python3 - zlib - ] ++ lib.optionals enableJavaScript [ - (if stdenv.hostPlatform.isDarwin then JavaScriptCore else duktape) - ] ++ (if stdenv.hostPlatform.isDarwin then [ - SystemConfiguration + curl + duktape + ] ++ (if stdenv.hostPlatform.isDarwin then (with darwin.apple_sdk.frameworks; [ CoreFoundation - ] else [ + SystemConfiguration + ]) else [ glib - dbus - networkmanager + gsettings-desktop-schemas ]); - cmakeFlags = [ - "-DWITH_PYTHON2=OFF" - "-DPYTHON3_SITEPKG_DIR=${placeholder "py3"}/${python3.sitePackages}" - ] ++ lib.optional (enableJavaScript && !stdenv.hostPlatform.isDarwin) "-DWITH_MOZJS=ON"; + doCheck = true; - postFixup = lib.optionalString stdenv.isLinux '' - # config_gnome3 uses the helper to find GNOME proxy settings - wrapProgram $out/libexec/pxgsettings --prefix XDG_DATA_DIRS : "${gsettings-desktop-schemas}/share/gsettings-schemas/${gsettings-desktop-schemas.name}" + postPatch = '' + # Fix running script that will try to install git hooks. + # Though it will not do anything since we do not keep .git/ directory. + # https://github.com/libproxy/libproxy/issues/262 + chmod +x data/install-git-hook.sh + patchShebangs data/install-git-hook.sh ''; - doCheck = false; # fails 1 out of 10 tests + postFixup = '' + # Cannot be in postInstall, otherwise _multioutDocs hook in preFixup will move right back. + moveToOutput "share/doc" "$devdoc" + ''; + + passthru = { + hardcodeGsettingsPatch = makeHardcodeGsettingsPatch { + schemaIdToVariableMapping = { + "org.gnome.system.proxy" = "gds"; + "org.gnome.system.proxy.http" = "gds"; + "org.gnome.system.proxy.https" = "gds"; + "org.gnome.system.proxy.ftp" = "gds"; + "org.gnome.system.proxy.socks" = "gds"; + }; + inherit (finalAttrs) src; + }; + + updateScript = + let + updateSource = gitUpdater { }; + updatePatch = _experimental-update-script-combinators.copyAttrOutputToFile "libproxy.hardcodeGsettingsPatch" ./hardcode-gsettings.patch; + in + _experimental-update-script-combinators.sequence [ + updateSource + updatePatch + ]; + }; meta = with lib; { - platforms = platforms.linux ++ platforms.darwin; - license = licenses.lgpl21; - homepage = "https://libproxy.github.io/libproxy/"; description = "A library that provides automatic proxy configuration management"; + homepage = "https://libproxy.github.io/libproxy/"; + license = licenses.lgpl21Plus; + platforms = platforms.linux ++ platforms.darwin; mainProgram = "proxy"; }; -} +}) diff --git a/pkgs/development/libraries/libproxy/hardcode-gsettings.patch b/pkgs/development/libraries/libproxy/hardcode-gsettings.patch new file mode 100644 index 000000000000..22aeb5836f9c --- /dev/null +++ b/pkgs/development/libraries/libproxy/hardcode-gsettings.patch @@ -0,0 +1,140 @@ +diff --git a/src/backend/plugins/config-gnome/config-gnome.c b/src/backend/plugins/config-gnome/config-gnome.c +index 820827b..338e269 100644 +--- a/src/backend/plugins/config-gnome/config-gnome.c ++++ b/src/backend/plugins/config-gnome/config-gnome.c +@@ -85,11 +85,60 @@ px_config_gnome_init (PxConfigGnome *self) + if (!self->available) + return; + +- self->proxy_settings = g_settings_new ("org.gnome.system.proxy"); +- self->http_proxy_settings = g_settings_new ("org.gnome.system.proxy.http"); +- self->https_proxy_settings = g_settings_new ("org.gnome.system.proxy.https"); +- self->ftp_proxy_settings = g_settings_new ("org.gnome.system.proxy.ftp"); +- self->socks_proxy_settings = g_settings_new ("org.gnome.system.proxy.socks"); ++ { ++ g_autoptr(GSettingsSchemaSource) schema_source; ++ g_autoptr(GSettingsSchema) schema; ++ schema_source = g_settings_schema_source_new_from_directory("@gds@", ++ g_settings_schema_source_get_default(), ++ TRUE, NULL); ++ schema = g_settings_schema_source_lookup(schema_source, ++ "org.gnome.system.proxy", FALSE); ++ self->proxy_settings = g_settings_new_full(schema, NULL, NULL); ++ } ++ { ++ g_autoptr(GSettingsSchemaSource) schema_source; ++ g_autoptr(GSettingsSchema) schema; ++ schema_source = g_settings_schema_source_new_from_directory("@gds@", ++ g_settings_schema_source_get_default(), ++ TRUE, NULL); ++ schema = g_settings_schema_source_lookup(schema_source, ++ "org.gnome.system.proxy.http", ++ FALSE); ++ self->http_proxy_settings = g_settings_new_full(schema, NULL, NULL); ++ } ++ { ++ g_autoptr(GSettingsSchemaSource) schema_source; ++ g_autoptr(GSettingsSchema) schema; ++ schema_source = g_settings_schema_source_new_from_directory("@gds@", ++ g_settings_schema_source_get_default(), ++ TRUE, NULL); ++ schema = g_settings_schema_source_lookup(schema_source, ++ "org.gnome.system.proxy.https", ++ FALSE); ++ self->https_proxy_settings = g_settings_new_full(schema, NULL, NULL); ++ } ++ { ++ g_autoptr(GSettingsSchemaSource) schema_source; ++ g_autoptr(GSettingsSchema) schema; ++ schema_source = g_settings_schema_source_new_from_directory("@gds@", ++ g_settings_schema_source_get_default(), ++ TRUE, NULL); ++ schema = g_settings_schema_source_lookup(schema_source, ++ "org.gnome.system.proxy.ftp", ++ FALSE); ++ self->ftp_proxy_settings = g_settings_new_full(schema, NULL, NULL); ++ } ++ { ++ g_autoptr(GSettingsSchemaSource) schema_source; ++ g_autoptr(GSettingsSchema) schema; ++ schema_source = g_settings_schema_source_new_from_directory("@gds@", ++ g_settings_schema_source_get_default(), ++ TRUE, NULL); ++ schema = g_settings_schema_source_lookup(schema_source, ++ "org.gnome.system.proxy.socks", ++ FALSE); ++ self->socks_proxy_settings = g_settings_new_full(schema, NULL, NULL); ++ } + } + + static void +diff --git a/tests/config-gnome-test.c b/tests/config-gnome-test.c +index f80914a..118d429 100644 +--- a/tests/config-gnome-test.c ++++ b/tests/config-gnome-test.c +@@ -60,11 +60,60 @@ static void + fixture_setup (Fixture *self, + gconstpointer data) + { +- self->proxy_settings = g_settings_new ("org.gnome.system.proxy"); +- self->http_proxy_settings = g_settings_new ("org.gnome.system.proxy.http"); +- self->https_proxy_settings = g_settings_new ("org.gnome.system.proxy.https"); +- self->ftp_proxy_settings = g_settings_new ("org.gnome.system.proxy.ftp"); +- self->socks_proxy_settings = g_settings_new ("org.gnome.system.proxy.socks"); ++ { ++ g_autoptr(GSettingsSchemaSource) schema_source; ++ g_autoptr(GSettingsSchema) schema; ++ schema_source = g_settings_schema_source_new_from_directory("@gds@", ++ g_settings_schema_source_get_default(), ++ TRUE, NULL); ++ schema = g_settings_schema_source_lookup(schema_source, ++ "org.gnome.system.proxy", FALSE); ++ self->proxy_settings = g_settings_new_full(schema, NULL, NULL); ++ } ++ { ++ g_autoptr(GSettingsSchemaSource) schema_source; ++ g_autoptr(GSettingsSchema) schema; ++ schema_source = g_settings_schema_source_new_from_directory("@gds@", ++ g_settings_schema_source_get_default(), ++ TRUE, NULL); ++ schema = g_settings_schema_source_lookup(schema_source, ++ "org.gnome.system.proxy.http", ++ FALSE); ++ self->http_proxy_settings = g_settings_new_full(schema, NULL, NULL); ++ } ++ { ++ g_autoptr(GSettingsSchemaSource) schema_source; ++ g_autoptr(GSettingsSchema) schema; ++ schema_source = g_settings_schema_source_new_from_directory("@gds@", ++ g_settings_schema_source_get_default(), ++ TRUE, NULL); ++ schema = g_settings_schema_source_lookup(schema_source, ++ "org.gnome.system.proxy.https", ++ FALSE); ++ self->https_proxy_settings = g_settings_new_full(schema, NULL, NULL); ++ } ++ { ++ g_autoptr(GSettingsSchemaSource) schema_source; ++ g_autoptr(GSettingsSchema) schema; ++ schema_source = g_settings_schema_source_new_from_directory("@gds@", ++ g_settings_schema_source_get_default(), ++ TRUE, NULL); ++ schema = g_settings_schema_source_lookup(schema_source, ++ "org.gnome.system.proxy.ftp", ++ FALSE); ++ self->ftp_proxy_settings = g_settings_new_full(schema, NULL, NULL); ++ } ++ { ++ g_autoptr(GSettingsSchemaSource) schema_source; ++ g_autoptr(GSettingsSchema) schema; ++ schema_source = g_settings_schema_source_new_from_directory("@gds@", ++ g_settings_schema_source_get_default(), ++ TRUE, NULL); ++ schema = g_settings_schema_source_lookup(schema_source, ++ "org.gnome.system.proxy.socks", ++ FALSE); ++ self->socks_proxy_settings = g_settings_new_full(schema, NULL, NULL); ++ } + } + + static void diff --git a/pkgs/development/libraries/libproxy/skip-gsettings-detection.patch b/pkgs/development/libraries/libproxy/skip-gsettings-detection.patch new file mode 100644 index 000000000000..1882079b94b0 --- /dev/null +++ b/pkgs/development/libraries/libproxy/skip-gsettings-detection.patch @@ -0,0 +1,29 @@ +diff --git a/src/backend/plugins/config-gnome/config-gnome.c b/src/backend/plugins/config-gnome/config-gnome.c +index 52e812e..a1edcab 100644 +--- a/src/backend/plugins/config-gnome/config-gnome.c ++++ b/src/backend/plugins/config-gnome/config-gnome.c +@@ -57,7 +57,6 @@ enum { + static void + px_config_gnome_init (PxConfigGnome *self) + { +- GSettingsSchemaSource *source; + g_autoptr (GSettingsSchema) proxy_schema = NULL; + const char *desktops; + +@@ -71,15 +70,7 @@ px_config_gnome_init (PxConfigGnome *self) + if (strstr (desktops, "GNOME") == NULL) + return; + +- source = g_settings_schema_source_get_default (); +- if (!source) { +- g_warning ("GNOME desktop detected but no schemes installed, aborting."); +- return; +- } +- +- proxy_schema = g_settings_schema_source_lookup (source, "org.gnome.system.proxy", TRUE); +- +- self->available = proxy_schema != NULL; ++ self->available = TRUE; + if (!self->available) + return; + diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 710ded329967..42b1949aee32 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -22971,9 +22971,7 @@ with pkgs; stdenv = gccStdenv; # Required for darwin }) libprom libpromhttp; - libproxy = callPackage ../development/libraries/libproxy { - inherit (darwin.apple_sdk.frameworks) SystemConfiguration CoreFoundation JavaScriptCore; - }; + libproxy = callPackage ../development/libraries/libproxy { }; libpseudo = callPackage ../development/libraries/libpseudo { };