summaryrefslogtreecommitdiffstats
path: root/recipes
diff options
context:
space:
mode:
authorGatis Paeglis <gatis.paeglis@theqtcompany.com>2015-11-10 14:52:38 +0100
committerGatis Paeglis <gatis.paeglis@theqtcompany.com>2015-11-18 09:44:17 +0000
commitaed413df1ee31aad6f67eca405ed01d82d628fc7 (patch)
tree1d622ab6a164f682b80a54341ce9207e9267b26e /recipes
parent886e2f139ecc56846203736eb9616f67ccb74d4f (diff)
downloadmeta-boot2qt-aed413df1ee31aad6f67eca405ed01d82d628fc7.tar.gz
ostree: patch upstream project
- This allows updating files on the boot partition. - Merges ostree's uEnv.txt with system's uEnv.txt - Adds support for convenience symlinks in top level of the /boot directory. This does not affect the atomic property of an update. Change-Id: Ie654e22d6e26aaa0c1395d226ed967765b0c764b Reviewed-by: Samuli Piippo <samuli.piippo@theqtcompany.com>
Diffstat (limited to 'recipes')
-rw-r--r--recipes/ostree/ostree.bb8
-rw-r--r--recipes/ostree/ostree/0001-Allow-updating-files-on-the-boot-partition.patch92
-rw-r--r--recipes/ostree/ostree/0001-Don-t-require-boot-uEnv.txt-for-u-boot-support.patch62
-rw-r--r--recipes/ostree/ostree/0002-u-boot-Merge-ostree-s-and-systems-uEnv.txt.patch99
-rw-r--r--recipes/ostree/ostree/0003-Allow-updating-files-in-root-of-boot.patch104
5 files changed, 301 insertions, 64 deletions
diff --git a/recipes/ostree/ostree.bb b/recipes/ostree/ostree.bb
index ab17671..c4a6f69 100644
--- a/recipes/ostree/ostree.bb
+++ b/recipes/ostree/ostree.bb
@@ -28,10 +28,14 @@ LIC_FILES_CHKSUM = "file://COPYING;md5=5f30f0716dfdd0d91eb439ebec522ec2"
28inherit autotools pkgconfig 28inherit autotools pkgconfig
29 29
30SRC_URI = " \ 30SRC_URI = " \
31 git://github.com/GNOME/ostree.git;tag=v2015.9 \ 31 git://github.com/GNOME/ostree.git \
32 file://0001-Don-t-require-boot-uEnv.txt-for-u-boot-support.patch \ 32 file://0001-Allow-updating-files-on-the-boot-partition.patch \
33 file://0002-u-boot-Merge-ostree-s-and-systems-uEnv.txt.patch \
34 file://0003-Allow-updating-files-in-root-of-boot.patch \
33 " 35 "
34 36
37SRCREV = "efdb4d8f443768e59529c299290bee8b1f8f93c3"
38
35S = "${WORKDIR}/git" 39S = "${WORKDIR}/git"
36 40
37DEPENDS = "glib-2.0 e2fsprogs gpgme attr libsoup-2.4 libgsystem libassuan xz" 41DEPENDS = "glib-2.0 e2fsprogs gpgme attr libsoup-2.4 libgsystem libassuan xz"
diff --git a/recipes/ostree/ostree/0001-Allow-updating-files-on-the-boot-partition.patch b/recipes/ostree/ostree/0001-Allow-updating-files-on-the-boot-partition.patch
new file mode 100644
index 0000000..0905cc1
--- /dev/null
+++ b/recipes/ostree/ostree/0001-Allow-updating-files-on-the-boot-partition.patch
@@ -0,0 +1,92 @@
1From bbb7a8ce89e3e13672c63fd4f1f19988fdf40014 Mon Sep 17 00:00:00 2001
2From: Gatis Paeglis <gatis.paeglis@theqtcompany.com>
3Date: Thu, 5 Nov 2015 17:37:54 +0100
4Subject: [PATCH 1/2] Allow updating files on the boot partition
5
6Until now OSTree copied only vmlinuz and initramfs
7binaries to the boot partition. This patch adds support
8for copying other files from the /boot directory of the
9tree.
10
11How this works:
12
13Ignore subdirectories, only files in root of the boot
14directory are copied. There is overhead of copying files
15to boot partition, therefore the amount of files in the
16boot/ should be kept to the minimum and subdirectories
17shouldn't really be necessary.
18
19Files on the boot partition are updated only with major
20releases, when kernel/initramfs bootcsum changes. Files
21that require frequent updates should not be stored here.
22---
23 src/libostree/ostree-sysroot-deploy.c | 53 +++++++++++++++++++++++++++++++++++
24 1 file changed, 53 insertions(+)
25
26diff --git a/src/libostree/ostree-sysroot-deploy.c b/src/libostree/ostree-sysroot-deploy.c
27index f7afe3d..4d6534d 100644
28--- a/src/libostree/ostree-sysroot-deploy.c
29+++ b/src/libostree/ostree-sysroot-deploy.c
30@@ -1340,6 +1340,59 @@ install_deployment_kernel (OstreeSysroot *sysroot,
31 }
32 }
33
34+ {
35+ /* Copy other files that are stored in the boot directory. Lets keep this simple:
36+ *
37+ * - Ignore subdirectories, only files in root of the boot directory are copied. There is
38+ * overhead of copying files to boot partition, therefore the amount of files in the boot/
39+ * should be kept to the minimum and subdirectories shouldn't really be necessary.
40+ * - Files on the boot partition are updated only with major releases, when kernel/initramfs
41+ * bootcsum changes. Files that require frequent updates should not be stored here.
42+ */
43+ g_autoptr(GFileEnumerator) dir_enum = NULL;
44+ g_autoptr(GFile) deployments_bootdir = g_file_get_child (deployment_dir, "boot");
45+ dir_enum = g_file_enumerate_children (deployments_bootdir, OSTREE_GIO_FAST_QUERYINFO,
46+ G_FILE_QUERY_INFO_NOFOLLOW_SYMLINKS,
47+ NULL, error);
48+ while (TRUE)
49+ {
50+ GFileInfo *file_info = NULL;
51+ g_autoptr(GFile) source_file = NULL;
52+ g_autoptr(GFile) dest_file = NULL;
53+ g_autoptr(GFile) symlink_target = NULL;
54+ GFileType type;
55+ const char *name;
56+
57+ if (!gs_file_enumerator_iterate (dir_enum, &file_info, NULL, cancellable, error))
58+ goto out;
59+ if (file_info == NULL)
60+ break;
61+
62+ type = g_file_info_get_file_type (file_info);
63+ name = g_file_info_get_name (file_info);
64+ if (type == G_FILE_TYPE_DIRECTORY)
65+ continue;
66+ if (type == G_FILE_TYPE_SYMBOLIC_LINK)
67+ {
68+ symlink_target = g_file_get_child (bootcsumdir, g_file_info_get_symlink_target(file_info));
69+ if (!g_file_query_exists (symlink_target, NULL))
70+ continue;
71+ }
72+ if (g_str_has_prefix (name, "vmlinuz-") || g_str_has_prefix (name, "initramfs-"))
73+ continue;
74+
75+ dest_file = g_file_get_child (bootcsumdir, name);
76+ if (!g_file_query_exists (dest_file, NULL))
77+ {
78+ source_file = g_file_enumerator_get_child (dir_enum, file_info);
79+ if (!gs_file_linkcopy_sync_data (source_file, dest_file,
80+ G_FILE_COPY_OVERWRITE | G_FILE_COPY_NOFOLLOW_SYMLINKS | G_FILE_COPY_ALL_METADATA,
81+ cancellable, error))
82+ goto out;
83+ }
84+ }
85+ }
86+
87 if (fstatat (deployment_dfd, "usr/lib/os-release", &stbuf, 0) != 0)
88 {
89 if (errno != ENOENT)
90--
912.1.4
92
diff --git a/recipes/ostree/ostree/0001-Don-t-require-boot-uEnv.txt-for-u-boot-support.patch b/recipes/ostree/ostree/0001-Don-t-require-boot-uEnv.txt-for-u-boot-support.patch
deleted file mode 100644
index 8e1be94..0000000
--- a/recipes/ostree/ostree/0001-Don-t-require-boot-uEnv.txt-for-u-boot-support.patch
+++ /dev/null
@@ -1,62 +0,0 @@
1From ca0a0261be6397d5acb7a4fa2a492c5b554fb1fe Mon Sep 17 00:00:00 2001
2From: Gatis Paeglis <gatis.paeglis@theqtcompany.com>
3Date: Tue, 6 Oct 2015 23:43:25 +0200
4Subject: [PATCH] Don't require /boot/uEnv.txt for u-boot support
5
6The current code checks if /boot/uEnv.txt is a symlink to
7decice if sysroot requires u-boot support. Why this is bad:
8
9There are 2 ways to provide a custom env to u-boot from user space:
10
111) A compiled binary that is sourced from u-boot.
122) A text file (usually /uEnv.txt) that is imported into env from u-boot.
13
14The current OSTree u-boot integration code was designed with the 1st
15case in mind.
16
17Many bootscripts provided by an embedded device vendors expect
18to find uEnv.txt in the top level directory, it is often hardcoded
19when building u-boot and is difficult to change later on. Or in other
20cases it is stored in read-only memory so changing it would require
21re-flushing boot loader with a new env. So the issue here is that
22OSTree's and vendor uEnv.txt want to exist on the same path and OSTree
23would throw away any changes added to /uEnv.txt by user on the next
24upgrade/deploy.
25
26This patch "hides" away the OSTree's env file loader/uEnv.txt from users
27who are used to edditing uEnv.txt at the top level directory. Now to add
28OSTree support on such boards you can simply add a custom logic in uEnv.txt
29that loads ostree env from /loader/uEnv.txt
30
31This change is backward compatible with the previous ostree releases and
32solves the issue described in:
33
34https://bugzilla.gnome.org/show_bug.cgi?id=755787
35---
36 src/libostree/ostree-bootloader-uboot.c | 4 ++--
37 1 file changed, 2 insertions(+), 2 deletions(-)
38
39diff --git a/src/libostree/ostree-bootloader-uboot.c b/src/libostree/ostree-bootloader-uboot.c
40index 4c0218f..f67e9bd 100644
41--- a/src/libostree/ostree-bootloader-uboot.c
42+++ b/src/libostree/ostree-bootloader-uboot.c
43@@ -52,7 +52,7 @@ _ostree_bootloader_uboot_query (OstreeBootloader *bootloader,
44 {
45 OstreeBootloaderUboot *self = OSTREE_BOOTLOADER_UBOOT (bootloader);
46
47- *out_is_active = g_file_query_file_type (self->config_path, G_FILE_QUERY_INFO_NOFOLLOW_SYMLINKS, NULL) == G_FILE_TYPE_SYMBOLIC_LINK;
48+ *out_is_active = g_file_query_file_type (self->config_path, G_FILE_QUERY_INFO_NOFOLLOW_SYMLINKS, NULL) == G_FILE_TYPE_REGULAR;
49 return TRUE;
50 }
51
52@@ -177,6 +177,6 @@ _ostree_bootloader_uboot_new (OstreeSysroot *sysroot)
53 {
54 OstreeBootloaderUboot *self = g_object_new (OSTREE_TYPE_BOOTLOADER_UBOOT, NULL);
55 self->sysroot = g_object_ref (sysroot);
56- self->config_path = g_file_resolve_relative_path (self->sysroot->path, "boot/uEnv.txt");
57+ self->config_path = g_file_resolve_relative_path (self->sysroot->path, "boot/loader/uEnv.txt");
58 return self;
59 }
60--
612.1.4
62
diff --git a/recipes/ostree/ostree/0002-u-boot-Merge-ostree-s-and-systems-uEnv.txt.patch b/recipes/ostree/ostree/0002-u-boot-Merge-ostree-s-and-systems-uEnv.txt.patch
new file mode 100644
index 0000000..08855de
--- /dev/null
+++ b/recipes/ostree/ostree/0002-u-boot-Merge-ostree-s-and-systems-uEnv.txt.patch
@@ -0,0 +1,99 @@
1From 5ee49772b001b9757d6cb21fcc587d5ddc66cdb7 Mon Sep 17 00:00:00 2001
2From: Gatis Paeglis <gatis.paeglis@theqtcompany.com>
3Date: Thu, 5 Nov 2015 17:39:16 +0100
4Subject: [PATCH 2/2] u-boot: Merge ostree's and systems uEnv.txt
5
6This allows for simpler u-boot scripts and is
7a proper fix for:
8
9https://bugzilla.gnome.org/show_bug.cgi?id=755787
10---
11 src/libostree/ostree-bootloader-uboot.c | 42 ++++++++++++++++++++++++++++++---
12 1 file changed, 39 insertions(+), 3 deletions(-)
13
14diff --git a/src/libostree/ostree-bootloader-uboot.c b/src/libostree/ostree-bootloader-uboot.c
15index f67e9bd..be1a40d 100644
16--- a/src/libostree/ostree-bootloader-uboot.c
17+++ b/src/libostree/ostree-bootloader-uboot.c
18@@ -29,6 +29,10 @@
19 #include "otutil.h"
20
21 #include <string.h>
22+#include <stdlib.h>
23+#include <stdio.h>
24+#include <unistd.h>
25+#include <fcntl.h>
26
27 struct _OstreeBootloaderUboot
28 {
29@@ -69,13 +73,17 @@ create_config_from_boot_loader_entries (OstreeBootloaderUboot *self,
30 GCancellable *cancellable,
31 GError **error)
32 {
33+ gboolean ret = FALSE;
34 g_autoptr(GPtrArray) boot_loader_configs = NULL;
35 OstreeBootconfigParser *config;
36 const char *val;
37+ g_autofree char *boot_path = NULL;
38+ g_autoptr(GFile) uenv_file = NULL;
39+ char uenv_path[2048];
40
41 if (!_ostree_sysroot_read_boot_loader_configs (self->sysroot, bootversion, &boot_loader_configs,
42 cancellable, error))
43- return FALSE;
44+ goto out;
45
46 /* U-Boot doesn't support a menu so just pick the first one since the list is ordered */
47 config = boot_loader_configs->pdata[0];
48@@ -85,10 +93,13 @@ create_config_from_boot_loader_entries (OstreeBootloaderUboot *self,
49 {
50 g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
51 "No \"linux\" key in bootloader config");
52- return FALSE;
53+ goto out;
54 }
55 g_ptr_array_add (new_lines, g_strdup_printf ("kernel_image=%s", val));
56
57+ boot_path = strndup (val, strlen (val) - strlen ("/vmlinuz"));
58+ g_ptr_array_add (new_lines, g_strdup_printf ("bootdir=%s", boot_path));
59+
60 val = ostree_bootconfig_parser_get (config, "initrd");
61 if (val)
62 g_ptr_array_add (new_lines, g_strdup_printf ("ramdisk_image=%s", val));
63@@ -97,7 +108,32 @@ create_config_from_boot_loader_entries (OstreeBootloaderUboot *self,
64 if (val)
65 g_ptr_array_add (new_lines, g_strdup_printf ("bootargs=%s", val));
66
67- return TRUE;
68+ /* Merge with user's uEnv.txt if it exists */
69+ snprintf (uenv_path, sizeof(uenv_path), "boot/%s/uEnv.txt", boot_path);
70+ uenv_file = g_file_get_child (self->sysroot->path, uenv_path);
71+ if (g_file_query_exists (uenv_file, cancellable))
72+ {
73+ g_autoptr(GInputStream) instream = NULL;
74+ g_autoptr(GDataInputStream) datastream = NULL;
75+ gsize len;
76+
77+ instream = (GInputStream*)g_file_read (uenv_file, cancellable, error);
78+ if (!instream)
79+ goto out;
80+
81+ datastream = g_data_input_stream_new (instream);
82+ while (TRUE)
83+ {
84+ val = g_data_input_stream_read_line (datastream, &len, cancellable, error);
85+ if (!val)
86+ break;
87+ g_ptr_array_add (new_lines, (char *)val);
88+ }
89+ }
90+
91+ ret = TRUE;
92+out:
93+ return ret;
94 }
95
96 static gboolean
97--
982.1.4
99
diff --git a/recipes/ostree/ostree/0003-Allow-updating-files-in-root-of-boot.patch b/recipes/ostree/ostree/0003-Allow-updating-files-in-root-of-boot.patch
new file mode 100644
index 0000000..d93da22
--- /dev/null
+++ b/recipes/ostree/ostree/0003-Allow-updating-files-in-root-of-boot.patch
@@ -0,0 +1,104 @@
1From f5a1391e64d4b17ed05fb47f23d5d35affb9f1fd Mon Sep 17 00:00:00 2001
2From: Gatis Paeglis <gatis.paeglis@theqtcompany.com>
3Date: Thu, 5 Nov 2015 14:58:56 +0100
4Subject: [PATCH] Allow updating files in root of /boot
5
6It is common for u-boot based systems to search
7top level directory of the boot partiton for
8additional files that are required for booting.
9It can be difficult to change this search logic
10if it is hardcoded somewhere low in the stack or
11in u-boot env that is in read-only memory. To
12allow updating these files you need to add a
13symlink in your ostree sysroot:
14
15cd sysroot/boot
16ln -s loader/my-special-file my-special-file
17
18The bellow code will make sure that loader/my-special-file
19points to the correct target file version.
20
21This does not break the atomic property of update.
22---
23 src/libostree/ostree-bootloader-uboot.c | 65 +++++++++++++++++++++++++++++++++
24 1 file changed, 65 insertions(+)
25
26diff --git a/src/libostree/ostree-bootloader-uboot.c b/src/libostree/ostree-bootloader-uboot.c
27index be1a40d..779c302 100644
28--- a/src/libostree/ostree-bootloader-uboot.c
29+++ b/src/libostree/ostree-bootloader-uboot.c
30@@ -131,6 +131,71 @@ create_config_from_boot_loader_entries (OstreeBootloaderUboot *self,
31 }
32 }
33
34+ {
35+ /* It is common for u-boot based systems to search top level directory of the boot
36+ * partiton for additional files that are required for booting. It can be difficult
37+ * to change this search logic if it is hardcoded somewhere low in the stack or in
38+ * u-boot env that is in read-only memory. To allow updating these files you need to
39+ * add a symlink in your ostree sysroot:
40+ *
41+ * cd sysroot/boot
42+ * ln -s loader/my-special-file my-special-file
43+ *
44+ * The bellow code will make sure that loader/my-special-file points to the correct
45+ * target file version.
46+ *
47+ */
48+ g_autoptr(GFile) child = NULL;
49+ int loader_fd;
50+ g_autoptr(GFileEnumerator) dir_enum = NULL;
51+ g_autoptr(GFile) real_boot = NULL;
52+ g_autofree char *loader_path = NULL;
53+ char buf[2048];
54+
55+ child = ot_gfile_resolve_path_printf (self->sysroot->path, "boot/loader.%d/", bootversion);
56+ loader_path = g_file_get_path(child);
57+ loader_fd = open (loader_path, O_RDONLY);
58+ if (loader_fd == -1) {
59+ perror("open");
60+ goto out;
61+ }
62+
63+ child = g_file_get_child (self->sysroot->path, "boot");
64+ dir_enum = g_file_enumerate_children (child, OSTREE_GIO_FAST_QUERYINFO,
65+ G_FILE_QUERY_INFO_NOFOLLOW_SYMLINKS,
66+ NULL, error);
67+
68+ while (TRUE) {
69+ const char *symlink_target, *name;
70+ GFileInfo *file_info = NULL;
71+
72+ if (!gs_file_enumerator_iterate (dir_enum, &file_info, NULL, cancellable, error)) {
73+ close(loader_fd);
74+ goto out;
75+ }
76+
77+ if (file_info == NULL)
78+ break;
79+
80+ if (g_file_info_get_is_symlink(file_info)) {
81+ symlink_target = g_file_info_get_symlink_target(file_info);
82+ if (g_str_has_prefix(symlink_target, "loader/")) {
83+ name = g_file_info_get_name(file_info);
84+ if (g_strcmp0 (name, "uEnv.txt") == 0)
85+ continue;
86+
87+ snprintf(buf, sizeof(buf), "%s/%s", loader_path, name);
88+ remove(buf);
89+ snprintf(buf, sizeof(buf), "..%s/%s", boot_path, name);
90+ if (symlinkat(buf, loader_fd, name) == -1)
91+ perror("symlinkat");
92+ }
93+ }
94+ }
95+
96+ close(loader_fd);
97+ }
98+
99 ret = TRUE;
100 out:
101 return ret;
102--
1032.1.4
104