From 0f4819ab3651bcd7bc0916c1a3c1e2fcc6612f71 Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Thu, 21 Nov 2019 15:14:50 +0100 Subject: contrib/rpm: use proper check for nmtui conditional build --- contrib/fedora/rpm/NetworkManager.spec | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/contrib/fedora/rpm/NetworkManager.spec b/contrib/fedora/rpm/NetworkManager.spec index 317fe9a82a..9b7af5d353 100644 --- a/contrib/fedora/rpm/NetworkManager.spec +++ b/contrib/fedora/rpm/NetworkManager.spec @@ -466,7 +466,7 @@ configurations using "/etc/sysconfig/network-scripts/rule-NAME" files (eg, to do policy-based routing). -%if 0%{with_nmtui} +%if %{with nmtui} %package tui Summary: NetworkManager curses-based UI Group: System Environment/Base @@ -533,6 +533,11 @@ by nm-connection-editor and nm-applet in a non-graphical environment. -Diwd=true \ %else -Diwd=false \ +%endif +%if %{with nmtui} + -Dnmtui=true \ +%else + -Dnmtui=false \ %endif -Dvapi=true \ -Dintrospection=true \ @@ -649,6 +654,11 @@ intltoolize --automake --copy --force --with-iwd=yes \ %else --with-iwd=no \ +%endif +%if %{with nmtui} + --with-nmtui=yes \ +%else + --with-nmtui=no \ %endif --enable-vala=yes \ --enable-introspection \ -- cgit v1.2.1 From 9c5741ccd2b8d52df8d299ef53adc4b727654949 Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Sat, 9 Nov 2019 08:47:10 +0100 Subject: shared/nm-glib: add compat implementation for G_SOURCE_FUNC() G_SOURCE_FUNC() was only added in glib 2.58. --- shared/nm-glib-aux/nm-glib.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/shared/nm-glib-aux/nm-glib.h b/shared/nm-glib-aux/nm-glib.h index 8eee05bfc3..fa44f316c8 100644 --- a/shared/nm-glib-aux/nm-glib.h +++ b/shared/nm-glib-aux/nm-glib.h @@ -569,4 +569,10 @@ _nm_g_value_unset (GValue *value) /*****************************************************************************/ +#if !GLIB_CHECK_VERSION (2, 57, 2) +#define G_SOURCE_FUNC(f) ((GSourceFunc) (void (*)(void)) (f)) +#endif + +/*****************************************************************************/ + #endif /* __NM_GLIB_H__ */ -- cgit v1.2.1 From c40ff42ae6a5282bed5cbe59ff86bf146ae71ffa Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Wed, 13 Nov 2019 17:46:14 +0100 Subject: shared: add nm_g_*_source_new() and nm_g_source_attach() helpers Small utilities to make is more convenient to create and attach GSource instances. --- shared/nm-glib-aux/nm-shared-utils.c | 51 ++++++++++++++++++++++++++++++++++++ shared/nm-glib-aux/nm-shared-utils.h | 25 ++++++++++++++++++ 2 files changed, 76 insertions(+) diff --git a/shared/nm-glib-aux/nm-shared-utils.c b/shared/nm-glib-aux/nm-shared-utils.c index 60f1bfaf81..6b290b4bc9 100644 --- a/shared/nm-glib-aux/nm-shared-utils.c +++ b/shared/nm-glib-aux/nm-shared-utils.c @@ -11,6 +11,7 @@ #include #include #include +#include #include "nm-errno.h" @@ -3388,3 +3389,53 @@ nm_utils_parse_debug_string (const char *string, return result; } + +/*****************************************************************************/ + +GSource * +nm_g_idle_source_new (int priority, + GSourceFunc func, + gpointer user_data, + GDestroyNotify destroy_notify) +{ + GSource *source; + + source = g_idle_source_new (); + if (priority != G_PRIORITY_DEFAULT) + g_source_set_priority (source, priority); + g_source_set_callback (source, func, user_data, destroy_notify); + return source; +} + +GSource * +nm_g_timeout_source_new (guint timeout_ms, + int priority, + GSourceFunc func, + gpointer user_data, + GDestroyNotify destroy_notify) +{ + GSource *source; + + source = g_timeout_source_new (timeout_ms); + if (priority != G_PRIORITY_DEFAULT) + g_source_set_priority (source, priority); + g_source_set_callback (source, func, user_data, destroy_notify); + return source; +} + +GSource * +nm_g_unix_signal_source_new (int signum, + int priority, + GSourceFunc handler, + gpointer user_data, + GDestroyNotify notify) +{ + GSource *source; + + source = g_unix_signal_source_new (signum); + + if (priority != G_PRIORITY_DEFAULT) + g_source_set_priority (source, priority); + g_source_set_callback (source, handler, user_data, notify); + return source; +} diff --git a/shared/nm-glib-aux/nm-shared-utils.h b/shared/nm-glib-aux/nm-shared-utils.h index 5f1edcb219..d04f99f666 100644 --- a/shared/nm-glib-aux/nm-shared-utils.h +++ b/shared/nm-glib-aux/nm-shared-utils.h @@ -931,6 +931,31 @@ NM_AUTO_DEFINE_FCN0 (GSource *, _nm_auto_destroy_and_unref_gsource, nm_g_source_ NM_AUTO_DEFINE_FCN0 (GMainContext *, _nm_auto_pop_gmaincontext, g_main_context_pop_thread_default) #define nm_auto_pop_gmaincontext nm_auto (_nm_auto_pop_gmaincontext) +GSource *nm_g_idle_source_new (int priority, + GSourceFunc func, + gpointer user_data, + GDestroyNotify destroy_notify); + +GSource *nm_g_timeout_source_new (guint timeout_ms, + int priority, + GSourceFunc func, + gpointer user_data, + GDestroyNotify destroy_notify); + +GSource *nm_g_unix_signal_source_new (int signum, + int priority, + GSourceFunc handler, + gpointer user_data, + GDestroyNotify notify); + +static inline GSource * +nm_g_source_attach (GSource *source, + GMainContext *context) +{ + g_source_attach (source, context); + return source; +} + static inline GMainContext * nm_g_main_context_push_thread_default (GMainContext *context) { -- cgit v1.2.1 From 2ef5014f986fea91f1886e7231f6083bc042ec43 Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Thu, 14 Nov 2019 12:28:54 +0100 Subject: shared: add nm_clear_g_source_inst() glib really likes the numeric source IDs. That is, g_idle_add(), g_timeout_add(), etc. return those IDs, that can then be destroyed with g_remove_source() (or nm_clear_g_source()). I think these numeric IDs are really not great. - API like g_idle_add() and g_remove_source() only works with the g_main_context_get_default() instance. That means, you cannot use this API for any other contexts. If you'd insist on using numeric IDs, you'd need to call g_main_context_find_source_by_id() on the right context first (but you'd also have to track the context alongside the ID). - g_remove_source() requires first a call to g_main_context_find_source_by_id(). This involves taking a mutex and doing an extra hash lookup. Instead, it often seems preferable to use the GSource instance directly. It works with any context, it can be referenced and unreferenced, and it can be destroyed, and avoids the overhead of g_main_context_find_source_by_id(). The only downside really is that keeping a GSource pointer takes one pointer size, while the guint source ID is usually only 4 bytes. Anyway, I think we should deal more with GSource instances directly. Hence, add this convenience macro, that works like nm_clear_g_source(). --- shared/nm-glib-aux/nm-shared-utils.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/shared/nm-glib-aux/nm-shared-utils.h b/shared/nm-glib-aux/nm-shared-utils.h index d04f99f666..350fc7aae7 100644 --- a/shared/nm-glib-aux/nm-shared-utils.h +++ b/shared/nm-glib-aux/nm-shared-utils.h @@ -925,6 +925,8 @@ nm_g_source_destroy_and_unref (GSource *source) g_source_unref (source); } +#define nm_clear_g_source_inst(ptr) (nm_clear_pointer ((ptr), nm_g_source_destroy_and_unref)) + NM_AUTO_DEFINE_FCN0 (GSource *, _nm_auto_destroy_and_unref_gsource, nm_g_source_destroy_and_unref); #define nm_auto_destroy_and_unref_gsource nm_auto(_nm_auto_destroy_and_unref_gsource) -- cgit v1.2.1 From ec868916c870072cb3f8007d36d8c879271fb5c7 Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Tue, 19 Nov 2019 13:05:09 +0100 Subject: shared: move nm_utils_ip._address_clear_host_address() helpers to shared --- shared/nm-glib-aux/nm-shared-utils.c | 96 ++++++++++++++++++++++++++++++++++++ shared/nm-glib-aux/nm-shared-utils.h | 5 ++ src/nm-core-utils.c | 96 ------------------------------------ 3 files changed, 101 insertions(+), 96 deletions(-) diff --git a/shared/nm-glib-aux/nm-shared-utils.c b/shared/nm-glib-aux/nm-shared-utils.c index 6b290b4bc9..4afc10eabc 100644 --- a/shared/nm-glib-aux/nm-shared-utils.c +++ b/shared/nm-glib-aux/nm-shared-utils.c @@ -541,6 +541,102 @@ _nm_utils_ip4_prefix_to_netmask (guint32 prefix) return prefix < 32 ? ~htonl(0xFFFFFFFF >> prefix) : 0xFFFFFFFF; } +gconstpointer +nm_utils_ipx_address_clear_host_address (int family, gpointer dst, gconstpointer src, guint8 plen) +{ + g_return_val_if_fail (dst, NULL); + + switch (family) { + case AF_INET: + g_return_val_if_fail (plen <= 32, NULL); + + if (!src) { + /* allow "self-assignment", by specifying %NULL as source. */ + src = dst; + } + + *((guint32 *) dst) = nm_utils_ip4_address_clear_host_address (*((guint32 *) src), plen); + break; + case AF_INET6: + nm_utils_ip6_address_clear_host_address (dst, src, plen); + break; + default: + g_return_val_if_reached (NULL); + } + return dst; +} + +/* nm_utils_ip4_address_clear_host_address: + * @addr: source ip6 address + * @plen: prefix length of network + * + * returns: the input address, with the host address set to 0. + */ +in_addr_t +nm_utils_ip4_address_clear_host_address (in_addr_t addr, guint8 plen) +{ + return addr & _nm_utils_ip4_prefix_to_netmask (plen); +} + +/* nm_utils_ip6_address_clear_host_address: + * @dst: destination output buffer, will contain the network part of the @src address + * @src: source ip6 address + * @plen: prefix length of network + * + * Note: this function is self assignment safe, to update @src inplace, set both + * @dst and @src to the same destination or set @src NULL. + */ +const struct in6_addr * +nm_utils_ip6_address_clear_host_address (struct in6_addr *dst, const struct in6_addr *src, guint8 plen) +{ + g_return_val_if_fail (plen <= 128, NULL); + g_return_val_if_fail (dst, NULL); + + if (!src) + src = dst; + + if (plen < 128) { + guint nbytes = plen / 8; + guint nbits = plen % 8; + + if (nbytes && dst != src) + memcpy (dst, src, nbytes); + if (nbits) { + dst->s6_addr[nbytes] = (src->s6_addr[nbytes] & (0xFF << (8 - nbits))); + nbytes++; + } + if (nbytes <= 15) + memset (&dst->s6_addr[nbytes], 0, 16 - nbytes); + } else if (src != dst) + *dst = *src; + + return dst; +} + +int +nm_utils_ip6_address_same_prefix_cmp (const struct in6_addr *addr_a, const struct in6_addr *addr_b, guint8 plen) +{ + int nbytes; + guint8 va, vb, m; + + if (plen >= 128) + NM_CMP_DIRECT_MEMCMP (addr_a, addr_b, sizeof (struct in6_addr)); + else { + nbytes = plen / 8; + if (nbytes) + NM_CMP_DIRECT_MEMCMP (addr_a, addr_b, nbytes); + + plen = plen % 8; + if (plen != 0) { + m = ~((1 << (8 - plen)) - 1); + va = ((((const guint8 *) addr_a))[nbytes]) & m; + vb = ((((const guint8 *) addr_b))[nbytes]) & m; + NM_CMP_DIRECT (va, vb); + } + } + return 0; +} + /** * _nm_utils_ip4_get_default_prefix: * @ip: an IPv4 address (in network byte order) diff --git a/shared/nm-glib-aux/nm-shared-utils.h b/shared/nm-glib-aux/nm-shared-utils.h index 350fc7aae7..70b0193b59 100644 --- a/shared/nm-glib-aux/nm-shared-utils.h +++ b/shared/nm-glib-aux/nm-shared-utils.h @@ -522,6 +522,11 @@ nm_utils_escaped_tokens_escape_gstr (const char *str, guint32 _nm_utils_ip4_prefix_to_netmask (guint32 prefix); guint32 _nm_utils_ip4_get_default_prefix (guint32 ip); +gconstpointer nm_utils_ipx_address_clear_host_address (int family, gpointer dst, gconstpointer src, guint8 plen); +in_addr_t nm_utils_ip4_address_clear_host_address (in_addr_t addr, guint8 plen); +const struct in6_addr *nm_utils_ip6_address_clear_host_address (struct in6_addr *dst, const struct in6_addr *src, guint8 plen); +int nm_utils_ip6_address_same_prefix_cmp (const struct in6_addr *addr_a, const struct in6_addr *addr_b, guint8 plen); + gboolean nm_utils_ip_is_site_local (int addr_family, const void *address); diff --git a/src/nm-core-utils.c b/src/nm-core-utils.c index 4c258d4b25..a5394c9e55 100644 --- a/src/nm-core-utils.c +++ b/src/nm-core-utils.c @@ -231,102 +231,6 @@ nm_ethernet_address_is_valid (gconstpointer addr, gssize len) return TRUE; } -gconstpointer -nm_utils_ipx_address_clear_host_address (int family, gpointer dst, gconstpointer src, guint8 plen) -{ - g_return_val_if_fail (dst, NULL); - - switch (family) { - case AF_INET: - g_return_val_if_fail (plen <= 32, NULL); - - if (!src) { - /* allow "self-assignment", by specifying %NULL as source. */ - src = dst; - } - - *((guint32 *) dst) = nm_utils_ip4_address_clear_host_address (*((guint32 *) src), plen); - break; - case AF_INET6: - nm_utils_ip6_address_clear_host_address (dst, src, plen); - break; - default: - g_return_val_if_reached (NULL); - } - return dst; -} - -/* nm_utils_ip4_address_clear_host_address: - * @addr: source ip6 address - * @plen: prefix length of network - * - * returns: the input address, with the host address set to 0. - */ -in_addr_t -nm_utils_ip4_address_clear_host_address (in_addr_t addr, guint8 plen) -{ - return addr & _nm_utils_ip4_prefix_to_netmask (plen); -} - -/* nm_utils_ip6_address_clear_host_address: - * @dst: destination output buffer, will contain the network part of the @src address - * @src: source ip6 address - * @plen: prefix length of network - * - * Note: this function is self assignment safe, to update @src inplace, set both - * @dst and @src to the same destination or set @src NULL. - */ -const struct in6_addr * -nm_utils_ip6_address_clear_host_address (struct in6_addr *dst, const struct in6_addr *src, guint8 plen) -{ - g_return_val_if_fail (plen <= 128, NULL); - g_return_val_if_fail (dst, NULL); - - if (!src) - src = dst; - - if (plen < 128) { - guint nbytes = plen / 8; - guint nbits = plen % 8; - - if (nbytes && dst != src) - memcpy (dst, src, nbytes); - if (nbits) { - dst->s6_addr[nbytes] = (src->s6_addr[nbytes] & (0xFF << (8 - nbits))); - nbytes++; - } - if (nbytes <= 15) - memset (&dst->s6_addr[nbytes], 0, 16 - nbytes); - } else if (src != dst) - *dst = *src; - - return dst; -} - -int -nm_utils_ip6_address_same_prefix_cmp (const struct in6_addr *addr_a, const struct in6_addr *addr_b, guint8 plen) -{ - int nbytes; - guint8 va, vb, m; - - if (plen >= 128) - NM_CMP_DIRECT_MEMCMP (addr_a, addr_b, sizeof (struct in6_addr)); - else { - nbytes = plen / 8; - if (nbytes) - NM_CMP_DIRECT_MEMCMP (addr_a, addr_b, nbytes); - - plen = plen % 8; - if (plen != 0) { - m = ~((1 << (8 - plen)) - 1); - va = ((((const guint8 *) addr_a))[nbytes]) & m; - vb = ((((const guint8 *) addr_b))[nbytes]) & m; - NM_CMP_DIRECT (va, vb); - } - } - return 0; -} - /*****************************************************************************/ void -- cgit v1.2.1 From 05c31da4d9cb23d8a9170410295849aad4bf290f Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Wed, 13 Nov 2019 17:57:38 +0100 Subject: connectivity: don't cancel curl timerfunction from timeout Curl documents about CURLMOPT_TIMERFUNCTION: The timer_callback will only be called when the timeout expire time is changed. That means, we should not cancel the timeout when it happend, but only when the callback is called again (or during cleanup). See-also: https://curl.haxx.se/libcurl/c/CURLMOPT_TIMERFUNCTION.html --- src/nm-connectivity.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/nm-connectivity.c b/src/nm-connectivity.c index 8cf9f0bc56..b1311fbb70 100644 --- a/src/nm-connectivity.c +++ b/src/nm-connectivity.c @@ -408,10 +408,9 @@ _con_curl_timeout_cb (gpointer user_data) { NMConnectivityCheckHandle *cb_data = user_data; - cb_data->concheck.curl_timer = 0; _con_curl_check_connectivity (cb_data->concheck.curl_mhandle, CURL_SOCKET_TIMEOUT, 0); _complete_queued (cb_data->self); - return G_SOURCE_REMOVE; + return G_SOURCE_CONTINUE; } static int -- cgit v1.2.1 From 0871c9533f3efe3dca37102c55a22efa2d45edda Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Thu, 14 Nov 2019 12:30:01 +0100 Subject: connectivity: don't use the GIOChannel but poll the file descriptor directly I guess, if you write portable applications, then GIOChannel makes a lot of sense. But we know that this is on Linux. We don't need to pretend that we cannot poll on the file descriptor directly. --- src/nm-connectivity.c | 38 +++++++++++++++++++++++--------------- 1 file changed, 23 insertions(+), 15 deletions(-) diff --git a/src/nm-connectivity.c b/src/nm-connectivity.c index b1311fbb70..b9cbfee1ab 100644 --- a/src/nm-connectivity.c +++ b/src/nm-connectivity.c @@ -13,6 +13,7 @@ #include #endif #include +#include #include "c-list/src/c-list.h" #include "nm-core-internal.h" @@ -426,7 +427,8 @@ multi_timer_cb (CURLM *multi, long timeout_ms, void *userdata) typedef struct { NMConnectivityCheckHandle *cb_data; - GIOChannel *ch; + + GSource *source; /* this is a very simplistic weak-pointer. If ConCurlSockData gets * destroyed, it will set *destroy_notify to TRUE. @@ -435,15 +437,15 @@ typedef struct { * safely access @fdp after _con_curl_check_connectivity(). */ gboolean *destroy_notify; - guint ev; } ConCurlSockData; static gboolean -_con_curl_socketevent_cb (GIOChannel *ch, GIOCondition condition, gpointer user_data) +_con_curl_socketevent_cb (int fd, + GIOCondition condition, + gpointer user_data) { ConCurlSockData *fdp = user_data; NMConnectivityCheckHandle *cb_data = fdp->cb_data; - int fd = g_io_channel_unix_get_fd (ch); int action = 0; gboolean fdp_destroyed = FALSE; gboolean success; @@ -467,12 +469,12 @@ _con_curl_socketevent_cb (GIOChannel *ch, GIOCondition condition, gpointer user_ nm_assert (fdp->destroy_notify == &fdp_destroyed); fdp->destroy_notify = NULL; if (!success) - fdp->ev = 0; + nm_clear_g_source_inst (&fdp->source); } _complete_queued (cb_data->self); - return success ? G_SOURCE_CONTINUE : G_SOURCE_REMOVE; + return G_SOURCE_CONTINUE; } static int @@ -480,7 +482,6 @@ multi_socket_cb (CURL *e_handle, curl_socket_t fd, int what, void *userdata, voi { NMConnectivityCheckHandle *cb_data = userdata; ConCurlSockData *fdp = socketp; - GIOCondition condition = 0; (void) _NM_ENSURE_TYPE (int, fd); @@ -488,19 +489,21 @@ multi_socket_cb (CURL *e_handle, curl_socket_t fd, int what, void *userdata, voi if (fdp) { if (fdp->destroy_notify) *fdp->destroy_notify = TRUE; + nm_clear_g_source_inst (&fdp->source); curl_multi_assign (cb_data->concheck.curl_mhandle, fd, NULL); - nm_clear_g_source (&fdp->ev); - g_io_channel_unref (fdp->ch); g_slice_free (ConCurlSockData, fdp); } } else { + GIOCondition condition; + if (!fdp) { - fdp = g_slice_new0 (ConCurlSockData); - fdp->cb_data = cb_data; - fdp->ch = g_io_channel_unix_new (fd); + fdp = g_slice_new (ConCurlSockData); + *fdp = (ConCurlSockData) { + .cb_data = cb_data, + }; curl_multi_assign (cb_data->concheck.curl_mhandle, fd, fdp); } else - nm_clear_g_source (&fdp->ev); + nm_clear_g_source_inst (&fdp->source); if (what == CURL_POLL_IN) condition = G_IO_IN; @@ -508,9 +511,14 @@ multi_socket_cb (CURL *e_handle, curl_socket_t fd, int what, void *userdata, voi condition = G_IO_OUT; else if (what == CURL_POLL_INOUT) condition = G_IO_IN | G_IO_OUT; + else + condition = 0; - if (condition) - fdp->ev = g_io_add_watch (fdp->ch, condition, _con_curl_socketevent_cb, fdp); + if (condition) { + fdp->source = g_unix_fd_source_new (fd, condition); + g_source_set_callback (fdp->source, G_SOURCE_FUNC (_con_curl_socketevent_cb), fdp, NULL); + g_source_attach (fdp->source, NULL); + } } return CURLM_OK; -- cgit v1.2.1 From c24f122e222f60246037a3a75c544612c34f0bac Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Thu, 14 Nov 2019 14:26:17 +0100 Subject: connectivity: fix using curl_multi_strerror() for CURLMcode error code --- src/nm-connectivity.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/nm-connectivity.c b/src/nm-connectivity.c index b9cbfee1ab..ccac63766b 100644 --- a/src/nm-connectivity.c +++ b/src/nm-connectivity.c @@ -314,7 +314,6 @@ _con_curl_check_connectivity (CURLM *mhandle, int sockfd, int ev_bitmask) { NMConnectivityCheckHandle *cb_data; CURLMsg *msg; - CURLcode eret; int m_left; long response_code; CURLMcode ret; @@ -323,12 +322,13 @@ _con_curl_check_connectivity (CURLM *mhandle, int sockfd, int ev_bitmask) ret = curl_multi_socket_action (mhandle, sockfd, ev_bitmask, &running_handles); if (ret != CURLM_OK) { - _LOGD ("connectivity check failed: (%d) %s", ret, curl_easy_strerror (ret)); + _LOGD ("connectivity check failed: (%d) %s", ret, curl_multi_strerror (ret)); success = FALSE; } while ((msg = curl_multi_info_read (mhandle, &m_left))) { const char *response; + CURLcode eret; if (msg->msg != CURLMSG_DONE) continue; -- cgit v1.2.1 From 033c2b82c2068ac1a47d890cf8dee24749bd6829 Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Tue, 12 Nov 2019 17:11:29 +0100 Subject: core: move _LOG*() macros to "shared/nm-glib-aux/nm-logging-fwd.h" We preferably should use our convenience macros like _LOGD(). Since those macros expand to _NMLOG() (which needs to be defined separately), we can move it to "nm-logging-fwd.h" and reuse. --- shared/nm-glib-aux/nm-logging-fwd.h | 110 ++++++++++++++++++++++++++++++++++++ src/nm-logging.h | 108 ----------------------------------- 2 files changed, 110 insertions(+), 108 deletions(-) diff --git a/shared/nm-glib-aux/nm-logging-fwd.h b/shared/nm-glib-aux/nm-logging-fwd.h index 7d76a5b13d..ba7729a148 100644 --- a/shared/nm-glib-aux/nm-logging-fwd.h +++ b/shared/nm-glib-aux/nm-logging-fwd.h @@ -135,4 +135,114 @@ extern void _nm_utils_monotonic_timestamp_initialized (const struct timespec *tp gint64 offset_sec, gboolean is_boottime); +/*****************************************************************************/ + +/* This is the default definition of _NMLOG_ENABLED(). Special implementations + * might want to undef this and redefine it. */ +#define _NMLOG_ENABLED(level) ( nm_logging_enabled ((level), (_NMLOG_DOMAIN)) ) + +#define _LOGT(...) _NMLOG (LOGL_TRACE, __VA_ARGS__) +#define _LOGD(...) _NMLOG (LOGL_DEBUG, __VA_ARGS__) +#define _LOGI(...) _NMLOG (LOGL_INFO , __VA_ARGS__) +#define _LOGW(...) _NMLOG (LOGL_WARN , __VA_ARGS__) +#define _LOGE(...) _NMLOG (LOGL_ERR , __VA_ARGS__) + +#define _LOGT_ENABLED(...) _NMLOG_ENABLED (LOGL_TRACE, ##__VA_ARGS__) +#define _LOGD_ENABLED(...) _NMLOG_ENABLED (LOGL_DEBUG, ##__VA_ARGS__) +#define _LOGI_ENABLED(...) _NMLOG_ENABLED (LOGL_INFO , ##__VA_ARGS__) +#define _LOGW_ENABLED(...) _NMLOG_ENABLED (LOGL_WARN , ##__VA_ARGS__) +#define _LOGE_ENABLED(...) _NMLOG_ENABLED (LOGL_ERR , ##__VA_ARGS__) + +#define _LOGT_err(errsv, ...) _NMLOG_err (errsv, LOGL_TRACE, __VA_ARGS__) +#define _LOGD_err(errsv, ...) _NMLOG_err (errsv, LOGL_DEBUG, __VA_ARGS__) +#define _LOGI_err(errsv, ...) _NMLOG_err (errsv, LOGL_INFO , __VA_ARGS__) +#define _LOGW_err(errsv, ...) _NMLOG_err (errsv, LOGL_WARN , __VA_ARGS__) +#define _LOGE_err(errsv, ...) _NMLOG_err (errsv, LOGL_ERR , __VA_ARGS__) + +/* _LOGT() and _LOGt() both log with level TRACE, but the latter is disabled by default, + * unless building with --with-more-logging. */ +#if NM_MORE_LOGGING +#define _LOGt_ENABLED(...) _NMLOG_ENABLED (LOGL_TRACE, ##__VA_ARGS__) +#define _LOGt(...) _NMLOG (LOGL_TRACE, __VA_ARGS__) +#define _LOGt_err(errsv, ...) _NMLOG_err (errsv, LOGL_TRACE, __VA_ARGS__) +#else +/* still call the logging macros to get compile time checks, but they will be optimized out. */ +#define _LOGt_ENABLED(...) ( FALSE && (_NMLOG_ENABLED (LOGL_TRACE, ##__VA_ARGS__)) ) +#define _LOGt(...) G_STMT_START { if (FALSE) { _NMLOG (LOGL_TRACE, __VA_ARGS__); } } G_STMT_END +#define _LOGt_err(errsv, ...) G_STMT_START { if (FALSE) { _NMLOG_err (errsv, LOGL_TRACE, __VA_ARGS__); } } G_STMT_END +#endif + +/*****************************************************************************/ + +/* Some implementation define a second set of logging macros, for a separate + * use. As with the _LOGD() macro family above, the exact implementation + * depends on the file that uses them. + * Still, it encourages a common pattern to have the common set of macros + * like _LOG2D(), _LOG2I(), etc. and have _LOG2t() which by default + * is disabled at compile time. */ + +#define _NMLOG2_ENABLED(level) ( nm_logging_enabled ((level), (_NMLOG2_DOMAIN)) ) + +#define _LOG2T(...) _NMLOG2 (LOGL_TRACE, __VA_ARGS__) +#define _LOG2D(...) _NMLOG2 (LOGL_DEBUG, __VA_ARGS__) +#define _LOG2I(...) _NMLOG2 (LOGL_INFO , __VA_ARGS__) +#define _LOG2W(...) _NMLOG2 (LOGL_WARN , __VA_ARGS__) +#define _LOG2E(...) _NMLOG2 (LOGL_ERR , __VA_ARGS__) + +#define _LOG2T_ENABLED(...) _NMLOG2_ENABLED (LOGL_TRACE, ##__VA_ARGS__) +#define _LOG2D_ENABLED(...) _NMLOG2_ENABLED (LOGL_DEBUG, ##__VA_ARGS__) +#define _LOG2I_ENABLED(...) _NMLOG2_ENABLED (LOGL_INFO , ##__VA_ARGS__) +#define _LOG2W_ENABLED(...) _NMLOG2_ENABLED (LOGL_WARN , ##__VA_ARGS__) +#define _LOG2E_ENABLED(...) _NMLOG2_ENABLED (LOGL_ERR , ##__VA_ARGS__) + +#define _LOG2T_err(errsv, ...) _NMLOG2_err (errsv, LOGL_TRACE, __VA_ARGS__) +#define _LOG2D_err(errsv, ...) _NMLOG2_err (errsv, LOGL_DEBUG, __VA_ARGS__) +#define _LOG2I_err(errsv, ...) _NMLOG2_err (errsv, LOGL_INFO , __VA_ARGS__) +#define _LOG2W_err(errsv, ...) _NMLOG2_err (errsv, LOGL_WARN , __VA_ARGS__) +#define _LOG2E_err(errsv, ...) _NMLOG2_err (errsv, LOGL_ERR , __VA_ARGS__) + +#if NM_MORE_LOGGING +#define _LOG2t_ENABLED(...) _NMLOG2_ENABLED (LOGL_TRACE, ##__VA_ARGS__) +#define _LOG2t(...) _NMLOG2 (LOGL_TRACE, __VA_ARGS__) +#define _LOG2t_err(errsv, ...) _NMLOG2_err (errsv, LOGL_TRACE, __VA_ARGS__) +#else +/* still call the logging macros to get compile time checks, but they will be optimized out. */ +#define _LOG2t_ENABLED(...) ( FALSE && (_NMLOG2_ENABLED (LOGL_TRACE, ##__VA_ARGS__)) ) +#define _LOG2t(...) G_STMT_START { if (FALSE) { _NMLOG2 (LOGL_TRACE, __VA_ARGS__); } } G_STMT_END +#define _LOG2t_err(errsv, ...) G_STMT_START { if (FALSE) { _NMLOG2_err (errsv, LOGL_TRACE, __VA_ARGS__); } } G_STMT_END +#endif + +#define _NMLOG3_ENABLED(level) ( nm_logging_enabled ((level), (_NMLOG3_DOMAIN)) ) + +#define _LOG3T(...) _NMLOG3 (LOGL_TRACE, __VA_ARGS__) +#define _LOG3D(...) _NMLOG3 (LOGL_DEBUG, __VA_ARGS__) +#define _LOG3I(...) _NMLOG3 (LOGL_INFO , __VA_ARGS__) +#define _LOG3W(...) _NMLOG3 (LOGL_WARN , __VA_ARGS__) +#define _LOG3E(...) _NMLOG3 (LOGL_ERR , __VA_ARGS__) + +#define _LOG3T_ENABLED(...) _NMLOG3_ENABLED (LOGL_TRACE, ##__VA_ARGS__) +#define _LOG3D_ENABLED(...) _NMLOG3_ENABLED (LOGL_DEBUG, ##__VA_ARGS__) +#define _LOG3I_ENABLED(...) _NMLOG3_ENABLED (LOGL_INFO , ##__VA_ARGS__) +#define _LOG3W_ENABLED(...) _NMLOG3_ENABLED (LOGL_WARN , ##__VA_ARGS__) +#define _LOG3E_ENABLED(...) _NMLOG3_ENABLED (LOGL_ERR , ##__VA_ARGS__) + +#define _LOG3T_err(errsv, ...) _NMLOG3_err (errsv, LOGL_TRACE, __VA_ARGS__) +#define _LOG3D_err(errsv, ...) _NMLOG3_err (errsv, LOGL_DEBUG, __VA_ARGS__) +#define _LOG3I_err(errsv, ...) _NMLOG3_err (errsv, LOGL_INFO , __VA_ARGS__) +#define _LOG3W_err(errsv, ...) _NMLOG3_err (errsv, LOGL_WARN , __VA_ARGS__) +#define _LOG3E_err(errsv, ...) _NMLOG3_err (errsv, LOGL_ERR , __VA_ARGS__) + +#if NM_MORE_LOGGING +#define _LOG3t_ENABLED(...) _NMLOG3_ENABLED (LOGL_TRACE, ##__VA_ARGS__) +#define _LOG3t(...) _NMLOG3 (LOGL_TRACE, __VA_ARGS__) +#define _LOG3t_err(errsv, ...) _NMLOG3_err (errsv, LOGL_TRACE, __VA_ARGS__) +#else +/* still call the logging macros to get compile time checks, but they will be optimized out. */ +#define _LOG3t_ENABLED(...) ( FALSE && (_NMLOG3_ENABLED (LOGL_TRACE, ##__VA_ARGS__)) ) +#define _LOG3t(...) G_STMT_START { if (FALSE) { _NMLOG3 (LOGL_TRACE, __VA_ARGS__); } } G_STMT_END +#define _LOG3t_err(errsv, ...) G_STMT_START { if (FALSE) { _NMLOG3_err (errsv, LOGL_TRACE, __VA_ARGS__); } } G_STMT_END +#endif + +/*****************************************************************************/ + #endif /* __NM_LOGGING_DEFINES_H__ */ diff --git a/src/nm-logging.h b/src/nm-logging.h index 743ed19b6a..54887b0f39 100644 --- a/src/nm-logging.h +++ b/src/nm-logging.h @@ -177,114 +177,6 @@ gboolean nm_logging_syslog_enabled (void); /*****************************************************************************/ -/* This is the default definition of _NMLOG_ENABLED(). Special implementations - * might want to undef this and redefine it. */ -#define _NMLOG_ENABLED(level) ( nm_logging_enabled ((level), (_NMLOG_DOMAIN)) ) - -#define _LOGT(...) _NMLOG (LOGL_TRACE, __VA_ARGS__) -#define _LOGD(...) _NMLOG (LOGL_DEBUG, __VA_ARGS__) -#define _LOGI(...) _NMLOG (LOGL_INFO , __VA_ARGS__) -#define _LOGW(...) _NMLOG (LOGL_WARN , __VA_ARGS__) -#define _LOGE(...) _NMLOG (LOGL_ERR , __VA_ARGS__) - -#define _LOGT_ENABLED(...) _NMLOG_ENABLED (LOGL_TRACE, ##__VA_ARGS__) -#define _LOGD_ENABLED(...) _NMLOG_ENABLED (LOGL_DEBUG, ##__VA_ARGS__) -#define _LOGI_ENABLED(...) _NMLOG_ENABLED (LOGL_INFO , ##__VA_ARGS__) -#define _LOGW_ENABLED(...) _NMLOG_ENABLED (LOGL_WARN , ##__VA_ARGS__) -#define _LOGE_ENABLED(...) _NMLOG_ENABLED (LOGL_ERR , ##__VA_ARGS__) - -#define _LOGT_err(errsv, ...) _NMLOG_err (errsv, LOGL_TRACE, __VA_ARGS__) -#define _LOGD_err(errsv, ...) _NMLOG_err (errsv, LOGL_DEBUG, __VA_ARGS__) -#define _LOGI_err(errsv, ...) _NMLOG_err (errsv, LOGL_INFO , __VA_ARGS__) -#define _LOGW_err(errsv, ...) _NMLOG_err (errsv, LOGL_WARN , __VA_ARGS__) -#define _LOGE_err(errsv, ...) _NMLOG_err (errsv, LOGL_ERR , __VA_ARGS__) - -/* _LOGT() and _LOGt() both log with level TRACE, but the latter is disabled by default, - * unless building with --with-more-logging. */ -#if NM_MORE_LOGGING -#define _LOGt_ENABLED(...) _NMLOG_ENABLED (LOGL_TRACE, ##__VA_ARGS__) -#define _LOGt(...) _NMLOG (LOGL_TRACE, __VA_ARGS__) -#define _LOGt_err(errsv, ...) _NMLOG_err (errsv, LOGL_TRACE, __VA_ARGS__) -#else -/* still call the logging macros to get compile time checks, but they will be optimized out. */ -#define _LOGt_ENABLED(...) ( FALSE && (_NMLOG_ENABLED (LOGL_TRACE, ##__VA_ARGS__)) ) -#define _LOGt(...) G_STMT_START { if (FALSE) { _NMLOG (LOGL_TRACE, __VA_ARGS__); } } G_STMT_END -#define _LOGt_err(errsv, ...) G_STMT_START { if (FALSE) { _NMLOG_err (errsv, LOGL_TRACE, __VA_ARGS__); } } G_STMT_END -#endif - -/*****************************************************************************/ - -/* Some implementation define a second set of logging macros, for a separate - * use. As with the _LOGD() macro family above, the exact implementation - * depends on the file that uses them. - * Still, it encourages a common pattern to have the common set of macros - * like _LOG2D(), _LOG2I(), etc. and have _LOG2t() which by default - * is disabled at compile time. */ - -#define _NMLOG2_ENABLED(level) ( nm_logging_enabled ((level), (_NMLOG2_DOMAIN)) ) - -#define _LOG2T(...) _NMLOG2 (LOGL_TRACE, __VA_ARGS__) -#define _LOG2D(...) _NMLOG2 (LOGL_DEBUG, __VA_ARGS__) -#define _LOG2I(...) _NMLOG2 (LOGL_INFO , __VA_ARGS__) -#define _LOG2W(...) _NMLOG2 (LOGL_WARN , __VA_ARGS__) -#define _LOG2E(...) _NMLOG2 (LOGL_ERR , __VA_ARGS__) - -#define _LOG2T_ENABLED(...) _NMLOG2_ENABLED (LOGL_TRACE, ##__VA_ARGS__) -#define _LOG2D_ENABLED(...) _NMLOG2_ENABLED (LOGL_DEBUG, ##__VA_ARGS__) -#define _LOG2I_ENABLED(...) _NMLOG2_ENABLED (LOGL_INFO , ##__VA_ARGS__) -#define _LOG2W_ENABLED(...) _NMLOG2_ENABLED (LOGL_WARN , ##__VA_ARGS__) -#define _LOG2E_ENABLED(...) _NMLOG2_ENABLED (LOGL_ERR , ##__VA_ARGS__) - -#define _LOG2T_err(errsv, ...) _NMLOG2_err (errsv, LOGL_TRACE, __VA_ARGS__) -#define _LOG2D_err(errsv, ...) _NMLOG2_err (errsv, LOGL_DEBUG, __VA_ARGS__) -#define _LOG2I_err(errsv, ...) _NMLOG2_err (errsv, LOGL_INFO , __VA_ARGS__) -#define _LOG2W_err(errsv, ...) _NMLOG2_err (errsv, LOGL_WARN , __VA_ARGS__) -#define _LOG2E_err(errsv, ...) _NMLOG2_err (errsv, LOGL_ERR , __VA_ARGS__) - -#if NM_MORE_LOGGING -#define _LOG2t_ENABLED(...) _NMLOG2_ENABLED (LOGL_TRACE, ##__VA_ARGS__) -#define _LOG2t(...) _NMLOG2 (LOGL_TRACE, __VA_ARGS__) -#define _LOG2t_err(errsv, ...) _NMLOG2_err (errsv, LOGL_TRACE, __VA_ARGS__) -#else -/* still call the logging macros to get compile time checks, but they will be optimized out. */ -#define _LOG2t_ENABLED(...) ( FALSE && (_NMLOG2_ENABLED (LOGL_TRACE, ##__VA_ARGS__)) ) -#define _LOG2t(...) G_STMT_START { if (FALSE) { _NMLOG2 (LOGL_TRACE, __VA_ARGS__); } } G_STMT_END -#define _LOG2t_err(errsv, ...) G_STMT_START { if (FALSE) { _NMLOG2_err (errsv, LOGL_TRACE, __VA_ARGS__); } } G_STMT_END -#endif - -#define _NMLOG3_ENABLED(level) ( nm_logging_enabled ((level), (_NMLOG3_DOMAIN)) ) - -#define _LOG3T(...) _NMLOG3 (LOGL_TRACE, __VA_ARGS__) -#define _LOG3D(...) _NMLOG3 (LOGL_DEBUG, __VA_ARGS__) -#define _LOG3I(...) _NMLOG3 (LOGL_INFO , __VA_ARGS__) -#define _LOG3W(...) _NMLOG3 (LOGL_WARN , __VA_ARGS__) -#define _LOG3E(...) _NMLOG3 (LOGL_ERR , __VA_ARGS__) - -#define _LOG3T_ENABLED(...) _NMLOG3_ENABLED (LOGL_TRACE, ##__VA_ARGS__) -#define _LOG3D_ENABLED(...) _NMLOG3_ENABLED (LOGL_DEBUG, ##__VA_ARGS__) -#define _LOG3I_ENABLED(...) _NMLOG3_ENABLED (LOGL_INFO , ##__VA_ARGS__) -#define _LOG3W_ENABLED(...) _NMLOG3_ENABLED (LOGL_WARN , ##__VA_ARGS__) -#define _LOG3E_ENABLED(...) _NMLOG3_ENABLED (LOGL_ERR , ##__VA_ARGS__) - -#define _LOG3T_err(errsv, ...) _NMLOG3_err (errsv, LOGL_TRACE, __VA_ARGS__) -#define _LOG3D_err(errsv, ...) _NMLOG3_err (errsv, LOGL_DEBUG, __VA_ARGS__) -#define _LOG3I_err(errsv, ...) _NMLOG3_err (errsv, LOGL_INFO , __VA_ARGS__) -#define _LOG3W_err(errsv, ...) _NMLOG3_err (errsv, LOGL_WARN , __VA_ARGS__) -#define _LOG3E_err(errsv, ...) _NMLOG3_err (errsv, LOGL_ERR , __VA_ARGS__) - -#if NM_MORE_LOGGING -#define _LOG3t_ENABLED(...) _NMLOG3_ENABLED (LOGL_TRACE, ##__VA_ARGS__) -#define _LOG3t(...) _NMLOG3 (LOGL_TRACE, __VA_ARGS__) -#define _LOG3t_err(errsv, ...) _NMLOG3_err (errsv, LOGL_TRACE, __VA_ARGS__) -#else -/* still call the logging macros to get compile time checks, but they will be optimized out. */ -#define _LOG3t_ENABLED(...) ( FALSE && (_NMLOG3_ENABLED (LOGL_TRACE, ##__VA_ARGS__)) ) -#define _LOG3t(...) G_STMT_START { if (FALSE) { _NMLOG3 (LOGL_TRACE, __VA_ARGS__); } } G_STMT_END -#define _LOG3t_err(errsv, ...) G_STMT_START { if (FALSE) { _NMLOG3_err (errsv, LOGL_TRACE, __VA_ARGS__); } } G_STMT_END -#endif - -/*****************************************************************************/ - #define __NMLOG_DEFAULT(level, domain, prefix, ...) \ G_STMT_START { \ nm_log ((level), (domain), NULL, NULL, \ -- cgit v1.2.1 From d1eb52f8ce82e198f4820a2a0f7ebe3ed0fcecb7 Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Thu, 21 Nov 2019 15:27:21 +0100 Subject: build: cleanup Makefile.am by moving "data_edit" first $(data_edit) will be used later at an earlier place in the makefile (to edit "clients/cloud-setup/nm-cloud-setup.service", which will be handled earlier). Move it. Also minor cleanups, like allowing to incrementally build systemdsystemunit_DATA variable. --- Makefile.am | 58 ++++++++++++++++++++++++++++++++-------------------------- 1 file changed, 32 insertions(+), 26 deletions(-) diff --git a/Makefile.am b/Makefile.am index babc3bbc9e..ec9c9feb45 100644 --- a/Makefile.am +++ b/Makefile.am @@ -48,6 +48,7 @@ check_local = VAPIGEN_VAPIS = dbusservice_DATA = dbusactivation_DATA = +systemdsystemunit_DATA = INTROSPECTION_GIRS = INTROSPECTION_SCANNER_ARGS = @@ -158,6 +159,24 @@ DISTCLEANFILES += intltool-extract intltool-merge intltool-update ############################################################################### +data_edit = sed \ + -e 's|@NM_VERSION[@]|$(NM_VERSION)|g' \ + -e 's|@bindir[@]|$(bindir)|g' \ + -e 's|@sbindir[@]|$(sbindir)|g' \ + -e 's|@sysconfdir[@]|$(sysconfdir)|g' \ + -e 's|@nmrundir[@]|$(nmrundir)|g' \ + -e 's|@nmstatedir[@]|$(nmstatedir)|g' \ + -e 's|@localstatedir[@]|$(localstatedir)|g' \ + -e 's|@libexecdir[@]|$(libexecdir)|g' \ + -e 's|@DISTRO_NETWORK_SERVICE[@]|$(DISTRO_NETWORK_SERVICE)|g' \ + -e 's|@NM_CONFIG_DEFAULT_MAIN_AUTH_POLKIT_TEXT[@]|$(NM_CONFIG_DEFAULT_MAIN_AUTH_POLKIT_TEXT)|g' \ + -e 's|@NM_CONFIG_DEFAULT_LOGGING_BACKEND_TEXT[@]|$(NM_CONFIG_DEFAULT_LOGGING_BACKEND_TEXT)|g' \ + -e 's|@NM_CONFIG_DEFAULT_LOGGING_AUDIT_TEXT[@]|$(NM_CONFIG_DEFAULT_LOGGING_AUDIT_TEXT)|g' \ + -e 's|@NM_CONFIG_DEFAULT_MAIN_RC_MANAGER[@]|$(NM_CONFIG_DEFAULT_MAIN_RC_MANAGER)|g' \ + -e 's|@NM_CONFIG_DEFAULT_MAIN_DHCP[@]|$(NM_CONFIG_DEFAULT_MAIN_DHCP)|g' + +############################################################################### + polkit_policydir = $(datadir)/polkit-1/actions dist_polkit_policy_in_in_files = \ @@ -4633,28 +4652,13 @@ EXTRA_DIST += \ # data ############################################################################### -data_edit = sed \ - -e 's|@NM_VERSION[@]|$(NM_VERSION)|g' \ - -e 's|@bindir[@]|$(bindir)|g' \ - -e 's|@sbindir[@]|$(sbindir)|g' \ - -e 's|@sysconfdir[@]|$(sysconfdir)|g' \ - -e 's|@nmrundir[@]|$(nmrundir)|g' \ - -e 's|@nmstatedir[@]|$(nmstatedir)|g' \ - -e 's|@localstatedir[@]|$(localstatedir)|g' \ - -e 's|@libexecdir[@]|$(libexecdir)|g' \ - -e 's|@DISTRO_NETWORK_SERVICE[@]|$(DISTRO_NETWORK_SERVICE)|g' \ - -e 's|@NM_CONFIG_DEFAULT_MAIN_AUTH_POLKIT_TEXT[@]|$(NM_CONFIG_DEFAULT_MAIN_AUTH_POLKIT_TEXT)|g' \ - -e 's|@NM_CONFIG_DEFAULT_LOGGING_BACKEND_TEXT[@]|$(NM_CONFIG_DEFAULT_LOGGING_BACKEND_TEXT)|g' \ - -e 's|@NM_CONFIG_DEFAULT_LOGGING_AUDIT_TEXT[@]|$(NM_CONFIG_DEFAULT_LOGGING_AUDIT_TEXT)|g' \ - -e 's|@NM_CONFIG_DEFAULT_MAIN_RC_MANAGER[@]|$(NM_CONFIG_DEFAULT_MAIN_RC_MANAGER)|g' \ - -e 's|@NM_CONFIG_DEFAULT_MAIN_DHCP[@]|$(NM_CONFIG_DEFAULT_MAIN_DHCP)|g' - if HAVE_SYSTEMD -systemdsystemunit_DATA = \ +systemdsystemunit_DATA += \ data/NetworkManager.service \ data/NetworkManager-wait-online.service \ - data/NetworkManager-dispatcher.service + data/NetworkManager-dispatcher.service \ + $(NULL) data/NetworkManager.service: $(srcdir)/data/NetworkManager.service.in $(AM_V_GEN) $(data_edit) $< >$@ @@ -4687,21 +4691,23 @@ data/server.conf: $(srcdir)/data/server.conf.in $(AM_V_GEN) $(data_edit) $< >$@ EXTRA_DIST += \ - data/NetworkManager.service.in \ - data/NetworkManager-wait-online.service.in \ - data/NetworkManager-wait-online-systemd-pre200.service.in \ - data/NetworkManager-dispatcher.service.in \ data/84-nm-drivers.rules \ data/85-nm-unmanaged.rules \ data/90-nm-thunderbolt.rules \ + data/NetworkManager-dispatcher.service.in \ + data/NetworkManager-wait-online-systemd-pre200.service.in \ + data/NetworkManager-wait-online.service.in \ + data/NetworkManager.service.in \ + data/meson.build \ data/server.conf.in \ - data/meson.build + $(NULL) CLEANFILES += \ - data/NetworkManager.service \ - data/NetworkManager-wait-online.service \ data/NetworkManager-dispatcher.service \ - data/server.conf + data/NetworkManager-wait-online.service \ + data/NetworkManager.service \ + data/server.conf \ + $(NULL) ############################################################################### # man -- cgit v1.2.1 From 18c5ce50fbd40534cdd7d8e46277e89b7e7b5dd3 Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Fri, 22 Nov 2019 15:39:25 +0100 Subject: build: create base directories for install-data-hook first The dependencies of make are exectured in the order as they appear. We probably should start by creating the directories, before invoking other install hooks. Currently there is no difference, because none of the other hooks depend on the base directories. Still split it to a special target. --- Makefile.am | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/Makefile.am b/Makefile.am index ec9c9feb45..f2bcc6ae42 100644 --- a/Makefile.am +++ b/Makefile.am @@ -159,6 +159,21 @@ DISTCLEANFILES += intltool-extract intltool-merge intltool-update ############################################################################### +install-data-hook-dirs: + $(mkinstalldirs) -m 0755 $(DESTDIR)$(nmconfdir)/conf.d + $(mkinstalldirs) -m 0755 $(DESTDIR)$(nmconfdir)/system-connections + $(mkinstalldirs) -m 0755 $(DESTDIR)$(nmconfdir)/dnsmasq.d + $(mkinstalldirs) -m 0755 $(DESTDIR)$(nmconfdir)/dnsmasq-shared.d + $(mkinstalldirs) -m 0755 $(DESTDIR)$(nmlibdir)/conf.d + $(mkinstalldirs) -m 0755 $(DESTDIR)$(nmlibdir)/VPN + $(mkinstalldirs) -m 0755 $(DESTDIR)$(nmlibdir)/system-connections + $(mkinstalldirs) -m 0700 $(DESTDIR)$(nmstatedir) + $(mkinstalldirs) -m 0755 $(DESTDIR)$(plugindir) + +install_data_hook += install-data-hook-dirs + +############################################################################### + data_edit = sed \ -e 's|@NM_VERSION[@]|$(NM_VERSION)|g' \ -e 's|@bindir[@]|$(bindir)|g' \ @@ -4958,15 +4973,6 @@ dist-hook: $(dist_hook) install-exec-hook: $(install_exec_hook) install-data-hook: $(install_data_hook) - $(mkinstalldirs) -m 0755 $(DESTDIR)$(nmconfdir)/conf.d - $(mkinstalldirs) -m 0755 $(DESTDIR)$(nmconfdir)/system-connections - $(mkinstalldirs) -m 0755 $(DESTDIR)$(nmconfdir)/dnsmasq.d - $(mkinstalldirs) -m 0755 $(DESTDIR)$(nmconfdir)/dnsmasq-shared.d - $(mkinstalldirs) -m 0755 $(DESTDIR)$(nmlibdir)/conf.d - $(mkinstalldirs) -m 0755 $(DESTDIR)$(nmlibdir)/VPN - $(mkinstalldirs) -m 0755 $(DESTDIR)$(nmlibdir)/system-connections - $(mkinstalldirs) -m 0700 $(DESTDIR)$(nmstatedir) - $(mkinstalldirs) -m 0755 $(DESTDIR)$(plugindir) uninstall-hook: $(uninstall_hook) -- cgit v1.2.1 From 6d7270e222cce3edaf95c463bec9f3212f5e5c73 Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Thu, 21 Nov 2019 15:27:21 +0100 Subject: build/meson: cleanup configuration_data() for paths We don't need such data duplicated. The build setup should have only one configuration_data() for patching such values. Now we only have one global, immutable data_conf dictionary with configuration values. Note that none of the users of data_conf uses all entries, but as the entries are basically only dependent on the meson/configure option and valid for the entire project, this simplifies to handling. --- data/meson.build | 8 -------- dispatcher/meson.build | 8 +------- docs/api/meson.build | 2 +- docs/libnm/meson.build | 2 +- docs/meson.build | 3 --- man/meson.build | 13 +------------ meson.build | 21 +++++++++++++++++++++ shared/meson.build | 7 +------ 8 files changed, 26 insertions(+), 38 deletions(-) diff --git a/data/meson.build b/data/meson.build index c317877070..b572d27da2 100644 --- a/data/meson.build +++ b/data/meson.build @@ -1,11 +1,3 @@ -data_conf = configuration_data() -data_conf.set('bindir', nm_bindir) -data_conf.set('libexecdir', nm_libexecdir) -data_conf.set('sbindir', nm_sbindir) -data_conf.set('sysconfdir', nm_sysconfdir) -data_conf.set('DISTRO_NETWORK_SERVICE', (enable_ifcfg_rh ? 'network.service' : '')) -data_conf.set('NM_MODIFY_SYSTEM_POLICY', (enable_modify_system ? 'yes' : 'auth_admin_keep')) - configure_file( input: 'server.conf.in', output: '@BASENAME@', diff --git a/dispatcher/meson.build b/dispatcher/meson.build index a7e555702a..7feb9597fc 100644 --- a/dispatcher/meson.build +++ b/dispatcher/meson.build @@ -2,17 +2,11 @@ dispatcher_inc = include_directories('.') name = 'nm-dispatcher' -service_conf = configuration_data() -service_conf.set('sbindir', nm_sbindir) -service_conf.set('sysconfdir', nm_sysconfdir) -service_conf.set('localstatedir', nm_localstatedir) -service_conf.set('libexecdir', nm_libexecdir) - configure_file( input: 'org.freedesktop.nm_dispatcher.service.in', output: '@BASENAME@', install_dir: dbus_system_bus_services_dir, - configuration: service_conf, + configuration: data_conf, ) install_data( diff --git a/docs/api/meson.build b/docs/api/meson.build index dde1eecb03..30f82188f9 100644 --- a/docs/api/meson.build +++ b/docs/api/meson.build @@ -19,7 +19,7 @@ endif content_files += configure_file( input: 'version.xml.in', output: '@BASENAME@', - configuration: version_conf, + configuration: data_conf, ) filecopier = find_program('cp') diff --git a/docs/libnm/meson.build b/docs/libnm/meson.build index 43a13f498a..9bbd9d9807 100644 --- a/docs/libnm/meson.build +++ b/docs/libnm/meson.build @@ -39,7 +39,7 @@ scan_args = [ version_xml = configure_file( input: 'version.xml.in', output: '@BASENAME@', - configuration: version_conf, + configuration: data_conf, ) gnome.gtkdoc( diff --git a/docs/meson.build b/docs/meson.build index e9768e5275..53fcc96082 100644 --- a/docs/meson.build +++ b/docs/meson.build @@ -1,6 +1,3 @@ -version_conf = configuration_data() -version_conf.set('VERSION', nm_version) - subdir('libnm') subdir('api') diff --git a/man/meson.build b/man/meson.build index 8ba6f4d8a1..f9130535c9 100644 --- a/man/meson.build +++ b/man/meson.build @@ -1,18 +1,7 @@ -common_conf = configuration_data() -common_conf.set('NM_VERSION', nm_version) -common_conf.set('sysconfdir', nm_sysconfdir) -common_conf.set('nmrundir', nm_pkgrundir) -common_conf.set('nmstatedir', nm_pkgstatedir) -common_conf.set('NM_CONFIG_DEFAULT_MAIN_AUTH_POLKIT_TEXT', config_default_main_auth_polkit) -common_conf.set('NM_CONFIG_DEFAULT_LOGGING_BACKEND_TEXT', config_logging_backend_default) -common_conf.set('NM_CONFIG_DEFAULT_LOGGING_AUDIT_TEXT', config_default_logging_audit) -common_conf.set('NM_CONFIG_DEFAULT_MAIN_RC_MANAGER', config_dns_rc_manager_default) -common_conf.set('NM_CONFIG_DEFAULT_MAIN_DHCP', config_dhcp_default) - common_ent_file = configure_file( input: 'common.ent.in', output: '@BASENAME@', - configuration: common_conf, + configuration: data_conf, ) xsltproc_options = [ diff --git a/meson.build b/meson.build index 9d4e2cd34d..29da0b0504 100644 --- a/meson.build +++ b/meson.build @@ -774,6 +774,27 @@ if python.found() config_h.set_quoted('TEST_NM_PYTHON', python.path()) endif +data_conf = configuration_data() +data_conf.set('DISTRO_NETWORK_SERVICE', (enable_ifcfg_rh ? 'network.service' : '')) +data_conf.set('NM_CONFIG_DEFAULT_LOGGING_AUDIT_TEXT', config_default_logging_audit) +data_conf.set('NM_CONFIG_DEFAULT_LOGGING_BACKEND_TEXT', config_logging_backend_default) +data_conf.set('NM_CONFIG_DEFAULT_MAIN_AUTH_POLKIT_TEXT', config_default_main_auth_polkit) +data_conf.set('NM_CONFIG_DEFAULT_MAIN_DHCP', config_dhcp_default) +data_conf.set('NM_CONFIG_DEFAULT_MAIN_RC_MANAGER', config_dns_rc_manager_default) +data_conf.set('NM_MAJOR_VERSION', nm_major_version) +data_conf.set('NM_MICRO_VERSION', nm_micro_version) +data_conf.set('NM_MINOR_VERSION', nm_minor_version) +data_conf.set('NM_MODIFY_SYSTEM_POLICY', (enable_modify_system ? 'yes' : 'auth_admin_keep')) +data_conf.set('NM_VERSION', nm_version) +data_conf.set('VERSION', nm_version) +data_conf.set('bindir', nm_bindir) +data_conf.set('libexecdir', nm_libexecdir) +data_conf.set('localstatedir', nm_localstatedir) +data_conf.set('nmrundir', nm_pkgrundir) +data_conf.set('nmstatedir', nm_pkgstatedir) +data_conf.set('sbindir', nm_sbindir) +data_conf.set('sysconfdir', nm_sysconfdir) + # check if we can build setting property documentation ''' build_docs=no diff --git a/shared/meson.build b/shared/meson.build index 7a9dbaac48..e87d9a3b66 100644 --- a/shared/meson.build +++ b/shared/meson.build @@ -99,15 +99,10 @@ libn_dhcp4_dep = declare_dependency( link_with: libn_dhcp4, ) -nm_version_macro_conf = configuration_data() -nm_version_macro_conf.set('NM_MAJOR_VERSION', nm_major_version) -nm_version_macro_conf.set('NM_MINOR_VERSION', nm_minor_version) -nm_version_macro_conf.set('NM_MICRO_VERSION', nm_micro_version) - nm_version_macro_header = configure_file( input: 'nm-version-macros.h.in', output: '@BASENAME@', - configuration: nm_version_macro_conf, + configuration: data_conf, ) nm_ethtool_utils_source = files('nm-libnm-core-intern/nm-ethtool-utils.c') -- cgit v1.2.1 From 21845ae4e342bca61ad71a1ec6ba239df805eb76 Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Fri, 22 Nov 2019 15:59:11 +0100 Subject: build/meson: cleanup "meson-post-install.sh" - the variables in meson.build and in the meson-post-install.sh script should have the same names. - the positional command line arguments should be assigned to variables, because the variable name acts like a documentation what the variable means (contrary to the argument number). - the boolean flags should not map to other special values, like "enable_docs ? 'install_docs' : ''". The name "enable_docs" is good already, it shall be either passed as 1 or 0 and use the name consistently. --- meson.build | 4 +-- tools/meson-post-install.sh | 72 +++++++++++++++++++++++---------------------- 2 files changed, 39 insertions(+), 37 deletions(-) diff --git a/meson.build b/meson.build index 29da0b0504..ec2f5a94a8 100644 --- a/meson.build +++ b/meson.build @@ -906,10 +906,10 @@ meson.add_install_script( nm_pkgconfdir, nm_pkglibdir, nm_pkgstatedir, - enable_docs ? 'install_docs' : '', nm_mandir, - enable_ifcfg_rh ? 'create_network_scripts' : '', nm_sysconfdir, + enable_docs ? '1' : '0', + enable_ifcfg_rh ? '1' : '0', ) output = '\nSystem paths:\n' diff --git a/tools/meson-post-install.sh b/tools/meson-post-install.sh index aaf3576da4..4e8549a95e 100755 --- a/tools/meson-post-install.sh +++ b/tools/meson-post-install.sh @@ -1,55 +1,57 @@ #!/bin/sh -datadir=$1 -bindir=$2 -pkgconfdir=$3 -pkglibdir=$4 -pkgstatedir=$5 - -[ -n "$DESTDIR" ] && DESTDIR=${DESTDIR%%/}/ - -if [ -f "${DESTDIR}${datadir}/bash-completion/completions/nmcli-completion" ]; then - mv "${DESTDIR}${datadir}/bash-completion/completions/nmcli-completion" \ - "${DESTDIR}${datadir}/bash-completion/completions/nmcli" +nm_datadir="$1" +nm_bindir="$2" +nm_pkgconfdir="$3" +nm_pkglibdir="$4" +nm_pkgstatedir="$5" +nm_mandir="$6" +nm_sysconfdir="$7" +enable_docs="$8" +enable_ifcfg_rh="$9" + +[ -n "$DESTDIR" ] && DESTDIR="${DESTDIR%%/}/" + +if [ -f "${DESTDIR}${nm_datadir}/bash-completion/completions/nmcli-completion" ]; then + mv "${DESTDIR}${nm_datadir}/bash-completion/completions/nmcli-completion" \ + "${DESTDIR}${nm_datadir}/bash-completion/completions/nmcli" fi -if [ -x "${DESTDIR}${bindir}/nmtui" ]; then +if [ -x "${DESTDIR}${nm_bindir}/nmtui" ]; then for alias in nmtui-connect nmtui-edit nmtui-hostname; do - ln -sf nmtui "${DESTDIR}${bindir}/$alias" + ln -sf nmtui "${DESTDIR}${nm_bindir}/$alias" done fi -for dir in "${pkgconfdir}/conf.d" \ - "${pkgconfdir}/system-connections" \ - "${pkgconfdir}/dispatcher.d/no-wait.d" \ - "${pkgconfdir}/dispatcher.d/pre-down.d" \ - "${pkgconfdir}/dispatcher.d/pre-up.d" \ - "${pkgconfdir}/dnsmasq.d" \ - "${pkgconfdir}/dnsmasq-shared.d" \ - "${pkglibdir}/conf.d" \ - "${pkglibdir}/dispatcher.d/no-wait.d" \ - "${pkglibdir}/dispatcher.d/pre-down.d" \ - "${pkglibdir}/dispatcher.d/pre-up.d" \ - "${pkglibdir}/system-connections" \ - "${pkglibdir}/VPN"; do +for dir in "${nm_pkgconfdir}/conf.d" \ + "${nm_pkgconfdir}/system-connections" \ + "${nm_pkgconfdir}/dispatcher.d/no-wait.d" \ + "${nm_pkgconfdir}/dispatcher.d/pre-down.d" \ + "${nm_pkgconfdir}/dispatcher.d/pre-up.d" \ + "${nm_pkgconfdir}/dnsmasq.d" \ + "${nm_pkgconfdir}/dnsmasq-shared.d" \ + "${nm_pkglibdir}/conf.d" \ + "${nm_pkglibdir}/dispatcher.d/no-wait.d" \ + "${nm_pkglibdir}/dispatcher.d/pre-down.d" \ + "${nm_pkglibdir}/dispatcher.d/pre-up.d" \ + "${nm_pkglibdir}/system-connections" \ + "${nm_pkglibdir}/VPN"; do mkdir -p "${DESTDIR}${dir}" chmod 0755 "${DESTDIR}${dir}" done -mkdir -p "${DESTDIR}${pkgstatedir}" -chmod 0700 "${DESTDIR}${pkgstatedir}" +mkdir -p "${DESTDIR}${nm_pkgstatedir}" +chmod 0700 "${DESTDIR}${nm_pkgstatedir}" -if [ "$6" = install_docs ]; then - mandir=$7 +if [ "$enable_docs" = 1 ]; then for alias in nmtui-connect nmtui-edit nmtui-hostname; do - ln -f "${DESTDIR}${mandir}/man1/nmtui.1" "${DESTDIR}${mandir}/man1/${alias}.1" + ln -f "${DESTDIR}${nm_mandir}/man1/nmtui.1" "${DESTDIR}${nm_mandir}/man1/${alias}.1" done - ln -f "${DESTDIR}${mandir}/man5/NetworkManager.conf.5" "${DESTDIR}${mandir}/man5/nm-system-settings.conf.5" + ln -f "${DESTDIR}${nm_mandir}/man5/NetworkManager.conf.5" "${DESTDIR}${nm_mandir}/man5/nm-system-settings.conf.5" fi -if [ "$8" = create_network_scripts ]; then - sysconfdir=$9 - mkdir -p "${DESTDIR}${sysconfdir}/sysconfig/network-scripts" +if [ "$enable_ifcfg_rh" = 1 ]; then + mkdir -p "${DESTDIR}${nm_sysconfdir}/sysconfig/network-scripts" fi -- cgit v1.2.1