1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
|
From 5ee49772b001b9757d6cb21fcc587d5ddc66cdb7 Mon Sep 17 00:00:00 2001
From: Gatis Paeglis <gatis.paeglis@theqtcompany.com>
Date: Thu, 5 Nov 2015 17:39:16 +0100
Subject: [PATCH 2/2] u-boot: Merge ostree's and systems uEnv.txt
This allows for simpler u-boot scripts and is
a proper fix for:
https://bugzilla.gnome.org/show_bug.cgi?id=755787
---
src/libostree/ostree-bootloader-uboot.c | 42 ++++++++++++++++++++++++++++++---
1 file changed, 39 insertions(+), 3 deletions(-)
diff --git a/src/libostree/ostree-bootloader-uboot.c b/src/libostree/ostree-bootloader-uboot.c
index f67e9bd..be1a40d 100644
--- a/src/libostree/ostree-bootloader-uboot.c
+++ b/src/libostree/ostree-bootloader-uboot.c
@@ -29,6 +29,10 @@
#include "otutil.h"
#include <string.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <unistd.h>
+#include <fcntl.h>
struct _OstreeBootloaderUboot
{
@@ -69,13 +73,17 @@ create_config_from_boot_loader_entries (OstreeBootloaderUboot *self,
GCancellable *cancellable,
GError **error)
{
+ gboolean ret = FALSE;
g_autoptr(GPtrArray) boot_loader_configs = NULL;
OstreeBootconfigParser *config;
const char *val;
+ g_autofree char *boot_path = NULL;
+ g_autoptr(GFile) uenv_file = NULL;
+ char uenv_path[2048];
if (!_ostree_sysroot_read_boot_loader_configs (self->sysroot, bootversion, &boot_loader_configs,
cancellable, error))
- return FALSE;
+ goto out;
/* U-Boot doesn't support a menu so just pick the first one since the list is ordered */
config = boot_loader_configs->pdata[0];
@@ -85,10 +93,13 @@ create_config_from_boot_loader_entries (OstreeBootloaderUboot *self,
{
g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
"No \"linux\" key in bootloader config");
- return FALSE;
+ goto out;
}
g_ptr_array_add (new_lines, g_strdup_printf ("kernel_image=%s", val));
+ boot_path = strndup (val, strlen (val) - strlen ("/vmlinuz"));
+ g_ptr_array_add (new_lines, g_strdup_printf ("bootdir=%s", boot_path));
+
val = ostree_bootconfig_parser_get (config, "initrd");
if (val)
g_ptr_array_add (new_lines, g_strdup_printf ("ramdisk_image=%s", val));
@@ -97,7 +108,32 @@ create_config_from_boot_loader_entries (OstreeBootloaderUboot *self,
if (val)
g_ptr_array_add (new_lines, g_strdup_printf ("bootargs=%s", val));
- return TRUE;
+ /* Merge with user's uEnv.txt if it exists */
+ snprintf (uenv_path, sizeof(uenv_path), "boot/%s/uEnv.txt", boot_path);
+ uenv_file = g_file_get_child (self->sysroot->path, uenv_path);
+ if (g_file_query_exists (uenv_file, cancellable))
+ {
+ g_autoptr(GInputStream) instream = NULL;
+ g_autoptr(GDataInputStream) datastream = NULL;
+ gsize len;
+
+ instream = (GInputStream*)g_file_read (uenv_file, cancellable, error);
+ if (!instream)
+ goto out;
+
+ datastream = g_data_input_stream_new (instream);
+ while (TRUE)
+ {
+ val = g_data_input_stream_read_line (datastream, &len, cancellable, error);
+ if (!val)
+ break;
+ g_ptr_array_add (new_lines, (char *)val);
+ }
+ }
+
+ ret = TRUE;
+out:
+ return ret;
}
static gboolean
--
2.1.4
|