|author||Patrick Ohly <firstname.lastname@example.org>||2016-10-07 12:53:43 +0200|
|committer||Patrick Ohly <email@example.com>||2016-12-08 14:12:55 +0100|
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 <firstname.lastname@example.org>
1 files changed, 12 insertions, 7 deletions
diff --git a/lib/swupd/utils.py b/lib/swupd/utils.py
index 0ffd9c5..b32e26a 100644
@@ -2,13 +2,15 @@
- 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
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()]
@@ -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')