aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPatrick Ohly <patrick.ohly@intel.com>2016-10-07 12:53:43 +0200
committerPatrick Ohly <patrick.ohly@intel.com>2016-12-08 14:12:55 +0100
commit1624762b968455409c857d2fc81cd2ad74fb407a (patch)
treea02241791ba57052a68bba998622f94423f723cb
parentb243df94d9314eace5f2a8735e8c3238e015c256 (diff)
downloadmeta-swupd-1624762b968455409c857d2fc81cd2ad74fb407a.tar.gz
meta-swupd-1624762b968455409c857d2fc81cd2ad74fb407a.tar.bz2
meta-swupd-1624762b968455409c857d2fc81cd2ad74fb407a.zip
utils.py: list files with leading slash in manifests
When reading the manifest .content.txt files in swupd-server, it matters whether they list entries with or without leading slash. Without it, matching files against the full content fails because that is read from a directory and happens to use a leading slash inside swupd_create_update, and then swupd created bundle manifests without hashsums, leading to 404 errors during updates. Fixing this in meta-swupd is easier than in swupd-server. Signed-off-by: Patrick Ohly <patrick.ohly@intel.com>
-rw-r--r--lib/swupd/utils.py19
1 files changed, 12 insertions, 7 deletions
diff --git a/lib/swupd/utils.py b/lib/swupd/utils.py
index 0ffd9c5..b32e26a 100644
--- a/lib/swupd/utils.py
+++ b/lib/swupd/utils.py
@@ -2,13 +2,15 @@
def manifest_to_file_list(manifest_fn):
"""
- open a manifest file and read it into a list
+ Open a manifest file and read it into a list.
+ Entries in the list are relative, i.e. no leading
+ slash.
manifest_fn -- the manifest file to read
"""
image_manifest_list = []
with open(manifest_fn) as image:
- image_manifest_list = image.read().splitlines()
+ image_manifest_list = [x[1:] for x in image.read().splitlines()]
return image_manifest_list
@@ -16,8 +18,8 @@ def manifest_to_file_list(manifest_fn):
def create_content_manifests(dir, included, excluded, blacklist):
"""
Iterate over the content of the directory, decide which entries are
- included in the swupd update mechanism and write the full paths of the remaining
- entries (without leading ./ or /) to the respective file. All directories
+ included in the swupd update mechanism and write the absolute paths of the remaining
+ entries (with leading slash) to the respective file. All directories
are explicitly listed.
"""
bb.debug(3, 'Creating %s and %s from directory %s, excluding %s' %
@@ -28,11 +30,14 @@ def create_content_manifests(dir, included, excluded, blacklist):
with open(included, 'w') as i:
with open(excluded or '/dev/null', 'w') as e:
for root, dirs, files in os.walk('.'):
- # Strip the leading ./ that we get in root from os.walk('.').
- root = root[2:]
+ # Strip the leading . that we get in root from os.walk('.').
+ # Resulting path must be absolute (for consistency with how
+ # swupd-server handles scanning real directories); this
+ # also matches the blacklist convention (also absolute).
+ root = '/' if root == '.' else root[1:]
for entry in sorted(dirs + files):
fullpath = os.path.join(root, entry)
- out = e if blacklist and ('/' + fullpath) in blacklist else i
+ out = e if blacklist and fullpath in blacklist else i
out.write(fullpath + '\n')
finally:
os.chdir(cwd)