]> git.ipfire.org Git - thirdparty/libarchive.git/commitdiff
Fix mtree generation 20/head
authorAllan McRae <allan@archlinux.org>
Sat, 8 Sep 2012 08:59:33 +0000 (18:59 +1000)
committerAllan McRae <allan@archlinux.org>
Sat, 8 Sep 2012 09:12:03 +0000 (19:12 +1000)
When generating an mtree file, libarchive writes a "Relative" type (entries
that have no /) for files in the base directory. For directories, this causes
the mtree reader to change the parent directory and give subsequent files in
the root directory the wrong path.

Fix this by prefixing entries in the root directory with "./".

libarchive/archive_write_set_format_mtree.c

index 4b300012f7a6e512c8fc285c568cfa9da18c5fbc..6d558a0383b318b165cbd99ba6d7ece6aa0c19c5 100644 (file)
@@ -887,6 +887,9 @@ write_entry(struct archive_write *a, struct mtree_entry *me)
 
        archive_string_empty(&mtree->ebuf);
        str = (mtree->indent)? &mtree->ebuf : &mtree->buf;
+       if (strchr(me->pathname, '/') == NULL ) {
+               archive_strcat(str, "./");
+       }
        mtree_quote(str, me->pathname);
        keys = get_keys(mtree, me);
        if ((keys & F_NLINK) != 0 &&