[packagekit] [PATCH] Bug #12883, PackageKit has a hard dependency on libnm_glib

S.Çağlar Onur caglar at pardus.org.tr
Mon Oct 22 05:14:59 PDT 2007


Hi;

22 Eki 2007 Pts tarihinde, S.Çağlar Onur şunları yazmıştı: 
> While trying/playing to integrate our package manager (PiSi) into PackageKit i realize it has strict dep. to NetworkManager which is not available for Pardus.
> And according to [1]  it is not desired also so here is the quick patch to remove that dependency from PackageKit. 

Grr, i think previous one broke the NM support :) this seems works for me if i'm still not missing something.

P.S: NM_SUPPORT renamed to HAVE_NETWORKMANAGER for consistency

diff --git a/configure.ac b/configure.ac
index 6af5641..36b0324 100644
--- a/configure.ac
+++ b/configure.ac
@@ -56,7 +56,7 @@ dnl ---------------------------------------------------------------------------
 GLIB_REQUIRED=2.14.0
 DBUS_REQUIRED=1.1.1
 DBUS_GLIB_REQUIRED=0.73
-LIBNM_REQUIRED=0.6.4
+LIBNM_GLIB_REQUIRED=0.6.4
 POLKIT_DBUS_REQUIRED=0.5
 POLKIT_GRANT_REQUIRED=0.5
 
@@ -89,8 +89,15 @@ PKG_CHECK_MODULES(DBUS, \
 AC_SUBST(DBUS_CFLAGS)
 AC_SUBST(DBUS_LIBS)
 
-PKG_CHECK_MODULES(LIBNM, \
- libnm_glib >= $LIBNM_REQUIRED)
+PKG_CHECK_MODULES(LIBNM, $LIBNM_GLIB_REQUIRED, HAVE_NETWORKMANAGER="yes", HAVE_NETWORKMANAGER="no")
+AC_CHECK_HEADER(NetworkManager/NetworkManager.h, [ nm_header="yes" ] )
+if test "x$HAVE_NETWORKMANAGER" = "xyes" -a "x$nm_header" = "xyes"; then
+    AC_DEFINE(HAVE_NETWORKMANAGER, 1, [define if NetworkManager is installed])
+else
+    HAVE_NETWORKMANAGER=no
+fi
+
+AM_CONDITIONAL(HAVE_NETWORKMANAGER, test x$HAVE_NETWORKMANAGER = xyes)
 AC_SUBST(LIBNM_CFLAGS)
 AC_SUBST(LIBNM_LIBS)
 
diff --git a/libpackagekit/pk-network.c b/libpackagekit/pk-network.c
index cb12231..8769a17 100644
--- a/libpackagekit/pk-network.c
+++ b/libpackagekit/pk-network.c
@@ -19,6 +19,8 @@
  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  */
 
+#ifdef HAVE_NETWORKMANAGER /* NetworkManager support */
+
 #include "config.h"
 
 #include <stdlib.h>
@@ -166,3 +168,4 @@ pk_network_new (void)
 	}
 	return PK_NETWORK (pk_network_object);
 }
+#endif /* NetworkManager support */
diff --git a/src/pk-backend.c b/src/pk-backend.c
index 171879e..963d860 100644
--- a/src/pk-backend.c
+++ b/src/pk-backend.c
@@ -39,7 +39,9 @@
 #include <gmodule.h>
 #include <pk-package-id.h>
 #include <pk-enum.h>
+#ifdef HAVE_NETWORKMANAGER
 #include <pk-network.h>
+#endif 
 
 #include "pk-debug.h"
 #include "pk-backend-internal.h"
@@ -76,7 +78,9 @@ struct _PkBackendPrivate
 	gboolean		 during_initialize;
 	gboolean		 assigned;
 	gboolean		 set_error;
+#ifdef HAVE_NETWORKMANAGER
 	PkNetwork		*network;
+#endif
 	PkInhibit		*inhibit;
 	/* needed for gui coldplugging */
 	guint			 last_percentage;
@@ -1618,7 +1622,11 @@ pk_backend_get_runtime (PkBackend *backend)
 gboolean
 pk_backend_network_is_online (PkBackend *backend)
 {
+#ifdef HAVE_NETWORKMANAGER
 	return pk_network_is_online (backend->priv->network);
+#else
+	return TRUE;
+#endif
 }
 
 /**
@@ -1661,7 +1669,10 @@ pk_backend_finalize (GObject *object)
 	pk_inhibit_remove (backend->priv->inhibit, backend);
 	g_object_unref (backend->priv->inhibit);
 
+#ifdef HAVE_NETWORKMANAGER
 	g_object_unref (backend->priv->network);
+#endif
+
 	g_object_unref (backend->priv->thread_list);
 
 	G_OBJECT_CLASS (pk_backend_parent_class)->finalize (object);
@@ -1789,7 +1800,9 @@ pk_backend_init (PkBackend *backend)
 	backend->priv->status = PK_STATUS_ENUM_UNKNOWN;
 	backend->priv->exit = PK_EXIT_ENUM_SUCCESS;
 	backend->priv->inhibit = pk_inhibit_new ();
+#ifdef HAVE_NETWORKMANAGER
 	backend->priv->network = pk_network_new ();
+#endif
 	backend->priv->thread_list = pk_thread_list_new ();
 }
 
diff --git a/src/pk-engine.c b/src/pk-engine.c
index 540c89b..39f642a 100644
--- a/src/pk-engine.c
+++ b/src/pk-engine.c
@@ -41,7 +41,9 @@
 
 #include <pk-debug.h>
 #include <pk-common.h>
+#ifdef HAVE_NETWORKMANAGER
 #include <pk-network.h>
+#endif
 #include <pk-package-list.h>
 #include <pk-enum.h>
 
@@ -68,7 +70,9 @@ struct PkEnginePrivate
 	PkTransactionItem	*sync_item;
 	PkPackageList		*updates_cache;
 	PkInhibit		*inhibit;
+#ifdef HAVE_NETWORKMANAGER
 	PkNetwork		*network;
+#endif
 	PkSecurity		*security;
 	PkEnumList		*actions;
 	PkEnumList		*groups;
@@ -2468,8 +2472,10 @@ pk_engine_init (PkEngine *engine)
 	/* we save a cache of the latest update lists sowe can do cached responses */
 	engine->priv->updates_cache = NULL;
 
+#ifdef HAVE_NETWORKMANAGER
 	/* we dont need this, just don't keep creating and destroying it */
 	engine->priv->network = pk_network_new ();
+#endif
 
 	/* we need an auth framework */
 	engine->priv->security = pk_security_new ();
@@ -2513,7 +2519,9 @@ pk_engine_finalize (GObject *object)
 	g_object_unref (engine->priv->actions);
 	g_object_unref (engine->priv->groups);
 	g_object_unref (engine->priv->filters);
+#ifdef HAVE_NETWORKMANAGER
 	g_object_unref (engine->priv->network);
+#endif
 	g_object_unref (engine->priv->security);
 
 	if (engine->priv->updates_cache != NULL) {


Cheers
-- 
S.Çağlar Onur <caglar at pardus.org.tr>
http://cekirdek.pardus.org.tr/~caglar/

Linux is like living in a teepee. No Windows, no Gates and an Apache in house!



More information about the PackageKit mailing list