diff --git a/src/libostree/ostree-core.h b/src/libostree/ostree-core.h index 979b35a2..3e3631fb 100644 --- a/src/libostree/ostree-core.h +++ b/src/libostree/ostree-core.h @@ -228,6 +228,23 @@ typedef enum { * Since: 2017.7 */ #define OSTREE_COMMIT_META_KEY_ENDOFLIFE "ostree.endoflife" +/** + * OSTREE_COMMIT_META_KEY_SOURCE_TITLE: + * + * GVariant type `s`. This should hold a relatively short single line value + * containing a human-readable "source" for a commit, intended to be displayed + * near the origin ref. This is particularly useful for systems that inject + * content into an OSTree commit from elsewhere - for example, generating from + * an OCI or qcow2 image. Or if generating from packages, the enabled repository + * names and their versions. + * + * Try to keep this key short (e.g. < 80 characters) and human-readable; if you + * desire machine readable data, consider injecting separate metadata keys. + * + * Since: 2017.13 + */ +#define OSTREE_COMMIT_META_KEY_SOURCE_TITLE "ostree.source-title" + /** * OSTREE_COMMIT_META_KEY_REF_BINDING: * diff --git a/src/ostree/ot-admin-builtin-status.c b/src/ostree/ot-admin-builtin-status.c index 8d180a6a..b6fc7117 100644 --- a/src/ostree/ot-admin-builtin-status.c +++ b/src/ostree/ot-admin-builtin-status.c @@ -114,8 +114,12 @@ ot_admin_builtin_status (int argc, char **argv, OstreeCommandInvocation *invocat commit_metadata = g_variant_get_child_value (commit, 0); const char *version = NULL; + const char *source_title = NULL; if (commit_metadata) - (void) g_variant_lookup (commit_metadata, OSTREE_COMMIT_META_KEY_VERSION, "&s", &version); + { + (void) g_variant_lookup (commit_metadata, OSTREE_COMMIT_META_KEY_VERSION, "&s", &version); + (void) g_variant_lookup (commit_metadata, OSTREE_COMMIT_META_KEY_SOURCE_TITLE, "&s", &source_title); + } GKeyFile *origin = ostree_deployment_get_origin (deployment); @@ -152,6 +156,8 @@ ot_admin_builtin_status (int argc, char **argv, OstreeCommandInvocation *invocat g_print (" origin: \n"); else g_print (" origin refspec: %s\n", origin_refspec); + if (source_title) + g_print (" `- %s\n", source_title); } if (deployment_get_gpg_verify (deployment, repo)) diff --git a/tests/admin-test.sh b/tests/admin-test.sh index f5d33a6f..dafbc79b 100644 --- a/tests/admin-test.sh +++ b/tests/admin-test.sh @@ -19,7 +19,7 @@ set -euo pipefail -echo "1..$((22 + ${extra_admin_tests:-0}))" +echo "1..$((23 + ${extra_admin_tests:-0}))" function validate_bootloader() { cd ${test_tmpdir}; @@ -277,6 +277,14 @@ assert_streq ${curr_rev} ${head_rev} echo "ok upgrade with and without override-commit" +${CMD_PREFIX} ostree --repo=${test_tmpdir}/testos-repo commit --add-metadata-string "version=${version}" \ + --add-metadata-string 'ostree.source-title=libtest os_repository_new_commit()' -b testos/buildmaster/x86_64-runtime \ + -s "Build" --tree=dir=${test_tmpdir}/osdata +${CMD_PREFIX} ostree admin upgrade --os=testos +${CMD_PREFIX} ostree admin status | tee status.txt +assert_file_has_content_literal status.txt '`- libtest os_repository_new_commit()' +echo "ok source title" + deployment=$(${CMD_PREFIX} ostree admin --sysroot=sysroot --print-current-dir) ${CMD_PREFIX} ostree --sysroot=sysroot remote add --set=gpg-verify=false remote-test-physical file://$(pwd)/testos-repo assert_not_has_file ${deployment}/etc/ostree/remotes.d/remote-test-physical.conf testos-repo diff --git a/tests/test-admin-deploy-uboot.sh b/tests/test-admin-deploy-uboot.sh index 7791360e..ec031477 100755 --- a/tests/test-admin-deploy-uboot.sh +++ b/tests/test-admin-deploy-uboot.sh @@ -30,6 +30,10 @@ extra_admin_tests=1 . $(dirname $0)/admin-test.sh cd ${test_tmpdir} +# Note this test actually requires a checksum change to /boot, +# because adding the uEnv.txt isn't currently covered by the +# "bootcsum". +os_repository_new_commit "uboot test" "test upgrade multiple kernel args" mkdir -p osdata/usr/lib/ostree-boot cat << 'EOF' > osdata/usr/lib/ostree-boot/uEnv.txt loaduimage=load mmc ${bootpart} ${loadaddr} ${kernel_image}