2014-09-04 14:31 GMT+02:00 Zbigniew Jędrzejewski-Szmek <zbys...@in.waw.pl>:
> On Thu, Sep 04, 2014 at 02:14:23PM +0200, Michael Biebl wrote:
>> Hi,
>>
>> 2014-09-04 6:16 GMT+02:00 Zbigniew Jędrzejewski-Szmek <zbys...@in.waw.pl>:
>> > On Wed, Sep 03, 2014 at 11:51:58PM +0200, Michael Biebl wrote:
>>
>> >>  define add-wants
>> >> -     [ -z "$$what" ] || ( \
>> >> +     [ -z "$$what" ] || ! echo $$what | grep -q '[^[:space:]]' || ( \
>> > Maybe we could use something simpler like
>> >         [[ $what =~ ^[[:space:]]*$ ]] || ( \
>>
>> I didn't want to use a bash specific feature here, since /bin/sh is
>> not guaranteed to point to bash.
>> So I guess using grep is the safer choice and I'd like to keep that as is.
> What about folding the first case into the grep pattern then?

Since I didn't think this improved readability, I kept this as-is for now.

>
>> >> +if ENABLE_KDBUS
>> >> +dist_systemunit_DATA += \
>> >> +     units/busnames.target
>> >> +endif
>> > This is quite intrusive. Maybe another layer of indirection would help:
>>
>>
>>
>> >> +if ENABLE_KDBUS
>> >>  BUSNAMES_TARGET_WANTS += \
>> >>       org.freedesktop.hostname1.busname
>> >> +endif
>> > And similarly with this one: if the line in add-wants using
>> > $(BUSNAMES_TARGET_WANTS) could be made conditional, it would be
>> > the only place to modify.
>>
>>
>> I used that, since this was already used for
>> org.freedesktop.systemd1.busname, i.e.
>>
>> if ENABLE_KDBUS
>> dist_systemunit_DATA += \
>>         units/org.freedesktop.systemd1.busname
>>
>> BUSNAMES_TARGET_WANTS += \
>>         org.freedesktop.systemd1.busname
>> endif
>>
>>
>> Do you want me to rework everything, including
>> org.freedesktop.systemd1.busname, based on your suggestion?
> Yes, please.

Updated patch attached


-- 
Why is it that all of the instruments seeking intelligent life in the
universe are pointed away from Earth?
From 3bc9a2554fef2fcc83ac72645a75b0f5da372980 Mon Sep 17 00:00:00 2001
From: Michael Biebl <bi...@debian.org>
Date: Wed, 3 Sep 2014 23:34:29 +0200
Subject: [PATCH] build: don't install busname units and target if kdbus
 support is disabled

When creating the wants symlinks, we also need to check if the string
contains any non-space characters, simply testing for a string with
length zero is not sufficient. This is due to how automake composes the
variables.

E.g. the generated Makefile looks something like this for
BUSNAMES_TARGET_WANTS:

BUSNAMES_TARGET_WANTS = $(am__append_195) $(am__append_200) \
        $(am__append_208) $(am__append_220) $(am__append_243) \
        $(am__append_254) $(am__append_286)

If kdbus support is disabled, the $what variable in
install-target-wants-hook is set to "       ".
---
 Makefile.am | 47 ++++++++++++++++++++++++++++++++++-------------
 1 file changed, 34 insertions(+), 13 deletions(-)

diff --git a/Makefile.am b/Makefile.am
index 58e5ce6..488e2f8 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -140,6 +140,7 @@ nodist_pkgsysconf_DATA =
 dist_pkgdata_DATA =
 dist_dbuspolicy_DATA =
 dist_dbussystemservice_DATA =
+dist_systemunit_DATA_busnames =
 check_PROGRAMS =
 check_DATA =
 tests=
@@ -263,14 +264,16 @@ install-target-wants-hook:
 	what="$(MULTI_USER_TARGET_WANTS)" && wants=multi-user.target && dir=$(systemunitdir) && $(add-wants)
 	what="$(SYSINIT_TARGET_WANTS)" && wants=sysinit.target && dir=$(systemunitdir) && $(add-wants)
 	what="$(SOCKETS_TARGET_WANTS)" && wants=sockets.target && dir=$(systemunitdir) && $(add-wants)
-	what="$(BUSNAMES_TARGET_WANTS)" && wants=busnames.target && dir=$(systemunitdir) && $(add-wants)
 	what="$(TIMERS_TARGET_WANTS)" && wants=timers.target && dir=$(systemunitdir) && $(add-wants)
 	what="$(SLICES_TARGET_WANTS)" && wants=slices.target && dir=$(systemunitdir) && $(add-wants)
 	what="$(USER_SOCKETS_TARGET_WANTS)" && wants=sockets.target && dir=$(userunitdir) && $(add-wants)
+
+install-target-wants-hook-busnames:
+	what="$(BUSNAMES_TARGET_WANTS)" && wants=busnames.target && dir=$(systemunitdir) && $(add-wants)
 	what="$(USER_BUSNAMES_TARGET_WANTS)" && wants=busnames.target && dir=$(userunitdir) && $(add-wants)
 
 define add-wants
-	[ -z "$$what" ] || ( \
+	[ -z "$$what" ] || ! echo $$what | grep -q '[^[:space:]]' || ( \
 	  dir=$(DESTDIR)$$dir/$$wants.wants && \
 	  $(MKDIR_P) -m 0755 $$dir && \
 	  cd $$dir && \
@@ -316,6 +319,11 @@ INSTALL_EXEC_HOOKS += \
 	install-aliases-hook \
 	install-touch-usr-hook
 
+if ENABLE_KDBUS
+INSTALL_EXEC_HOOKS += \
+	install-target-wants-hook-busnames
+endif
+
 # ------------------------------------------------------------------------------
 AM_V_M4 = $(AM_V_M4_$(V))
 AM_V_M4_ = $(AM_V_M4_$(AM_DEFAULT_VERBOSITY))
@@ -463,7 +471,6 @@ dist_systemunit_DATA = \
 	units/sigpwr.target \
 	units/sleep.target \
 	units/sockets.target \
-	units/busnames.target \
 	units/timers.target \
 	units/paths.target \
 	units/suspend.target \
@@ -491,6 +498,14 @@ dist_systemunit_DATA = \
 	units/system-update.target \
 	units/initrd-switch-root.target
 
+if ENABLE_KDBUS
+dist_systemunit_DATA += \
+	$(dist_systemunit_DATA_busnames)
+endif
+
+dist_systemunit_DATA_busnames += \
+	units/busnames.target
+
 nodist_systemunit_DATA = \
 	units/getty@.service \
 	units/serial-getty@.service \
@@ -4486,7 +4501,7 @@ rootlibexec_PROGRAMS += \
 nodist_systemunit_DATA += \
 	units/systemd-hostnamed.service
 
-dist_systemunit_DATA += \
+dist_systemunit_DATA_busnames += \
 	units/org.freedesktop.hostname1.busname
 
 dist_dbuspolicy_DATA += \
@@ -4529,13 +4544,11 @@ EXTRA_DIST += \
 	units/systemd-hostnamed.service.in
 
 # ------------------------------------------------------------------------------
-if ENABLE_KDBUS
-dist_systemunit_DATA += \
+dist_systemunit_DATA_busnames += \
 	units/org.freedesktop.systemd1.busname
 
 BUSNAMES_TARGET_WANTS += \
 	org.freedesktop.systemd1.busname
-endif
 
 # ------------------------------------------------------------------------------
 if ENABLE_LOCALED
@@ -4550,7 +4563,7 @@ systemd_localed_LDADD = \
 nodist_systemunit_DATA += \
 	units/systemd-localed.service
 
-dist_systemunit_DATA += \
+dist_systemunit_DATA_busnames += \
 	units/org.freedesktop.locale1.busname
 
 rootlibexec_PROGRAMS += \
@@ -4625,7 +4638,7 @@ dist_dbuspolicy_DATA += \
 nodist_systemunit_DATA += \
 	units/systemd-timedated.service
 
-dist_systemunit_DATA += \
+dist_systemunit_DATA_busnames += \
 	units/org.freedesktop.timedate1.busname
 
 polkitpolicy_files += \
@@ -4787,7 +4800,9 @@ nodist_systemunit_DATA += \
 	units/systemd-machined.service
 
 dist_systemunit_DATA += \
-	units/machine.slice \
+	units/machine.slice
+
+dist_systemunit_DATA_busnames += \
 	units/org.freedesktop.machine1.busname
 
 dist_dbussystemservice_DATA += \
@@ -4897,7 +4912,7 @@ rootlibexec_PROGRAMS += \
 nodist_systemunit_DATA += \
 	units/systemd-resolved.service
 
-dist_systemunit_DATA += \
+dist_systemunit_DATA_busnames += \
 	units/org.freedesktop.resolve1.busname
 
 dist_dbuspolicy_DATA += \
@@ -5289,7 +5304,9 @@ nodist_systemunit_DATA += \
 	units/systemd-user-sessions.service
 
 dist_systemunit_DATA += \
-	units/user.slice \
+	units/user.slice
+
+dist_systemunit_DATA_busnames += \
 	units/org.freedesktop.login1.busname
 
 dist_dbussystemservice_DATA += \
@@ -5903,7 +5920,6 @@ SYSTEM_UNIT_ALIASES += \
 USER_UNIT_ALIASES += \
 	$(systemunitdir)/shutdown.target shutdown.target \
 	$(systemunitdir)/sockets.target sockets.target \
-	$(systemunitdir)/busnames.target busnames.target \
 	$(systemunitdir)/timers.target timers.target \
 	$(systemunitdir)/paths.target paths.target \
 	$(systemunitdir)/bluetooth.target bluetooth.target \
@@ -5911,6 +5927,11 @@ USER_UNIT_ALIASES += \
 	$(systemunitdir)/sound.target sound.target \
 	$(systemunitdir)/smartcard.target smartcard.target
 
+if ENABLE_KDBUS
+USER_UNIT_ALIASES += \
+	$(systemunitdir)/busnames.target busnames.target
+endif
+
 GENERAL_ALIASES += \
 	$(systemunitdir)/remote-fs.target $(pkgsysconfdir)/system/multi-user.target.wants/remote-fs.target \
 	$(systemunitdir)/getty@.service $(pkgsysconfdir)/system/getty.target.wants/getty@tty1.service \
-- 
2.1.0

_______________________________________________
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel

Reply via email to