bwrap: Split out a "base" constructor
The bwrap code has some "opinionated" setup around e.g. /etc and such that I'd like to centralize even more. However, the dracut case of taking the host's `/etc` is the unusual standout. Let's split out a base constructor. Prep for https://github.com/projectatomic/rpm-ostree/issues/1329 Closes: #1333 Approved by: jlebon
This commit is contained in:
parent
4be214a978
commit
e38c64c330
@ -201,12 +201,8 @@ running_in_nspawn (void)
|
||||
}
|
||||
|
||||
RpmOstreeBwrap *
|
||||
rpmostree_bwrap_new (int rootfs_fd,
|
||||
RpmOstreeBwrapMutability mutable,
|
||||
GError **error,
|
||||
...)
|
||||
rpmostree_bwrap_new_base (int rootfs_fd, GError **error)
|
||||
{
|
||||
va_list args;
|
||||
g_autoptr(RpmOstreeBwrap) ret = g_new0 (RpmOstreeBwrap, 1);
|
||||
static const char *usr_links[] = {"lib", "lib32", "lib64", "bin", "sbin"};
|
||||
|
||||
@ -301,6 +297,20 @@ rpmostree_bwrap_new (int rootfs_fd,
|
||||
rpmostree_bwrap_append_bwrap_argv (ret, "--symlink", srcpath, destpath, NULL);
|
||||
}
|
||||
|
||||
return g_steal_pointer (&ret);
|
||||
}
|
||||
|
||||
RpmOstreeBwrap *
|
||||
rpmostree_bwrap_new (int rootfs_fd,
|
||||
RpmOstreeBwrapMutability mutable,
|
||||
GError **error,
|
||||
...)
|
||||
{
|
||||
g_autoptr(RpmOstreeBwrap) ret = rpmostree_bwrap_new_base (rootfs_fd, error);
|
||||
if (!ret)
|
||||
return FALSE;
|
||||
|
||||
va_list args;
|
||||
switch (mutable)
|
||||
{
|
||||
case RPMOSTREE_BWRAP_IMMUTABLE:
|
||||
@ -315,12 +325,11 @@ rpmostree_bwrap_new (int rootfs_fd,
|
||||
break;
|
||||
}
|
||||
|
||||
{ const char *arg;
|
||||
va_start (args, error);
|
||||
while ((arg = va_arg (args, char *)))
|
||||
g_ptr_array_add (ret->argv, g_strdup (arg));
|
||||
va_end (args);
|
||||
}
|
||||
const char *arg;
|
||||
va_start (args, error);
|
||||
while ((arg = va_arg (args, char *)))
|
||||
g_ptr_array_add (ret->argv, g_strdup (arg));
|
||||
va_end (args);
|
||||
|
||||
return g_steal_pointer (&ret);
|
||||
}
|
||||
|
@ -38,6 +38,8 @@ G_DEFINE_AUTOPTR_CLEANUP_FUNC(RpmOstreeBwrap, rpmostree_bwrap_unref)
|
||||
/* TODO - move this utility elsewhere */
|
||||
void rpmostree_ptrarray_append_strdup (GPtrArray *argv_array, ...) G_GNUC_NULL_TERMINATED;
|
||||
|
||||
RpmOstreeBwrap *rpmostree_bwrap_new_base (int rootfs, GError **error);
|
||||
|
||||
RpmOstreeBwrap *rpmostree_bwrap_new (int rootfs,
|
||||
RpmOstreeBwrapMutability mutable,
|
||||
GError **error,
|
||||
|
@ -437,15 +437,25 @@ rpmostree_run_dracut (int rootfs_dfd,
|
||||
* config files. Otherwise, we use the usr/etc defaults.
|
||||
*/
|
||||
if (rebuild_from_initramfs)
|
||||
bwrap = rpmostree_bwrap_new (rootfs_dfd, RPMOSTREE_BWRAP_IMMUTABLE, error,
|
||||
"--ro-bind", "/etc", "/etc",
|
||||
NULL);
|
||||
{
|
||||
bwrap = rpmostree_bwrap_new_base (rootfs_dfd, error);
|
||||
if (!bwrap)
|
||||
return FALSE;
|
||||
rpmostree_bwrap_append_bwrap_argv (bwrap,
|
||||
"--ro-bind", "/etc", "/etc",
|
||||
"--ro-bind", "usr", "/usr",
|
||||
NULL);
|
||||
}
|
||||
else
|
||||
bwrap = rpmostree_bwrap_new (rootfs_dfd, RPMOSTREE_BWRAP_IMMUTABLE, error,
|
||||
"--ro-bind", "usr/etc", "/etc",
|
||||
NULL);
|
||||
if (!bwrap)
|
||||
return FALSE;
|
||||
{
|
||||
bwrap = rpmostree_bwrap_new_base (rootfs_dfd, error);
|
||||
if (!bwrap)
|
||||
return FALSE;
|
||||
rpmostree_bwrap_append_bwrap_argv (bwrap,
|
||||
"--ro-bind", "usr/etc", "/etc",
|
||||
"--ro-bind", "usr", "/usr",
|
||||
NULL);
|
||||
}
|
||||
|
||||
if (dracut_host_tmpdir)
|
||||
rpmostree_bwrap_append_bwrap_argv (bwrap, "--bind", dracut_host_tmpdir->path, "/tmp/dracut", NULL);
|
||||
|
Loading…
Reference in New Issue
Block a user