Skip to content
Snippets Groups Projects
Commit d7396500 authored by Simon McVittie's avatar Simon McVittie
Browse files

mtree: Don't fail verification for parents of a contents= filename


The files listed in the manifest as `contents=` are part of the files
that are physically distributed, but they are not part of the logical
hierarchy described by the manifest, so it wouldn't make sense to list
their parents as part of the manifest. This will matter if we want to
split files into subdirectories by a prefix of their hash, to avoid
having a very large number of content-addressed files at top level.

steamrt/tasks#422

Signed-off-by: default avatarSimon McVittie <smcv@collabora.com>
parent 53199345
Branches
Tags
1 merge request!696mtree: Don't fail verification for parents of a contents= filename
Pipeline #82645 passed
......@@ -908,6 +908,27 @@ pv_mtree_foreach_verify_cb (PvMtreeEntry *entry,
if (flags & PV_MTREE_APPLY_FLAGS_MINIMIZED_RUNTIME)
{
if (entry->contents != NULL)
{
g_autofree gchar *ancestor = g_strdup (name);
char *slash;
while (TRUE)
{
slash = strrchr (ancestor, '/');
if (slash == NULL)
break;
*slash = '\0';
if (!g_hash_table_lookup_extended (state->names, ancestor,
NULL, NULL))
g_hash_table_insert (state->names, g_strdup (ancestor),
GINT_TO_POINTER (PV_MTREE_ENTRY_FLAGS_OPTIONAL));
}
}
switch (entry->kind)
{
case PV_MTREE_ENTRY_KIND_FILE:
......
......@@ -138,11 +138,30 @@ class TestPvVerify(BaseTest):
with tempfile.TemporaryDirectory() as tree:
(Path(tree) / 'files/bin').mkdir(parents=True)
(Path(tree) / 'files/bin/env').symlink_to('../usr/bin/env')
(Path(tree) / 'files/usr/bin').mkdir(parents=True)
(Path(tree) / 'files/33/43').mkdir(parents=True)
# Use the smallest non-trivial file (1 byte) as a placeholder
# for the real unzip(1) executable.
# 334359b9... happens to be the sha256 of '#'.
(Path(tree) / 'files/33/43/59b9.bin').write_bytes(b'#')
self.write_mtree(
Path(tree), 'usr-mtree.txt.gz',
[
'./bin type=dir',
'./bin/env type=link link=../usr/bin/env',
'./usr type=dir',
'./usr/bin type=dir',
# unzip and zipinfo are hard links to the same file
('./usr/bin/unzip type=file size=1'
' sha256='
'334359b90efed75da5f0ada1d5e6b256'
'f4a6bd0aee7eb39c0f90182a021ffc8b'
' contents=./33/43/59b9.bin'),
('./usr/bin/zipinfo type=file size=1'
' sha256='
'334359b90efed75da5f0ada1d5e6b256'
'f4a6bd0aee7eb39c0f90182a021ffc8b'
' contents=./33/43/59b9.bin'),
'./empty type=file size=0',
]
)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment