summaryrefslogtreecommitdiffstats
path: root/recipes/ostree/ostree/Allow-updating-files-in-the-boot-directory.patch
blob: ffcc77c8afd3e477f0072e27f90df837af3d69f3 (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
93
94
95
96
97
98
99
From 7f4549c6e94494460be06311c3a4d23ae684ab21 Mon Sep 17 00:00:00 2001
From: Gatis Paeglis <gatis.paeglis@theqtcompany.com>
Date: Wed, 20 Apr 2016 13:58:27 +0200
Subject: [PATCH 1/3] Allow updating files in the /boot directory.

Until now OSTree copied only the vmlinuz and initramfs
binaries to the boot/ directory (which in some setups
might be on a separate partition). This patch adds
support for copying other files from the deployment's
/boot directory to the real /boot.

How this works:

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

Files in the boot/ directory 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 | 52 +++++++++++++++++++++++++++++++++++
 1 file changed, 52 insertions(+)

diff --git a/src/libostree/ostree-sysroot-deploy.c b/src/libostree/ostree-sysroot-deploy.c
index 8877236..8cf080e 100644
--- a/src/libostree/ostree-sysroot-deploy.c
+++ b/src/libostree/ostree-sysroot-deploy.c
@@ -1295,6 +1295,7 @@ install_deployment_kernel (OstreeSysroot   *sysroot,
   g_autofree char *version_key = NULL;
   g_autofree char *ostree_kernel_arg = NULL;
   g_autofree char *options_key = NULL;
+  g_auto(GLnxDirFdIterator) dfd_iter = { 0, };
   GString *title_key;
   __attribute__((cleanup(_ostree_kernel_args_cleanup))) OstreeKernelArgs *kargs = NULL;
   const char *val;
@@ -1361,6 +1362,57 @@ install_deployment_kernel (OstreeSysroot   *sysroot,
         }
     }
 
+
+  /* Copy other files that are stored in deployment's /usr/lib/ostree-boot. Lets keep this simple:
+   *
+   * - Ignore subdirectories. Only files in root of the /usr/lib/ostree-boot directory are copied.
+   *   There is an overhead of copying files to boot/, therefore the amount of files in a deployment's
+   *   usr/lib/ostree-boot should be kept to the minimum and subdirectories shouldn't really
+   *   be necessary.
+   *
+   * - Files in /boot are updated only with major releases, when kernel/initramfs
+   *   bootcsum changes. Files that require frequent updates should not be stored here.
+   */
+  if (!glnx_dirfd_iterator_init_take_fd (dup (tree_boot_dfd), &dfd_iter, error))
+    goto out;
+
+  while (TRUE)
+    {
+      struct dirent *dent;
+
+      if (!glnx_dirfd_iterator_next_dent (&dfd_iter, &dent, cancellable, error))
+        goto out;
+
+      if (dent == NULL)
+        break;
+
+      if (fstatat (dfd_iter.fd, dent->d_name, &stbuf, 0) != 0)
+        {
+          if (errno == ENOENT)
+              continue;
+          glnx_set_error_from_errno (error);
+          goto out;
+        }
+
+      if (g_str_has_prefix (dent->d_name, "vmlinuz-") || g_str_has_prefix (dent->d_name, "initramfs-")
+              || !S_ISREG(stbuf.st_mode))
+        continue;
+
+      if (fstatat (bootcsum_dfd, dent->d_name, &stbuf, 0) != 0)
+        {
+          if (errno != ENOENT)
+            {
+              glnx_set_prefix_error_from_errno (error, "fstat %s", dent->d_name);
+              goto out;
+            }
+          if (!glnx_file_copy_at (tree_boot_dfd, dent->d_name, &stbuf,
+                                  bootcsum_dfd, dent->d_name, 0,
+                                  cancellable, error))
+            goto out;
+        }
+    }
+
+
   if (fstatat (deployment_dfd, "usr/lib/os-release", &stbuf, 0) != 0)
     {
       if (errno != ENOENT)
-- 
2.7.4