-
Notifications
You must be signed in to change notification settings - Fork 198
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This command reads treefile dropins in `/etc` and applies it to the system. Only the OSTree container flow is supported for now. For the client-side flow, see #2326. In the container flow, only `packages` is currently supported. But this paves the way for supporting more derivation fields as well as making currently "base" fields only become valid derivation fields too (by promoting it from the `BaseComposeConfigFields` struct to `TreeComposeConfig`). What we're doing here is providing a "container" backend for derivation treefiles, but #2326 will provide a "client" backend which uses the core more fully. But the inputs themselves are the exact same, hence providing symmetry between the two flows. (See also discussions about this in coreos/fedora-coreos-tracker#1054). This will also allow us to drop the `microdnf` dependency which will be done in a following patch.
- Loading branch information
Showing
11 changed files
with
202 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- | ||
* | ||
* Copyright (C) 2022 Red Hat, Inc. | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Lesser General Public License as published | ||
* by the Free Software Foundation; either version 2 of the licence or (at | ||
* your option) any later version. | ||
* | ||
* This library is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
* Lesser General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Lesser General | ||
* Public License along with this library; if not, write to the | ||
* Free Software Foundation, Inc., 59 Temple Place, Suite 330, | ||
* Boston, MA 02111-1307, USA. | ||
*/ | ||
|
||
#include "config.h" | ||
|
||
#include <string.h> | ||
#include <glib-unix.h> | ||
|
||
#include "rpmostree-ex-builtins.h" | ||
#include "rpmostree-libbuiltin.h" | ||
#include "rpmostree-clientlib.h" | ||
#include "rpmostree-container.h" | ||
|
||
#include <libglnx.h> | ||
|
||
gboolean | ||
rpmostree_ex_builtin_rebuild (int argc, | ||
char **argv, | ||
RpmOstreeCommandInvocation *invocation, | ||
GCancellable *cancellable, | ||
GError **error) | ||
{ | ||
g_autoptr(GOptionContext) context = g_option_context_new (""); | ||
|
||
if (!rpmostree_option_context_parse (context, | ||
NULL, | ||
&argc, &argv, | ||
invocation, | ||
cancellable, | ||
NULL, NULL, NULL, | ||
error)) | ||
return FALSE; | ||
|
||
bool in_container = false; | ||
if (rpmostreecxx::running_in_container()) | ||
{ | ||
auto is_ostree_container = CXX_TRY_VAL(is_ostree_container(), error); | ||
if (!is_ostree_container) | ||
return glnx_throw (error, "This command can only run in an OSTree container."); | ||
in_container = true; | ||
} | ||
|
||
auto basearch = rpmostreecxx::get_rpm_basearch(); | ||
auto treefile = CXX_TRY_VAL(treefile_new_client_from_etc (basearch), error); | ||
|
||
/* This is the big switch: we support running this command in two modes: | ||
* "client containers", where the effect takes place in the active rootfs, and | ||
* possibly eventually "client host systems", where the effect takes place in | ||
* a new deployment. */ | ||
if (in_container) | ||
{ | ||
if (!rpmostree_container_rebuild (*treefile, cancellable, error)) | ||
return FALSE; | ||
|
||
/* In the container flow, we effectively "consume" the treefiles after | ||
* modifying the rootfs. */ | ||
CXX_TRY(treefile_delete_client_etc (), error); | ||
} | ||
else | ||
{ | ||
return glnx_throw (error, "This command is not yet supported on host systems. " | ||
"See https://github.com/coreos/rpm-ostree/issues/2326."); | ||
} | ||
|
||
return TRUE; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- | ||
* | ||
* Copyright (C) 2022 Red Hat, Inc. | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Lesser General Public License as published | ||
* by the Free Software Foundation; either version 2 of the licence or (at | ||
* your option) any later version. | ||
* | ||
* This library is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
* Lesser General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Lesser General | ||
* Public License along with this library; if not, write to the | ||
* Free Software Foundation, Inc., 59 Temple Place, Suite 330, | ||
* Boston, MA 02111-1307, USA. | ||
*/ | ||
|
||
#include "config.h" | ||
|
||
#include <string.h> | ||
#include <glib-unix.h> | ||
|
||
#include "rpmostree-core.h" | ||
#include "rpmostree-container.h" | ||
|
||
#include <libglnx.h> | ||
|
||
gboolean | ||
rpmostree_container_rebuild (rpmostreecxx::Treefile &treefile, | ||
GCancellable *cancellable, | ||
GError **error) | ||
{ | ||
auto packages = treefile.get_packages(); | ||
|
||
/* for now, we only support package installs */ | ||
if (packages.empty()) | ||
return TRUE; | ||
|
||
g_autoptr(RpmOstreeContext) ctx = rpmostree_context_new_container (); | ||
rpmostree_context_set_treefile (ctx, treefile); | ||
|
||
if (!rpmostree_context_setup (ctx, "/", "/", cancellable, error)) | ||
return FALSE; | ||
|
||
if (!rpmostree_context_prepare (ctx, cancellable, error)) | ||
return FALSE; | ||
|
||
if (!rpmostree_context_download (ctx, cancellable, error)) | ||
return FALSE; | ||
|
||
DnfContext *dnfctx = rpmostree_context_get_dnf (ctx); | ||
|
||
/* can't use cancellable here because it wants to re-set it on the state, | ||
* which will trigger an assertion; XXX: tweak libdnf */ | ||
if (!dnf_context_run (dnfctx, NULL, error)) | ||
return FALSE; | ||
|
||
return TRUE; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- | ||
* | ||
* Copyright (C) 2022 Red Hat, Inc. | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Lesser General Public License as published | ||
* by the Free Software Foundation; either version 2 of the licence or (at | ||
* your option) any later version. | ||
* | ||
* This library is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
* Lesser General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Lesser General | ||
* Public License along with this library; if not, write to the | ||
* Free Software Foundation, Inc., 59 Temple Place, Suite 330, | ||
* Boston, MA 02111-1307, USA. | ||
*/ | ||
|
||
#pragma once | ||
|
||
G_BEGIN_DECLS | ||
|
||
gboolean | ||
rpmostree_container_rebuild (rpmostreecxx::Treefile &treefile, | ||
GCancellable *cancellable, | ||
GError **error); | ||
|
||
G_END_DECLS |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters