summaryrefslogblamecommitdiffstats
path: root/remote/modules/systemd/module.build.scientific
blob: 12170d813415f2a41cbe2649dec10838342b92ef (plain) (tree)

















































































































































































                                                                                                                                                                                                                              
#tool/distro specific functions for fetching, building and installing dependencies

# Please read systemd.build.scientific.README before using this script!

fetch_source () {
	download_untar "$REQUIRED_URL" "src/"
	download_untar "$REQUIRED_LIBKMOD_URL" "src/"

	# Another nice hack for Scientific Linux - experimental.
	if [ "$SYS_DISTRIBUTION" == "scientific" ]; then
		download_untar "$REQUIRED_UTILLINUX_URL" "src/"	|| perror "Cannot download util-linux!"
		download_untar "$REQUIRED_M4_URL" "src/"	|| perror "Cannot download m4 version $REQUIRED_AUTOMAKE_VERSION!"
		download_untar "$REQUIRED_AUTOCONF_URL" "src/"	|| perror "Cannot download autoconf version $REQUIRED_AUTOCONF_VERSION!"
		download_untar "$REQUIRED_AUTOMAKE_URL" "src/"	|| perror "Cannot download automake version $REQUIRED_AUTOMAKE_VERSION!"
		download_untar "$REQUIRED_DBUS_URL" "src/"	|| perror "Cannot download dbus version $REQUIRED_DBUS_VERSION!"
	fi

	# Patch PATH environment
	sed -s -i -r 's#"/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin(:/sbin:/bin)?"#& ":/opt/openslx/usr/sbin:/opt/openslx/usr/bin:/opt/openslx/sbin:/opt/openslx/bin"#g' src/systemd-*/src/core/main.c
	sed -s -i -r 's#"PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"#& ":/opt/openslx/usr/sbin:/opt/openslx/usr/bin:/opt/openslx/sbin:/opt/openslx/bin"#g' src/systemd-*/src/nspawn/nspawn.c
}

