summaryrefslogtreecommitdiffstats
path: root/meta/recipes-extended
diff options
context:
space:
mode:
authorPatrick Ohly <patrick.ohly@intel.com>2016-12-01 10:40:46 +0100
committerRichard Purdie <richard.purdie@linuxfoundation.org>2016-12-07 10:38:04 +0000
commit2b9b684ad985433d440bf0de220ab4fcca17b279 (patch)
tree04fdcd7c7e57241d64b85848225c203203282145 /meta/recipes-extended
parent1b9b617b7da8d5aafa1501a2bfaa840d2e4ac9d2 (diff)
downloadpoky-2b9b684ad985433d440bf0de220ab4fcca17b279.tar.gz
libarchive: enable non-recursive extract/list
Required for meta-swupd performance enhancements: in meta-swupd, the so called "mega" image contains a rootfs with all files that can potentially be installed on a device. Other virtual image recipes need a subset of those files or directories, and a partial extraction from a single tar archive is faster than letting all virtual image recipes share access to a directory under a single pseudo instance. It may be necessary to extract a directory with all of its attributes without the content of the directory, hence this patch. Upstream agreed to consider merging such a patch (see https://groups.google.com/forum/#!topic/libarchive-discuss/JO3hqSaAVfs) but has been slow in actually commenting on it, so for now it has to be carried as distro patch. (From OE-Core rev: 53126f0fbc63148cc5b22605ffbdf54d0610b545) Signed-off-by: Patrick Ohly <patrick.ohly@intel.com> Signed-off-by: Ross Burton <ross.burton@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/recipes-extended')
-rw-r--r--meta/recipes-extended/libarchive/files/non-recursive-extract-and-list.patch153
-rw-r--r--meta/recipes-extended/libarchive/libarchive_3.2.2.bb1
2 files changed, 154 insertions, 0 deletions
diff --git a/meta/recipes-extended/libarchive/files/non-recursive-extract-and-list.patch b/meta/recipes-extended/libarchive/files/non-recursive-extract-and-list.patch
new file mode 100644
index 0000000000..61f8f3ec8d
--- /dev/null
+++ b/meta/recipes-extended/libarchive/files/non-recursive-extract-and-list.patch
@@ -0,0 +1,153 @@
1From d6271709d2deb980804f92e75f9b5cb600dc42ed Mon Sep 17 00:00:00 2001
2From: Patrick Ohly <patrick.ohly@intel.com>
3Date: Mon, 24 Oct 2016 12:54:48 +0200
4Subject: [PATCH 1/2] non-recursive extract and list
5
6Sometimes it makes sense to extract or list a directory contained in
7an archive without also doing the same for the content of the
8directory, i.e. allowing -n (= --no-recursion) in combination with the
9x and t modes.
10
11bsdtar uses the match functionality in libarchive to track include
12matches. A new libarchive API call
13archive_match_include_directories_recursively() gets introduced to
14influence the matching behavior, with the default behavior as before.
15
16Non-recursive matching can be achieved by anchoring the path match at
17both start and end. Asking for a directory which itself isn't in the
18archive when in non-recursive mode is an error and handled by the
19existing mechanism for tracking unused inclusion entries.
20
21Upstream-Status: Submitted [https://github.com/libarchive/libarchive/pull/812]
22
23Signed-off-by: Patrick Ohly <patrick.ohly@intel.com>
24
25---
26 libarchive/archive.h | 2 ++
27 libarchive/archive_match.c | 30 +++++++++++++++++++++++++++++-
28 tar/bsdtar.1 | 3 +--
29 tar/bsdtar.c | 12 ++++++++++--
30 4 files changed, 42 insertions(+), 5 deletions(-)
31
32diff --git a/libarchive/archive.h b/libarchive/archive.h
33index ff401e9..38d8746 100644
34--- a/libarchive/archive.h
35+++ b/libarchive/archive.h
36@@ -1085,6 +1085,8 @@ __LA_DECL int archive_match_excluded(struct archive *,
37 */
38 __LA_DECL int archive_match_path_excluded(struct archive *,
39 struct archive_entry *);
40+/* Control recursive inclusion of directory content when directory is included. Default on. */
41+__LA_DECL int archive_match_include_directories_recursively(struct archive *, int _enabled);
42 /* Add exclusion pathname pattern. */
43 __LA_DECL int archive_match_exclude_pattern(struct archive *, const char *);
44 __LA_DECL int archive_match_exclude_pattern_w(struct archive *,
45diff --git a/libarchive/archive_match.c b/libarchive/archive_match.c
46index 0719cbd..6d03a65 100644
47--- a/libarchive/archive_match.c
48+++ b/libarchive/archive_match.c
49@@ -93,6 +93,9 @@ struct archive_match {
50 /* exclusion/inclusion set flag. */
51 int setflag;
52
53+ /* Recursively include directory content? */
54+ int recursive_include;
55+
56 /*
57 * Matching filename patterns.
58 */
59@@ -223,6 +226,7 @@ archive_match_new(void)
60 return (NULL);
61 a->archive.magic = ARCHIVE_MATCH_MAGIC;
62 a->archive.state = ARCHIVE_STATE_NEW;
63+ a->recursive_include = 1;
64 match_list_init(&(a->inclusions));
65 match_list_init(&(a->exclusions));
66 __archive_rb_tree_init(&(a->exclusion_tree), &rb_ops_mbs);
67@@ -471,6 +475,28 @@ archive_match_path_excluded(struct archive *_a,
68 }
69
70 /*
71+ * When recursive inclusion of directory content is enabled,
72+ * an inclusion pattern that matches a directory will also
73+ * include everything beneath that directory. Enabled by default.
74+ *
75+ * For compatibility with GNU tar, exclusion patterns always
76+ * match if a subset of the full patch matches (i.e., they are
77+ * are not rooted at the beginning of the path) and thus there
78+ * is no corresponding non-recursive exclusion mode.
79+ */
80+int
81+archive_match_include_directories_recursively(struct archive *_a, int _enabled)
82+{
83+ struct archive_match *a;
84+
85+ archive_check_magic(_a, ARCHIVE_MATCH_MAGIC,
86+ ARCHIVE_STATE_NEW, "archive_match_include_directories_recursively");
87+ a = (struct archive_match *)_a;
88+ a->recursive_include = _enabled;
89+ return (ARCHIVE_OK);
90+}
91+
92+/*
93 * Utilty functions to get statistic information for inclusion patterns.
94 */
95 int
96@@ -781,7 +807,9 @@ static int
97 match_path_inclusion(struct archive_match *a, struct match *m,
98 int mbs, const void *pn)
99 {
100- int flag = PATHMATCH_NO_ANCHOR_END;
101+ int flag = a->recursive_include ?
102+ PATHMATCH_NO_ANCHOR_END : /* Prefix match is good enough. */
103+ 0; /* Full match required. */
104 int r;
105
106 if (mbs) {
107diff --git a/tar/bsdtar.1 b/tar/bsdtar.1
108index 9eadaaf..f5d6457 100644
109--- a/tar/bsdtar.1
110+++ b/tar/bsdtar.1
111@@ -346,8 +346,7 @@ In extract or list modes, this option is ignored.
112 Do not extract modification time.
113 By default, the modification time is set to the time stored in the archive.
114 .It Fl n , Fl Fl norecurse , Fl Fl no-recursion
115-(c, r, u modes only)
116-Do not recursively archive the contents of directories.
117+Do not recursively archive (c, r, u), extract (x) or list (t) the contents of directories.
118 .It Fl Fl newer Ar date
119 (c, r, u modes only)
120 Only include files and directories newer than the specified date.
121diff --git a/tar/bsdtar.c b/tar/bsdtar.c
122index 93bf60a..001d5ed 100644
123--- a/tar/bsdtar.c
124+++ b/tar/bsdtar.c
125@@ -738,8 +738,6 @@ main(int argc, char **argv)
126 break;
127 }
128 }
129- if (bsdtar->option_no_subdirs)
130- only_mode(bsdtar, "-n", "cru");
131 if (bsdtar->option_stdout)
132 only_mode(bsdtar, "-O", "xt");
133 if (bsdtar->option_unlink_first)
134@@ -788,6 +786,16 @@ main(int argc, char **argv)
135 only_mode(bsdtar, buff, "cru");
136 }
137
138+ /*
139+ * When creating an archive from a directory tree, the directory
140+ * walking code will already avoid entering directories when
141+ * recursive inclusion of directory content is disabled, therefore
142+ * changing the matching behavior has no effect for creation modes.
143+ * It is relevant for extraction or listing.
144+ */
145+ archive_match_include_directories_recursively(bsdtar->matching,
146+ !bsdtar->option_no_subdirs);
147+
148 /* Filename "-" implies stdio. */
149 if (strcmp(bsdtar->filename, "-") == 0)
150 bsdtar->filename = NULL;
151--
1522.1.4
153
diff --git a/meta/recipes-extended/libarchive/libarchive_3.2.2.bb b/meta/recipes-extended/libarchive/libarchive_3.2.2.bb
index cf66e9d8e8..64e8983585 100644
--- a/meta/recipes-extended/libarchive/libarchive_3.2.2.bb
+++ b/meta/recipes-extended/libarchive/libarchive_3.2.2.bb
@@ -32,6 +32,7 @@ PACKAGECONFIG[nettle] = "--with-nettle,--without-nettle,nettle,"
32PACKAGECONFIG[lz4] = "--with-lz4,--without-lz4,lz4," 32PACKAGECONFIG[lz4] = "--with-lz4,--without-lz4,lz4,"
33 33
34SRC_URI = "http://libarchive.org/downloads/libarchive-${PV}.tar.gz \ 34SRC_URI = "http://libarchive.org/downloads/libarchive-${PV}.tar.gz \
35 file://non-recursive-extract-and-list.patch \
35 " 36 "
36 37
37SRC_URI[md5sum] = "1ec00b7dcaf969dd2a5712f85f23c764" 38SRC_URI[md5sum] = "1ec00b7dcaf969dd2a5712f85f23c764"