Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Makefile-boot.am
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ systemdsystemunit_DATA = src/boot/ostree-prepare-root.service \
src/boot/ostree-remount.service \
src/boot/ostree-finalize-staged.service \
src/boot/ostree-finalize-staged.path \
src/boot/ostree-finalize-staged-hold.service \
$(NULL)
systemdtmpfilesdir = $(prefix)/lib/tmpfiles.d
dist_systemdtmpfiles_DATA = src/boot/ostree-tmpfiles.conf
Expand Down Expand Up @@ -68,6 +69,7 @@ EXTRA_DIST += src/boot/dracut/module-setup.sh \
src/boot/ostree-finalize-staged.path \
src/boot/ostree-remount.service \
src/boot/ostree-finalize-staged.service \
src/boot/ostree-finalize-staged-hold.service \
src/boot/grub2/grub2-15_ostree \
src/boot/grub2/ostree-grub-generator \
$(NULL)
2 changes: 1 addition & 1 deletion libglnx
Submodule libglnx updated from ef502a to 07e3e4
1 change: 1 addition & 0 deletions man/ostree-summary.xml
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,7 @@ License along with this library. If not, see <https://www.gnu.org/licenses/>.
Latest Commit (4.2 MB):
9828ab80f357459b4ab50f0629beab2ae3b67318fc3d161d10a89fae353afa90
Timestamp (ostree.commit.timestamp): 2017-11-21T01:41:10-08
Version (ostree.commit.version): 1.2.3

Last-Modified (ostree.summary.last-modified): 2018-01-12T22:06:38-08
</programlisting>
Expand Down
35 changes: 35 additions & 0 deletions src/boot/ostree-finalize-staged-hold.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# Copyright (C) 2018 Red Hat, Inc.
# Copyright (C) 2022 Endless OS Foundation LLC
#
# This library 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 License, 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, see <https://www.gnu.org/licenses/>.

# See https://github.com/ostreedev/ostree/pull/2543 for background.
[Unit]
Description=Hold /boot Open for OSTree Finalize Staged Deployment
Documentation=man:ostree(1)
ConditionPathExists=/run/ostree-booted
DefaultDependencies=no

RequiresMountsFor=/sysroot /boot
After=local-fs.target
Before=basic.target final.target

[Service]
Type=exec

# This is explicitly run in the root namespace to ensure an automounted
# /boot doesn't time out since autofs doesn't handle mount namespaces.
#
# https://bugzilla.redhat.com/show_bug.cgi?id=2056090
ExecStart=+/usr/bin/ostree admin finalize-staged --hold
5 changes: 5 additions & 0 deletions src/boot/ostree-finalize-staged.service
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@ Before=basic.target final.target
After=systemd-journal-flush.service
Conflicts=final.target

# Start the hold unit and ensure it stays active throughout this
# service.
Wants=ostree-finalize-staged-hold.service
After=ostree-finalize-staged-hold.service

