summaryrefslogtreecommitdiffstats
path: root/core/modules/systemd/module.build
blob: ff0311e330c82a7ac683c1d71fd0818a1727949e (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
#!/bin/bash
#tool/distro specific functions for fetching, building and installing dependencies

fetch_source () {
	# systemd
	download_untar "$REQUIRED_URL" "src/"

	sed -i '2 a #undef HAVE_DECL_MEMFD_CREATE\n#define HAVE_DECL_MEMFD_CREATE 1\n#include <sys/mman.h>' \
		"src/systemd-$REQUIRED_VERSION/src/basic/missing_syscall.h" || perror "Could not patch syscall memfd"

	# now check if the a fix needs to be applied
	if  [ -e "${MODULE_DIR}/systemd-openslx-${REQUIRED_VERSION#systemd-}.patch" ]; then
		patch -p0 src/systemd-*/src/basic/path-util.h < "${MODULE_DIR}/systemd-openslx-${REQUIRED_VERSION#systemd-}.patch" || perror "Failed to apply openslx systemd patch."
	else
		# TODO use the above hint for setting environmenet through /etc/systemd/system.conf
		pwarning "OpenSLX patch for systemd missing..."
	fi

	# libkmod
	download_untar "$REQUIRED_LIBKMOD_URL" "src/"
}

build () {
	#build libkmod
	pinfo "Building libkmod"
	cd "${MODULE_WORK_DIR}/src/$REQUIRED_LIBKMOD_VERSION"
	./configure || perror "./configure kmod failed."
	make || perror "kmod make failed."
	DESTDIR="${MODULE_BUILD_DIR}" make install || perror "kmod make install failed."
	cd - &> /dev/null

	#build systemd
	pinfo "Building systemd"
	cd "${MODULE_WORK_DIR}/src/systemd-$REQUIRED_VERSION"
	pinfo "calling configure in ${MODULE_WORK_DIR}/src/systemd-$REQUIRED_VERSION"

	# Save potentially pre-used paths/flages
	OLDLDFLAGS="$LDFLAGS"
	OLDCPPFLAGS="$CPPFLAGS"
	OLDPKG_CONFIG_PATH="$PKG_CONFIG_PATH"
	OLDLD_LIBRARY_PATH="$LD_LIBRARY_PATH"

	export LDFLAGS="$LDFLAGS -L${MODULE_BUILD_DIR}/usr/lib"
	export CPPFLAGS="-I${MODULE_BUILD_DIR}/usr/include"
	export PKG_CONFIG_PATH="${MODULE_BUILD_DIR}/usr/lib64/pkgconfig:${MODULE_BUILD_DIR}/usr/lib/pkgconfig"
	export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:${MODULE_BUILD_DIR}/usr/lib:${MODULE_BUILD_DIR}/usr/lib64"

	[ ! -e "./configure" ] && ./autogen.sh

	./configure \
		--exec-prefix=/ \
		--disable-manpages \
		--enable-split-usr \
		--sysconfdir="/etc" \
		--runstatedir="/run" \
		--enable-gtk-doc-html=no \
		--disable-nls \
		--disable-microhttpd \
		--disable-bootchart \
		--disable-quotacheck \
		--disable-hostnamed \
		--disable-timedated \
		--disable-localed \
		--disable-coredump \
		--disable-keymap \
		--disable-hwdb \
		--disable-ldconfig \
		--disable-networkd \
		--disable-resolved \
		--disable-timesyncd \
		--disable-importd \
		--disable-rfkill \
		--disable-backlight \
		--disable-firstboot \
		--disable-nss-systemd \
		--without-python \
		--enable-blkid \
		--enable-acl \
		--enable-pam \
		--enable-kmod \
		--with-pamlibdir="$SYS_PAM_MODULES_PATH" \
			|| perror "configure failed."

	pinfo "calling make"
	make || perror "make failed."
	pinfo "calling make install"
	DESTDIR="${MODULE_BUILD_DIR}" make install || perror "make install failed."
	cd - &> /dev/null
	# Nonsense in our env
	rm -f -- "${MODULE_BUILD_DIR}/usr/lib/tmpfiles.d/etc.conf"
	rm -f -- "${MODULE_BUILD_DIR}/usr/lib/tmpfiles.d/systemd-remote.conf"

	# Restore used flags/paths:
	export LDFLAGS="$OLDLDFLAGS"
	export CPPFLAGS="$OLDCPPFLAGS"
	export PKG_CONFIG_PATH="$OLDPKG_CONFIG_PATH"
	export LD_LIBRARY_PATH="$OLDLD_LIBRARY_PATH"
}

post_copy() {
	useradd --system --no-create-home "kvm"
	useradd --system --no-create-home  "systemd-journal-upload"
}