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