diff options
author | Karol Lewandowski <k.lewandowsk@samsung.com> | 2017-03-20 17:30:27 +0100 |
---|---|---|
committer | INSUN PYO <insun.pyo@samsung.com> | 2017-03-22 10:10:35 +0900 |
commit | 7cec0c49fe33351a8c3f856f4a2289eff68aa859 (patch) | |
tree | a916027be7c53f378db90ba1925a09e7005a8053 | |
parent | 1d1960f8b26f42ac93bed8d8af520d377dfff4a0 (diff) | |
download | systemd-7cec0c49fe33351a8c3f856f4a2289eff68aa859.tar.gz systemd-7cec0c49fe33351a8c3f856f4a2289eff68aa859.tar.bz2 systemd-7cec0c49fe33351a8c3f856f4a2289eff68aa859.zip |
packaging: Simplify kdbus setup for Tizen:Unified
This commit adds marker file to extension-kdbus package to signal that
kdbus should really be used only if this package is installed.
Additionally, build time is reduced by a half.
Change-Id: I6d27b7c15985b189432fc7ff54bb4693cf79be24
-rw-r--r-- | packaging/systemd.spec | 107 | ||||
-rw-r--r-- | src/core/busname.c | 7 | ||||
-rw-r--r-- | src/core/kmod-setup.c | 2 | ||||
-rw-r--r-- | src/shared/bus-util.c | 53 |
4 files changed, 44 insertions, 125 deletions
diff --git a/packaging/systemd.spec b/packaging/systemd.spec index 3dd40b4be2..9eb751554b 100644 --- a/packaging/systemd.spec +++ b/packaging/systemd.spec @@ -1,7 +1,3 @@ -# Do not create provides from extension .so files because the main package -# should anchor any reverse-dependencies -%global __provides_exclude_from ^(.*\\.extension-kdbus)$ - # "enable foo" will turn into --enable-foo or --disable-foo # depending "with_foo" macro %define enable() %{expand:%%{?with_%{1}:--enable-%{1}}%%{!?with_%{1}:--disable-%{1}}} @@ -27,9 +23,9 @@ Group: Base/Startup Source0: https://github.com/systemd/systemd/archive/v%{version}.tar.gz Source1: pamconsole-tmp.conf Source2: %{name}-rpmlintrc -Source1001: systemd.manifest Source3: 500.systemd_upgrade.sh Source4: test-runner.c +Source1001: systemd.manifest BuildRequires: gperf BuildRequires: intltool >= 0.40.0 BuildRequires: libacl-devel @@ -131,8 +127,6 @@ cp %{SOURCE4} . %build %autogen - -# Create kdbus extension first %configure \ --enable-kdbus \ %if ! %{WITH_RANDOMSEED} @@ -177,66 +171,6 @@ make %{?_smp_mflags} \ systemunitdir=%{_unitdir} \ userunitdir=%{_unitdir_user} -%make_install -mkdir -p extension-kdbus -mv %{buildroot}%{_prefix}/lib/systemd/systemd extension-kdbus/ -mv %{buildroot}%{_prefix}/lib/systemd/systemd-remount-fs extension-kdbus/ -mv %{buildroot}%{_prefix}/lib/systemd/systemd-shutdown extension-kdbus/ -mv %{buildroot}%{_prefix}/lib/systemd/system-generators/systemd-dbus1-generator extension-kdbus/ -mv %{buildroot}%{_prefix}/lib/systemd/system-generators/systemd-fstab-generator extension-kdbus/ -mv %{buildroot}%{_prefix}/lib/systemd/libsystemd-*.so extension-kdbus/ -mv %{buildroot}%{_libdir}/security/pam_systemd.so extension-kdbus/ - -%{__make} clean - - -# Support for generating separate packages with libraries generating coverage files -# WARNING: if coverage build is enabled, incremental builds will not work correctly. -# Use the option only to generate systemd-coverage packages. -%configure \ - --disable-kdbus \ -%if ! %{WITH_RANDOMSEED} - --disable-randomseed \ -%endif -%if ! %{?WITH_COREDUMP} - --disable-coredump \ -%endif -%if ! %{?WITH_BACKLIGHT} - --disable-backlight \ -%endif -%if ! %{?WITH_TIMEDATED} - --disable-timedated \ -%endif -%if ! %{WITH_RFKILL} - --disable-rfkill \ -%endif - --enable-compat-libs \ - --disable-hwdb \ - --disable-sysusers \ - --disable-firstboot \ - --disable-polkit \ - --disable-timesyncd \ - --disable-resolved \ - --disable-networkd \ -%if ! %{?WITH_MACHINED} - --disable-machined \ -%endif - --disable-importd \ - --disable-gcrypt \ - --libexecdir=%{_prefix}/lib \ - --docdir=%{_docdir}/systemd \ - --disable-static \ - --with-sysvinit-path= \ - --with-sysvrcnd-path= \ - --with-smack-run-label=System::Privileged \ -%if ! %{?with_multiuser} - --disable-logind \ -%endif - cc_cv_CFLAGS__flto=no -make %{?_smp_mflags} \ - systemunitdir=%{_unitdir} \ - userunitdir=%{_unitdir_user} - # compile test-runner for 'dbus-integration-test' framework %__cc %{_builddir}/%{name}-%{version}/test-runner.c -o %{_builddir}/%{name}-%{version}/systemd-tests @@ -256,17 +190,6 @@ cat <<EOF >> systemd.lang %lang(zh) /usr/lib/systemd/catalog/systemd.zh_TW.catalog EOF -# kdbus extension -pushd extension-kdbus -mv systemd %{buildroot}%{_prefix}/lib/systemd/systemd.extension-kdbus -mv systemd-remount-fs %{buildroot}%{_prefix}/lib/systemd/systemd-remount-fs.extension-kdbus -mv systemd-shutdown %{buildroot}%{_prefix}/lib/systemd/systemd-shutdown.extension-kdbus -mv systemd-dbus1-generator %{buildroot}%{_prefix}/lib/systemd/system-generators/systemd-dbus1-generator.extension-kdbus -mv systemd-fstab-generator %{buildroot}%{_prefix}/lib/systemd/system-generators/systemd-fstab-generator.extension-kdbus -for FILE in libsystemd-shared*; do mv "$FILE" "%{buildroot}%{_prefix}/lib/systemd/$FILE.extension-kdbus"; done -mv pam_systemd.so %{buildroot}%{_libdir}/security/pam_systemd.so.extension-kdbus -popd - # udev links /usr/bin/mkdir -p %{buildroot}/%{_sbindir} /usr/bin/ln -sf ../bin/udevadm %{buildroot}%{_sbindir}/udevadm @@ -347,12 +270,14 @@ install -m644 src/core/macros.systemd %{buildroot}%{_sysconfdir}/rpm/macros.syst rm -f %{buildroot}%{_prefix}/lib/rpm/macros.d/macros.systemd # Exclude ELF binaries -rm -f %{buildroot}/%{_prefix}/lib/systemd/system-generators/systemd-dbus1-generator rm -f %{buildroot}/%{_prefix}/lib/systemd/system-generators/systemd-debug-generator rm -f %{buildroot}/%{_prefix}/lib/systemd/system-generators/systemd-efi-boot-generator rm -f %{buildroot}/%{_prefix}/lib/systemd/system-generators/systemd-gpt-auto-generator rm -f %{buildroot}/%{_prefix}/lib/systemd/system-generators/systemd-hibernate-resume-generator +# Marker file for kdbus +touch %{buildroot}/%{_sysconfdir}/systemd/extension-kdbus + # Preapre tests for 'dbus-integration-test' framework install -D -m 755 %{_builddir}/%{name}-%{version}/systemd-tests %{buildroot}%{_prefix}/lib/dbus-tests/runner/systemd-tests mkdir -p %{buildroot}%{_prefix}/lib/dbus-tests/test-suites/systemd-tests/ @@ -618,10 +543,6 @@ fi %{_datadir}/upgrade/scripts/500.systemd_upgrade.sh -# remove kdbus extension file on legacy package -%exclude %{_prefix}/lib/systemd/systemd-remount-fs.extension-kdbus -%exclude %{_prefix}/lib/systemd/systemd-shutdown.extension-kdbus - %files -n libsystemd %manifest %{name}.manifest %if %{?with_multiuser} @@ -634,27 +555,11 @@ fi %{_libdir}/libnss_mymachines.so.2 %endif -%post extension-kdbus -pushd %{_prefix}/lib/systemd/ -mv systemd.extension-kdbus systemd -mv systemd-remount-fs.extension-kdbus systemd-remount-fs -mv systemd-shutdown.extension-kdbus systemd-shutdown -mv system-generators/systemd-dbus1-generator.extension-kdbus system-generators/systemd-dbus1-generator -mv system-generators/systemd-fstab-generator.extension-kdbus system-generators/systemd-fstab-generator -for FILE in libsystemd-shared*.so.extension-kdbus; do mv "$FILE" "${FILE%.extension-kdbus}"; done -popd -mv %{_libdir}/security/pam_systemd.so.extension-kdbus %{_libdir}/security/pam_systemd.so - %files extension-kdbus %manifest %{name}.manifest -%{_prefix}/lib/systemd/systemd.extension-kdbus -%{_prefix}/lib/systemd/systemd-remount-fs.extension-kdbus -%{_prefix}/lib/systemd/systemd-shutdown.extension-kdbus -%{_prefix}/lib/systemd/system-generators/systemd-dbus1-generator.extension-kdbus -%{_prefix}/lib/systemd/system-generators/systemd-fstab-generator.extension-kdbus -%{_prefix}/lib/systemd/libsystemd-shared*.so.extension-kdbus -%{_libdir}/security/pam_systemd.so.extension-kdbus +%{_sysconfdir}/systemd/extension-kdbus %{_prefix}/lib/systemd/user/busnames.target +%{_prefix}/lib/systemd/system-generators/systemd-dbus1-generator %{_prefix}/lib/systemd/user-generators/systemd-dbus1-generator %files devel diff --git a/src/core/busname.c b/src/core/busname.c index f03a95c24e..77704a1155 100644 --- a/src/core/busname.c +++ b/src/core/busname.c @@ -998,12 +998,7 @@ static int busname_get_timeout(Unit *u, usec_t *timeout) { } static bool busname_supported(void) { - static int supported = -1; - - if (supported < 0) - supported = is_kdbus_available(); - - return supported; + return is_kdbus_available(); } static int busname_control_pid(Unit *u) { diff --git a/src/core/kmod-setup.c b/src/core/kmod-setup.c index 3503db52ed..7d61a34cc6 100644 --- a/src/core/kmod-setup.c +++ b/src/core/kmod-setup.c @@ -64,8 +64,10 @@ int kmod_setup(void) { /* this should never be a module */ { "unix", "/proc/net/unix", true, true, NULL }, +#ifdef ENABLE_KDBUS /* IPC is needed before we bring up any other services */ { "kdbus", "/sys/fs/kdbus", false, false, is_kdbus_wanted }, +#endif #ifdef HAVE_LIBIPTC /* netfilter is needed by networkd, nspawn among others, and cannot be autoloaded */ diff --git a/src/shared/bus-util.c b/src/shared/bus-util.c index 8a5e057406..0c08250053 100644 --- a/src/shared/bus-util.c +++ b/src/shared/bus-util.c @@ -1506,37 +1506,54 @@ int bus_path_decode_unique(const char *path, const char *prefix, char **ret_send } bool is_kdbus_wanted(void) { - _cleanup_free_ char *value = NULL; #ifdef ENABLE_KDBUS - const bool configured = true; -#else - const bool configured = false; -#endif + static int wanted = -1; - int r; + if (wanted < 0) { + _cleanup_free_ char *value = NULL; - if (get_proc_cmdline_key("kdbus", NULL) > 0) - return true; + if (get_proc_cmdline_key("kdbus", NULL) > 0) { + wanted = true; + goto finish; + } - r = get_proc_cmdline_key("kdbus=", &value); - if (r <= 0) - return configured; + if (get_proc_cmdline_key("kdbus=", &value) > 0) { + wanted = parse_boolean(value) == 1; + goto finish; + } - return parse_boolean(value) == 1; + wanted = access("/etc/systemd/extension-kdbus", F_OK) == 0; + } + +finish: + return wanted ? true : false; +#else + return false; +#endif } bool is_kdbus_available(void) { - _cleanup_close_ int fd = -1; - struct kdbus_cmd cmd = { .size = sizeof(cmd), .flags = KDBUS_FLAG_NEGOTIATE }; +#ifdef ENABLE_KDBUS + static int available = -1; if (!is_kdbus_wanted()) return false; - fd = open("/sys/fs/kdbus/control", O_RDWR | O_CLOEXEC | O_NONBLOCK | O_NOCTTY); - if (fd < 0) - return false; + if (available < 0) { + _cleanup_close_ int fd = -1; + struct kdbus_cmd cmd = { .size = sizeof(cmd), .flags = KDBUS_FLAG_NEGOTIATE }; - return ioctl(fd, KDBUS_CMD_BUS_MAKE, &cmd) >= 0; + fd = open("/sys/fs/kdbus/control", O_RDWR | O_CLOEXEC | O_NONBLOCK | O_NOCTTY); + if (fd < 0) + available = false; + else + available = ioctl(fd, KDBUS_CMD_BUS_MAKE, &cmd) >= 0; + } + + return available ? true : false; +#else + return false; +#endif } int bus_property_get_rlimit( |