diff options
Diffstat (limited to 'recipes/ostree/ostree/Allow-updating-files-in-the-boot-directory.patch')
-rw-r--r-- | recipes/ostree/ostree/Allow-updating-files-in-the-boot-directory.patch | 194 |
1 files changed, 128 insertions, 66 deletions
diff --git a/recipes/ostree/ostree/Allow-updating-files-in-the-boot-directory.patch b/recipes/ostree/ostree/Allow-updating-files-in-the-boot-directory.patch index ffcc77c..d416543 100644 --- a/recipes/ostree/ostree/Allow-updating-files-in-the-boot-directory.patch +++ b/recipes/ostree/ostree/Allow-updating-files-in-the-boot-directory.patch | |||
@@ -1,34 +1,90 @@ | |||
1 | From 7f4549c6e94494460be06311c3a4d23ae684ab21 Mon Sep 17 00:00:00 2001 | 1 | From cc31c80658a90cf1b13fdf9fe8b6dde1cc9a0d24 Mon Sep 17 00:00:00 2001 |
2 | From: Gatis Paeglis <gatis.paeglis@theqtcompany.com> | 2 | From: Gatis Paeglis <gatis.paeglis@qt.io> |
3 | Date: Wed, 20 Apr 2016 13:58:27 +0200 | 3 | Date: Mon, 22 Aug 2016 11:32:16 +0200 |
4 | Subject: [PATCH 1/3] Allow updating files in the /boot directory. | 4 | Subject: [PATCH 1/3] Allow updating files in the /boot directory |
5 | 5 | ||
6 | Until now OSTree copied only the vmlinuz and initramfs | 6 | This patch adds support for copying (or hardlinking on |
7 | binaries to the boot/ directory (which in some setups | 7 | single partition systems) all files from the deployment's |
8 | might be on a separate partition). This patch adds | 8 | /usr/lib/ostree-boot directory to the relevant |
9 | support for copying other files from the deployment's | 9 | /boot/ostree/$os-$bootcsum/ directory. This feature can |
10 | /boot directory to the real /boot. | 10 | be enabled by 'touch .ostree-bootcsumdir-source' in |
11 | 11 | /usr/lib/ostree-boot. | |
12 | How this works: | ||
13 | |||
14 | Ignore subdirectories, only files in root of the boot | ||
15 | directory are copied. There is overhead of copying files | ||
16 | to boot/, therefore the amount of files in boot/ should | ||
17 | be kept to the minimum and subdirectories shouldn't | ||
18 | really be necessary. | ||
19 | |||
20 | Files in the boot/ directory are updated only with major | ||
21 | releases, when kernel/initramfs bootcsum changes. Files | ||
22 | that require frequent updates should not be stored here. | ||
23 | --- | 12 | --- |
24 | src/libostree/ostree-sysroot-deploy.c | 52 +++++++++++++++++++++++++++++++++++ | 13 | src/libostree/ostree-sysroot-deploy.c | 101 +++++++++++++++++++++++++++++++--- |
25 | 1 file changed, 52 insertions(+) | 14 | 1 file changed, 94 insertions(+), 7 deletions(-) |
26 | 15 | ||
27 | diff --git a/src/libostree/ostree-sysroot-deploy.c b/src/libostree/ostree-sysroot-deploy.c | 16 | diff --git a/src/libostree/ostree-sysroot-deploy.c b/src/libostree/ostree-sysroot-deploy.c |
28 | index 8877236..8cf080e 100644 | 17 | index a05ca30..f34e3f3 100644 |
29 | --- a/src/libostree/ostree-sysroot-deploy.c | 18 | --- a/src/libostree/ostree-sysroot-deploy.c |
30 | +++ b/src/libostree/ostree-sysroot-deploy.c | 19 | +++ b/src/libostree/ostree-sysroot-deploy.c |
31 | @@ -1295,6 +1295,7 @@ install_deployment_kernel (OstreeSysroot *sysroot, | 20 | @@ -165,12 +165,31 @@ dirfd_copy_attributes_and_xattrs (int src_parent_dfd, |
21 | } | ||
22 | |||
23 | static gboolean | ||
24 | +hardlink_or_copy_dir_recurse (int src_parent_dfd, | ||
25 | + int dest_parent_dfd, | ||
26 | + const char *name, | ||
27 | + gboolean hardlink, | ||
28 | + GCancellable *cancellable, | ||
29 | + GError **error); | ||
30 | + | ||
31 | +static gboolean | ||
32 | copy_dir_recurse (int src_parent_dfd, | ||
33 | int dest_parent_dfd, | ||
34 | const char *name, | ||
35 | GCancellable *cancellable, | ||
36 | GError **error) | ||
37 | { | ||
38 | + return hardlink_or_copy_dir_recurse (src_parent_dfd, dest_parent_dfd, name, FALSE, cancellable, error); | ||
39 | +} | ||
40 | + | ||
41 | +static gboolean | ||
42 | +hardlink_or_copy_dir_recurse (int src_parent_dfd, | ||
43 | + int dest_parent_dfd, | ||
44 | + const char *name, | ||
45 | + gboolean hardlink, | ||
46 | + GCancellable *cancellable, | ||
47 | + GError **error) | ||
48 | +{ | ||
49 | g_auto(GLnxDirFdIterator) src_dfd_iter = { 0, }; | ||
50 | glnx_fd_close int dest_dfd = -1; | ||
51 | struct dirent *dent; | ||
52 | @@ -210,17 +229,27 @@ copy_dir_recurse (int src_parent_dfd, | ||
53 | |||
54 | if (S_ISDIR (child_stbuf.st_mode)) | ||
55 | { | ||
56 | - if (!copy_dir_recurse (src_dfd_iter.fd, dest_dfd, dent->d_name, | ||
57 | - cancellable, error)) | ||
58 | + if (!hardlink_or_copy_dir_recurse (src_dfd_iter.fd, dest_dfd, dent->d_name, | ||
59 | + hardlink, cancellable, error)) | ||
60 | return FALSE; | ||
61 | } | ||
62 | else | ||
63 | { | ||
64 | - if (!glnx_file_copy_at (src_dfd_iter.fd, dent->d_name, &child_stbuf, | ||
65 | - dest_dfd, dent->d_name, | ||
66 | - GLNX_FILE_COPY_OVERWRITE, | ||
67 | - cancellable, error)) | ||
68 | - return FALSE; | ||
69 | + if (hardlink) | ||
70 | + { | ||
71 | + if (!hardlink_or_copy_at (src_dfd_iter.fd, dent->d_name, | ||
72 | + dest_dfd, dent->d_name, | ||
73 | + cancellable, error)) | ||
74 | + return FALSE; | ||
75 | + } | ||
76 | + else | ||
77 | + { | ||
78 | + if (!glnx_file_copy_at (src_dfd_iter.fd, dent->d_name, &child_stbuf, | ||
79 | + dest_dfd, dent->d_name, | ||
80 | + GLNX_FILE_COPY_OVERWRITE, | ||
81 | + cancellable, error)) | ||
82 | + return FALSE; | ||
83 | + } | ||
84 | } | ||
85 | } | ||
86 | |||
87 | @@ -1301,6 +1330,7 @@ install_deployment_kernel (OstreeSysroot *sysroot, | ||
32 | g_autofree char *version_key = NULL; | 88 | g_autofree char *version_key = NULL; |
33 | g_autofree char *ostree_kernel_arg = NULL; | 89 | g_autofree char *ostree_kernel_arg = NULL; |
34 | g_autofree char *options_key = NULL; | 90 | g_autofree char *options_key = NULL; |
@@ -36,60 +92,66 @@ index 8877236..8cf080e 100644 | |||
36 | GString *title_key; | 92 | GString *title_key; |
37 | __attribute__((cleanup(_ostree_kernel_args_cleanup))) OstreeKernelArgs *kargs = NULL; | 93 | __attribute__((cleanup(_ostree_kernel_args_cleanup))) OstreeKernelArgs *kargs = NULL; |
38 | const char *val; | 94 | const char *val; |
39 | @@ -1361,6 +1362,57 @@ install_deployment_kernel (OstreeSysroot *sysroot, | 95 | @@ -1367,6 +1397,63 @@ install_deployment_kernel (OstreeSysroot *sysroot, |
40 | } | 96 | } |
41 | } | 97 | } |
42 | 98 | ||
43 | + | 99 | + if (fstatat (tree_boot_dfd, ".ostree-bootcsumdir-source", &stbuf, 0) == 0) |
44 | + /* Copy other files that are stored in deployment's /usr/lib/ostree-boot. Lets keep this simple: | ||
45 | + * | ||
46 | + * - Ignore subdirectories. Only files in root of the /usr/lib/ostree-boot directory are copied. | ||
47 | + * There is an overhead of copying files to boot/, therefore the amount of files in a deployment's | ||
48 | + * usr/lib/ostree-boot should be kept to the minimum and subdirectories shouldn't really | ||
49 | + * be necessary. | ||
50 | + * | ||
51 | + * - Files in /boot are updated only with major releases, when kernel/initramfs | ||
52 | + * bootcsum changes. Files that require frequent updates should not be stored here. | ||
53 | + */ | ||
54 | + if (!glnx_dirfd_iterator_init_take_fd (dup (tree_boot_dfd), &dfd_iter, error)) | ||
55 | + goto out; | ||
56 | + | ||
57 | + while (TRUE) | ||
58 | + { | 100 | + { |
59 | + struct dirent *dent; | 101 | + if (!glnx_dirfd_iterator_init_at (tree_boot_dfd, ".", FALSE, &dfd_iter, error)) |
60 | + | ||
61 | + if (!glnx_dirfd_iterator_next_dent (&dfd_iter, &dent, cancellable, error)) | ||
62 | + goto out; | 102 | + goto out; |
63 | + | 103 | + |
64 | + if (dent == NULL) | 104 | + while (TRUE) |
65 | + break; | ||
66 | + | ||
67 | + if (fstatat (dfd_iter.fd, dent->d_name, &stbuf, 0) != 0) | ||
68 | + { | 105 | + { |
69 | + if (errno == ENOENT) | 106 | + struct dirent *dent; |
70 | + continue; | ||
71 | + glnx_set_error_from_errno (error); | ||
72 | + goto out; | ||
73 | + } | ||
74 | + | 107 | + |
75 | + if (g_str_has_prefix (dent->d_name, "vmlinuz-") || g_str_has_prefix (dent->d_name, "initramfs-") | 108 | + if (!glnx_dirfd_iterator_next_dent (&dfd_iter, &dent, cancellable, error)) |
76 | + || !S_ISREG(stbuf.st_mode)) | 109 | + goto out; |
77 | + continue; | 110 | + if (dent == NULL) |
111 | + break; | ||
78 | + | 112 | + |
79 | + if (fstatat (bootcsum_dfd, dent->d_name, &stbuf, 0) != 0) | 113 | + /* Skip special files - vmlinuz-* and initramfs-* are handled separately */ |
80 | + { | 114 | + if (g_str_has_prefix (dent->d_name, "vmlinuz-") || g_str_has_prefix (dent->d_name, "initramfs-")) |
81 | + if (errno != ENOENT) | 115 | + continue; |
116 | + | ||
117 | + if (fstatat (bootcsum_dfd, dent->d_name, &stbuf, AT_SYMLINK_NOFOLLOW) != 0) | ||
82 | + { | 118 | + { |
83 | + glnx_set_prefix_error_from_errno (error, "fstat %s", dent->d_name); | 119 | + if (errno != ENOENT) |
84 | + goto out; | 120 | + { |
121 | + glnx_set_prefix_error_from_errno (error, "fstatat %s", dent->d_name); | ||
122 | + goto out; | ||
123 | + } | ||
124 | + | ||
125 | + if (fstatat (dfd_iter.fd, dent->d_name, &stbuf, AT_SYMLINK_NOFOLLOW) != 0) | ||
126 | + { | ||
127 | + glnx_set_error_from_errno (error); | ||
128 | + goto out; | ||
129 | + } | ||
130 | + | ||
131 | + if (S_ISDIR (stbuf.st_mode)) | ||
132 | + { | ||
133 | + if (!hardlink_or_copy_dir_recurse (tree_boot_dfd, bootcsum_dfd, dent->d_name, | ||
134 | + TRUE, cancellable, error)) | ||
135 | + goto out; | ||
136 | + } | ||
137 | + else | ||
138 | + { | ||
139 | + if (!hardlink_or_copy_at (tree_boot_dfd, dent->d_name, | ||
140 | + bootcsum_dfd, dent->d_name, | ||
141 | + cancellable, error)) | ||
142 | + goto out; | ||
143 | + } | ||
85 | + } | 144 | + } |
86 | + if (!glnx_file_copy_at (tree_boot_dfd, dent->d_name, &stbuf, | ||
87 | + bootcsum_dfd, dent->d_name, 0, | ||
88 | + cancellable, error)) | ||
89 | + goto out; | ||
90 | + } | 145 | + } |
91 | + } | 146 | + } |
92 | + | 147 | + else |
148 | + { | ||
149 | + if (errno != ENOENT) | ||
150 | + { | ||
151 | + glnx_set_prefix_error_from_errno (error, "fstatat %s", ".ostree-bootcsumdir-source"); | ||
152 | + goto out; | ||
153 | + } | ||
154 | + } | ||
93 | + | 155 | + |
94 | if (fstatat (deployment_dfd, "usr/lib/os-release", &stbuf, 0) != 0) | 156 | if (fstatat (deployment_dfd, "usr/lib/os-release", &stbuf, 0) != 0) |
95 | { | 157 | { |