summaryrefslogtreecommitdiffstats
path: root/recipes/ostree/ostree/0001-Allow-updating-files-on-the-boot-partition.patch
blob: 0905cc1958ab7113a8f0745b183a3c58d5e6bc8b (plain)
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
From bbb7a8ce89e3e13672c63fd4f1f19988fdf40014 Mon Sep 17 00:00:00 2001
From: Gatis Paeglis <gatis.paeglis@theqtcompany.com>
Date: Thu, 5 Nov 2015 17:37:54 +0100
Subject: [PATCH 1/2] Allow updating files on the boot partition

Until now OSTree copied only vmlinuz and initramfs
binaries to the boot partition. This patch adds support
for copying other files from the /boot directory of the
tree.

How this works:

Ignore subdirectories, only files in root of the boot
directory are copied. There is overhead of copying files
to boot partition, therefore the amount of files in the
boot/ should be kept to the minimum and subdirectories
shouldn't really be necessary.

Files on the boot partition are updated only with major
releases, when kernel/initramfs bootcsum changes. Files
that require frequent updates should not be stored here.
---
 src/libostree/ostree-sysroot-deploy.c | 53 +++++++++++++++++++++++++++++++++++
 1 file changed, 53 insertions(+)

diff --git a/src/libostree/ostree-sysroot-deploy.c b/src/libostree/ostree-sysroot-deploy.c
index f7afe3d..4d6534d 100644
--- a/src/libostree/ostree-sysroot-deploy.c
+++ b/src/libostree/ostree-sysroot-deploy.c
@@ -1340,6 +1340,59 @@ install_deployment_kernel (OstreeSysroot   *sysroot,
         }
     }
 
+  {
+    /* Copy other files that are stored in the boot directory. Lets keep this simple:
+     *
+     * - Ignore subdirectories, only files in root of the boot directory are copied. There is
+     *   overhead of copying files to boot partition, therefore the amount of files in the boot/
+     *   should be kept to the minimum and subdirectories shouldn't really be necessary.
+     * - Files on the boot partition are updated only with major releases, when kernel/initramfs
+     *   bootcsum changes. Files that require frequent updates should not be stored here.
+     */
+    g_autoptr(GFileEnumerator) dir_enum = NULL;
+    g_autoptr(GFile) deployments_bootdir = g_file_get_child (deployment_dir, "boot");
+    dir_enum = g_file_enumerate_children (deployments_bootdir, OSTREE_GIO_FAST_QUERYINFO,
+                                          G_FILE_QUERY_INFO_NOFOLLOW_SYMLINKS,
+                                          NULL, error);
+    while (TRUE)
+      {
+        GFileInfo *file_info = NULL;
+        g_autoptr(GFile) source_file = NULL;
+        g_autoptr(GFile) dest_file = NULL;
+        g_autoptr(GFile) symlink_target = NULL;
+        GFileType type;
+        const char *name;
+
+        if (!gs_file_enumerator_iterate (dir_enum, &file_info, NULL, cancellable, error))
+          goto out;
+        if (file_info == NULL)
+          break;
+
+        type = g_file_info_get_file_type (file_info);
+        name = g_file_info_get_name (file_info);
+        if (type == G_FILE_TYPE_DIRECTORY)
+          continue;
+        if (type == G_FILE_TYPE_SYMBOLIC_LINK)
+          {
+            symlink_target = g_file_get_child (bootcsumdir, g_file_info_get_symlink_target(file_info));
+            if (!g_file_query_exists (symlink_target, NULL))
+              continue;
+          }
+        if (g_str_has_prefix (name, "vmlinuz-") || g_str_has_prefix (name, "initramfs-"))
+          continue;
+
+        dest_file = g_file_get_child (bootcsumdir, name);
+        if (!g_file_query_exists (dest_file, NULL))
+          {
+            source_file = g_file_enumerator_get_child (dir_enum, file_info);
+            if (!gs_file_linkcopy_sync_data (source_file, dest_file,
+                                             G_FILE_COPY_OVERWRITE | G_FILE_COPY_NOFOLLOW_SYMLINKS | G_FILE_COPY_ALL_METADATA,
+                                             cancellable, error))
+              goto out;
+          }
+      }
+  }
+
   if (fstatat (deployment_dfd, "usr/lib/os-release", &stbuf, 0) != 0)
     {
       if (errno != ENOENT)
-- 
2.1.4