From e1198dfbfb5861dbd3545ba7315724c7dcd5244c Mon Sep 17 00:00:00 2001 From: Nils Date: Fri, 9 Aug 2024 21:31:25 +0000 Subject: [PATCH] ahlap --- .github/workflows/ci.yml | 18 ++++++++++++- .gitmodules | 3 ++- build.zig | 31 ++++++++++------------ crun | 2 +- crun_include/git-version.h | 3 +++ libfuse_include/fuse_config.h | 44 ++++++++++++++++++++++++++++++++ libfuse_include/libfuse_config.h | 15 +++++++++++ 7 files changed, 95 insertions(+), 21 deletions(-) create mode 100644 crun_include/git-version.h create mode 100644 libfuse_include/fuse_config.h create mode 100644 libfuse_include/libfuse_config.h diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d6e9c96..e3b6511 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -7,4 +7,20 @@ jobs: - uses: goto-bus-stop/setup-zig@v2 with: version: 0.13.0 - - run: zig fmt --check . \ No newline at end of file + - run: zig fmt --check . + test: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + submodules: 'recursive' + - uses: actions/setup-go@v5 + with: + go-version: '1.22.6' + - uses: goto-bus-stop/setup-zig@v2 + with: + version: 0.13.0 + - run: sudo apt install autoconf libtool pkg-config make libzstd-dev libfuse3-dev + - run: zig build -Doptimize=ReleaseSafe -Dtarget=x86_64-linux-musl + - run: zig-out/bin/dockerc --image docker://hello-world --output enlo + - run: ./enlo \ No newline at end of file diff --git a/.gitmodules b/.gitmodules index 599df75..60bfe50 100644 --- a/.gitmodules +++ b/.gitmodules @@ -6,7 +6,8 @@ url = https://github.com/containers/skopeo.git [submodule "crun"] path = crun - url = https://github.com/containers/crun.git + url = https://github.com/NilsIrl/crun.git + branch = dockerc [submodule "squashfs-tools"] path = squashfs-tools url = https://github.com/plougher/squashfs-tools.git diff --git a/build.zig b/build.zig index bacc2fe..b302bfc 100644 --- a/build.zig +++ b/build.zig @@ -57,7 +57,7 @@ pub fn build(b: *std.Build) void { fuse_fss.addIncludePath(b.path("zstd/lib")); fuse_fss.addIncludePath(b.path("libfuse/include")); - fuse_fss.addIncludePath(b.path("libfuse/build")); + fuse_fss.addIncludePath(b.path("libfuse_include")); fuse_fss.addCSourceFiles(.{ .files = &[_][]const u8{ @@ -137,6 +137,13 @@ pub fn build(b: *std.Build) void { .target = target, }); + const cc = std.fmt.allocPrint( + b.allocator, + // TODO: find exact zig location + "zig cc --target={s}", + .{target.result.zigTriple(b.allocator) catch @panic("OOM")}, + ) catch @panic("OOM"); + const squashfuse_autogen = b.addSystemCommand(&[_][]const u8{ "./autogen.sh", }); @@ -172,21 +179,6 @@ pub fn build(b: *std.Build) void { overlayfs_configure.setCwd(b.path("fuse-overlayfs")); overlayfs_configure.step.dependOn(&overlayfs_autogen.step); - const libfuse_mkdir_build = b.addSystemCommand(&[_][]const u8{ - "mkdir", - "-p", - "build", - }); - libfuse_mkdir_build.setCwd(b.path("libfuse")); - - const configure_libfuse = b.addSystemCommand(&[_][]const u8{ - "meson", - "setup", - "..", - }); - configure_libfuse.setCwd(b.path("libfuse/build")); - configure_libfuse.step.dependOn(&libfuse_mkdir_build.step); - const runtime = b.createModule(.{ .root_source_file = b.path("src/main.zig"), .link_libc = true, @@ -195,6 +187,7 @@ pub fn build(b: *std.Build) void { runtime.addImport("zstd", zstd); runtime.addImport("fuse-overlayfs", fuse_fss); + runtime.addIncludePath(b.path("crun_include")); runtime.addIncludePath(b.path("crun")); runtime.addIncludePath(b.path("crun/src")); runtime.addIncludePath(b.path("crun/libocispec/src")); @@ -297,6 +290,10 @@ pub fn build(b: *std.Build) void { "--disable-caps", "--disable-seccomp", }); + crun_configure.setEnvironmentVariable( + "CC", + cc, + ); crun_configure.setCwd(b.path("crun")); crun_configure.step.dependOn(&crun_autogen.step); @@ -320,12 +317,10 @@ pub fn build(b: *std.Build) void { runtime_x86_64.step.dependOn(&squashfuse_make_generate_swap.step); runtime_x86_64.step.dependOn(&overlayfs_configure.step); runtime_x86_64.step.dependOn(&libocspec_generate_files.step); - runtime_x86_64.step.dependOn(&configure_libfuse.step); runtime_aarch64.step.dependOn(&squashfuse_make_generate_swap.step); runtime_aarch64.step.dependOn(&overlayfs_configure.step); runtime_aarch64.step.dependOn(&libocspec_generate_files.step); - runtime_aarch64.step.dependOn(&configure_libfuse.step); } const go_cpu_arch = switch (target.query.cpu_arch orelse target.result.cpu.arch) { diff --git a/crun b/crun index 05c4ea1..fe982fa 160000 --- a/crun +++ b/crun @@ -1 +1 @@ -Subproject commit 05c4ea19412e77770f3959bec4ac4bd33be46776 +Subproject commit fe982fafdd2487d408045eca3aaf4dff986d458b diff --git a/crun_include/git-version.h b/crun_include/git-version.h new file mode 100644 index 0000000..ca4a89f --- /dev/null +++ b/crun_include/git-version.h @@ -0,0 +1,3 @@ +#ifndef GIT_VERSION +# define GIT_VERSION "dockerc-hash" +#endif diff --git a/libfuse_include/fuse_config.h b/libfuse_include/fuse_config.h new file mode 100644 index 0000000..f376a81 --- /dev/null +++ b/libfuse_include/fuse_config.h @@ -0,0 +1,44 @@ +/* + * Autogenerated by the Meson build system. + * Do not edit, your changes will be lost. + */ + +#pragma once + +// not available in musl +// #define HAVE_BACKTRACE + +#define HAVE_COPY_FILE_RANGE + +#define HAVE_FALLOCATE + +#define HAVE_FDATASYNC + +#define HAVE_FORK + +#define HAVE_FSTATAT + +#define HAVE_ICONV + +#define HAVE_OPENAT + +#define HAVE_PIPE2 + +#define HAVE_POSIX_FALLOCATE + +#define HAVE_READLINKAT + +#define HAVE_SETXATTR + +#define HAVE_SPLICE + +#define HAVE_STRUCT_STAT_ST_ATIM + +#undef HAVE_STRUCT_STAT_ST_ATIMESPEC + +#define HAVE_UTIMENSAT + +#define HAVE_VMSPLICE + +#define PACKAGE_VERSION "3.17.0" + diff --git a/libfuse_include/libfuse_config.h b/libfuse_include/libfuse_config.h new file mode 100644 index 0000000..31403da --- /dev/null +++ b/libfuse_include/libfuse_config.h @@ -0,0 +1,15 @@ +/* + * Autogenerated by the Meson build system. + * Do not edit, your changes will be lost. + */ + +#pragma once + +#define FUSE_HOTFIX_VERSION 0 + +#define FUSE_MAJOR_VERSION 3 + +#define FUSE_MINOR_VERSION 17 + +#define LIBFUSE_BUILT_WITH_VERSIONED_SYMBOLS 1 +