Sync configuration option with TIZEN OS ones
[scm/bb/meta-tizen.git] / meta-tizen-common-base / recipes-core / systemd / systemd_git.bb
1 SUMMARY = "System and service manager for Linux, replacing SysVinit"
2 HOMEPAGE = "http://www.freedesktop.org/wiki/Software/systemd"
3
4 LICENSE = "GPLv2 & LGPLv2.1 & MIT"
5 LIC_FILES_CHKSUM = "file://LICENSE.GPL2;md5=751419260aa954499f7abaabaa882bbe \
6                     file://LICENSE.LGPL2.1;md5=4fbd65380cdd255951079008b364516c \
7                     file://LICENSE.MIT;md5=544799d0b492f119fa04641d1b8868ed"
8
9 PROVIDES = "udev"
10
11 PE = "1"
12
13 DEPENDS = "kmod docbook-sgml-dtd-4.1-native intltool-native gperf-native acl readline dbus libcap libcgroup glib-2.0 qemu-native util-linux"
14 DEPENDS += "${@bb.utils.contains('DISTRO_FEATURES', 'pam', 'libpam', '', d)}"
15
16 SECTION = "base/shell"
17
18 inherit gtk-doc useradd pkgconfig autotools perlnative update-rc.d update-alternatives qemu systemd ptest gettext
19
20 SRCREV = "1c6d7a3b259467df3c02c1fb0bb4c57d70192d15"
21
22 PV = "216+git${SRCPV}"
23
24 SRC_URI = "git://review.tizen.org/platform/upstream/systemd;protocol=git;tag=1c6d7a3b259467df3c02c1fb0bb4c57d70192d15;nobranch=1 \
25            file://touchscreen.rules \
26            file://00-create-volatile.conf \
27            file://init \
28            file://run-ptest \
29            "
30
31 S = "${WORKDIR}/git"
32
33 SRC_URI_append_libc-uclibc = "\
34                              file://systemd-pam-fix-getty-unit.patch \
35                             "
36 LDFLAGS_append_libc-uclibc = " -lrt"
37
38 GTKDOC_DOCDIR = "${S}/docs/"
39
40 PACKAGECONFIG ??= "xz"
41 PACKAGECONFIG[journal-upload] = "--enable-libcurl,--disable-libcurl,curl"
42 # Sign the journal for anti-tampering
43 PACKAGECONFIG[gcrypt] = "--enable-gcrypt,--disable-gcrypt,libgcrypt"
44 # regardless of PACKAGECONFIG, libgcrypt is always required to expand
45 # the AM_PATH_LIBGCRYPT autoconf macro
46 DEPENDS += "libgcrypt"
47 # Compress the journal
48 PACKAGECONFIG[xz] = "--enable-xz,--disable-xz,xz"
49 PACKAGECONFIG[cryptsetup] = "--enable-libcryptsetup,--disable-libcryptsetup,cryptsetup"
50 PACKAGECONFIG[microhttpd] = "--enable-microhttpd,--disable-microhttpd,libmicrohttpd"
51 PACKAGECONFIG[elfutils] = "--enable-elfutils,--disable-elfutils,elfutils"
52 PACKAGECONFIG[resolved] = "--enable-resolved,--disable-resolved"
53 PACKAGECONFIG[networkd] = "--enable-networkd,--disable-networkd"
54
55 CACHED_CONFIGUREVARS = "ac_cv_path_KILL=${base_bindir}/kill"
56
57 # Helper variables to clarify locations.  This mirrors the logic in systemd's
58 # build system.
59 rootprefix ?= "${base_prefix}"
60 rootlibdir ?= "${base_libdir}"
61 rootlibexecdir = "${rootprefix}/lib"
62
63 # The gtk+ tools should get built as a separate recipe e.g. systemd-tools
64 EXTRA_OECONF = " --with-rootprefix=${rootprefix} \
65                  --with-rootlibdir=${rootlibdir} \
66                  --with-roothomedir=${ROOT_HOME} \
67                  ${@bb.utils.contains('DISTRO_FEATURES', 'pam', '--enable-pam', '--disable-pam', d)} \
68                  --disable-manpages \
69                  --disable-coredump \
70                  --disable-introspection \
71                  --disable-kdbus \
72                  --enable-split-usr \
73                  --without-python \
74                  --with-sysvrcnd-path= \
75                  --with-firmware-path=/lib/firmware \
76                  --enable-compat-libs \
77                  ac_cv_path_KILL=${base_bindir}/kill \
78                "
79
80 EXTRA_OECONF += " --enable-bootchart --disable-sysusers --disable-firstboot --disable-timesyncd --disable-resolved --disable-networkd --libexecdir=${prefix}/lib --docdir=${prefix}/share/doc/packages/systemd --disable-static --disable-libcurl --with-sysvinit-path=  --with-smack-run-label=System cc_cv_CFLAGS__flto=no"
81
82
83
84 # uclibc does not have NSS
85 EXTRA_OECONF_append_libc-uclibc = " --disable-myhostname "
86
87 do_configure_prepend() {
88         export CPP="${HOST_PREFIX}cpp ${TOOLCHAIN_OPTIONS} ${HOST_CC_ARCH}"
89         export NM="${HOST_PREFIX}gcc-nm"
90         export AR="${HOST_PREFIX}gcc-ar"
91         export RANLIB="${HOST_PREFIX}gcc-ranlib"
92         export KMOD="${base_bindir}/kmod"
93         if [ -d ${S}/units.pre_sed ] ; then
94                 cp -r ${S}/units.pre_sed ${S}/units
95         else
96                 cp -r ${S}/units ${S}/units.pre_sed
97         fi
98         sed -i '/ln --relative --help/d' ${S}/configure.ac
99         sed -i -e 's:\$(LN_S) --relative -f:lnr:g' ${S}/Makefile.am
100         sed -i -e 's:\$(LN_S) --relative:lnr:g' ${S}/Makefile.am
101 }
102
103 do_install() {
104         autotools_do_install
105         install -d ${D}/${base_sbindir}
106         # Provided by a separate recipe
107         rm ${D}${systemd_unitdir}/system/serial-getty* -f
108
109         # Provide support for initramfs
110         [ ! -e ${D}/init ] && ln -s ${rootlibexecdir}/systemd/systemd ${D}/init
111         [ ! -e ${D}/${base_sbindir}/udevd ] && ln -s ${rootlibexecdir}/systemd/systemd-udevd ${D}/${base_sbindir}/udevd
112
113         # Create machine-id
114         # 20:12 < mezcalero> koen: you have three options: a) run systemd-machine-id-setup at install time, b) have / read-only and an empty file there (for stateless) and c) boot with / writable
115         touch ${D}${sysconfdir}/machine-id
116
117         install -m 0644 ${WORKDIR}/*.rules ${D}${sysconfdir}/udev/rules.d/
118
119         install -m 0644 ${WORKDIR}/00-create-volatile.conf ${D}${sysconfdir}/tmpfiles.d/
120
121         if ${@bb.utils.contains('DISTRO_FEATURES','sysvinit','true','false',d)}; then
122                 install -d ${D}${sysconfdir}/init.d
123                 install -m 0755 ${WORKDIR}/init ${D}${sysconfdir}/init.d/systemd-udevd
124                 sed -i s%@UDEVD@%${rootlibexecdir}/systemd/systemd-udevd% ${D}${sysconfdir}/init.d/systemd-udevd
125         fi
126
127         # Move libgudev back to ${rootlibdir} to keep backward compatibility
128         [ ${rootlibdir} != ${libdir} ] && mv -t ${D}${rootlibdir} ${D}${libdir}/libgudev*
129
130         # Delete journal README, as log can be symlinked inside volatile.
131         rm -f ${D}/${localstatedir}/log/README
132         rm -rf ${D}/${localstatedir}/log
133
134
135         # Create symlinks for systemd-update-utmp-runlevel.service
136         install -d ${D}${systemd_unitdir}/system/graphical.target.wants
137         install -d ${D}${systemd_unitdir}/system/multi-user.target.wants
138         install -d ${D}${systemd_unitdir}/system/poweroff.target.wants
139         install -d ${D}${systemd_unitdir}/system/reboot.target.wants
140         install -d ${D}${systemd_unitdir}/system/rescue.target.wants
141         ln -sf ../systemd-update-utmp-runlevel.service ${D}${systemd_unitdir}/system/graphical.target.wants/systemd-update-utmp-runlevel.service
142         ln -sf ../systemd-update-utmp-runlevel.service ${D}${systemd_unitdir}/system/multi-user.target.wants/systemd-update-utmp-runlevel.service
143         ln -sf ../systemd-update-utmp-runlevel.service ${D}${systemd_unitdir}/system/poweroff.target.wants/systemd-update-utmp-runlevel.service
144         ln -sf ../systemd-update-utmp-runlevel.service ${D}${systemd_unitdir}/system/reboot.target.wants/systemd-update-utmp-runlevel.service
145         ln -sf ../systemd-update-utmp-runlevel.service ${D}${systemd_unitdir}/system/rescue.target.wants/systemd-update-utmp-runlevel.service
146
147         # Enable journal to forward message to syslog daemon
148         sed -i -e 's/.*ForwardToSyslog.*/ForwardToSyslog=yes/' ${D}${sysconfdir}/systemd/journald.conf
149 }
150
151 do_install_ptest () {
152        install -d ${D}${PTEST_PATH}/test
153        cp -rf ${S}/test/* ${D}${PTEST_PATH}/test
154        install -m 0755  ${B}/test-udev ${D}${PTEST_PATH}/
155        install -d ${D}${PTEST_PATH}/build-aux
156        cp ${S}/build-aux/test-driver ${D}${PTEST_PATH}/build-aux/
157        cp -rf ${B}/rules ${D}${PTEST_PATH}/
158        # This directory needs to be there for udev-test.pl to work.
159        install -d ${D}${libdir}/udev/rules.d
160        cp ${B}/Makefile ${D}${PTEST_PATH}/
161        cp ${S}/test/sys.tar.xz ${D}${PTEST_PATH}/test
162        sed -i 's/"tree"/"ls"/' ${D}${PTEST_PATH}/test/udev-test.pl
163        sed -i 's#${S}#${PTEST_PATH}#g' ${D}${PTEST_PATH}/Makefile
164        sed -i 's#${B}#${PTEST_PATH}#g' ${D}${PTEST_PATH}/Makefile
165 }
166
167 python populate_packages_prepend (){
168     systemdlibdir = d.getVar("rootlibdir", True)
169     do_split_packages(d, systemdlibdir, '^lib(.*)\.so\.*', 'lib%s', 'Systemd %s library', extra_depends='', allow_links=True)
170 }
171 PACKAGES_DYNAMIC += "^lib(udev|gudev|systemd).*"
172
173 PACKAGES =+ "${PN}-gui ${PN}-vconsole-setup ${PN}-initramfs ${PN}-analyze ${PN}-kernel-install \
174              ${PN}-rpm-macros ${PN}-binfmt ${PN}-pam ${PN}-zsh"
175
176 SYSTEMD_PACKAGES = "${PN}-binfmt"
177 SYSTEMD_SERVICE_${PN}-binfmt = "systemd-binfmt.service"
178
179 USERADD_PACKAGES = "${PN}"
180 USERADD_PARAM_${PN} += "--system systemd-journal-gateway"
181 GROUPADD_PARAM_${PN} = "-r lock; -r systemd-journal"
182
183 FILES_${PN}-analyze = "${bindir}/systemd-analyze"
184
185 FILES_${PN}-initramfs = "/init"
186 RDEPENDS_${PN}-initramfs = "${PN}"
187
188 # The test cases need perl and bash to run correctly.
189 RDEPENDS_${PN}-ptest += "perl bash"
190 FILES_${PN}-ptest += "${libdir}/udev/rules.d"
191
192 FILES_${PN}-dbg += "${libdir}/systemd/ptest/.debug"
193
194 FILES_${PN}-gui = "${bindir}/systemadm"
195
196 FILES_${PN}-vconsole-setup = "${rootlibexecdir}/systemd/systemd-vconsole-setup \
197                               ${systemd_unitdir}/system/systemd-vconsole-setup.service \
198                               ${systemd_unitdir}/system/sysinit.target.wants/systemd-vconsole-setup.service"
199
200 FILES_${PN}-kernel-install = "${bindir}/kernel-install \
201                               ${sysconfdir}/kernel/ \
202                               ${exec_prefix}/lib/kernel \
203                              "
204 FILES_${PN}-rpm-macros = "${exec_prefix}/lib/rpm \
205                          "
206
207 FILES_${PN}-zsh = "${datadir}/zsh/site-functions"
208
209 FILES_${PN}-binfmt = "${sysconfdir}/binfmt.d/ \
210                       ${exec_prefix}/lib/binfmt.d \
211                       ${rootlibexecdir}/systemd/systemd-binfmt \
212                       ${systemd_unitdir}/system/proc-sys-fs-binfmt_misc.* \
213                       ${systemd_unitdir}/system/systemd-binfmt.service"
214 RRECOMMENDS_${PN}-binfmt = "kernel-module-binfmt-misc"
215
216 RRECOMMENDS_${PN}-vconsole-setup = "kbd kbd-consolefonts kbd-keymaps"
217
218 CONFFILES_${PN} = "${sysconfdir}/systemd/journald.conf \
219                 ${sysconfdir}/systemd/logind.conf \
220                 ${sysconfdir}/systemd/system.conf \
221                 ${sysconfdir}/systemd/user.conf"
222
223 FILES_${PN} = " ${base_bindir}/* \
224                 ${datadir}/bash-completion \
225                 ${datadir}/dbus-1/services \
226                 ${datadir}/dbus-1/system-services \
227                 ${datadir}/polkit-1 \
228                 ${datadir}/${BPN} \
229                 ${datadir}/factory \
230                 ${sysconfdir}/bash_completion.d/ \
231                 ${sysconfdir}/dbus-1/ \
232                 ${sysconfdir}/machine-id \
233                 ${sysconfdir}/modules-load.d/ \
234                 ${sysconfdir}/sysctl.d/ \
235                 ${sysconfdir}/systemd/ \
236                 ${sysconfdir}/tmpfiles.d/ \
237                 ${sysconfdir}/xdg/ \
238                 ${sysconfdir}/init.d/README \
239                 ${rootlibexecdir}/systemd/* \
240                 ${systemd_unitdir}/* \
241                 ${base_libdir}/security/*.so \
242                 ${libdir}/libnss_* \
243                 /cgroup \
244                 ${bindir}/systemd* \
245                 ${bindir}/busctl \
246                 ${bindir}/localectl \
247                 ${bindir}/hostnamectl \
248                 ${bindir}/timedatectl \
249                 ${bindir}/bootctl \
250                 ${bindir}/kernel-install \
251                 ${exec_prefix}/lib/tmpfiles.d/*.conf \
252                 ${exec_prefix}/lib/systemd \
253                 ${exec_prefix}/lib/modules-load.d \
254                 ${exec_prefix}/lib/sysctl.d \
255                 ${exec_prefix}/lib/sysusers.d \
256                 ${localstatedir} \
257                 /lib/udev/rules.d/70-uaccess.rules \
258                 /lib/udev/rules.d/71-seat.rules \
259                 /lib/udev/rules.d/73-seat-late.rules \
260                 /lib/udev/rules.d/99-systemd.rules \
261                 ${@bb.utils.contains('DISTRO_FEATURES', 'pam', '${sysconfdir}/pam.d', '', d)} \
262                "
263
264 FILES_${PN}-dbg += "${rootlibdir}/.debug ${systemd_unitdir}/.debug ${systemd_unitdir}/*/.debug ${base_libdir}/security/.debug/"
265 FILES_${PN}-dev += "${base_libdir}/security/*.la ${datadir}/dbus-1/interfaces/ ${sysconfdir}/rpm/macros.systemd"
266
267 RDEPENDS_${PN} += "kmod dbus util-linux-mount udev (= ${EXTENDPKGV})"
268 RDEPENDS_${PN} += "volatile-binds"
269
270 RRECOMMENDS_${PN} += "systemd-serialgetty systemd-compat-units udev-hwdb\
271                       util-linux-agetty \
272                       util-linux-fsck e2fsprogs-e2fsck \
273                       kernel-module-autofs4 kernel-module-unix kernel-module-ipv6 os-release \
274 "
275
276 PACKAGES =+ "udev-dbg udev udev-hwdb"
277
278 FILES_udev-dbg += "/lib/udev/.debug"
279
280 RPROVIDES_udev = "hotplug"
281
282 RDEPENDS_udev-hwdb += "udev"
283
284 FILES_udev += "${base_sbindir}/udevd \
285                ${rootlibexecdir}/systemd/systemd-udevd \
286                ${rootlibexecdir}/udev/accelerometer \
287                ${rootlibexecdir}/udev/ata_id \
288                ${rootlibexecdir}/udev/cdrom_id \
289                ${rootlibexecdir}/udev/collect \
290                ${rootlibexecdir}/udev/findkeyboards \
291                ${rootlibexecdir}/udev/keyboard-force-release.sh \
292                ${rootlibexecdir}/udev/keymap \
293                ${rootlibexecdir}/udev/mtd_probe \
294                ${rootlibexecdir}/udev/scsi_id \
295                ${rootlibexecdir}/udev/v4l_id \
296                ${rootlibexecdir}/udev/keymaps \
297                ${rootlibexecdir}/udev/rules.d/4*.rules \
298                ${rootlibexecdir}/udev/rules.d/5*.rules \
299                ${rootlibexecdir}/udev/rules.d/6*.rules \
300                ${rootlibexecdir}/udev/rules.d/70-power-switch.rules \
301                ${rootlibexecdir}/udev/rules.d/75*.rules \
302                ${rootlibexecdir}/udev/rules.d/78*.rules \
303                ${rootlibexecdir}/udev/rules.d/8*.rules \
304                ${rootlibexecdir}/udev/rules.d/95*.rules \
305                ${sysconfdir}/udev \
306                ${sysconfdir}/init.d/systemd-udevd \
307                ${systemd_unitdir}/system/*udev* \
308                ${systemd_unitdir}/system/*.wants/*udev* \
309                ${base_bindir}/udevadm \
310                ${datadir}/bash-completion/completions/udevadm \
311               "
312
313 FILES_udev-hwdb = "${rootlibexecdir}/udev/hwdb.d"
314
315 INITSCRIPT_PACKAGES = "udev"
316 INITSCRIPT_NAME_udev = "systemd-udevd"
317 INITSCRIPT_PARAMS_udev = "start 03 S ."
318
319 python __anonymous() {
320     if not bb.utils.contains('DISTRO_FEATURES', 'sysvinit', True, False, d):
321         d.setVar("INHIBIT_UPDATERCD_BBCLASS", "1")
322 }
323
324 # TODO:
325 # u-a for runlevel and telinit
326
327 ALTERNATIVE_${PN} = "init halt reboot shutdown poweroff runlevel"
328
329 ALTERNATIVE_TARGET[init] = "${rootlibexecdir}/systemd/systemd"
330 ALTERNATIVE_LINK_NAME[init] = "${base_sbindir}/init"
331 ALTERNATIVE_PRIORITY[init] ?= "300"
332
333 ALTERNATIVE_TARGET[halt] = "${base_bindir}/systemctl"
334 ALTERNATIVE_LINK_NAME[halt] = "${base_sbindir}/halt"
335 ALTERNATIVE_PRIORITY[halt] ?= "300"
336
337 ALTERNATIVE_TARGET[reboot] = "${base_bindir}/systemctl"
338 ALTERNATIVE_LINK_NAME[reboot] = "${base_sbindir}/reboot"
339 ALTERNATIVE_PRIORITY[reboot] ?= "300"
340
341 ALTERNATIVE_TARGET[shutdown] = "${base_bindir}/systemctl"
342 ALTERNATIVE_LINK_NAME[shutdown] = "${base_sbindir}/shutdown"
343 ALTERNATIVE_PRIORITY[shutdown] ?= "300"
344
345 ALTERNATIVE_TARGET[poweroff] = "${base_bindir}/systemctl"
346 ALTERNATIVE_LINK_NAME[poweroff] = "${base_sbindir}/poweroff"
347 ALTERNATIVE_PRIORITY[poweroff] ?= "300"
348
349 ALTERNATIVE_TARGET[runlevel] = "${base_bindir}/systemctl"
350 ALTERNATIVE_LINK_NAME[runlevel] = "${base_sbindir}/runlevel"
351 ALTERNATIVE_PRIORITY[runlevel] ?= "300"
352
353 pkg_postinst_udev-hwdb () {
354         if test -n "$D"; then
355                 ${@qemu_run_binary(d, '$D', '${base_bindir}/udevadm')} hwdb --update \
356                         --root $D
357         else
358                 udevadm hwdb --update
359         fi
360 }
361
362 pkg_prerm_udev-hwdb () {
363         if test -n "$D"; then
364                 exit 1
365         fi
366
367         rm -f ${sysconfdir}/udev/hwdb.bin
368 }
369
370 # As this recipe builds udev, respect systemd being in DISTRO_FEATURES so
371 # that we don't build both udev and systemd in world builds.
372 python () {
373     if not bb.utils.contains ('DISTRO_FEATURES', 'systemd', True, False, d):
374         raise bb.parse.SkipPackage("'systemd' not in DISTRO_FEATURES")
375 }