diff options
Diffstat (limited to 'recipes/ostree/ostree/Support-for-booting-without-initramfs.patch')
-rw-r--r-- | recipes/ostree/ostree/Support-for-booting-without-initramfs.patch | 131 |
1 files changed, 131 insertions, 0 deletions
diff --git a/recipes/ostree/ostree/Support-for-booting-without-initramfs.patch b/recipes/ostree/ostree/Support-for-booting-without-initramfs.patch new file mode 100644 index 0000000..4ec137f --- /dev/null +++ b/recipes/ostree/ostree/Support-for-booting-without-initramfs.patch | |||
@@ -0,0 +1,131 @@ | |||
1 | From a31c9083870fd934e242cc9cc56fdd39ad0a42cb Mon Sep 17 00:00:00 2001 | ||
2 | From: Gatis Paeglis <gatis.paeglis@qt.io> | ||
3 | Date: Wed, 24 Aug 2016 12:00:14 +0200 | ||
4 | Subject: [PATCH 3/4] Support for booting without initramfs | ||
5 | |||
6 | Previously when initramfs-* was not found in a deployment's | ||
7 | boot directory, it was assumed that rootfs is prepared for | ||
8 | ostree booting by a kernel patch. | ||
9 | |||
10 | With this patch, the behaviour changes to be - if initramfs-* | ||
11 | is not found, assume that system is using a static | ||
12 | ostree-prepare-root as init process. Booting without initramfs | ||
13 | is a common use case on embedded systems. This approach is | ||
14 | also more convenient, than having to patch the kernel. | ||
15 | --- | ||
16 | Makefile-switchroot.am | 3 +++ | ||
17 | configure.ac | 8 ++++++++ | ||
18 | src/boot/grub2/ostree-grub-generator | 8 +++++--- | ||
19 | src/libostree/ostree-sysroot-deploy.c | 18 +++++++++++++----- | ||
20 | 4 files changed, 29 insertions(+), 8 deletions(-) | ||
21 | |||
22 | diff --git a/Makefile-switchroot.am b/Makefile-switchroot.am | ||
23 | index ef837ce..70a6de7 100644 | ||
24 | --- a/Makefile-switchroot.am | ||
25 | +++ b/Makefile-switchroot.am | ||
26 | @@ -29,6 +29,9 @@ libswitchroot_mountutil_la_SOURCES = \ | ||
27 | ostree_prepare_root_SOURCES = src/switchroot/ostree-prepare-root.c | ||
28 | ostree_prepare_root_LDADD = libswitchroot-mountutil.la | ||
29 | ostree_prepare_root_CFLAGS = $(AM_CFLAGS) -Isrc/switchroot | ||
30 | +if BUILDOPT_STATIC_PREPARE_ROOT | ||
31 | +ostree_prepare_root_LDFLAGS = --static | ||
32 | +endif | ||
33 | |||
34 | ostree_remount_SOURCES = src/switchroot/ostree-remount.c | ||
35 | ostree_remount_LDADD = libswitchroot-mountutil.la | ||
36 | diff --git a/configure.ac b/configure.ac | ||
37 | index 4831bcc..97f3112 100644 | ||
38 | --- a/configure.ac | ||
39 | +++ b/configure.ac | ||
40 | @@ -294,6 +294,13 @@ AS_IF([test x$with_grub2_mkconfig_path = x], [ | ||
41 | ],[GRUB2_MKCONFIG=$with_grub2_mkconfig_path]) | ||
42 | AC_DEFINE_UNQUOTED([GRUB2_MKCONFIG_PATH], ["$GRUB2_MKCONFIG"], [The system grub2-mkconfig executible name]) | ||
43 | |||
44 | +AC_ARG_WITH(static-prepare-root, | ||
45 | + AS_HELP_STRING([--with-static-prepare-root], | ||
46 | + [Build static version of the 'ostree-prepare-root' binary. Useful when | ||
47 | + using 'ostree-prepare-root' as the init (PID 1) process. (default: no)]),, | ||
48 | + [with_static_prepare_root=no]) | ||
49 | +AM_CONDITIONAL(BUILDOPT_STATIC_PREPARE_ROOT, test x$with_static_prepare_root = xyes) | ||
50 | + | ||
51 | dnl for tests | ||
52 | AS_IF([test "x$found_introspection" = xyes], [ | ||
53 | AC_PATH_PROG(GJS, [gjs]) | ||
54 | @@ -327,6 +334,7 @@ echo " | ||
55 | libarchive (parse tar files directly): $with_libarchive | ||
56 | static deltas: yes (always enabled now) | ||
57 | O_TMPFILE: $enable_otmpfile | ||
58 | + static ostree-prepare-root $with_static_prepare_root | ||
59 | man pages (xsltproc): $enable_man | ||
60 | api docs (gtk-doc): $enable_gtk_doc | ||
61 | gjs-based tests: $have_gjs | ||
62 | diff --git a/src/boot/grub2/ostree-grub-generator b/src/boot/grub2/ostree-grub-generator | ||
63 | index 5673b26..ceca806 100644 | ||
64 | --- a/src/boot/grub2/ostree-grub-generator | ||
65 | +++ b/src/boot/grub2/ostree-grub-generator | ||
66 | @@ -28,7 +28,7 @@ entries_path=$(dirname $new_grub2_cfg)/entries | ||
67 | |||
68 | read_config() | ||
69 | { | ||
70 | - config_file=${entries_path}/${1} | ||
71 | + config_file=${1} | ||
72 | title="" | ||
73 | initrd="" | ||
74 | options="" | ||
75 | @@ -62,11 +62,13 @@ read_config() | ||
76 | populate_menu() | ||
77 | { | ||
78 | boot_prefix="${OSTREE_BOOT_PARTITION}" | ||
79 | - for config in $(ls ${entries_path}); do | ||
80 | + for config in $(ls $entries_path/*.conf); do | ||
81 | read_config ${config} | ||
82 | menu="${menu}menuentry '${title}' {\n" | ||
83 | menu="${menu}\t linux ${boot_prefix}${linux} ${options}\n" | ||
84 | - menu="${menu}\t initrd ${boot_prefix}${initrd}\n" | ||
85 | + if [ -n "${initrd}" ] ; then | ||
86 | + menu="${menu}\t initrd ${boot_prefix}${initrd}\n" | ||
87 | + fi | ||
88 | menu="${menu}}\n\n" | ||
89 | done | ||
90 | # The printf command seems to be more reliable across shells for special character (\n, \t) evaluation | ||
91 | diff --git a/src/libostree/ostree-sysroot-deploy.c b/src/libostree/ostree-sysroot-deploy.c | ||
92 | index a05ca30..c0a0347 100644 | ||
93 | --- a/src/libostree/ostree-sysroot-deploy.c | ||
94 | +++ b/src/libostree/ostree-sysroot-deploy.c | ||
95 | @@ -1458,20 +1458,28 @@ install_deployment_kernel (OstreeSysroot *sysroot, | ||
96 | ostree_bootconfig_parser_set (bootconfig, "linux", boot_relpath); | ||
97 | } | ||
98 | |||
99 | + val = ostree_bootconfig_parser_get (bootconfig, "options"); | ||
100 | + kargs = _ostree_kernel_args_from_string (val); | ||
101 | + | ||
102 | if (dest_initramfs_name) | ||
103 | { | ||
104 | g_autofree char * boot_relpath = g_strconcat ("/", bootcsumdir, "/", dest_initramfs_name, NULL); | ||
105 | ostree_bootconfig_parser_set (bootconfig, "initrd", boot_relpath); | ||
106 | } | ||
107 | - | ||
108 | - val = ostree_bootconfig_parser_get (bootconfig, "options"); | ||
109 | + else | ||
110 | + { | ||
111 | + g_autofree char *prepare_root_arg = NULL; | ||
112 | + prepare_root_arg = g_strdup_printf ("init=/ostree/boot.%d/%s/%s/%d/usr/lib/ostree/ostree-prepare-root", | ||
113 | + new_bootversion, osname, bootcsum, | ||
114 | + ostree_deployment_get_bootserial (deployment)); | ||
115 | + _ostree_kernel_args_replace_take (kargs, g_steal_pointer (&prepare_root_arg)); | ||
116 | + } | ||
117 | |||
118 | ostree_kernel_arg = g_strdup_printf ("ostree=/ostree/boot.%d/%s/%s/%d", | ||
119 | new_bootversion, osname, bootcsum, | ||
120 | ostree_deployment_get_bootserial (deployment)); | ||
121 | - kargs = _ostree_kernel_args_from_string (val); | ||
122 | - _ostree_kernel_args_replace_take (kargs, ostree_kernel_arg); | ||
123 | - ostree_kernel_arg = NULL; | ||
124 | + _ostree_kernel_args_replace_take (kargs, g_steal_pointer (&ostree_kernel_arg)); | ||
125 | + | ||
126 | options_key = _ostree_kernel_args_to_string (kargs); | ||
127 | ostree_bootconfig_parser_set (bootconfig, "options", options_key); | ||
128 | |||
129 | -- | ||
130 | 2.7.4 | ||
131 | |||