From 978cffed70640cca66cb1623dea68b179288b453 Mon Sep 17 00:00:00 2001 From: Jonathan Lebon Date: Fri, 1 Mar 2019 09:16:55 -0500 Subject: [PATCH] lib/deploy: Don't include version twice in bootmenu title In Silverblue right now, the boot menu title looks like this: Fedora 29.20190301.0 (Workstation Edition) 29.20190301.0 (ostree) This is because RPM-OSTree's `mutate-os-release` feature is enabled, which injects the OSTree version string directly into `VERSION` and `PRETTY_NAME`. So appending the version string again is a bit redundant. Let's just do a simple substring check here before adding the version to the title. Closes: #1829 Approved by: cgwalters --- src/libostree/ostree-sysroot-deploy.c | 2 +- tests/admin-test.sh | 12 +++++++++++- tests/libtest.sh | 3 +-- 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/src/libostree/ostree-sysroot-deploy.c b/src/libostree/ostree-sysroot-deploy.c index ec9d1592..d37861b7 100644 --- a/src/libostree/ostree-sysroot-deploy.c +++ b/src/libostree/ostree-sysroot-deploy.c @@ -1739,7 +1739,7 @@ install_deployment_kernel (OstreeSysroot *sysroot, * (specifically, it looks for the substring "(ostree"), so further * changes to the title format may require updating that backend. */ g_autoptr(GString) title_key = g_string_new (val); - if (deployment_version && *deployment_version) + if (deployment_version && *deployment_version && !strstr (val, deployment_version)) { g_string_append_c (title_key, ' '); g_string_append (title_key, deployment_version); diff --git a/tests/admin-test.sh b/tests/admin-test.sh index 4f0b9e93..79a23f59 100644 --- a/tests/admin-test.sh +++ b/tests/admin-test.sh @@ -21,7 +21,7 @@ set -euo pipefail -echo "1..$((25 + ${extra_admin_tests:-0}))" +echo "1..$((26 + ${extra_admin_tests:-0}))" function validate_bootloader() { cd ${test_tmpdir}; @@ -280,6 +280,16 @@ validate_bootloader echo "ok upgrade with multiple kernel args" +os_repository_new_commit +${CMD_PREFIX} ostree admin upgrade --os=testos +assert_file_has_content sysroot/boot/loader/entries/ostree-4-testos.conf "^title TestOS 42 ${version} (ostree:testos)$" +os_repository_new_commit 0 0 testos/buildmaster/x86_64-runtime 42 +${CMD_PREFIX} ostree admin upgrade --os=testos +assert_file_has_content sysroot/boot/loader/entries/ostree-4-testos.conf "^title TestOS 42 (ostree:testos)$" + +echo "ok no duplicate version strings in title" + + # Test upgrade with and without --override-commit # See https://github.com/GNOME/ostree/pull/147 ${CMD_PREFIX} ostree pull --repo=sysroot/ostree/repo --commit-metadata-only --depth=-1 testos:testos/buildmaster/x86_64-runtime diff --git a/tests/libtest.sh b/tests/libtest.sh index a737a9bb..e0022512 100755 --- a/tests/libtest.sh +++ b/tests/libtest.sh @@ -473,6 +473,7 @@ os_repository_new_commit () boot_checksum_iteration=${1:-0} content_iteration=${2:-0} branch=${3:-testos/buildmaster/x86_64-runtime} + export version=${4:-$(date "+%Y%m%d.${content_iteration}")} echo "BOOT ITERATION: $boot_checksum_iteration" cd ${test_tmpdir}/osdata kver=3.6.0 @@ -507,8 +508,6 @@ os_repository_new_commit () echo "content iteration ${content_iteration}" > usr/bin/content-iteration - export version=$(date "+%Y%m%d.${content_iteration}") - ${CMD_PREFIX} ostree --repo=${test_tmpdir}/testos-repo commit --add-metadata-string "version=${version}" -b $branch -s "Build" cd ${test_tmpdir} }