mirror of
https://github.com/NilsIrl/dockerc.git
synced 2025-09-26 19:11:13 +08:00
Remove mksquashfs executable
This commit is contained in:
6
.gitmodules
vendored
6
.gitmodules
vendored
@@ -7,3 +7,9 @@
|
||||
[submodule "crun"]
|
||||
path = crun
|
||||
url = https://github.com/containers/crun.git
|
||||
[submodule "squashfs-tools"]
|
||||
path = squashfs-tools
|
||||
url = https://github.com/plougher/squashfs-tools.git
|
||||
[submodule "zstd"]
|
||||
path = zstd
|
||||
url = https://github.com/facebook/zstd.git
|
||||
|
68
build.zig
68
build.zig
@@ -114,6 +114,74 @@ pub fn build(b: *std.Build) void {
|
||||
.link_libc = true,
|
||||
});
|
||||
|
||||
dockerc.addIncludePath(b.path("zstd/lib"));
|
||||
dockerc.addCSourceFiles(.{
|
||||
.files = &[_][]const u8{
|
||||
"zstd/lib/common/debug.c",
|
||||
"zstd/lib/common/entropy_common.c",
|
||||
"zstd/lib/common/error_private.c",
|
||||
"zstd/lib/common/fse_decompress.c",
|
||||
"zstd/lib/common/pool.c",
|
||||
"zstd/lib/common/threading.c",
|
||||
"zstd/lib/common/xxhash.c",
|
||||
"zstd/lib/common/zstd_common.c",
|
||||
|
||||
"zstd/lib/compress/fse_compress.c",
|
||||
"zstd/lib/compress/hist.c",
|
||||
"zstd/lib/compress/huf_compress.c",
|
||||
"zstd/lib/compress/zstd_compress.c",
|
||||
"zstd/lib/compress/zstd_compress_literals.c",
|
||||
"zstd/lib/compress/zstd_compress_sequences.c",
|
||||
"zstd/lib/compress/zstd_compress_superblock.c",
|
||||
"zstd/lib/compress/zstd_double_fast.c",
|
||||
"zstd/lib/compress/zstd_fast.c",
|
||||
"zstd/lib/compress/zstd_lazy.c",
|
||||
"zstd/lib/compress/zstd_ldm.c",
|
||||
"zstd/lib/compress/zstdmt_compress.c",
|
||||
"zstd/lib/compress/zstd_opt.c",
|
||||
|
||||
"zstd/lib/decompress/huf_decompress.c",
|
||||
"zstd/lib/decompress/zstd_ddict.c",
|
||||
"zstd/lib/decompress/zstd_decompress_block.c",
|
||||
"zstd/lib/decompress/zstd_decompress.c",
|
||||
|
||||
"squashfs-tools/squashfs-tools/mksquashfs.c",
|
||||
"squashfs-tools/squashfs-tools/progressbar.c",
|
||||
"squashfs-tools/squashfs-tools/caches-queues-lists.c",
|
||||
"squashfs-tools/squashfs-tools/date.c",
|
||||
"squashfs-tools/squashfs-tools/pseudo.c",
|
||||
"squashfs-tools/squashfs-tools/action.c",
|
||||
"squashfs-tools/squashfs-tools/sort.c",
|
||||
"squashfs-tools/squashfs-tools/restore.c",
|
||||
"squashfs-tools/squashfs-tools/info.c",
|
||||
"squashfs-tools/squashfs-tools/mksquashfs_help.c",
|
||||
"squashfs-tools/squashfs-tools/print_pager.c",
|
||||
"squashfs-tools/squashfs-tools/compressor.c",
|
||||
"squashfs-tools/squashfs-tools/tar.c",
|
||||
"squashfs-tools/squashfs-tools/reader.c",
|
||||
"squashfs-tools/squashfs-tools/read_fs.c",
|
||||
"squashfs-tools/squashfs-tools/memory.c",
|
||||
"squashfs-tools/squashfs-tools/process_fragments.c",
|
||||
"squashfs-tools/squashfs-tools/zstd_wrapper.c",
|
||||
},
|
||||
.flags = &[_][]const u8{
|
||||
// avoid collision of main function
|
||||
"-Dmain=mksquashfs_main",
|
||||
// zstd: asm is only used for decompression so it is fine to disable
|
||||
"-DZSTD_DISABLE_ASM",
|
||||
// squashfs defines
|
||||
"-DZSTD_SUPPORT",
|
||||
"-D_GNU_SOURCE",
|
||||
"-DVERSION=\"dockerc\"",
|
||||
"-DDATE=\"2024/07/21\"",
|
||||
"-DYEAR=\"2024\"",
|
||||
"-DCOMP_DEFAULT=\"zstd\"",
|
||||
"-DCOMPRESSORS=\"zstd\"",
|
||||
// There's UB in squashfs. This deals with it.
|
||||
"-fno-sanitize=undefined",
|
||||
},
|
||||
});
|
||||
|
||||
dockerc.root_module.addAnonymousImport(
|
||||
"runtime",
|
||||
.{ .root_source_file = runtime.getEmittedBin() },
|
||||
|
1
squashfs-tools
Submodule
1
squashfs-tools
Submodule
Submodule squashfs-tools added at c00dfaf2cd
@@ -10,7 +10,6 @@ const debug = std.debug;
|
||||
const io = std.io;
|
||||
|
||||
const skopeo_content = @embedFile("skopeo");
|
||||
const mksquashfs_content = @embedFile("tools/mksquashfs");
|
||||
const umoci_content = @embedFile("umoci");
|
||||
|
||||
const policy_content = @embedFile("tools/policy.json");
|
||||
@@ -23,6 +22,8 @@ const runtime_content_len_u64 = data: {
|
||||
break :data buf;
|
||||
};
|
||||
|
||||
extern fn mksquashfs_main(argc: c_int, argv: [*:null]const ?[*:0]const u8) void;
|
||||
|
||||
pub fn main() !void {
|
||||
var gpa = std.heap.GeneralPurposeAllocator(.{}){};
|
||||
defer _ = gpa.deinit();
|
||||
@@ -37,9 +38,6 @@ pub fn main() !void {
|
||||
const umoci_path = try extract_file(&temp_dir_path, "umoci", umoci_content, allocator);
|
||||
defer allocator.free(umoci_path);
|
||||
|
||||
const mksquashfs_path = try extract_file(&temp_dir_path, "mksquashfs", mksquashfs_content, allocator);
|
||||
defer allocator.free(mksquashfs_path);
|
||||
|
||||
const policy_path = try extract_file(&temp_dir_path, "policy.json", policy_content, allocator);
|
||||
defer allocator.free(policy_path);
|
||||
|
||||
@@ -85,7 +83,8 @@ pub fn main() !void {
|
||||
|
||||
// safe to assert because checked above
|
||||
const image = res.args.image.?;
|
||||
const output_path = res.args.output.?;
|
||||
const output_path = try allocator.dupeZ(u8, res.args.output.?);
|
||||
defer allocator.free(output_path);
|
||||
|
||||
const destination_arg = try std.fmt.allocPrint(allocator, "oci:{s}/image:latest", .{temp_dir_path});
|
||||
defer allocator.free(destination_arg);
|
||||
@@ -96,7 +95,7 @@ pub fn main() !void {
|
||||
const umoci_image_layout_path = try std.fmt.allocPrint(allocator, "{s}/image:latest", .{temp_dir_path});
|
||||
defer allocator.free(umoci_image_layout_path);
|
||||
|
||||
const bundle_destination = try std.fmt.allocPrint(allocator, "{s}/bundle", .{temp_dir_path});
|
||||
const bundle_destination = try std.fmt.allocPrintZ(allocator, "{s}/bundle", .{temp_dir_path});
|
||||
defer allocator.free(bundle_destination);
|
||||
|
||||
const umoci_args = [_][]const u8{
|
||||
@@ -110,11 +109,11 @@ pub fn main() !void {
|
||||
var umociProcess = std.process.Child.init(if (res.args.rootfull == 0) &umoci_args else umoci_args[0 .. umoci_args.len - 1], gpa.allocator());
|
||||
_ = try umociProcess.spawnAndWait();
|
||||
|
||||
const offset_arg = try std.fmt.allocPrint(allocator, "{}", .{runtime_content.len});
|
||||
const offset_arg = try std.fmt.allocPrintZ(allocator, "{}", .{runtime_content.len});
|
||||
defer allocator.free(offset_arg);
|
||||
|
||||
var mksquashfsProcess = std.process.Child.init(&[_][]const u8{
|
||||
mksquashfs_path,
|
||||
const mksquashfs_args = [_:null]?[*:0]const u8{
|
||||
"mksquashfs",
|
||||
bundle_destination,
|
||||
output_path,
|
||||
"-comp",
|
||||
@@ -122,8 +121,12 @@ pub fn main() !void {
|
||||
"-offset",
|
||||
offset_arg,
|
||||
"-noappend",
|
||||
}, gpa.allocator());
|
||||
_ = try mksquashfsProcess.spawnAndWait();
|
||||
};
|
||||
|
||||
mksquashfs_main(
|
||||
mksquashfs_args.len,
|
||||
&mksquashfs_args,
|
||||
);
|
||||
|
||||
const file = try std.fs.cwd().openFile(output_path, .{
|
||||
.mode = .write_only,
|
||||
|
BIN
src/tools/mksquashfs
(Stored with Git LFS)
BIN
src/tools/mksquashfs
(Stored with Git LFS)
Binary file not shown.
1
zstd
Submodule
1
zstd
Submodule
Submodule zstd added at 0ff651dd87
Reference in New Issue
Block a user