From cba2d4e6aa081fdf62e527d28eba137eb885f0cc Mon Sep 17 00:00:00 2001 From: Bruce Dubbs Date: Thu, 3 Apr 2014 21:52:09 +0000 Subject: Added systemd and dbus to the book. Set up systemd and System V side-by-side with the ability to reboot to either system. git-svn-id: http://svn.linuxfromscratch.org/LFS/trunk/BOOK@10520 4aa44e1e-78dd-0310-a6d2-fbcd4c07a689 --- chapter06/chapter06.xml | 10 +- chapter06/dbus.xml | 186 +++++++++++++ chapter06/systemd.xml | 606 +++++++++++++++++++++++++++++++++++------- chapter06/sysvinit-header.xml | 15 -- chapter06/sysvinit.xml | 36 ++- 5 files changed, 717 insertions(+), 136 deletions(-) create mode 100644 chapter06/dbus.xml delete mode 100644 chapter06/sysvinit-header.xml (limited to 'chapter06') diff --git a/chapter06/chapter06.xml b/chapter06/chapter06.xml index 51d5a932f..a7e866f75 100644 --- a/chapter06/chapter06.xml +++ b/chapter06/chapter06.xml @@ -84,14 +84,14 @@ - - - - - + + + + + diff --git a/chapter06/dbus.xml b/chapter06/dbus.xml new file mode 100644 index 000000000..476baf41d --- /dev/null +++ b/chapter06/dbus.xml @@ -0,0 +1,186 @@ + + + %general-entities; +]> + + + + + + dbus + &dbus-version; +
&dbus-url;
+
+ + D-Bus-&dbus-version; + + + D-Bus + + + + + + <para>D-Bus is a message bus system, a simple way for applications to talk + to one another. D-Bus supplies both a system daemon (for events such as + "new hardware device added" or "printer queue changed") and a + per-user-login-session daemon (for general IPC needs among user + applications). Also, the message bus is built on top of a general one-to-one + message passing framework, which can be used by any two applications to + communicate directly (without going through the message bus daemon).</para> + + <segmentedlist> + <segtitle>&buildtime;</segtitle> + <segtitle>&diskspace;</segtitle> + + <seglistitem> + <seg>&dbus-ch6-sbu;</seg> + <seg>&dbus-ch6-du;</seg> + </seglistitem> + </segmentedlist> + + </sect2> + + <sect2 role="installation"> + <title>Installation of D-Bus + + Prepare D-Bus for compilation: + +./configure --prefix=/usr \ + --sysconfdir=/etc \ + --localstatedir=/var \ + --docdir=/usr/share/doc/dbus-&dbus-version; \ + --with-console-auth-dir=/run/console + + + The meaning of the configure options: + + + --with-console-auth-dir=/run/console + + This specifies the location of the ConsoleKit auth + directory. + + + + + + Compile the package: + +make + + This package does come with a testsuite, but it requires several + packages that are not included in LFS. Instructions for running the + testsuite can be found in the BLFS book at + . + + Install the package: + +make install + + The shared library needs to be moved to + /lib, and as a result the + .so file in + /usr/lib will need to be recreated: + +mv -v /usr/lib/libdbus-1.so.* /lib +ln -sfv ../../lib/$(readlink /usr/lib/libdbus-1.so) /usr/lib/libdbus-1.so + + Create a symlink, so that D-Bus and Systemd can use the same + machine-id file: + +ln -sv /etc/machine-id /var/lib/dbus + + + + + Contents of D-Bus + + + Installed programs + Installed libraries + Installed directories + + + dbus-cleanup-sockets, dbus-daemon, dbus-launch, dbus-monitor, + dbus-send, and dbus-uuidgen + libdbus-1.{a,so} + /etc/dbus-1, /usr/include/dbus-1.0, /usr/lib/dbus-1.0, + /usr/share/dbus-1, /usr/share/doc/dbus-&dbus-version;, + /var/lib/dbus + + + + + Short Descriptions + + + + + dbus-cleanup-sockets + + Used to clean up leftover sockets in a directory. + + dbus-cleanup-sockets + + + + + + dbus-daemon + + The D-Bus message bus daemon. + + dbus-daemon + + + + + + dbus-launch + + Starts dbus-daemon from a shell + script. + + dbus-launch + + + + + + dbus-monitor + + Monitors messages passing through a D-Bus message bus. + + dbus-monitor + + + + + + dbus-send + + Sends a message to a D-Bus message bus. + + dbus-send + + + + + + dbus-uuidgen + + Generates a universally unique ID. + + dbus-uuidgen + + + + + + + + +
diff --git a/chapter06/systemd.xml b/chapter06/systemd.xml index 23314e563..8e669f1d2 100644 --- a/chapter06/systemd.xml +++ b/chapter06/systemd.xml @@ -5,28 +5,26 @@ %general-entities; ]> - - + + - udev + systemd &systemd-version;
&systemd-url;
- Udev-&systemd-version; (Extracted from systemd-&systemd-version;) + Systemd-&systemd-version; - - Udev + + Systemd - <para>The Udev package contains programs for dynamic creation of device - nodes. The development of udev has been merged with systemd, but - most of systemd is incompatible with LFS. Here we build and install just - the needed udev files.</para> + <para>The Systemd package contains programs for controlling the startup, + running, and shutdown of the system.</para> <segmentedlist> <segtitle>&buildtime;</segtitle> @@ -40,63 +38,155 @@ </sect2> <sect2 role="installation"> - <title>Installation of Udev + Installation of Systemd - This package is a little different from other packages. The - initial package that is extracted is - systemd-&systemd-version;.tar.xz even though the - application we are installing is udev. After changing to the - systemd directory, follow the instructions below. + First, create a file to allow Systemd to build when using Util-Linux + built in Chapter 5: - The udev-lfs tarball contains LFS-specific files used to build - Udev. Unpack it into the systemd source directory: +cat > config.cache << "EOF" +KILL=/bin/kill +HAVE_BLKID=1 +BLKID_LIBS="-lblkid" +BLKID_CFLAGS="-I/tools/include/blkid" +EOF -tar -xvf ../&udev-lfs;.tar.bz2 + Aditionally, fix a build error when using Util-Linux built in + Chapter 5: - Create two symbolic links to header files and set an - environment variable to properly use . +sed -i "s:blkid/::" $(grep -rl "blkid/blkid.h") -ln -svf /tools/include/blkid /usr/include -ln -svf /tools/include/uuid /usr/include -export LD_LIBRARY_PATH=/tools/lib + Apply a patch so that compat pkg-config files get + installed without installing compat libs which are useless on LFS: - Build the package: +patch -Np1 -i ../&systemd-compat-patch; -make -f &udev-lfs;/Makefile.lfs + Prepare Systemd for compilation: + +./configure --prefix=/usr \ + --sysconfdir=/etc \ + --localstatedir=/var \ + --config-cache \ + --with-rootprefix= \ + --with-rootlibdir=/lib \ + --enable-split-usr \ + --disable-gudev \ + --without-python \ + --docdir=/usr/share/doc/systemd-&systemd-version; \ + --with-dbuspolicydir=/etc/dbus-1/system.d \ + --with-dbusinterfacedir=/usr/share/dbus-1/interfaces \ + --with-dbussessionservicedir=/usr/share/dbus-1/services \ + --with-dbussystemservicedir=/usr/share/dbus-1/system-services + + + The meaning of the configure options: + + + --config-cache + + This switch tells the build system to use + the config.cache file which + was created earlier. + + + + + --with-root* + + These switches ensure that core programs and + shared libraries are installed in the subdirectories + of the root partition. + + + + + --enable-split-usr + + This switch ensures that Systemd will work on + systems where /bin, /lib and /sbin directories are not + symlinks to their /usr counterparts. + + + + + --disable-gudev --without-python + + These switches disable optional features because + LFS does not provide their dependencies. + + + + + --with-dbus* + + These switches ensure that D-Bus configuratil files + get installed in the correct locations. + + + + + + Compile the package: + +make LIBRARY_PATH=/tools/lib + + First prevent few broken test cases from running: + +sed -e "s:test/udev-test.pl::g" \ + -e "s:test-bus-cleanup\$(EXEEXT) ::g" \ + -e "s:test-bus-gvariant\$(EXEEXT) ::g" \ + -i Makefile + + To test the results, issue: + +make -k check + + Note that some tests might fail because the test are being run in a + chroot environment. For full test coverage, the test suite should be run + from a system booted using Systemd. Install the package: -make -f &udev-lfs;/Makefile.lfs install +make LD_LIBRARY_PATH=/tools/lib install + + Move NSS myhostname library to /lib: + +mv -v /usr/lib/libnss_myhostname.so.2 /lib + + Remove an unnecessary directory: + +rm -rfv /usr/lib/rpm - There are several places within the - systemd source code that have explicit directory - paths embedded. For instance, the binary version of the hardware - database's path and file name used at run time, - /etc/udev/hwdb.bin, cannot be changed without explicit - changes to the source code. + Create the Sysvinit compatibility symlinks, and move some man pages + and a library that conflict with so + both systems can be installed side-by-side: - Now initialize the hardware database: +for tool in runlevel reboot shutdown poweroff halt telinit; do + ln -sfv ../bin/systemctl /sbin/${tool}-systemd + mv -v /usr/share/man/man8/${tool}.8 /usr/share/man/man8/${tool}-systemd.8 +done -build/udevadm hwdb --update +ln -sfv ../lib/systemd/systemd /sbin/init-systemd +mv -v /etc/init.d /etc/init.d-systemd - Finally set up the persistent network udev rules. This task will be - explained in detail in . Note that the - /sys and /proc filesystems must be mounted in the - chroot environment as explained at the beginning of this chapter for the - following script to work. + Remove a reference to a non-existent group: -bash &udev-lfs;/init-net-rules.sh +sed -i "s:0775 root lock:0755 root root:g" /usr/lib/tmpfiles.d/legacy.conf - Do some cleanup: + Create the /etc/machine-id file needed by + Journald: -rm -fv /usr/include/{uuid,blkid} -unset LD_LIBRARY_PATH +systemd-machine-id-setup + + Finally install some LFS specific udev rules: + +tar -xf ../&udev-lfs-version;.tar.bz2 +make -f &udev-lfs-version;/Makefile.lfs install - - Contents of Udev + + Contents of Systemd Installed programs @@ -104,12 +194,22 @@ unset LD_LIBRARY_PATH Installed directories - accelerometer, ata_id, cdrom_id, collect, mtd_probe, - scsi_id, v4l_id, udevadm, and udevd - - libudev.so - - /etc/udev, /lib/udev, /lib/firmware, /usr/share/doc/udev + bootctl, busctl, halt, hostnamectl, init, journalctl, kernel-install, + localectl, loginctl, machinectl, poweroff, reboot, runlevel, shutdown, + systemctl, systemd-analyze, systemd-ask-password, systemd-cat, systemd-cgls, + systemd-cgtop, systemd-coredumpctl, systemd-delta, systemd-detect-virt, + systemd-inhibit, systemd-machine-id-setup, systemd-notify, systemd-nspawn, + systemd-run, systemd-stdio-bridge, systemd-tmpfiles, systemd-tty-ask-password-agent, + telinit, timedatectl, and udevadm + + libnss_myhostname.so.2, libsystemd.so, libudev.so + /etc/binfmt.d, /etc/init.d, /etc/kernel, /etc/modules-load.d, + /etc/sysctl.d, /etc/systemd, /etc/tmpfiles.d, /etc/udev, + /etc/xdg/systemd, /lib/systemd, /lib/udev, /usr/include/systemd, + /usr/lib/binfmt.d, /usr/lib/kernel, /usr/lib/modules-load.d, + /usr/lib/sysctl.d, /usr/lib/systemd, /usr/lib/tmpfiles.d, + /usr/share/doc/systemd-&systemd-version;, /usr/share/systemd, + /var/lib/systemd, /var/log/journal @@ -118,48 +218,363 @@ unset LD_LIBRARY_PATH - - ata_id + + bootctl + + used to query the firmware and boot manager settings. + + bootctl + + + + + + busctl + + used to introspect and monitor the D-Bus bus. + + busctl + + + + + + halt + + Normally invokes shutdown with the + -h option, except when already in run-level 0, + then it tells the kernel to halt the system; it notes in the + file /var/log/wtmp that the system is being + brought down. + + halt + + + + + + hostnamectl + + used to query and change the system hostname and related + settings. + + hostnamectl + + + + + + init + + The first process to be started when the kernel has initialized + the hardware which takes over the boot process and starts all the + proceses it is instructed to. + + init + + + + + + journalctl + + used to query the contents of the Systemd Journal. + + journalctl + + + + + + kernel-install + + used to add and remove kernel and initramfs images to and + from /boot. + + kernel-install + + + + + + localectl + + used to query and change the system locale and keyboard layout + settings. + + localectl + + + + + + loginctl + + used to introspect and control the state of the Systemd Login + Manager. + + loginctl + + + + + + machinectl + + used to introspect and control the state of the Systemd Virtual + Machine and Container Registration Manager + + machinectl + + + + + + poweroff + + Tells the kernel to halt the system and switch off the computer + (see halt). + + poweroff + + + + + + reboot - Provides Udev with a unique string and - additional information (uuid, label) for an ATA drive - - ata_id + Tells the kernel to reboot the system (see + halt). + + reboot - - cdrom_id + + runlevel - Provides Udev with the capabilities of a - CD-ROM or DVD-ROM drive - - cdrom_id + Reports the previous and the current run-level, as noted in the + last run-level record in /var/run/utmp. + + runlevel - - collect + + shutdown - Given an ID for the current uevent and a list of - IDs (for all target uevents), registers the current ID - and indicates whether all target IDs have been registered - - collect + Brings the system down in a secure way, signaling all processes + and notifying all logged-in users. + + shutdown - - scsi_id + + systemctl - Provides Udev with a unique SCSI identifier - based on the data returned from sending a SCSI INQUIRY command to - the specified device - - scsi_id + used to introspect and control the state of the Systemd system and + service manager. + + systemctl + + + + + + systemd-analyze + + used to determine system boot-up performance of the current boot. + + + systemd-analyze + + + + + + systemd-ask-password + + used to query a system password or passphrase from the user, using a + question message specified on the command line. + + systemd-ask-password + + + + + + systemd-cat + + used to connect STDOUT and STDERR of a process with the Journal. + + + systemd-cat + + + + + + systemd-cgls + + recursively shows the contents of the selected Linux control group + hierarchy in a tree. + + systemd-cgls + + + + + + systemd-cgtop + + shows the top control groups of the local Linux control group hierarchy, + ordered by their CPU, memory and disk I/O load. + + systemd-cgtop + + + + + + systemd-coredumpctl + + used to retrieve coredumps from the Systemd Journal + + systemd-coredumpctl + + + + + + systemd-delta + + used to identify and compare configuration files in + /etc that override default + counterparts in /usr. + + systemd-delta + + + + + + systemd-detect-virt + + detects execution in a virtualized environment. + + systemd-detect-virt + + + + + + systemd-inhibit + + used to execute a program with a shutdown, sleep or idle inhibitor lock + taken. + + systemd-inhibit + + + + + + systemd-machine-id-setup + + used by system installer tools to initialize the machine ID stored in + /etc/machine-id at install time with a randomly + generated ID. + + systemd-machine-id-setup + + + + + + systemd-notify + + used by daemon scripts to notify the init system about status changes. + + + systemd-notify + + + + + + systemd-nspawn + + used to run a command or OS in a light-weight namespace container. + + systemd-nspawn + + + + + + systemd-run + + used to create and start a transient .service or a .scope unit and + run the specified command in it. + + systemd-run + + + + + + + + systemd-tmpfiles + + creates, deletes and cleans up volatile and temporary files and directories, + based on the configuration file format and location specified in + tmpfiles.d directories. + + systemd-tmpfiles + + + + + + systemd-tty-ask-password-agent + + used to list or process pending Systemd password requests + + systemd-tty-ask-password-agent + + + + + + telinit + + Tells init which run-level to change to. + + telinit + + + + + + timedatectl + + used to query and change the system clock and its settings. + + + timedatectl @@ -167,24 +582,22 @@ unset LD_LIBRARY_PATH udevadm - Generic udev administration tool: controls the udevd daemon, + Generic Udev administration tool: controls the udevd daemon, provides info from the Udev database, monitors uevents, waits for uevents to finish, tests Udev configuration, and triggers uevents - for a given device - + for a given device. + udevadm - - udevd + + libsystemd - A daemon that listens for uevents on the netlink socket, - creates devices and runs the configured external programs in - response to these uevents - - udevd + Systemd utility library. + + libsystemd @@ -192,24 +605,13 @@ unset LD_LIBRARY_PATH libudev - A library interface to udev device information - + A library to access Udev device information. + libudev - - /etc/udev - - Contains Udev configuration files, - device permissions, and rules for device naming - - /etc/udev - - - - diff --git a/chapter06/sysvinit-header.xml b/chapter06/sysvinit-header.xml deleted file mode 100644 index e42fad79e..000000000 --- a/chapter06/sysvinit-header.xml +++ /dev/null @@ -1,15 +0,0 @@ - - - - - - - $LastChangedBy$ - $Date$ - - - System V - - - diff --git a/chapter06/sysvinit.xml b/chapter06/sysvinit.xml index b1fac46db..c77f77ca1 100644 --- a/chapter06/sysvinit.xml +++ b/chapter06/sysvinit.xml @@ -82,6 +82,14 @@ make -C src install + Move files that have a name conflict with + so that both packages can be installed side-by-side: + +for p in init halt poweroff reboot runlevel shutdown telinit; do + mv -v /sbin/$p /sbin/$p-sysv + mv -v /usr/share/man/man8/$p.8 /usr/share/man/man8/$p-sysv.8 +done + @@ -122,7 +130,7 @@ - + halt Normally invokes shutdown with the @@ -130,19 +138,19 @@ then it tells the kernel to halt the system; it notes in the file /var/log/wtmp that the system is being brought down - + halt - + init The first process to be started when the kernel has initialized the hardware which takes over the boot process and starts all the proceses it is instructed to - + init @@ -160,55 +168,55 @@ - + poweroff Tells the kernel to halt the system and switch off the computer (see halt) - + poweroff - + reboot Tells the kernel to reboot the system (see halt) - + reboot - + runlevel Reports the previous and the current run-level, as noted in the last run-level record in /var/run/utmp - + runlevel - + shutdown Brings the system down in a secure way, signaling all processes and notifying all logged-in users - + shutdown - + telinit Tells init which run-level to change to - + telinit -- cgit v1.2.3-54-g00ecf