summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorColin Walters <walters@verbum.org>2013-09-20 08:09:06 -0400
committerColin Walters <walters@verbum.org>2013-09-20 11:21:08 -0400
commit298625d7f82f1fe7434db5696fb7e9158c29e7b7 (patch)
tree746c30a5cf2b86ca30ab2df9a6a92a2f181e96b9
parent08b8734576eb198a27a8f5c6ba0dfbb74843071e (diff)
downloadostree-298625d7f82f1fe7434db5696fb7e9158c29e7b7.tar.gz
deploy: Correctly swap bootloader version with new boot checksums
If we had two deployments with different boot checksums, and were trying to remove the one that was the same and add a new one (the normal case), we'd end up assuming due to comparison with 0 that we only needed to do the fast subbootversion swap. Fix this by actually putting 1 where we really mean 1. And update the tests to verify the fix; I have double-verified by undoing the fix, and noting that the test fails. https://bugzilla.gnome.org/show_bug.cgi?id=708351
-rw-r--r--src/libostree/ostree-sysroot-deploy.c14
-rw-r--r--tests/libtest.sh9
-rwxr-xr-xtests/test-admin-deploy-2.sh12
3 files changed, 18 insertions, 17 deletions
diff --git a/src/libostree/ostree-sysroot-deploy.c b/src/libostree/ostree-sysroot-deploy.c
index e0232dd2..14136d24 100644
--- a/src/libostree/ostree-sysroot-deploy.c
+++ b/src/libostree/ostree-sysroot-deploy.c
@@ -980,18 +980,10 @@ bootcsum_counts_for_deployment_list (GPtrArray *deployments)
{
OstreeDeployment *deployment = deployments->pdata[i];
const char *bootcsum = ostree_deployment_get_bootcsum (deployment);
- gpointer orig_key;
- gpointer countp;
+ guint count;
- if (!g_hash_table_lookup_extended (ret, bootcsum, &orig_key, &countp))
- {
- g_hash_table_insert (ret, (char*)bootcsum, GUINT_TO_POINTER (0));
- }
- else
- {
- guint count = GPOINTER_TO_UINT (countp);
- g_hash_table_replace (ret, (char*)bootcsum, GUINT_TO_POINTER (count + 1));
- }
+ count = GPOINTER_TO_UINT (g_hash_table_lookup (ret, bootcsum));
+ g_hash_table_replace (ret, (char*)bootcsum, GUINT_TO_POINTER (count + 1));
}
return ret;
}
diff --git a/tests/libtest.sh b/tests/libtest.sh
index fc6eef1b..c421b452 100644
--- a/tests/libtest.sh
+++ b/tests/libtest.sh
@@ -239,10 +239,15 @@ EOF
os_repository_new_commit ()
{
+ boot_checksum_iteration=$1
+ echo "BOOT ITERATION: $boot_checksum_iteration"
+ if test -z "$boot_checksum_iteration"; then
+ boot_checksum_iteration=0
+ fi
cd ${test_tmpdir}/osdata
rm boot/*
- echo "new: a kernel" > boot/vmlinuz-3.6.0
- echo "new: an initramfs" > boot/initramfs-3.6.0
+ echo "new: a kernel ${boot_checksum_iteration}" > boot/vmlinuz-3.6.0
+ echo "new: an initramfs ${boot_checksum_iteration}" > boot/initramfs-3.6.0
bootcsum=$(cat boot/vmlinuz-3.6.0 boot/initramfs-3.6.0 | sha256sum | cut -f 1 -d ' ')
export bootcsum
mv boot/vmlinuz-3.6.0 boot/vmlinuz-3.6.0-${bootcsum}
diff --git a/tests/test-admin-deploy-2.sh b/tests/test-admin-deploy-2.sh
index a133e701..2e6e248e 100755
--- a/tests/test-admin-deploy-2.sh
+++ b/tests/test-admin-deploy-2.sh
@@ -39,20 +39,24 @@ assert_has_dir sysroot/boot/ostree/testos-${bootcsum}
echo "ok deploy command"
# Commit + upgrade twice, so that we'll rotate out the original deployment
-orig_bootcsum=${bootcsum}
+bootcsum1=${bootcsum}
os_repository_new_commit
ostree --repo=sysroot/ostree/repo remote add testos file://$(pwd)/testos-repo testos/buildmaster/x86_64-runtime
ostree admin --sysroot=sysroot upgrade --os=testos
-os_repository_new_commit
+bootcsum2=${bootcsum}
+os_repository_new_commit "1"
+bootcsum3=${bootcsum}
ostree --repo=sysroot/ostree/repo remote add testos file://$(pwd)/testos-repo testos/buildmaster/x86_64-runtime
ostree admin --sysroot=sysroot upgrade --os=testos
rev=${newrev}
newrev=$(ostree --repo=sysroot/ostree/repo rev-parse testos/buildmaster/x86_64-runtime)
assert_not_streq ${rev} ${newrev}
-assert_not_streq ${orig_bootcsum} ${bootcsum}
-assert_not_has_dir sysroot/boot/ostree/testos-${orig_bootcsum}
+assert_not_streq ${bootcsum1} ${bootcsum2}
+assert_not_streq ${bootcsum2} ${bootcsum3}
+assert_not_has_dir sysroot/boot/ostree/testos-${bootcsum1}
assert_has_dir sysroot/boot/ostree/testos-${bootcsum}
+assert_has_dir sysroot/boot/ostree/testos-${bootcsum2}
assert_file_has_content sysroot/ostree/deploy/testos/deploy/${newrev}.0/etc/os-release 'NAME=TestOS'
echo "ok deploy and GC /boot"