@@ -80,6 +80,48 @@ rename_if_exists (int src_dfd, const char *from, int dest_dfd, const char *to, G
8080 return TRUE;
8181}
8282
83+ static gboolean
84+ run_dracut (int rootfs_dfd , rpmostreecxx ::Treefile & treefile , GLnxTmpfile * initramfs_tmpf ,
85+ const char * kver , GCancellable * cancellable , GError * * error )
86+ {
87+ /* Run dracut with our chosen arguments (commonly at least --no-hostonly) */
88+ g_autoptr (GPtrArray ) dracut_argv = g_ptr_array_new ();
89+ rust ::Vec < rust ::String > initramfs_args = treefile .get_initramfs_args ();
90+ if (!initramfs_args .empty ())
91+ {
92+ for (auto & arg : initramfs_args )
93+ g_ptr_array_add (dracut_argv , (void * )arg .c_str ());
94+ }
95+ else
96+ {
97+ /* Default to this for treecomposes */
98+ g_ptr_array_add (dracut_argv , (char * )"--no-hostonly" );
99+ }
100+ g_ptr_array_add (dracut_argv , NULL );
101+
102+ /* We use a tmpdir under the target root since dracut currently tries to copy
103+ * xattrs, including e.g. user.ostreemeta, which can't be copied to tmpfs.
104+ */
105+ {
106+ g_auto (GLnxTmpDir ) dracut_host_tmpd = {
107+ 0 ,
108+ };
109+ if (!glnx_mkdtempat (rootfs_dfd , "rpmostree-dracut.XXXXXX" , 0700 , & dracut_host_tmpd , error ))
110+ return FALSE;
111+ if (!rpmostree_run_dracut (rootfs_dfd , (const char * const * )dracut_argv -> pdata , kver , NULL ,
112+ FALSE, & dracut_host_tmpd , initramfs_tmpf , cancellable , error ))
113+ return FALSE;
114+ /* No reason to have the initramfs not be world-readable since
115+ * it's server-side generated and shouldn't contain any secrets.
116+ * https://github.com/coreos/coreos-assembler/pull/372#issuecomment-467620937
117+ */
118+ if (!glnx_fchmod (initramfs_tmpf -> fd , 0644 , error ))
119+ return FALSE;
120+ }
121+
122+ return TRUE;
123+ }
124+
83125/* Handle the kernel/initramfs, which can be in at least 2 different places:
84126 * - /boot (CentOS, Fedora treecompose before we suppressed kernel.spec's %posttrans)
85127 * - /usr/lib/modules (Fedora treecompose without kernel.spec's %posttrans)
@@ -195,43 +237,14 @@ process_kernel_and_initramfs (int rootfs_dfd, rpmostreecxx::Treefile &treefile,
195237 (void )unlinkat (rootfs_dfd , "usr/etc/machine-id" , 0 );
196238 }
197239
198- /* Run dracut with our chosen arguments (commonly at least --no-hostonly) */
199- g_autoptr (GPtrArray ) dracut_argv = g_ptr_array_new ();
200- rust ::Vec < rust ::String > initramfs_args = treefile .get_initramfs_args ();
201- if (!initramfs_args .empty ())
202- {
203- for (auto & arg : initramfs_args )
204- g_ptr_array_add (dracut_argv , (void * )arg .c_str ());
205- }
206- else
207- {
208- /* Default to this for treecomposes */
209- g_ptr_array_add (dracut_argv , (char * )"--no-hostonly" );
210- }
211- g_ptr_array_add (dracut_argv , NULL );
212-
213240 g_auto (GLnxTmpfile ) initramfs_tmpf = {
214241 0 ,
215242 };
216- /* We use a tmpdir under the target root since dracut currently tries to copy
217- * xattrs, including e.g. user.ostreemeta, which can't be copied to tmpfs.
218- */
219- {
220- g_auto (GLnxTmpDir ) dracut_host_tmpd = {
221- 0 ,
222- };
223- if (!glnx_mkdtempat (rootfs_dfd , "rpmostree-dracut.XXXXXX" , 0700 , & dracut_host_tmpd , error ))
224- return FALSE;
225- if (!rpmostree_run_dracut (rootfs_dfd , (const char * const * )dracut_argv -> pdata , kver , NULL ,
226- FALSE, & dracut_host_tmpd , & initramfs_tmpf , cancellable , error ))
227- return FALSE;
228- /* No reason to have the initramfs not be world-readable since
229- * it's server-side generated and shouldn't contain any secrets.
230- * https://github.com/coreos/coreos-assembler/pull/372#issuecomment-467620937
231- */
232- if (!glnx_fchmod (initramfs_tmpf .fd , 0644 , error ))
233- return FALSE;
234- }
243+ if (!treefile .get_no_initramfs ())
244+ {
245+ if (!run_dracut (rootfs_dfd , treefile , & initramfs_tmpf , kver , cancellable , error ))
246+ return FALSE;
247+ }
235248
236249 /* We always tell rpmostree_finalize_kernel() to skip /boot, since we'll do a
237250 * full hardlink pass if needed after that for the kernel + bootloader data.
0 commit comments