From 29d06589ccceeba13322df12e0030e6c01617a7a Mon Sep 17 00:00:00 2001 From: Peter Robinson Date: Sun, 26 Aug 2018 22:09:10 +0100 Subject: [PATCH] Add patch and build against mozjs 52 --- libproxy-0.4.15-mozjs52.patch | 101 ++++++++++++++++++++++++++++++++++ libproxy.spec | 9 ++- 2 files changed, 108 insertions(+), 2 deletions(-) create mode 100644 libproxy-0.4.15-mozjs52.patch diff --git a/libproxy-0.4.15-mozjs52.patch b/libproxy-0.4.15-mozjs52.patch new file mode 100644 index 0000000..535df6d --- /dev/null +++ b/libproxy-0.4.15-mozjs52.patch @@ -0,0 +1,101 @@ +From f594720280b2e40d81fa6e286a0ef8868687ef7e Mon Sep 17 00:00:00 2001 +From: Pierre Lejeune +Date: Sat, 30 Jun 2018 21:10:06 +0200 +Subject: [PATCH] Build with mozjs-52 + +Fixes #71 +--- + libproxy/cmake/modules/pacrunner_mozjs.cmk | 2 +- + libproxy/modules/pacrunner_mozjs.cpp | 19 +++++++------------ + 2 files changed, 8 insertions(+), 13 deletions(-) + +diff --git a/libproxy/cmake/modules/pacrunner_mozjs.cmk b/libproxy/cmake/modules/pacrunner_mozjs.cmk +index c2ae3db..20857fb 100644 +--- a/libproxy/cmake/modules/pacrunner_mozjs.cmk ++++ b/libproxy/cmake/modules/pacrunner_mozjs.cmk +@@ -9,7 +9,7 @@ if(WIN32) + elseif(NOT APPLE) + option(WITH_MOZJS "Search for MOZJS package" ON) + if (WITH_MOZJS) +- pkg_search_module(MOZJS mozjs-38) ++ pkg_search_module(MOZJS mozjs-52) + if(MOZJS_FOUND) + include_directories(${MOZJS_INCLUDE_DIRS}) + link_directories(${MOZJS_LIBRARY_DIRS}) +diff --git a/libproxy/modules/pacrunner_mozjs.cpp b/libproxy/modules/pacrunner_mozjs.cpp +index a70b2e9..ed07c69 100644 +--- a/libproxy/modules/pacrunner_mozjs.cpp ++++ b/libproxy/modules/pacrunner_mozjs.cpp +@@ -35,6 +35,7 @@ using namespace libproxy; + #pragma GCC diagnostic ignored "-Winvalid-offsetof" + #include + #pragma GCC diagnostic error "-Winvalid-offsetof" ++#include + #include + + #include "pacutils.h" +@@ -111,17 +112,14 @@ class mozjs_pacrunner : public pacrunner { + mozjs_pacrunner(string pac, const url& pacurl) throw (bad_alloc) : pacrunner(pac, pacurl) { + + // Set defaults +- this->jsrun = nullptr; + this->jsctx = nullptr; + JS_Init(); + +- // Initialize Javascript runtime environment +- if (!(this->jsrun = JS_NewRuntime(1024 * 1024))) goto error; +- if (!(this->jsctx = JS_NewContext(this->jsrun, 1024 * 1024))) goto error; ++ // Initialize Javascript context ++ if (!(this->jsctx = JS_NewContext(1024 * 1024))) goto error; + { + JS::RootedValue rval(this->jsctx); + JS::CompartmentOptions compart_opts; +- compart_opts.setVersion(JSVERSION_LATEST); + + this->jsglb = new JS::Heap(JS_NewGlobalObject( + this->jsctx, &cls, +@@ -139,16 +137,15 @@ class mozjs_pacrunner : public pacrunner { + JS::CompileOptions options(this->jsctx); + options.setUTF8(true); + +- JS::Evaluate(this->jsctx, global, options, JAVASCRIPT_ROUTINES, +- strlen(JAVASCRIPT_ROUTINES), &rval); ++ JS::Evaluate(this->jsctx, options, JAVASCRIPT_ROUTINES, ++ strlen(JAVASCRIPT_ROUTINES), JS::MutableHandleValue(&rval)); + + // Add PAC to the environment +- JS::Evaluate(this->jsctx, global, options, pac.c_str(), pac.length(), &rval); ++ JS::Evaluate(this->jsctx, options, pac.c_str(), pac.length(), JS::MutableHandleValue(&rval)); + return; + } + error: + if (this->jsctx) JS_DestroyContext(this->jsctx); +- if (this->jsrun) JS_DestroyRuntime(this->jsrun); + throw bad_alloc(); + } + +@@ -156,7 +153,6 @@ class mozjs_pacrunner : public pacrunner { + if (this->jsac) delete this->jsac; + if (this->jsglb) delete this->jsglb; + if (this->jsctx) JS_DestroyContext(this->jsctx); +- if (this->jsrun) JS_DestroyRuntime(this->jsrun); + JS_ShutDown(); + } + +@@ -178,7 +174,7 @@ class mozjs_pacrunner : public pacrunner { + JS::RootedObject global(this->jsctx,this->jsglb->get()); + bool result = JS_CallFunctionName(this->jsctx, global, "FindProxyForURL", args, &rval); + if (!result) return ""; +- ++ + char * tmpanswer = JS_EncodeString(this->jsctx, rval.toString()); + string answer = string(tmpanswer); + JS_free(this->jsctx, tmpanswer); +@@ -188,7 +184,6 @@ class mozjs_pacrunner : public pacrunner { + } + + private: +- JSRuntime *jsrun; + JSContext *jsctx; + JS::Heap *jsglb; + JSAutoCompartment *jsac; diff --git a/libproxy.spec b/libproxy.spec index d337624..6bfaf22 100644 --- a/libproxy.spec +++ b/libproxy.spec @@ -4,7 +4,7 @@ Name: libproxy Version: 0.4.15 -Release: 8%{?dist} +Release: 9%{?dist} Summary: A library handling all the details of proxy configuration License: LGPLv2+ @@ -16,6 +16,8 @@ Source1: proxy.1 Patch0: 0001-Add-config-module-for-querying-PacRunner-d-mon.patch Patch1: libproxy-0.4.11-crash.patch Patch2: libproxy-0.4.15-python3738.patch +# https://github.com/libproxy/libproxy/pull/86 +Patch3: libproxy-0.4.15-mozjs52.patch BuildRequires: cmake >= 2.6.0 BuildRequires: gcc-c++ @@ -25,7 +27,7 @@ BuildRequires: libmodman-devel >= 2.0.1 # gnome BuildRequires: pkgconfig(gio-2.0) >= 2.26 # mozjs -BuildRequires: pkgconfig(mozjs-38) +BuildRequires: pkgconfig(mozjs-52) # NetworkManager BuildRequires: pkgconfig(libnm) # pacrunner (and NetworkManager) @@ -231,6 +233,9 @@ make test %changelog +* Sun Aug 26 2018 Peter Robinson 0.4.15-9 +- Add patch and build against mozjs 52 + * Fri Jul 20 2018 David King - 0.4.15-8 - Provide direct path to Python 2 (#1604646)