OpenSDE Packages Database (without history before r20070)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

205 lines
7.3 KiB

  1. # --- SDE-COPYRIGHT-NOTE-BEGIN ---
  2. # This copyright note is auto-generated by ./scripts/Create-CopyPatch.
  3. #
  4. # Filename: package/.../libarchive/libarchive-mtree.patch
  5. # Copyright (C) 2013 The OpenSDE Project
  6. #
  7. # More information can be found in the files COPYING and README.
  8. #
  9. # This patch file is dual-licensed. It is available under the license the
  10. # patched project is licensed under, as long as it is an OpenSource license
  11. # as defined at http://www.opensource.org/ (e.g. BSD, X11) or under the terms
  12. # of the GNU General Public License as published by the Free Software
  13. # Foundation; either version 2 of the License, or (at your option) any later
  14. # version.
  15. # --- SDE-COPYRIGHT-NOTE-END ---
  16. From e65bf287f0133426b26611fe3e80b51267987106 Mon Sep 17 00:00:00 2001
  17. From: Dave Reisner <dreisner@archlinux.org>
  18. Date: Thu, 21 Feb 2013 19:01:06 -0500
  19. Subject: [PATCH] mtree: fix line filename length calculation. Fixes #301.
  20. Signed-off-by: Andres Mejia <amejia004@gmail.com>
  21. ---
  22. libarchive/archive_write_set_format_mtree.c | 4 ++--
  23. 1 file changed, 2 insertions(+), 2 deletions(-)
  24. diff --git a/libarchive/archive_write_set_format_mtree.c b/libarchive/archive_write_set_format_mtree.c
  25. index 9c0613c..f37f723 100644
  26. --- a/libarchive/archive_write_set_format_mtree.c
  27. +++ b/libarchive/archive_write_set_format_mtree.c
  28. @@ -1855,9 +1855,9 @@ mtree_entry_setup_filenames(struct archive_write *a, struct mtree_entry *file,
  29. return (ret);
  30. }
  31. - /* Make a basename from dirname and slash */
  32. + /* Make a basename from file->parentdir.s and slash */
  33. *slash = '\0';
  34. - file->parentdir.length = slash - dirname;
  35. + file->parentdir.length = slash - file->parentdir.s;
  36. archive_strcpy(&(file->basename), slash + 1);
  37. return (ret);
  38. }
  39. --
  40. 1.7.10.2
  41. From aefbb66fd6bad3d1aa62c7d372c6eae0444312f1 Mon Sep 17 00:00:00 2001
  42. From: Andres Mejia <amejia004@gmail.com>
  43. Date: Thu, 21 Feb 2013 19:51:22 -0500
  44. Subject: [PATCH] Add test case for adding pathnames with no leading './' in
  45. mtree format. libarchive should add the leading './' for
  46. such pathnames.
  47. ---
  48. libarchive/test/test_write_format_mtree.c | 123 +++++++++++++++++++++++++++++
  49. 1 file changed, 123 insertions(+)
  50. diff --git a/libarchive/test/test_write_format_mtree.c b/libarchive/test/test_write_format_mtree.c
  51. index c886709..5109e09 100644
  52. --- a/libarchive/test/test_write_format_mtree.c
  53. +++ b/libarchive/test/test_write_format_mtree.c
  54. @@ -48,6 +48,26 @@ static struct {
  55. { "./subdir3/mtree", S_IFREG | 0664, 1232266273, 1003, 1003 },
  56. { NULL, 0, 0, 0, 0 }
  57. };
  58. +static struct {
  59. + const char *path;
  60. + mode_t mode;
  61. + time_t mtime;
  62. + uid_t uid;
  63. + gid_t gid;
  64. +} entries2[] = {
  65. + { "COPYING", S_IFREG | 0644, 1231975636, 1001, 1001 },
  66. + { "Makefile", S_IFREG | 0644, 1233041050, 1001, 1001 },
  67. + { "NEWS", S_IFREG | 0644, 1231975636, 1001, 1001 },
  68. + { "PROJECTS", S_IFREG | 0644, 1231975636, 1001, 1001 },
  69. + { "README", S_IFREG | 0644, 1231975636, 1001, 1001 },
  70. + { "subdir", S_IFDIR | 0755, 1233504586, 1001, 1001 },
  71. + { "subdir/README", S_IFREG | 0664, 1231975636, 1002, 1001 },
  72. + { "subdir/config", S_IFREG | 0664, 1232266273, 1003, 1003 },
  73. + { "subdir2", S_IFDIR | 0755, 1233504586, 1001, 1001 },
  74. + { "subdir3", S_IFDIR | 0755, 1233504586, 1001, 1001 },
  75. + { "subdir3/mtree", S_IFREG | 0664, 1232266273, 1003, 1003 },
  76. + { NULL, 0, 0, 0, 0 }
  77. +};
  78. static void
  79. test_write_format_mtree_sub(int use_set, int dironly)
  80. @@ -136,6 +156,97 @@ test_write_format_mtree_sub(int use_set, int dironly)
  81. assertEqualInt(ARCHIVE_OK, archive_read_free(a));
  82. }
  83. +static void
  84. +test_write_format_mtree_sub2(int use_set, int dironly)
  85. +{
  86. + struct archive_entry *ae;
  87. + struct archive* a;
  88. + size_t used;
  89. + int i;
  90. + char str[32];
  91. +
  92. + /* Create a mtree format archive. */
  93. + assert((a = archive_write_new()) != NULL);
  94. + assertEqualIntA(a, ARCHIVE_OK, archive_write_set_format_mtree(a));
  95. + if (use_set)
  96. + assertEqualIntA(a, ARCHIVE_OK, archive_write_set_format_option(a, NULL, "use-set", "1"));
  97. + if (dironly)
  98. + assertEqualIntA(a, ARCHIVE_OK, archive_write_set_format_option(a, NULL, "dironly", "1"));
  99. + assertEqualIntA(a, ARCHIVE_OK, archive_write_open_memory(a, buff, sizeof(buff)-1, &used));
  100. +
  101. + /* Write entries2 */
  102. + for (i = 0; entries2[i].path != NULL; i++) {
  103. + assert((ae = archive_entry_new()) != NULL);
  104. + archive_entry_set_mtime(ae, entries2[i].mtime, 0);
  105. + assert(entries2[i].mtime == archive_entry_mtime(ae));
  106. + archive_entry_set_mode(ae, entries2[i].mode);
  107. + assert(entries2[i].mode == archive_entry_mode(ae));
  108. + archive_entry_set_uid(ae, entries2[i].uid);
  109. + assert(entries2[i].uid == archive_entry_uid(ae));
  110. + archive_entry_set_gid(ae, entries2[i].gid);
  111. + assert(entries2[i].gid == archive_entry_gid(ae));
  112. + archive_entry_copy_pathname(ae, entries2[i].path);
  113. + if ((entries2[i].mode & AE_IFMT) != S_IFDIR)
  114. + archive_entry_set_size(ae, 8);
  115. + assertEqualIntA(a, ARCHIVE_OK, archive_write_header(a, ae));
  116. + if ((entries2[i].mode & AE_IFMT) != S_IFDIR)
  117. + assertEqualIntA(a, 8,
  118. + archive_write_data(a, "Hello012", 15));
  119. + archive_entry_free(ae);
  120. + }
  121. + assertEqualIntA(a, ARCHIVE_OK, archive_write_close(a));
  122. + assertEqualInt(ARCHIVE_OK, archive_write_free(a));
  123. +
  124. + if (use_set) {
  125. + const char *p;
  126. +
  127. + buff[used] = '\0';
  128. + assert(NULL != (p = strstr(buff, "\n/set ")));
  129. + if (p != NULL) {
  130. + char *r;
  131. + const char *o;
  132. + p++;
  133. + r = strchr(p, '\n');
  134. + if (r != NULL)
  135. + *r = '\0';
  136. + if (dironly)
  137. + o = "/set type=dir uid=1001 gid=1001 mode=755";
  138. + else
  139. + o = "/set type=file uid=1001 gid=1001 mode=644";
  140. + assertEqualString(o, p);
  141. + if (r != NULL)
  142. + *r = '\n';
  143. + }
  144. + }
  145. +
  146. + /*
  147. + * Read the data and check it.
  148. + */
  149. + assert((a = archive_read_new()) != NULL);
  150. + assertEqualIntA(a, ARCHIVE_OK, archive_read_support_format_all(a));
  151. + assertEqualIntA(a, ARCHIVE_OK, archive_read_support_filter_all(a));
  152. + assertEqualIntA(a, ARCHIVE_OK, archive_read_open_memory(a, buff, used));
  153. +
  154. + /* Read entries2 */
  155. + memset(str, 0, sizeof(str));
  156. + strcpy(str, "./");
  157. + for (i = 0; entries2[i].path != NULL; i++) {
  158. + if (dironly && (entries2[i].mode & AE_IFMT) != S_IFDIR)
  159. + continue;
  160. + assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
  161. + assertEqualInt(entries2[i].mtime, archive_entry_mtime(ae));
  162. + assertEqualInt(entries2[i].mode, archive_entry_mode(ae));
  163. + assertEqualInt(entries2[i].uid, archive_entry_uid(ae));
  164. + assertEqualInt(entries2[i].gid, archive_entry_gid(ae));
  165. + strcpy(str + 2, entries2[i].path);
  166. + assertEqualString(str, archive_entry_pathname(ae));
  167. + if ((entries2[i].mode & AE_IFMT) != S_IFDIR)
  168. + assertEqualInt(8, archive_entry_size(ae));
  169. + }
  170. + assertEqualIntA(a, ARCHIVE_OK, archive_read_close(a));
  171. + assertEqualInt(ARCHIVE_OK, archive_read_free(a));
  172. +}
  173. +
  174. DEFINE_TEST(test_write_format_mtree)
  175. {
  176. /* Default setting */
  177. @@ -147,3 +258,15 @@ DEFINE_TEST(test_write_format_mtree)
  178. /* Use /set keyword with directory only */
  179. test_write_format_mtree_sub(1, 1);
  180. }
  181. +
  182. +DEFINE_TEST(test_write_format_mtree_no_leading_dotslash)
  183. +{
  184. + /* Default setting */
  185. + test_write_format_mtree_sub2(0, 0);
  186. + /* Directory only */
  187. + test_write_format_mtree_sub2(0, 1);
  188. + /* Use /set keyword */
  189. + test_write_format_mtree_sub2(1, 0);
  190. + /* Use /set keyword with directory only */
  191. + test_write_format_mtree_sub2(1, 1);
  192. +}
  193. --
  194. 1.7.10.2