[Service]
Type=oneshot
RemainAfterExit=yes
Expand Down
2 changes: 2 additions & 0 deletions src/libostree/ostree-core.h
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,8 @@ typedef enum {
* The currently defined keys for the `a{sv}` of additional metadata for each commit are:
* - key: `ostree.commit.timestamp`, value: `t`, timestamp (seconds since the
* Unix epoch in UTC, big-endian) when the commit was committed
* - key: `ostree.commit.version`, value: `s`, the `version` value from the
* commit's metadata if it was defined. Since: 2022.2
*/
#define OSTREE_SUMMARY_GVARIANT_STRING "(a(s(taya{sv}))a{sv})"
#define OSTREE_SUMMARY_GVARIANT_FORMAT G_VARIANT_TYPE (OSTREE_SUMMARY_GVARIANT_STRING)
Expand Down
1 change: 1 addition & 0 deletions src/libostree/ostree-repo-private.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ G_BEGIN_DECLS
/* Well-known keys for the additional metadata field in a commit in a ref entry
* in a summary file. */
#define OSTREE_COMMIT_TIMESTAMP "ostree.commit.timestamp"
#define OSTREE_COMMIT_VERSION "ostree.commit.version"

typedef enum {
OSTREE_REPO_TEST_ERROR_PRE_COMMIT = (1 << 0),
Expand Down
61 changes: 54 additions & 7 deletions src/libostree/ostree-repo-pull.c
Original file line number Diff line number Diff line change
Expand Up @@ -2244,6 +2244,9 @@ process_one_static_delta (OtPullData *pull_data,
ref, cancellable, error))
return FALSE;

if (!ostree_repo_mark_commit_partial (pull_data->repo, to_revision, TRUE, error))
return FALSE;

if (detached_data && !ostree_repo_write_commit_detached_metadata (pull_data->repo,
to_revision,
detached_data,
Expand Down Expand Up @@ -3706,13 +3709,13 @@ all_requested_refs_have_commit (GHashTable *requested_refs /* (element-type Ostr
* * `disable-verify-bindings` (`b`): Disable verification of commit bindings.
* Since: 2020.9
*/
gboolean
ostree_repo_pull_with_options (OstreeRepo *self,
const char *remote_name_or_baseurl,
GVariant *options,
OstreeAsyncProgress *progress,
GCancellable *cancellable,
GError **error)
static gboolean
ostree_repo_pull_with_options_internal (OstreeRepo *self,
const char *remote_name_or_baseurl,
GVariant *options,
OstreeAsyncProgress *progress,
GCancellable *cancellable,
GError **error)
{
gboolean ret = FALSE;
g_autoptr(GBytes) bytes_summary = NULL;
Expand Down Expand Up @@ -5193,6 +5196,50 @@ ostree_repo_pull_with_options (OstreeRepo *self,
return ret;
}

gboolean
ostree_repo_pull_with_options (OstreeRepo *self,
const char *remote_name_or_baseurl,
GVariant *options,
OstreeAsyncProgress *progress,
GCancellable *cancellable,
GError **error)
{
g_autoptr(GError) local_error = NULL;

if (!ostree_repo_pull_with_options_internal (self, remote_name_or_baseurl,
options, progress, cancellable,
&local_error))
{
gboolean disable_static_deltas = FALSE, require_static_deltas = FALSE;

if (options != NULL)
{
g_variant_lookup (options, "disable-static-deltas", "b", &disable_static_deltas);
g_variant_lookup (options, "require-static-deltas", "b", &require_static_deltas);
}

if (g_error_matches (local_error, G_IO_ERROR, G_IO_ERROR_NOT_FOUND) &&
!disable_static_deltas && !require_static_deltas)
{
g_autoptr(GVariant) modified_options = NULL;
g_auto(GVariantDict) modified_options_dict;
g_variant_dict_init (&modified_options_dict, options);
g_variant_dict_insert (&modified_options_dict, "disable-static-deltas",
"b", TRUE);
modified_options = g_variant_dict_end (&modified_options_dict);

return ostree_repo_pull_with_options_internal (self, remote_name_or_baseurl,
modified_options, progress,
cancellable, error);
}

g_propagate_error (error, g_steal_pointer (&local_error));
return FALSE;
}

return TRUE;
}

/* Structure used in ostree_repo_find_remotes_async() which stores metadata
* about a given OSTree commit. This includes the metadata from the commit
* #GVariant, plus some working state which is used to work out which remotes
Expand Down
7 changes: 6 additions & 1 deletion src/libostree/ostree-repo.c
Original file line number Diff line number Diff line change
Expand Up @@ -6064,17 +6064,22 @@ summary_add_ref_entry (OstreeRepo *self,
g_autoptr(GVariant) commit_obj = NULL;
if (!ostree_repo_load_variant (self, OSTREE_OBJECT_TYPE_COMMIT, checksum, &commit_obj, error))
return FALSE;
g_autoptr(GVariant) orig_metadata = g_variant_get_child_value (commit_obj, 0);

g_variant_dict_init (&commit_metadata_builder, NULL);

/* Forward the commit’s timestamp if it’s valid. */
/* Forward the commit’s timestamp and version if they're valid. */
guint64 commit_timestamp = ostree_commit_get_timestamp (commit_obj);
g_autoptr(GDateTime) dt = g_date_time_new_from_unix_utc (commit_timestamp);

if (dt != NULL)
g_variant_dict_insert_value (&commit_metadata_builder, OSTREE_COMMIT_TIMESTAMP,
g_variant_new_uint64 (GUINT64_TO_BE (commit_timestamp)));

const char *version = NULL;
if (g_variant_lookup (orig_metadata, OSTREE_COMMIT_META_KEY_VERSION, "&s", &version))
g_variant_dict_insert (&commit_metadata_builder, OSTREE_COMMIT_VERSION, "s", version);

g_variant_builder_add_value (refs_builder,
g_variant_new ("(s(t@ay@a{sv}))", ref,
(guint64) g_variant_get_size (commit_obj),
Expand Down
Loading