-
Notifications
You must be signed in to change notification settings - Fork 193
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
pkg-add: New builtin to layer additional packages
This builds upon the earlier prototype in https://github.com/cgwalters/atomic-pkglayer The `.origin` file says for a replicated installation: [origin] refspec=local:rhel-atomic-host/7/x86_64/standard If you then run `rpm-ostree pkg-add strace`, it will result in a new tree with: [origin] baserefspec=local:rhel-atomic-host/7/x86_64/standard [packages] requested=strace; Work still remaining here is to teach `rpm-ostree status` and `rpm-ostree upgrade` about this. Closes: #289 Approved by: <try>
- Loading branch information
1 parent
b1bb193
commit e72ebd3
Showing
22 changed files
with
1,650 additions
and
145 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,123 @@ | ||
/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- | ||
* | ||
* Copyright (C) 2015 Colin Walters <walters@verbum.org> | ||
* | ||
* 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 "rpmostree-builtins.h" | ||
#include "rpmostree-libbuiltin.h" | ||
#include "rpmostree-rpm-util.h" | ||
#include "rpmostree-dbus-helpers.h" | ||
|
||
#include <libglnx.h> | ||
|
||
static char *opt_osname; | ||
static gboolean opt_reboot; | ||
|
||
static GOptionEntry option_entries[] = { | ||
{ "os", 0, 0, G_OPTION_ARG_STRING, &opt_osname, "Operate on provided OSNAME", "OSNAME" }, | ||
{ "reboot", 'r', 0, G_OPTION_ARG_NONE, &opt_reboot, "Initiate a reboot after upgrade is prepared", NULL }, | ||
{ NULL } | ||
}; | ||
|
||
static GVariant * | ||
new_floating_empty_gvariant_dict (void) | ||
{ | ||
GVariantDict dict; | ||
g_variant_dict_init (&dict, NULL); | ||
return g_variant_dict_end (&dict); | ||
} | ||
|
||
int | ||
rpmostree_builtin_pkg_add (int argc, | ||
char **argv, | ||
GCancellable *cancellable, | ||
GError **error) | ||
{ | ||
int exit_status = EXIT_FAILURE; | ||
GOptionContext *context; | ||
glnx_unref_object RPMOSTreeOS *os_proxy = NULL; | ||
glnx_unref_object RPMOSTreeSysroot *sysroot_proxy = NULL; | ||
g_autoptr(GVariant) default_deployment = NULL; | ||
g_autofree char *transaction_address = NULL; | ||
int i; | ||
g_autoptr(GPtrArray) argv_and_null = g_ptr_array_new (); | ||
|
||
context = g_option_context_new ("PACKAGE [PACKAGE...] - Download and install layered RPM packages"); | ||
|
||
if (!rpmostree_option_context_parse (context, | ||
option_entries, | ||
&argc, &argv, | ||
RPM_OSTREE_BUILTIN_FLAG_NONE, | ||
cancellable, | ||
&sysroot_proxy, | ||
error)) | ||
goto out; | ||
|
||
if (argc < 2) | ||
{ | ||
rpmostree_usage_error (context, "At least one PACKAGE must be specified", error); | ||
goto out; | ||
} | ||
|
||
for (i = 1; i < argc; i++) | ||
g_ptr_array_add (argv_and_null, argv[i]); | ||
g_ptr_array_add (argv_and_null, NULL); | ||
|
||
if (!rpmostree_load_os_proxy (sysroot_proxy, opt_osname, | ||
cancellable, &os_proxy, error)) | ||
goto out; | ||
|
||
if (!rpmostree_os_call_pkg_add_sync (os_proxy, | ||
new_floating_empty_gvariant_dict (), | ||
(const char * const*)argv_and_null->pdata, | ||
&transaction_address, | ||
cancellable, | ||
error)) | ||
goto out; | ||
|
||
if (!rpmostree_transaction_get_response_sync (sysroot_proxy, | ||
transaction_address, | ||
cancellable, | ||
error)) | ||
goto out; | ||
|
||
if (!opt_reboot) | ||
{ | ||
const char *sysroot_path; | ||
|
||
|
||
sysroot_path = rpmostree_sysroot_get_path (sysroot_proxy); | ||
|
||
if (!rpmostree_print_treepkg_diff_from_sysroot_path (sysroot_path, | ||
cancellable, | ||
error)) | ||
goto out; | ||
|
||
g_print ("Run \"systemctl reboot\" to start a reboot\n"); | ||
} | ||
|
||
exit_status = EXIT_SUCCESS; | ||
|
||
out: | ||
/* Does nothing if using the message bus. */ | ||
rpmostree_cleanup_peer (); | ||
|
||
return exit_status; | ||
} |
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
Oops, something went wrong.