Fix fullfile delta application with path_prefix set

Fullfile deltas were only being applied to the root filesystem, since
the prefix was a compile-time constant string (STAGING_SUBVOL) set to
"/" by default.

Instead, use path_prefix for the prefix so that the deltas can be
applied when specifying --path on the command line. This also enables
writing a functional test for the delta application, added in this
commit.

Signed-off-by: Patrick McCarty <patrick.mccarty@intel.com>
This commit is contained in:
Patrick McCarty
2016-04-04 21:50:31 -07:00
parent b849edf662
commit 23dd3cc2dd
17 changed files with 124 additions and 1 deletions
+11
View File
@@ -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):
+1 -1
View File
@@ -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) {
+19
View File
@@ -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
@@ -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
@@ -0,0 +1 @@
VERSION_ID=10
+13
View File
@@ -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
@@ -0,0 +1,8 @@
MANIFEST 3
version: 10
previous: 0
filecount: 1
timestamp: 1451940175
contentsize: 13805671819
M... 6259043bcbac93ffff65097ec52ba0e8658e8b2b7cdb99bd2939d639ee23209e 10 os-core
@@ -0,0 +1,3 @@
-----BEGIN PKCS7-----
Empty
-----END PKCS7-----
@@ -0,0 +1,8 @@
MANIFEST 3
version: 10
previous: 0
filecount: 1
timestamp: 1451936779
contentsize: 17929151
F... 0832c0c7fb9d05ac3088a493f430e81044a0fc03f81cba9eb89d3b7816ef3962 10 /testfile
@@ -0,0 +1,3 @@
-----BEGIN PKCS7-----
Empty
-----END PKCS7-----
@@ -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
@@ -0,0 +1,8 @@
MANIFEST 3
version: 100
previous: 10
filecount: 1
timestamp: 1451940175
contentsize: 13805671819
M... 6259043bcbac93ffff65097ec52ba0e8658e8b2b7cdb99bd2939d639ee23209e 100 os-core
@@ -0,0 +1,3 @@
-----BEGIN PKCS7-----
Empty
-----END PKCS7-----
@@ -0,0 +1,8 @@
MANIFEST 3
version: 100
previous: 10
filecount: 1
timestamp: 1451936779
contentsize: 17929151
F... 9f83d713da9df6cabd2abc9d9061f9b611a207e1e0dd22ed7a071ddb1cc1537a 100 /testfile
@@ -0,0 +1,3 @@
-----BEGIN PKCS7-----
Empty
-----END PKCS7-----