|
32 | 32 |
|
33 | 33 | #include <libglnx.h> |
34 | 34 |
|
35 | | -gboolean |
36 | | -rpmostree_container_rebuild (rpmostreecxx::Treefile &treefile, GCancellable *cancellable, |
37 | | - GError **error) |
| 35 | +static gboolean |
| 36 | +container_rebuild_inner (int rootfs_fd, rpmostreecxx::Treefile &treefile, GCancellable *cancellable, |
| 37 | + GError **error) |
38 | 38 | { |
39 | 39 | CXX_TRY (treefile.validate_for_container (), error); |
40 | 40 |
|
41 | 41 | g_autoptr (RpmOstreeContext) ctx = rpmostree_context_new_container (); |
42 | 42 | rpmostree_context_set_treefile (ctx, treefile); |
43 | 43 |
|
44 | | - glnx_autofd int rootfs_fd = -1; |
45 | | - if (!glnx_opendirat (AT_FDCWD, "/", TRUE, &rootfs_fd, error)) |
46 | | - return FALSE; |
47 | | - |
48 | 44 | // Forcibly turn this on for the container flow because it's the only sane |
49 | 45 | // way for installing RPM packages that invoke useradd/groupadd to work. |
50 | 46 | g_setenv ("RPMOSTREE_EXP_BRIDGE_SYSUSERS", "1", TRUE); |
@@ -78,6 +74,22 @@ rpmostree_container_rebuild (rpmostreecxx::Treefile &treefile, GCancellable *can |
78 | 74 |
|
79 | 75 | CXX_TRY (fs_prep->undo (), error); |
80 | 76 |
|
| 77 | + return TRUE; |
| 78 | +} |
| 79 | + |
| 80 | +gboolean |
| 81 | +rpmostree_container_rebuild (rpmostreecxx::Treefile &treefile, GCancellable *cancellable, |
| 82 | + GError **error) |
| 83 | +{ |
| 84 | + |
| 85 | + glnx_autofd int rootfs_fd = -1; |
| 86 | + if (!glnx_opendirat (AT_FDCWD, "/", TRUE, &rootfs_fd, error)) |
| 87 | + return FALSE; |
| 88 | + |
| 89 | + // Do this in a new scope to ensure we teardown our connection to the rpmdb |
| 90 | + if (!container_rebuild_inner (rootfs_fd, treefile, cancellable, error)) |
| 91 | + return FALSE; |
| 92 | + |
81 | 93 | CXX_TRY (rpmostreecxx::postprocess_cleanup_rpmdb (rootfs_fd), error); |
82 | 94 |
|
83 | 95 | return TRUE; |
|
0 commit comments