summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJianxun Zhang <jianxun.zhang@linux.intel.com>2016-05-05 11:20:37 -0700
committerRichard Purdie <richard.purdie@linuxfoundation.org>2016-06-03 13:13:25 +0100
commitc71f5ab37416629793b9f826480d440d67531791 (patch)
tree3a605787ba786549c99b8923133ea38c24f4af3d
parent408297489d1b368e8cc539ce93fbe566976b0f3a (diff)
downloadpoky-c71f5ab37416629793b9f826480d440d67531791.tar.gz
systemd: support systemd-boot as a stand-alone EFI bootloader
The "systemd-boot" is gummiboot now included into systemd project. The old gummiboot project supported in OE is dead. Our intention is to get a gummiboot-like EFI bootloader without much dependency on systemd and its features. This work is largely derived from the existing bbclass and recipes of gummiboot and systemd. (commit tip: ee25d0e3987d7732a2e46e1640693b4cf419a9fc) Please refer to the history up to the tip for authorship and credit information for the original works. To enable the systemd-boot in build, add this line EFI_PROVIDER = "systemd-boot" in your machine conf file. (From OE-Core rev: e9add1cd01e498d2aa52528ec52342cae48a387a) Signed-off-by: Jianxun Zhang <jianxun.zhang@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r--meta/classes/systemd-boot.bbclass124
-rw-r--r--meta/recipes-bsp/systemd-boot/systemd-boot.bb35
-rw-r--r--meta/recipes-core/systemd/systemd.inc25
-rw-r--r--meta/recipes-core/systemd/systemd_229.bb26
4 files changed, 186 insertions, 24 deletions
diff --git a/meta/classes/systemd-boot.bbclass b/meta/classes/systemd-boot.bbclass
new file mode 100644
index 0000000000..9e9398a2a5
--- /dev/null
+++ b/meta/classes/systemd-boot.bbclass
@@ -0,0 +1,124 @@
1# Copyright (C) 2016 Intel Corporation
2#
3# Released under the MIT license (see COPYING.MIT)
4
5# systemd-boot.bbclass - The "systemd-boot" is essentially the gummiboot merged into systemd.
6# The original standalone gummiboot project is dead without any more
7# maintenance. As a start point, we replace all gummitboot occurrences
8# with systemd-boot in gummiboot.bbclass to have a base version of this
9# systemd-boot.bbclass.
10#
11# Set EFI_PROVIDER = "systemd-boot" to use systemd-boot on your live images instead of grub-efi
12# (images built by image-live.bbclass or image-vm.bbclass)
13
14do_bootimg[depends] += "${MLPREFIX}systemd-boot:do_deploy"
15do_bootdirectdisk[depends] += "${MLPREFIX}systemd-boot:do_deploy"
16
17EFIDIR = "/EFI/BOOT"
18
19SYSTEMD_BOOT_CFG ?= "${S}/loader.conf"
20SYSTEMD_BOOT_ENTRIES ?= ""
21SYSTEMD_BOOT_TIMEOUT ?= "10"
22
23# Need UUID utility code.
24inherit fs-uuid
25
26efi_populate() {
27 DEST=$1
28
29 EFI_IMAGE="systemd-bootia32.efi"
30 DEST_EFI_IMAGE="bootia32.efi"
31 if [ "${TARGET_ARCH}" = "x86_64" ]; then
32 EFI_IMAGE="systemd-bootx64.efi"
33 DEST_EFI_IMAGE="bootx64.efi"
34 fi
35
36 install -d ${DEST}${EFIDIR}
37 # systemd-boot requires these paths for configuration files
38 # they are not customizable so no point in new vars
39 install -d ${DEST}/loader
40 install -d ${DEST}/loader/entries
41 install -m 0644 ${DEPLOY_DIR_IMAGE}/${EFI_IMAGE} ${DEST}${EFIDIR}/${DEST_EFI_IMAGE}
42 install -m 0644 ${SYSTEMD_BOOT_CFG} ${DEST}/loader/loader.conf
43 for i in ${SYSTEMD_BOOT_ENTRIES}; do
44 install -m 0644 ${i} ${DEST}/loader/entries
45 done
46}
47
48efi_iso_populate() {
49 iso_dir=$1
50 efi_populate $iso_dir
51 mkdir -p ${EFIIMGDIR}/${EFIDIR}
52 cp $iso_dir/${EFIDIR}/* ${EFIIMGDIR}${EFIDIR}
53 cp $iso_dir/vmlinuz ${EFIIMGDIR}
54 EFIPATH=$(echo "${EFIDIR}" | sed 's/\//\\/g')
55 echo "fs0:${EFIPATH}\\${DEST_EFI_IMAGE}" > ${EFIIMGDIR}/startup.nsh
56 if [ -f "$iso_dir/initrd" ] ; then
57 cp $iso_dir/initrd ${EFIIMGDIR}
58 fi
59}
60
61efi_hddimg_populate() {
62 efi_populate $1
63}
64
65python build_efi_cfg() {
66 s = d.getVar("S", True)
67 labels = d.getVar('LABELS', True)
68 if not labels:
69 bb.debug(1, "LABELS not defined, nothing to do")
70 return
71
72 if labels == []:
73 bb.debug(1, "No labels, nothing to do")
74 return
75
76 cfile = d.getVar('SYSTEMD_BOOT_CFG', True)
77 try:
78 cfgfile = open(cfile, 'w')
79 except OSError:
80 raise bb.build.funcFailed('Unable to open %s' % (cfile))
81
82 cfgfile.write('# Automatically created by OE\n')
83 cfgfile.write('default %s\n' % (labels.split()[0]))
84 timeout = d.getVar('SYSTEMD_BOOT_TIMEOUT', True)
85 if timeout:
86 cfgfile.write('timeout %s\n' % timeout)
87 else:
88 cfgfile.write('timeout 10\n')
89 cfgfile.close()
90
91 for label in labels.split():
92 localdata = d.createCopy()
93
94 overrides = localdata.getVar('OVERRIDES', True)
95 if not overrides:
96 raise bb.build.FuncFailed('OVERRIDES not defined')
97
98 entryfile = "%s/%s.conf" % (s, label)
99 d.appendVar("SYSTEMD_BOOT_ENTRIES", " " + entryfile)
100 try:
101 entrycfg = open(entryfile, "w")
102 except OSError:
103 raise bb.build.funcFailed('Unable to open %s' % (entryfile))
104 localdata.setVar('OVERRIDES', label + ':' + overrides)
105 bb.data.update_data(localdata)
106
107 entrycfg.write('title %s\n' % label)
108 entrycfg.write('linux /vmlinuz\n')
109
110 append = localdata.getVar('APPEND', True)
111 initrd = localdata.getVar('INITRD', True)
112
113 if initrd:
114 entrycfg.write('initrd /initrd\n')
115 lb = label
116 if label == "install":
117 lb = "install-efi"
118 entrycfg.write('options LABEL=%s ' % lb)
119 if append:
120 append = replace_rootfs_uuid(d, append)
121 entrycfg.write('%s' % append)
122 entrycfg.write('\n')
123 entrycfg.close()
124}
diff --git a/meta/recipes-bsp/systemd-boot/systemd-boot.bb b/meta/recipes-bsp/systemd-boot/systemd-boot.bb
new file mode 100644
index 0000000000..87e98718f5
--- /dev/null
+++ b/meta/recipes-bsp/systemd-boot/systemd-boot.bb
@@ -0,0 +1,35 @@
1require recipes-core/systemd/systemd.inc
2
3DEPENDS = "intltool-native libcap util-linux gnu-efi"
4
5inherit autotools pkgconfig gettext
6inherit deploy
7
8EXTRA_OECONF = " --enable-gnuefi \
9 --with-efi-includedir=${STAGING_INCDIR} \
10 --with-efi-ldsdir=${STAGING_LIBDIR} \
11 --with-efi-libdir=${STAGING_LIBDIR} \
12 --disable-manpages \
13 "
14
15# Imported from gummiboot recipe
16TUNE_CCARGS_remove = "-mfpmath=sse"
17
18do_compile() {
19 SYSTEMD_BOOT_EFI_ARCH="ia32"
20 if [ "${TARGET_ARCH}" = "x86_64" ]; then
21 SYSTEMD_BOOT_EFI_ARCH="x64"
22 fi
23
24 oe_runmake systemd-boot${SYSTEMD_BOOT_EFI_ARCH}.efi
25}
26
27do_install() {
28 # Bypass systemd installation with a NOP
29 :
30}
31
32do_deploy () {
33 install ${B}/systemd-boot*.efi ${DEPLOYDIR}
34}
35addtask deploy before do_build after do_compile
diff --git a/meta/recipes-core/systemd/systemd.inc b/meta/recipes-core/systemd/systemd.inc
new file mode 100644
index 0000000000..824713057d
--- /dev/null
+++ b/meta/recipes-core/systemd/systemd.inc
@@ -0,0 +1,25 @@
1SUMMARY = "A System and service manager"
2HOMEPAGE = "http://www.freedesktop.org/wiki/Software/systemd"
3
4DESCRIPTION = "systemd is a system and service manager for Linux, compatible with \
5SysV and LSB init scripts. systemd provides aggressive parallelization \
6capabilities, uses socket and D-Bus activation for starting services, \
7offers on-demand starting of daemons, keeps track of processes using \
8Linux cgroups, supports snapshotting and restoring of the system \
9state, maintains mount and automount points and implements an \
10elaborate transactional dependency-based service control logic. It can \
11work as a drop-in replacement for sysvinit."
12
13LICENSE = "GPLv2 & LGPLv2.1"
14LIC_FILES_CHKSUM = "file://LICENSE.GPL2;md5=751419260aa954499f7abaabaa882bbe \
15 file://LICENSE.LGPL2.1;md5=4fbd65380cdd255951079008b364516c"
16
17SRCREV = "714c62b46379abb7558c544665522aca91691e10"
18
19SRC_URI = "git://github.com/systemd/systemd.git;protocol=git"
20
21PV = "229+git${SRCPV}"
22
23S = "${WORKDIR}/git"
24
25LDFLAGS_append_libc-uclibc = " -lrt -lssp_nonshared -lssp "
diff --git a/meta/recipes-core/systemd/systemd_229.bb b/meta/recipes-core/systemd/systemd_229.bb
index ae63c58056..c2cc06991b 100644
--- a/meta/recipes-core/systemd/systemd_229.bb
+++ b/meta/recipes-core/systemd/systemd_229.bb
@@ -1,18 +1,4 @@
1SUMMARY = "A System and service manager" 1require systemd.inc
2HOMEPAGE = "http://www.freedesktop.org/wiki/Software/systemd"
3
4DESCRIPTION = "systemd is a system and service manager for Linux, compatible with \
5SysV and LSB init scripts. systemd provides aggressive parallelization \
6capabilities, uses socket and D-Bus activation for starting services, \
7offers on-demand starting of daemons, keeps track of processes using \
8Linux cgroups, supports snapshotting and restoring of the system \
9state, maintains mount and automount points and implements an \
10elaborate transactional dependency-based service control logic. It can \
11work as a drop-in replacement for sysvinit."
12
13LICENSE = "GPLv2 & LGPLv2.1"
14LIC_FILES_CHKSUM = "file://LICENSE.GPL2;md5=751419260aa954499f7abaabaa882bbe \
15 file://LICENSE.LGPL2.1;md5=4fbd65380cdd255951079008b364516c"
16 2
17PROVIDES = "udev" 3PROVIDES = "udev"
18 4
@@ -24,11 +10,7 @@ SECTION = "base/shell"
24 10
25inherit useradd pkgconfig autotools perlnative update-rc.d update-alternatives qemu systemd ptest gettext bash-completion 11inherit useradd pkgconfig autotools perlnative update-rc.d update-alternatives qemu systemd ptest gettext bash-completion
26 12
27SRCREV = "714c62b46379abb7558c544665522aca91691e10" 13SRC_URI += " \
28
29PV = "229+git${SRCPV}"
30
31SRC_URI = "git://github.com/systemd/systemd.git;protocol=git \
32 file://touchscreen.rules \ 14 file://touchscreen.rules \
33 file://00-create-volatile.conf \ 15 file://00-create-volatile.conf \
34 file://init \ 16 file://init \
@@ -61,10 +43,6 @@ SRC_URI_append_libc-uclibc = "\
61" 43"
62SRC_URI_append_qemuall = " file://0001-core-device.c-Change-the-default-device-timeout-to-2.patch" 44SRC_URI_append_qemuall = " file://0001-core-device.c-Change-the-default-device-timeout-to-2.patch"
63 45
64S = "${WORKDIR}/git"
65
66LDFLAGS_append_libc-uclibc = " -lrt -lssp_nonshared -lssp "
67
68GTKDOC_DOCDIR = "${S}/docs/" 46GTKDOC_DOCDIR = "${S}/docs/"
69 47
70PACKAGECONFIG ??= "xz \ 48PACKAGECONFIG ??= "xz \