Use new ostree_commit_metadata_for_bootable() API

I planned to use this as part of doing live diffs, e.g. to
notice the kernel changed between commits.

But also, at some point I'd like to add `ostree.architecture`
there to obsolete the cosa-specific `coreos-assembler.basearch`
so that multiple buildsystems and consumers can use that.
(That said, they can also just use `$(arch)` today)
This commit is contained in:
Colin Walters 2021-05-26 15:07:52 -04:00
parent f2b1f2038b
commit c9d0850140
5 changed files with 26 additions and 4 deletions

View File

@ -26,3 +26,7 @@ ostree --repo="${repo}" ls -R "${ref}" /usr/lib/modules > tmp/modules-lsr.txt
assert_file_has_content tmp/modules-lsr.txt '/vmlinuz$'
assert_file_has_content tmp/modules-lsr.txt '/initramfs.img$'
echo "ok boot location modules"
ostree --repo="${repo}" show --print-metadata-key=ostree.bootable "${ref}" >out.txt
assert_file_has_content_literal out.txt 'true'
echo "ok bootable metadata"

View File

@ -49,7 +49,7 @@ BuildRequires: gnome-common
BuildRequires: /usr/bin/g-ir-scanner
# Core requirements
# One way to check this: `objdump -p /path/to/rpm-ostree | grep LIBOSTREE` and pick the highest (though that might miss e.g. new struct members)
BuildRequires: pkgconfig(ostree-1) >= 2020.7
BuildRequires: pkgconfig(ostree-1) >= 2021.1
BuildRequires: pkgconfig(polkit-gobject-1)
BuildRequires: pkgconfig(json-glib-1.0)
BuildRequires: pkgconfig(rpm) >= 4.16.0

View File

@ -4604,7 +4604,14 @@ rpmostree_context_commit (RpmOstreeContext *self,
if (!ostree_repo_write_mtree (self->ostreerepo, mtree, &root, cancellable, error))
return FALSE;
{ g_autoptr(GVariant) metadata = g_variant_ref_sink (g_variant_builder_end (&metadata_builder));
g_autoptr(GVariant) metadata_so_far = g_variant_ref_sink (g_variant_builder_end (&metadata_builder));
// Unfortunately this API takes GVariantDict, not GVariantBuilder, so convert
g_autoptr(GVariantDict) metadata_dict = g_variant_dict_new (metadata_so_far);
if (!ostree_commit_metadata_for_bootable (root, metadata_dict, cancellable, error))
return FALSE;
g_autoptr(GVariant) metadata = g_variant_dict_end (metadata_dict);
{
if (!ostree_repo_write_commit (self->ostreerepo, parent, "", "",
metadata,
OSTREE_REPO_FILE (root),

View File

@ -839,7 +839,7 @@ gboolean
rpmostree_compose_commit (int rootfs_fd,
OstreeRepo *repo,
const char *parent_revision,
GVariant *metadata,
GVariant *src_metadata,
const char *gpg_keyid,
gboolean enable_selinux,
OstreeRepoDevInoCache *devino_cache,
@ -918,6 +918,12 @@ rpmostree_compose_commit (int rootfs_fd,
if (!ostree_repo_write_mtree (repo, mtree, &root_tree, cancellable, error))
return glnx_prefix_error (error, "While writing tree");
// Unfortunately this API takes GVariantDict, not GVariantBuilder, so convert
g_autoptr(GVariantDict) metadata_dict = g_variant_dict_new (src_metadata);
if (!ostree_commit_metadata_for_bootable (root_tree, metadata_dict, cancellable, error))
return FALSE;
g_autoptr(GVariant) metadata = g_variant_dict_end (metadata_dict);
g_autofree char *new_revision = NULL;
if (!ostree_repo_write_commit (repo, parent_revision, "", "", metadata,
(OstreeRepoFile*)root_tree, &new_revision,

View File

@ -55,6 +55,12 @@ rpmostree_assert_status '.deployments[0]["packages"]|length == 0' \
assert_streq $(rpm -q foo) foo-1.2-3.x86_64
echo "ok pkg foo added locally"
booted_commit=$(rpm-ostree status --json | jq -r '.deployments[0].checksum')
ostree show --print-metadata-key=ostree.bootable ${booted_commit} >out.txt
assert_file_has_content_literal out.txt 'true'
echo "ok bootable metadata"
# check we could uninstall the package using either its NEVRA or name
rpm-ostree uninstall foo-1.2-3.x86_64
rpmostree_assert_status '.deployments[0]["requested-local-packages"]|length == 0'
@ -81,7 +87,6 @@ rpmostree_assert_status '.deployments[0]["packages"]|length == 1' \
echo "ok layer foo back from repos"
# check that trying to install a package already in the base errors out
booted_commit=$(rpm-ostree status --json | jq -r '.deployments[0].checksum')
ostree refs ${booted_commit} --create vmcheck_tmp/with_foo
ostree commit -b vmcheck --tree=ref=vmcheck_tmp/with_foo
rpm-ostree uninstall foo