build () {

	config_systemd () {
		pinfo "Building systemd"
		cd "${MODULE_DIR}/src/$REQUIRED_VERSION"
		pinfo "calling configure"
		./configure --disable-manpages --enable-split-usr --sysconfdir="/etc" --enable-gtk-doc-html=no --disable-nls \
				--disable-microhttpd --disable-bootchart --disable-quotacheck --disable-hostnamed --disable-timedated \
				--disable-localed --disable-coredump --disable-keymap --without-python --enable-blkid --enable-acl --enable-pam \
				|| perror "configure systemd failed."
	}

	#build libkmod
	pinfo "Building libkmod"
	cd "${MODULE_DIR}/src/$REQUIRED_LIBKMOD_VERSION"
	./configure || perror "./configure kmod failed."
	make || perror "kmod make failed."
	make install || perror "kmod make install failed."
	cd - &> /dev/null

	# Scientific Linux specials
	if [ "$SYS_DISTRIBUTION" == "scientific" ]; then
		pinfo "Scientific Linux detected ..."			# Freude, schöner Götterfunke!

		# Some path mainpulations for following utilities, save some envvars for later restituting
		OLDPATH=$PATH
		export PATH="${MODULE_BUILD_DIR}/sbin:${MODULE_BUILD_DIR}/usr/local/bin/:$PATH"	# for stuff installed at BUILD_DIR.
		OLDPKG_CONFIG_PATH="$PKG_CONFIG_PATH"
		OLDCPPFLAGS="$CPPFLAGS"
                OLDLDFLAGS="$LDFLAGS"

		# Utillinux stuff
		pinfo "Building util-linux"
		cd "${MODULE_DIR}/src/$REQUIRED_UTILLINUX_VERSION"
		./configure --disable-libuuid --disable-libmount --without-ncurses \
			--disable-mount --disable-losetup --disable-cytune --disable-fsck --disable-partx --disable-uuidd \
			--disable-mountpoint --disable-fallocate --disable-unshare --disable-nsenter --disable-setpriv \
			--disable-eject --disable-agetty --disable-cramfs --disable-bfs --disable-fdformat --disable-hwclock \
			--disable-wdctl --disable-switch_root --disable-pivot_root --disable-kill --disable-utmpdump --disable-raw \
			--disable-rename --disable-login --disable-sulogin --disable-su --disable-runuser --disable-ul --disable-more \
			--disable-pg --disable-schedutils --disable-wall --disable-bash-completion \
			|| perror "./configure util-linux failed."
		make || perror "util-linux make failed."
		DESTDIR="${MODULE_BUILD_DIR}" make install || perror "util-linux make install failed."
		cd - &> /dev/null

		# Let's have some starting fun with m4, as we want systemd, which wants automake 1.13, which wants autoconf,
		# which wants m4 ...
		pinfo "Building m4 Version $REQUIRED_M4_VERSION."
		cd "${MODULE_DIR}/src/$REQUIRED_M4_VERSION"
		./configure || perror "./configure m4 failed."
		make || perror "m4 make failed."
		DESTDIR="${MODULE_BUILD_DIR}" make install || perror "m4 make install failed."
		cd - &> /dev/null

		# And have some more fun with autoconf, chain see above:
		pinfo "Building autoconf Version $REQUIRED_AUTOCONF_VERSION."
		cd "${MODULE_DIR}/src/$REQUIRED_AUTOCONF_VERSION"
		./configure || perror "./configure autoconf failed."
		make || perror "autoconf make failed."
		DESTDIR="${MODULE_BUILD_DIR}" make install || perror "autoconf make install failed."
		cd - &> /dev/null

		# Now let's have some fun with automake, as config.log/automake will whine later about SL's automake 1.11:
		# AUTOMAKE='${SHELL} [...] missing automake-1.13'. We use a newer automake than 1.11, if we are at it.
                # Link fun, as configure searches in /usr/local/bin, ignores PATH above, also 'share':
		ln -s "${MODULE_BUILD_DIR}/usr/local/bin/autom4te" /usr/local/bin/autom4te
		ln -s "${MODULE_BUILD_DIR}/usr/local/share/autoconf" /usr/local/share/autoconf
		# ... and manipulate perl library path, as else the libs will not be found by (system) perl:
		OLDPERL5LIB="$PERL5LIB"
                export PERL5LIB="${MODULE_BUILD_DIR}/usr/local/share/autoconf/:$PERL5LIB"

		pinfo "Building automake Version $REQUIRED_AUTOMAKE_VERSION."
		cd "${MODULE_DIR}/src/$REQUIRED_AUTOMAKE_VERSION"
		./configure || perror "./configure automake failed."
		make || perror "automake make failed."
		DESTDIR="${MODULE_BUILD_DIR}" make install || perror "automake make install failed."
		cd - &> /dev/null
		
		# We are having so much compiling fun, why leave out dbus, then?
		pinfo "Building dbus Version $REQUIRED_AUTOMAKE_VERSION."
		cd "${MODULE_DIR}/src/$REQUIRED_DBUS_VERSION"
		./configure || perror "./configure dbus failed."
		make || perror "dbus make failed."
		DESTDIR="${MODULE_BUILD_DIR}" make install || perror "automake make install failed."
		cd - &> /dev/null

		# patching configure for Scientific Linux - cave - ugly hack!
		# pinfo "Scientific Linux detected; patching systemd/configure..."
		# cd "${MODULE_DIR}/src/$REQUIRED_VERSION"
		# sed 's/dbus-1 >= 1.3.2/dbus-1 >= 1.2.24/g' configure > configure.patched
		# mv configure configure.orig
		# mv configure.patched configure
		# chmod +x configure

		# For compiling systemd later
		export PKG_CONFIG_PATH="${MODULE_BUILD_DIR}/usr/lib/pkgconfig/:${MODULE_BUILD_DIR}/usr/local/lib/pkgconfig:$PKG_CONFIG_PATH"
		export CPPFLAGS="$CPPFLAGS -I${MODULE_BUILD_DIR}/usr/include/ -I${MODULE_BUILD_DIR}/usr/local/include/ -I${MODULE_BUILD_DIR}/usr/local/include/dbus-1.0 -I${MODULE_BUILD_DIR}/usr/local/lib/dbus-1.0/include/"
		export LDFLAGS="$LDFLAGS -L${MODULE_BUILD_DIR}/usr/lib/ -L${MODULE_BUILD_DIR}/usr/local/lib/ -ldl"
		ln -s ${MODULE_BUILD_DIR}/usr/local/include/dbus-1.0 /usr/local/include/dbus-1.0
		ln -s ${MODULE_BUILD_DIR}/usr/local/lib/dbus-1.0 /usr/local/lib/dbus-1.0
		cd - &> /dev/null

		config_systemd

		# ... and tidy our manipulations with path, perllib, links etc.
		export PERL5LIB="$OLDPERL5LIB"
		export PATH="$OLDPATH"
		unlink /usr/local/bin/autom4te
		unlink /usr/local/share/autoconf
		unlink /usr/local/lib/dbus-1.0
		unlink /usr/local/include/dbus-1.0
	else
		config_systemd		# Non-Scientific-Linux branch
	fi

	pinfo "calling make"
	make || perror "systemd make failed."
	pinfo "calling make install"
	DESTDIR="${MODULE_BUILD_DIR}" make install || perror "systemd make install failed."
	cd - &> /dev/null


	# Delete unneeded services
	pinfo "Deleting unneeded services"
	local SERVICE=
	local OTHER=
	for SERVICE in $REQUIRED_DISABLED_SERVICES; do
		find "${MODULE_BUILD_DIR}" -name "$SERVICE" -exec rm -r {} \;
		for OTHER in $(grep -l -r "$SERVICE" "$MODULE_BUILD_DIR/usr/lib/systemd/system"); do
			sed -i -r "s#\s*$SERVICE\s*# #g" "$OTHER"
		done
	done
}

post_copy() {
	# dont clear systemd log at startup
	sed -i "s/TTYVTDisallocate=yes/TTYVTDisallocate=no/g" "${TARGET_BUILD_DIR}/usr/lib/systemd/system/getty@.service"

	#old agetty version doesn't support --noclear option in getty service
	if [ "x$(dpkg -s util-linux | grep Version: | cut -d' ' -f2)" == "x2.19.1-2ubuntu3" ];
	then
		sed -i.bak "s/ExecStart=-\/sbin\/agetty --noclear %I 38400 linux/ExecStart=-\/sbin\/agetty %I 38400 linux/g" "${TARGET_BUILD_DIR}/usr/lib/systemd/system/getty@.service"
	fi

	# add nfs to modules-load list
	echo "nfs" > "${TARGET_BUILD_DIR}/etc/modules-load.d/nfs.conf"

	# add pam_systemd.so to pam modules directory
	if [ -e "${MODULE_BUILD_DIR}/usr/lib/security/pam_systemd.so" ]; then
		cp "${MODULE_BUILD_DIR}/usr/lib/security/pam_systemd.so" "${TARGET_BUILD_DIR}/lib/security/"
	else
		pdebug "No such file: ${MODULE_BUILD_DIR}/usr/lib/security/pam_systemd.so"
	fi
}