Skip to content

Commit a0fe4a9

Browse files
dzbarskyaiuto
authored andcommitted
1 parent f83d96c commit a0fe4a9

File tree

5 files changed

+350
-0
lines changed

5 files changed

+350
-0
lines changed

modules/libarchive/3.7.2/MODULE.bazel

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
module(
2+
name = "libarchive",
3+
version = "3.7.2",
4+
compatibility_level = 1,
5+
)
6+
bazel_dep(name = "platforms", version = "0.0.9")
7+
bazel_dep(name = "xz", version = "5.4.5.bcr.1")
8+
bazel_dep(name = "zlib", version = "1.3.1")
9+
bazel_dep(name = "zstd", version = "1.5.5.bcr.1")
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,300 @@
1+
diff --git a/BUILD.bazel b/BUILD.bazel
2+
new file mode 100644
3+
index 00000000..a8f0858c
4+
--- /dev/null
5+
+++ b/BUILD.bazel
6+
@@ -0,0 +1,37 @@
7+
+cc_library(
8+
+ name = "config_h",
9+
+ hdrs = ["xplat_config.h"],
10+
+ defines = select({
11+
+ "@platforms//os:linux": [
12+
+ "HAVE_PATHS_H",
13+
+ "HAVE_STRUCT_STAT_ST_MTIM_TV_NSEC",
14+
+ ],
15+
+ "//conditions:default": [],
16+
+ }) + select({
17+
+ "@platforms//os:windows": [
18+
+ "gid_t=short",
19+
+ "id_t=\"unsigned long\"",
20+
+ "uid_t=short",
21+
+ ],
22+
+ "//conditions:default": [
23+
+ "HAVE_SYS_TYPES_H",
24+
+ ],
25+
+ }) + select({
26+
+ "@platforms//os:windows": ["HAVE_WINCRYPT_H"],
27+
+ "//conditions:default": [],
28+
+ }) + select({
29+
+ "@platforms//os:windows": [],
30+
+ "//conditions:default": [
31+
+ "HAVE_FORK",
32+
+ "HAVE_PIPE",
33+
+ "HAVE_POLL",
34+
+ "HAVE_POLL_H",
35+
+ "HAVE_PWD_H",
36+
+ "HAVE_SYS_WAIT_H",
37+
+ ],
38+
+ }) + select({
39+
+ "@platforms//os:windows": [],
40+
+ "//conditions:default": ["HAVE_GRP_H"],
41+
+ }),
42+
+ visibility = ["//visibility:public"],
43+
+)
44+
diff --git a/MODULE.bazel b/MODULE.bazel
45+
new file mode 100644
46+
index 00000000..402b6f96
47+
--- /dev/null
48+
+++ b/MODULE.bazel
49+
@@ -0,0 +1,9 @@
50+
+module(
51+
+ name = "libarchive",
52+
+ version = "3.7.2",
53+
+ compatibility_level = 1,
54+
+)
55+
+bazel_dep(name = "platforms", version = "0.0.9")
56+
+bazel_dep(name = "xz", version = "5.4.5.bcr.1")
57+
+bazel_dep(name = "zlib", version = "1.3.1")
58+
+bazel_dep(name = "zstd", version = "1.5.5.bcr.1")
59+
diff --git a/WORKSPACE b/WORKSPACE
60+
new file mode 100644
61+
index 00000000..e69de29b
62+
diff --git a/libarchive/BUILD.bazel b/libarchive/BUILD.bazel
63+
new file mode 100644
64+
index 00000000..85b9b37b
65+
--- /dev/null
66+
+++ b/libarchive/BUILD.bazel
67+
@@ -0,0 +1,41 @@
68+
+PUBLIC_HEADERS = [
69+
+ "archive.h",
70+
+ "archive_entry.h",
71+
+]
72+
+
73+
+WINDOWS_SRCS = glob(["*_windows.*"]) + ["archive_entry_copy_bhfi.c"]
74+
+
75+
+cc_library(
76+
+ name = "libarchive",
77+
+ srcs = glob(
78+
+ [
79+
+ "*.c",
80+
+ "*.h",
81+
+ ],
82+
+ exclude = PUBLIC_HEADERS + WINDOWS_SRCS + [
83+
+ "archive_disk_acl_*.c",
84+
+ ],
85+
+ ) + select({
86+
+ "@platforms//os:windows": WINDOWS_SRCS,
87+
+ "@platforms//os:macos": ["archive_disk_acl_darwin.c"],
88+
+ "@platforms//os:linux": ["archive_disk_acl_linux.c"],
89+
+ "//conditions:default": [],
90+
+ }),
91+
+ hdrs = PUBLIC_HEADERS,
92+
+ local_defines = [
93+
+ "HAVE_CONFIG_H",
94+
+ # ZSTD support
95+
+ "HAVE_ZSTD_H",
96+
+ "HAVE_LIBZSTD",
97+
+ "HAVE_LIBZSTD_COMPRESSOR",
98+
+ # LZMA support
99+
+ "HAVE_LZMA_H",
100+
+ "HAVE_LZMA_STREAM_ENCODER_MT",
101+
+ ],
102+
+ visibility = ["//visibility:public"],
103+
+ deps = [
104+
+ "//:config_h",
105+
+ "@xz//:lzma",
106+
+ "@zstd",
107+
+ ],
108+
+)
109+
diff --git a/libarchive/archive_hmac_private.h b/libarchive/archive_hmac_private.h
110+
index d0fda7f9..e41c944d 100644
111+
--- a/libarchive/archive_hmac_private.h
112+
+++ b/libarchive/archive_hmac_private.h
113+
@@ -40,12 +40,13 @@
114+
*/
115+
int __libarchive_hmac_build_hack(void);
116+
117+
-#ifdef __APPLE__
118+
-# include <AvailabilityMacros.h>
119+
-# if MAC_OS_X_VERSION_MAX_ALLOWED >= 1060
120+
-# define ARCHIVE_HMAC_USE_Apple_CommonCrypto
121+
-# endif
122+
-#endif
123+
+// Don't compile against CommonCrypto.
124+
+// #ifdef __APPLE__
125+
+// # include <AvailabilityMacros.h>
126+
+// # if MAC_OS_X_VERSION_MAX_ALLOWED >= 1060
127+
+// # define ARCHIVE_HMAC_USE_Apple_CommonCrypto
128+
+// # endif
129+
+// #endif
130+
131+
#ifdef ARCHIVE_HMAC_USE_Apple_CommonCrypto
132+
#include <CommonCrypto/CommonHMAC.h>
133+
diff --git a/libarchive/config.h b/libarchive/config.h
134+
new file mode 100644
135+
index 00000000..1bb06802
136+
--- /dev/null
137+
+++ b/libarchive/config.h
138+
@@ -0,0 +1,13 @@
139+
+
140+
+#ifndef LIBARCHIVE_CONFIG_H
141+
+#define LIBARCHIVE_CONFIG_H
142+
+
143+
+#include <ctype.h>
144+
+#include <wchar.h>
145+
+
146+
+#include "xplat_config.h"
147+
+
148+
+#define __LIBARCHIVE_CONFIG_H_INCLUDED 1
149+
+
150+
+#endif // LIBARCHIVE_CONFIG_H
151+
+
152+
diff --git a/libarchive_fe/BUILD.bazel b/libarchive_fe/BUILD.bazel
153+
new file mode 100644
154+
index 00000000..51a75a64
155+
--- /dev/null
156+
+++ b/libarchive_fe/BUILD.bazel
157+
@@ -0,0 +1,9 @@
158+
+cc_library(
159+
+ name = "libarchive_fe",
160+
+ srcs = glob(["*.c"]),
161+
+ hdrs = glob(["*.h"]),
162+
+ visibility = ["//visibility:public"],
163+
+ deps = [
164+
+ "//:config_h",
165+
+ ],
166+
+)
167+
diff --git a/libarchive_fe/config.h b/libarchive_fe/config.h
168+
new file mode 100644
169+
index 00000000..1f484ee0
170+
--- /dev/null
171+
+++ b/libarchive_fe/config.h
172+
@@ -0,0 +1,6 @@
173+
+#ifndef LIBARCHIVE_FE_CONFIG_H
174+
+#define LIBARCHIVE_FE_CONFIG_H
175+
+
176+
+#include "xplat_config.h"
177+
+
178+
+#endif // LIBARCHIVE_FE_CONFIG_H
179+
\ No newline at end of file
180+
diff --git a/tar/BUILD.bazel b/tar/BUILD.bazel
181+
new file mode 100644
182+
index 00000000..39fc5330
183+
--- /dev/null
184+
+++ b/tar/BUILD.bazel
185+
@@ -0,0 +1,33 @@
186+
+cc_binary(
187+
+ name = "tar",
188+
+ srcs = select({
189+
+ "@platforms//os:windows": glob([
190+
+ "*.c",
191+
+ "*.h",
192+
+ ]),
193+
+ "//conditions:default": glob(
194+
+ [
195+
+ "*.c",
196+
+ "*.h",
197+
+ ],
198+
+ exclude = ["bsdtar_windows.*"],
199+
+ ),
200+
+ }),
201+
+ copts = [
202+
+ "-Wno-implicit-function-declaration",
203+
+ "-Wno-int-conversion",
204+
+ ],
205+
+ defines = [
206+
+ 'BSDTAR_VERSION_STRING=\\"3.7.2\\"',
207+
+ ],
208+
+ includes = [
209+
+ "../libarchive",
210+
+ "../libarchive_fe",
211+
+ ],
212+
+ visibility = ["//visibility:public"],
213+
+ deps = [
214+
+ "//:config_h",
215+
+ "//libarchive",
216+
+ "//libarchive_fe",
217+
+ ],
218+
+)
219+
diff --git a/tar/bsdtar.c b/tar/bsdtar.c
220+
index 64115198..c6698a08 100644
221+
--- a/tar/bsdtar.c
222+
+++ b/tar/bsdtar.c
223+
@@ -196,7 +196,7 @@ main(int argc, char **argv)
224+
#endif
225+
226+
/* Set lafe_progname before calling lafe_warnc. */
227+
- lafe_setprogname(*argv, "bsdtar");
228+
+ lafe_setprogname("tar", "bsdtar");
229+
230+
#if HAVE_SETLOCALE
231+
if (setlocale(LC_ALL, "") == NULL)
232+
@@ -1070,7 +1070,7 @@ static const char *long_help_msg =
233+
" -c Create -r Add/Replace -t List -u Update -x Extract\n"
234+
"Common Options:\n"
235+
" -b # Use # 512-byte records per I/O block\n"
236+
- " -f <filename> Location of archive (default " _PATH_DEFTAPE ")\n"
237+
+ " -f <filename> Location of archive\n"
238+
" -v Verbose\n"
239+
" -w Interactive\n"
240+
"Create: %p -c [options] [<file> | <dir> | @<archive> | -C <dir> ]\n"
241+
diff --git a/tar/config.h b/tar/config.h
242+
new file mode 100644
243+
index 00000000..f0a39c7e
244+
--- /dev/null
245+
+++ b/tar/config.h
246+
@@ -0,0 +1,7 @@
247+
+#ifndef TAR_CONFIG_H
248+
+#define TAR_CONFIG_H
249+
+
250+
+#include "xplat_config.h"
251+
+
252+
+#endif // TAR_CONFIG_H
253+
+
254+
diff --git a/xplat_config.h b/xplat_config.h
255+
new file mode 100644
256+
index 00000000..7598c496
257+
--- /dev/null
258+
+++ b/xplat_config.h
259+
@@ -0,0 +1,41 @@
260+
+#ifndef XPLAT_CONFIG_H
261+
+#define XPLAT_CONFIG_H
262+
+
263+
+#define HAVE_DECL_SIZE_MAX 1
264+
+#define HAVE_DECL_SSIZE_MAX 1
265+
+#define HAVE_DECL_UINT32_MAX 1
266+
+#define HAVE_DECL_INT32_MAX 1
267+
+#define HAVE_DECL_INT32_MIN 1
268+
+#define HAVE_DECL_UINT64_MAX 1
269+
+#define HAVE_DECL_INT64_MAX 1
270+
+#define HAVE_DECL_INT64_MIN 1
271+
+#define HAVE_DECL_UINTMAX_MAX 1
272+
+#define HAVE_DECL_INTMAX_MAX 1
273+
+#define HAVE_DECL_INTMAX_MIN 1
274+
+
275+
+#define HAVE_DIRENT_H 1
276+
+#define HAVE_ERRNO_H 1
277+
+#define HAVE_FCHDIR 1
278+
+#define HAVE_FCNTL 1
279+
+#define HAVE_FCNTL_H 1
280+
+#define HAVE_INTTYPES_H 1
281+
+#define HAVE_LIMITS_H 1
282+
+#define HAVE_PTHREAD_H 1
283+
+#define HAVE_STDARG_H 1
284+
+#define HAVE_STDLIB_H 1
285+
+#define HAVE_STDINT_H 1
286+
+#define HAVE_STRING_H 1
287+
+#define HAVE_SYS_STAT_H 1
288+
+#define HAVE_SYS_TIME_H 1
289+
+#define HAVE_TIME_H
290+
+#define HAVE_UINTMAX_T 1
291+
+#define HAVE_UNISTD_H 1
292+
+#define HAVE_UNSIGNED_LONG_LONG 1
293+
+#define HAVE_WCTYPE_H 1
294+
+#define HAVE_WCSCPY 1
295+
+#define HAVE_WCSLEN 1
296+
+
297+
+#define MAC_OS_X_VERSION_MIN_REQUIRED 1060
298+
+#define MAC_OS_X_VERSION_MAX_ALLOWED 1070
299+
+
300+
+#endif // XPLAT_CONFIG_H
+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
matrix:
2+
platform:
3+
- debian10
4+
- debian11
5+
- ubuntu2004
6+
- ubuntu2004_arm64
7+
- ubuntu2204
8+
- macos
9+
- macos_arm64
10+
bazel: [6.x, 7.x, rolling]
11+
tasks:
12+
verify_targets:
13+
name: Verify build targets
14+
platform: ${{ platform }}
15+
bazel: ${{ bazel }}
16+
build_targets:
17+
- '@libarchive//tar'

modules/libarchive/3.7.2/source.json

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"url": "https://www.libarchive.org/downloads/libarchive-3.7.2.tar.xz",
3+
"integrity": "sha256-BDV2YeZxe2lBaCzeAq10GuSBnGeiYFk9+yQxhhslGss=",
4+
"strip_prefix": "libarchive-3.7.2",
5+
"patches": {
6+
"build_with_bazel.patch": "sha256-fVxd36wUvLVFUv85ebJiQ5jaFhKksVMm6x34kgdy7xs="
7+
},
8+
"patch_strip": 1
9+
}

modules/libarchive/metadata.json

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"homepage": "https://www.libarchive.org/",
3+
"maintainers": [
4+
{
5+
"email": "[email protected]",
6+
"github": "dzbarsky",
7+
"name": "David Zbarsky"
8+
}
9+
],
10+
"repository": [],
11+
"versions": [
12+
"3.7.2"
13+
],
14+
"yanked_versions": {}
15+
}

0 commit comments

Comments
 (0)