diff --git a/functional-tests.py b/functional-tests.py index 206164e8..33dade02 100755 --- a/functional-tests.py +++ b/functional-tests.py @@ -310,6 +310,17 @@ class hashdump_file_hash(unittest.TestCase): self.assertIn('b03e11e3307de4d4f3f545c8a955c2208507dbc1927e9434d1da42917712c15b', test_output) +@http_command(option="") +class update_apply_full_file_delta(unittest.TestCase): + def validate(self, test_output): + self.assertIn('Extracting pack.', test_output) + self.assertIn(' changed files : 1', test_output) + self.assertIn(' changed manifests : 1', test_output) + self.assertIn('Staging file content', test_output) + self.assertIn('Update was applied.', test_output) + self.assertIn('Update successful. System updated from version 10 to version 100', test_output) + + @http_command(option="") class update_boot_file(unittest.TestCase): def validate(self, test_output): diff --git a/src/delta.c b/src/delta.c index a0b6cd2c..cf0b964b 100644 --- a/src/delta.c +++ b/src/delta.c @@ -100,7 +100,7 @@ static void do_delta(struct file *file) dir = dirname(tmp); base = basename(tmp2); - string_or_die(&origin, "%s/%s/%s", STAGING_SUBVOL, dir, base); + string_or_die(&origin, "%s/%s/%s", path_prefix, dir, base); ret = apply_bsdiff_delta(origin, filename, deltafile); if (ret) { diff --git a/test/functional/update/apply-full-file-delta/setup.sh b/test/functional/update/apply-full-file-delta/setup.sh new file mode 100755 index 00000000..dfb46486 --- /dev/null +++ b/test/functional/update/apply-full-file-delta/setup.sh @@ -0,0 +1,19 @@ +#!/bin/bash + +set -e + +rm -f web-dir/*/*.tar +tar -C web-dir/10 -cf web-dir/10/Manifest.MoM.tar Manifest.MoM Manifest.MoM.signed +tar -C web-dir/10 -cf web-dir/10/Manifest.os-core.tar Manifest.os-core Manifest.os-core.signed +tar -C web-dir/100 -cf web-dir/100/Manifest.MoM.tar Manifest.MoM Manifest.MoM.signed +tar -C web-dir/100 -cf web-dir/100/Manifest.os-core.tar Manifest.os-core Manifest.os-core.signed + +deltafile="10-100-9f83d713da9df6cabd2abc9d9061f9b611a207e1e0dd22ed7a071ddb1cc1537a" + +# delta files are currently only applied if they live in delta packs +sudo chown root:root web-dir/100/delta/$deltafile +mkdir -p web-dir/100/staged +tar -C web-dir/100 -cf web-dir/100/pack-os-core-from-10.tar delta/$deltafile staged/ + +# delta was created to apply to a file owned by root +sudo chown root:root target-dir/testfile diff --git a/test/functional/update/apply-full-file-delta/target-dir/testfile b/test/functional/update/apply-full-file-delta/target-dir/testfile new file mode 100644 index 00000000..33497358 --- /dev/null +++ b/test/functional/update/apply-full-file-delta/target-dir/testfile @@ -0,0 +1,17 @@ +orig content +orig content +orig content +orig content +orig content +orig content +orig content +orig content +orig content +orig content +orig content +orig content +orig content +orig content +orig content +orig content +orig content diff --git a/test/functional/update/apply-full-file-delta/target-dir/usr/lib/os-release b/test/functional/update/apply-full-file-delta/target-dir/usr/lib/os-release new file mode 100644 index 00000000..b01f31ec --- /dev/null +++ b/test/functional/update/apply-full-file-delta/target-dir/usr/lib/os-release @@ -0,0 +1 @@ +VERSION_ID=10 diff --git a/test/functional/update/apply-full-file-delta/teardown.sh b/test/functional/update/apply-full-file-delta/teardown.sh new file mode 100755 index 00000000..c0f3940a --- /dev/null +++ b/test/functional/update/apply-full-file-delta/teardown.sh @@ -0,0 +1,13 @@ +#!/bin/bash + +set -e + +deltafile="10-100-9f83d713da9df6cabd2abc9d9061f9b611a207e1e0dd22ed7a071ddb1cc1537a" +origfile="0832c0c7fb9d05ac3088a493f430e81044a0fc03f81cba9eb89d3b7816ef3962" + +sudo chown $(ls -l setup.sh | awk '{ print $3 ":" $4 }') web-dir/100/delta/$deltafile + +# replace the original file with the copy in staged/ +sudo rm target-dir/testfile +cp web-dir/10/staged/$origfile target-dir/testfile +rmdir web-dir/100/staged diff --git a/test/functional/update/apply-full-file-delta/web-dir/10/Manifest.MoM b/test/functional/update/apply-full-file-delta/web-dir/10/Manifest.MoM new file mode 100644 index 00000000..54dc81e5 --- /dev/null +++ b/test/functional/update/apply-full-file-delta/web-dir/10/Manifest.MoM @@ -0,0 +1,8 @@ +MANIFEST 3 +version: 10 +previous: 0 +filecount: 1 +timestamp: 1451940175 +contentsize: 13805671819 + +M... 6259043bcbac93ffff65097ec52ba0e8658e8b2b7cdb99bd2939d639ee23209e 10 os-core diff --git a/test/functional/update/apply-full-file-delta/web-dir/10/Manifest.MoM.signed b/test/functional/update/apply-full-file-delta/web-dir/10/Manifest.MoM.signed new file mode 100644 index 00000000..8b0f8fc5 --- /dev/null +++ b/test/functional/update/apply-full-file-delta/web-dir/10/Manifest.MoM.signed @@ -0,0 +1,3 @@ +-----BEGIN PKCS7----- +Empty +-----END PKCS7----- diff --git a/test/functional/update/apply-full-file-delta/web-dir/10/Manifest.os-core b/test/functional/update/apply-full-file-delta/web-dir/10/Manifest.os-core new file mode 100644 index 00000000..75da6138 --- /dev/null +++ b/test/functional/update/apply-full-file-delta/web-dir/10/Manifest.os-core @@ -0,0 +1,8 @@ +MANIFEST 3 +version: 10 +previous: 0 +filecount: 1 +timestamp: 1451936779 +contentsize: 17929151 + +F... 0832c0c7fb9d05ac3088a493f430e81044a0fc03f81cba9eb89d3b7816ef3962 10 /testfile diff --git a/test/functional/update/apply-full-file-delta/web-dir/10/Manifest.os-core.signed b/test/functional/update/apply-full-file-delta/web-dir/10/Manifest.os-core.signed new file mode 100644 index 00000000..8b0f8fc5 --- /dev/null +++ b/test/functional/update/apply-full-file-delta/web-dir/10/Manifest.os-core.signed @@ -0,0 +1,3 @@ +-----BEGIN PKCS7----- +Empty +-----END PKCS7----- diff --git a/test/functional/update/apply-full-file-delta/web-dir/10/staged/0832c0c7fb9d05ac3088a493f430e81044a0fc03f81cba9eb89d3b7816ef3962 b/test/functional/update/apply-full-file-delta/web-dir/10/staged/0832c0c7fb9d05ac3088a493f430e81044a0fc03f81cba9eb89d3b7816ef3962 new file mode 100644 index 00000000..33497358 --- /dev/null +++ b/test/functional/update/apply-full-file-delta/web-dir/10/staged/0832c0c7fb9d05ac3088a493f430e81044a0fc03f81cba9eb89d3b7816ef3962 @@ -0,0 +1,17 @@ +orig content +orig content +orig content +orig content +orig content +orig content +orig content +orig content +orig content +orig content +orig content +orig content +orig content +orig content +orig content +orig content +orig content diff --git a/test/functional/update/apply-full-file-delta/web-dir/100/Manifest.MoM b/test/functional/update/apply-full-file-delta/web-dir/100/Manifest.MoM new file mode 100644 index 00000000..20d9cfb7 --- /dev/null +++ b/test/functional/update/apply-full-file-delta/web-dir/100/Manifest.MoM @@ -0,0 +1,8 @@ +MANIFEST 3 +version: 100 +previous: 10 +filecount: 1 +timestamp: 1451940175 +contentsize: 13805671819 + +M... 6259043bcbac93ffff65097ec52ba0e8658e8b2b7cdb99bd2939d639ee23209e 100 os-core diff --git a/test/functional/update/apply-full-file-delta/web-dir/100/Manifest.MoM.signed b/test/functional/update/apply-full-file-delta/web-dir/100/Manifest.MoM.signed new file mode 100644 index 00000000..8b0f8fc5 --- /dev/null +++ b/test/functional/update/apply-full-file-delta/web-dir/100/Manifest.MoM.signed @@ -0,0 +1,3 @@ +-----BEGIN PKCS7----- +Empty +-----END PKCS7----- diff --git a/test/functional/update/apply-full-file-delta/web-dir/100/Manifest.os-core b/test/functional/update/apply-full-file-delta/web-dir/100/Manifest.os-core new file mode 100644 index 00000000..0e2106ed --- /dev/null +++ b/test/functional/update/apply-full-file-delta/web-dir/100/Manifest.os-core @@ -0,0 +1,8 @@ +MANIFEST 3 +version: 100 +previous: 10 +filecount: 1 +timestamp: 1451936779 +contentsize: 17929151 + +F... 9f83d713da9df6cabd2abc9d9061f9b611a207e1e0dd22ed7a071ddb1cc1537a 100 /testfile diff --git a/test/functional/update/apply-full-file-delta/web-dir/100/Manifest.os-core.signed b/test/functional/update/apply-full-file-delta/web-dir/100/Manifest.os-core.signed new file mode 100644 index 00000000..8b0f8fc5 --- /dev/null +++ b/test/functional/update/apply-full-file-delta/web-dir/100/Manifest.os-core.signed @@ -0,0 +1,3 @@ +-----BEGIN PKCS7----- +Empty +-----END PKCS7----- diff --git a/test/functional/update/apply-full-file-delta/web-dir/100/delta/10-100-9f83d713da9df6cabd2abc9d9061f9b611a207e1e0dd22ed7a071ddb1cc1537a b/test/functional/update/apply-full-file-delta/web-dir/100/delta/10-100-9f83d713da9df6cabd2abc9d9061f9b611a207e1e0dd22ed7a071ddb1cc1537a new file mode 100644 index 00000000..6c12b376 Binary files /dev/null and b/test/functional/update/apply-full-file-delta/web-dir/100/delta/10-100-9f83d713da9df6cabd2abc9d9061f9b611a207e1e0dd22ed7a071ddb1cc1537a differ diff --git a/test/functional/update/apply-full-file-delta/web-dir/version/formatstaging/latest b/test/functional/update/apply-full-file-delta/web-dir/version/formatstaging/latest new file mode 100644 index 00000000..29d6383b --- /dev/null +++ b/test/functional/update/apply-full-file-delta/web-dir/version/formatstaging/latest @@ -0,0 +1 @@ +100