2017-01-11 22:05:18 +03:00
/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*-
*
* Copyright ( C ) 2017 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 .
*/
# pragma once
# include <ostree.h>
2018-01-17 18:33:46 +03:00
# include "rpmostree-core.h"
2017-01-11 22:05:18 +03:00
2020-11-23 03:22:52 +03:00
G_BEGIN_DECLS
2017-01-11 22:05:18 +03:00
typedef struct RpmOstreeOrigin RpmOstreeOrigin ;
daemon/upgrader: Rework layer tracking
Working on initramfs, I hit a subtle issue with the fact that
I was trying to "redeploy", but with the origin file changed
during the process.
Previously, it was a bit unclear which parts of the upgrader logic are operating
on the *new* origin versus the "original origin".
The package layering code in the upgrader explicitly carries a delta on top in
the "add/remove" hash sets, which means it isn't visible to
`rpmostree_origin_is_locally_assembled()`.
Whereas for initramfs, I set a new origin. This broke things since we were
expecting to find a parent commit, but the original origin wasn't locally
assembled.
When looking more at this, I realized there's a far simpler model -
rather than keeping track of commit + origin, and using the origin
to try to determine whether or not the commit is layered, we can
keep track of `base_revision` and `final_revision`, and the latter
is only set if we're doing layering.
The diff speaks for itself here - a lot of fragile logic looking at the origin
drops away.
The next step here is probably to drop away the package layering hash sets, but
I'm trying to not change everything at once.
Closes: #579
Approved by: jlebon
2017-01-17 20:25:28 +03:00
RpmOstreeOrigin * rpmostree_origin_ref ( RpmOstreeOrigin * origin ) ;
2017-01-11 22:05:18 +03:00
void rpmostree_origin_unref ( RpmOstreeOrigin * origin ) ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC ( RpmOstreeOrigin , rpmostree_origin_unref )
RpmOstreeOrigin *
rpmostree_origin_parse_keyfile ( GKeyFile * keyfile ,
GError * * error ) ;
static inline
RpmOstreeOrigin *
2017-02-16 20:46:13 +03:00
rpmostree_origin_parse_deployment ( OstreeDeployment * deployment ,
GError * * error )
2017-01-11 22:05:18 +03:00
{
GKeyFile * origin = ostree_deployment_get_origin ( deployment ) ;
if ( ! origin )
{
g_set_error ( error , G_IO_ERROR , G_IO_ERROR_FAILED ,
" No origin known for deployment %s.%d " ,
ostree_deployment_get_csum ( deployment ) ,
ostree_deployment_get_deployserial ( deployment ) ) ;
return NULL ;
}
2017-02-16 20:46:13 +03:00
return rpmostree_origin_parse_keyfile ( origin , error ) ;
2017-01-11 22:05:18 +03:00
}
2017-02-15 20:41:38 +03:00
RpmOstreeOrigin *
rpmostree_origin_dup ( RpmOstreeOrigin * origin ) ;
2018-05-22 22:20:33 +03:00
void
rpmostree_origin_remove_transient_state ( RpmOstreeOrigin * origin ) ;
2017-01-11 22:05:18 +03:00
const char *
rpmostree_origin_get_refspec ( RpmOstreeOrigin * origin ) ;
2018-01-17 18:33:46 +03:00
void
rpmostree_origin_classify_refspec ( RpmOstreeOrigin * origin ,
RpmOstreeRefspecType * out_type ,
const char * * out_refspecdata ) ;
char *
rpmostree_origin_get_full_refspec ( RpmOstreeOrigin * origin ,
RpmOstreeRefspecType * out_refspectype ) ;
2018-02-13 23:11:36 +03:00
gboolean rpmostree_origin_is_rojig ( RpmOstreeOrigin * origin ) ;
2018-01-17 18:33:46 +03:00
const char *
2018-02-27 23:05:44 +03:00
rpmostree_origin_get_rojig_version ( RpmOstreeOrigin * origin ) ;
2018-01-17 18:33:46 +03:00
2018-02-11 20:52:16 +03:00
GVariant *
2018-02-27 23:05:44 +03:00
rpmostree_origin_get_rojig_description ( RpmOstreeOrigin * origin ) ;
2018-02-11 20:52:16 +03:00
2018-06-08 22:39:56 +03:00
void
rpmostree_origin_get_custom_description ( RpmOstreeOrigin * origin ,
char * * custom_type ,
char * * custom_description ) ;
2017-02-24 17:44:40 +03:00
GHashTable *
2017-01-11 22:05:18 +03:00
rpmostree_origin_get_packages ( RpmOstreeOrigin * origin ) ;
2017-03-03 23:48:56 +03:00
GHashTable *
rpmostree_origin_get_local_packages ( RpmOstreeOrigin * origin ) ;
2017-06-05 19:37:56 +03:00
GHashTable *
rpmostree_origin_get_overrides_remove ( RpmOstreeOrigin * origin ) ;
2017-07-04 20:50:52 +03:00
GHashTable *
rpmostree_origin_get_overrides_local_replace ( RpmOstreeOrigin * origin ) ;
2017-01-11 22:05:18 +03:00
const char *
rpmostree_origin_get_override_commit ( RpmOstreeOrigin * origin ) ;
2020-07-25 00:35:01 +03:00
GHashTable *
rpmostree_origin_get_initramfs_etc_files ( RpmOstreeOrigin * origin ) ;
2017-01-04 20:29:01 +03:00
gboolean
rpmostree_origin_get_regenerate_initramfs ( RpmOstreeOrigin * origin ) ;
2017-02-24 17:44:40 +03:00
const char * const *
2017-01-04 20:29:01 +03:00
rpmostree_origin_get_initramfs_args ( RpmOstreeOrigin * origin ) ;
2017-02-24 17:44:40 +03:00
const char *
rpmostree_origin_get_unconfigured_state ( RpmOstreeOrigin * origin ) ;
2017-05-29 21:45:15 +03:00
gboolean
rpmostree_origin_may_require_local_assembly ( RpmOstreeOrigin * origin ) ;
2017-01-11 22:05:18 +03:00
char *
rpmostree_origin_get_string ( RpmOstreeOrigin * origin ,
const char * section ,
const char * value ) ;
GKeyFile *
rpmostree_origin_dup_keyfile ( RpmOstreeOrigin * origin ) ;
2020-07-25 00:35:01 +03:00
void
rpmostree_origin_initramfs_etc_files_track ( RpmOstreeOrigin * origin ,
char * * paths ,
gboolean * out_changed ) ;
void
rpmostree_origin_initramfs_etc_files_untrack ( RpmOstreeOrigin * origin ,
char * * paths ,
gboolean * out_changed ) ;
void
rpmostree_origin_initramfs_etc_files_untrack_all ( RpmOstreeOrigin * origin ,
gboolean * out_changed ) ;
2017-02-15 20:41:38 +03:00
void
rpmostree_origin_set_regenerate_initramfs ( RpmOstreeOrigin * origin ,
gboolean regenerate ,
char * * args ) ;
void
rpmostree_origin_set_override_commit ( RpmOstreeOrigin * origin ,
const char * checksum ,
const char * version ) ;
2018-02-11 20:52:16 +03:00
void
2018-02-27 23:05:44 +03:00
rpmostree_origin_set_rojig_description ( RpmOstreeOrigin * origin ,
2018-02-11 20:52:16 +03:00
DnfPackage * package ) ;
2017-02-15 20:41:38 +03:00
2018-02-06 22:03:22 +03:00
void
2018-02-27 23:05:44 +03:00
rpmostree_origin_set_rojig_version ( RpmOstreeOrigin * origin ,
2018-02-06 22:03:22 +03:00
const char * version ) ;
2017-02-15 20:41:38 +03:00
gboolean
rpmostree_origin_set_rebase ( RpmOstreeOrigin * origin ,
const char * new_refspec ,
GError * * error ) ;
2018-06-08 22:39:56 +03:00
gboolean
rpmostree_origin_set_rebase_custom ( RpmOstreeOrigin * origin ,
const char * new_refspec ,
const char * custom_origin_url ,
const char * custom_origin_description ,
GError * * error ) ;
2017-02-16 20:46:13 +03:00
2017-02-24 17:44:40 +03:00
gboolean
rpmostree_origin_add_packages ( RpmOstreeOrigin * origin ,
char * * packages ,
2017-03-03 23:48:56 +03:00
gboolean local ,
2018-07-30 22:10:50 +03:00
gboolean allow_existing ,
gboolean * out_changed ,
2017-02-24 17:44:40 +03:00
GError * * error ) ;
gboolean
2017-06-05 19:33:18 +03:00
rpmostree_origin_remove_packages ( RpmOstreeOrigin * origin ,
2017-02-24 17:44:40 +03:00
char * * packages ,
2018-07-30 22:10:50 +03:00
gboolean allow_noent ,
gboolean * out_changed ,
2017-02-24 17:44:40 +03:00
GError * * error ) ;
2018-06-13 19:32:37 +03:00
gboolean
rpmostree_origin_remove_all_packages ( RpmOstreeOrigin * origin ,
gboolean * out_changed ,
GError * * error ) ;
Introduce `ex livefs`
There are a few different use cases here. First, for layering new packages,
there's no good reason for us to force a reboot. Second, we want some support
for cherry-picking security updates and allowing admins to restart services. Finally,
at some point we should offer support for entirely replacing the running tree
if that's what the user wants.
Until now we've been very conservative, but there's a spectrum here. In
particular, this patch changes things so we push a rollback before we start
doing anything live. I think in practice, many use cases would be totally fine
with doing most changes live, and falling back to the rollback if something went
wrong.
This initial code drop *only* supports live layering of new packages. However,
a lot of the base infrastructure is laid for future work.
For now, this will be classified as an experimental feature, hence `ex livefs`.
Part of: https://github.com/projectatomic/rpm-ostree/issues/639
Closes: #652
Approved by: jlebon
2017-03-01 01:16:48 +03:00
2017-07-04 20:50:52 +03:00
typedef enum {
/* RPMOSTREE_ORIGIN_OVERRIDE_REPLACE, */
RPMOSTREE_ORIGIN_OVERRIDE_REPLACE_LOCAL ,
RPMOSTREE_ORIGIN_OVERRIDE_REMOVE
} RpmOstreeOriginOverrideType ;
2017-06-05 19:37:56 +03:00
gboolean
rpmostree_origin_add_overrides ( RpmOstreeOrigin * origin ,
char * * packages ,
2017-07-04 20:50:52 +03:00
RpmOstreeOriginOverrideType type ,
2017-06-05 19:37:56 +03:00
GError * * error ) ;
gboolean
2017-07-04 20:50:52 +03:00
rpmostree_origin_remove_override ( RpmOstreeOrigin * origin ,
const char * package ,
RpmOstreeOriginOverrideType type ) ;
2017-06-05 19:37:56 +03:00
gboolean
rpmostree_origin_remove_all_overrides ( RpmOstreeOrigin * origin ,
gboolean * out_changed ,
GError * * error ) ;
2020-11-23 03:22:52 +03:00
G_END_DECLS