From a6bedfd09b7bba753de7a107dc471da0db801858 Mon Sep 17 00:00:00 2001 From: Xi Ruoyao Date: Thu, 27 Jan 2022 10:16:32 +0000 Subject: [PATCH] jsauthority: port to mozjs-91 --- Makefile.am | 2 ++ configure | 18 +++++++++--------- configure.ac | 2 +- meson.build | 2 +- src/polkitbackend/polkitbackendjsauthority.cpp | 9 +++++++-- 5 files changed, 20 insertions(+), 13 deletions(-) diff --git a/Makefile.am b/Makefile.am index 199576a..9d5e1c9 100644 --- a/Makefile.am +++ b/Makefile.am @@ -22,6 +22,8 @@ DISTCHECK_CONFIGURE_FLAGS= \ --disable-introspection \ --enable-gtk-doc \ --with-systemdsystemunitdir=$$dc_install_base/$(systemdsystemunitdir) \ + --enable-libsystemd-login=yes \ + --enable-libelogind=no \ $(NULL) sign : dist diff --git a/configure b/configure index f6829c0..bb1e688 100755 --- a/configure +++ b/configure @@ -19742,12 +19742,12 @@ if test -n "$LIBJS_CFLAGS"; then pkg_cv_LIBJS_CFLAGS="$LIBJS_CFLAGS" elif test -n "$PKG_CONFIG"; then if test -n "$PKG_CONFIG" && \ - { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"mozjs-78\""; } >&5 - ($PKG_CONFIG --exists --print-errors "mozjs-78") 2>&5 + { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"mozjs-91\""; } >&5 + ($PKG_CONFIG --exists --print-errors "mozjs-91") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then - pkg_cv_LIBJS_CFLAGS=`$PKG_CONFIG --cflags "mozjs-78" 2>/dev/null` + pkg_cv_LIBJS_CFLAGS=`$PKG_CONFIG --cflags "mozjs-91" 2>/dev/null` test "x$?" != "x0" && pkg_failed=yes else pkg_failed=yes @@ -19759,12 +19759,12 @@ if test -n "$LIBJS_LIBS"; then pkg_cv_LIBJS_LIBS="$LIBJS_LIBS" elif test -n "$PKG_CONFIG"; then if test -n "$PKG_CONFIG" && \ - { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"mozjs-78\""; } >&5 - ($PKG_CONFIG --exists --print-errors "mozjs-78") 2>&5 + { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"mozjs-91\""; } >&5 + ($PKG_CONFIG --exists --print-errors "mozjs-91") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then - pkg_cv_LIBJS_LIBS=`$PKG_CONFIG --libs "mozjs-78" 2>/dev/null` + pkg_cv_LIBJS_LIBS=`$PKG_CONFIG --libs "mozjs-91" 2>/dev/null` test "x$?" != "x0" && pkg_failed=yes else pkg_failed=yes @@ -19785,14 +19785,14 @@ else _pkg_short_errors_supported=no fi if test $_pkg_short_errors_supported = yes; then - LIBJS_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "mozjs-78" 2>&1` + LIBJS_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "mozjs-91" 2>&1` else - LIBJS_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "mozjs-78" 2>&1` + LIBJS_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "mozjs-91" 2>&1` fi # Put the nasty error message in config.log where it belongs echo "$LIBJS_PKG_ERRORS" >&5 - as_fn_error $? "Package requirements (mozjs-78) were not met: + as_fn_error $? "Package requirements (mozjs-91) were not met: $LIBJS_PKG_ERRORS diff --git a/configure.ac b/configure.ac index e434ca2..6783ee7 100644 --- a/configure.ac +++ b/configure.ac @@ -80,7 +80,7 @@ PKG_CHECK_MODULES(GLIB, [gmodule-2.0 gio-unix-2.0 >= 2.30.0]) AC_SUBST(GLIB_CFLAGS) AC_SUBST(GLIB_LIBS) -PKG_CHECK_MODULES(LIBJS, [mozjs-78]) +PKG_CHECK_MODULES(LIBJS, [mozjs-91]) AC_SUBST(LIBJS_CFLAGS) AC_SUBST(LIBJS_CXXFLAGS) diff --git a/meson.build b/meson.build index 858078d..09cce0f 100644 --- a/meson.build +++ b/meson.build @@ -133,7 +133,7 @@ expat_dep = dependency('expat') assert(cc.has_header('expat.h', dependencies: expat_dep), 'Can\'t find expat.h. Please install expat.') assert(cc.has_function('XML_ParserCreate', dependencies: expat_dep), 'Can\'t find expat library. Please install expat.') -mozjs_dep = dependency('mozjs-78') +mozjs_dep = dependency('mozjs-91') dbus_dep = dependency('dbus-1', required: false) dbus_policydir = pk_prefix / pk_datadir / 'dbus-1/system.d' diff --git a/src/polkitbackend/polkitbackendjsauthority.cpp b/src/polkitbackend/polkitbackendjsauthority.cpp index ca17108..b22c34e 100644 --- a/src/polkitbackend/polkitbackendjsauthority.cpp +++ b/src/polkitbackend/polkitbackendjsauthority.cpp @@ -75,6 +75,13 @@ /* ---------------------------------------------------------------------------------------------------- */ +static class JsInitHelperType +{ +public: + JsInitHelperType() { JS_Init(); } + ~JsInitHelperType() { JS_ShutDown(); } +} JsInitHelper; + struct _PolkitBackendJsAuthorityPrivate { gchar **rules_dirs; @@ -589,7 +596,6 @@ polkit_backend_js_authority_finalize (GObject *object) delete authority->priv->js_polkit; JS_DestroyContext (authority->priv->cx); - /* JS_ShutDown (); */ G_OBJECT_CLASS (polkit_backend_js_authority_parent_class)->finalize (object); } @@ -666,7 +672,6 @@ polkit_backend_js_authority_class_init (PolkitBackendJsAuthorityClass *klass) g_type_class_add_private (klass, sizeof (PolkitBackendJsAuthorityPrivate)); - JS_Init (); } /* ---------------------------------------------------------------------------------------------------- */ -- 2.27.0