summaryrefslogtreecommitdiffstats
path: root/recipes/ostree/ostree/0002-u-boot-Merge-ostree-s-and-systems-uEnv.txt.patch
diff options
context:
space:
mode:
Diffstat (limited to 'recipes/ostree/ostree/0002-u-boot-Merge-ostree-s-and-systems-uEnv.txt.patch')
-rw-r--r--recipes/ostree/ostree/0002-u-boot-Merge-ostree-s-and-systems-uEnv.txt.patch99
1 files changed, 99 insertions, 0 deletions
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