From c63e2aef29382a74c5d40e6f7ecad53558f801ae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Motiejus=20Jak=C5=A1tys?= Date: Mon, 24 May 2021 00:11:58 +0300 Subject: [PATCH] wip: rootfs --- BUILD | 1 + rules.bzl | 31 +++++++++++++++++++++++++++++++ 2 files changed, 32 insertions(+) create mode 100644 rules.bzl diff --git a/BUILD b/BUILD index a5a2102..bc608fb 100644 --- a/BUILD +++ b/BUILD @@ -1,4 +1,5 @@ load("@io_bazel_rules_go//go:def.bzl", "go_binary", "go_library") +load("//src/undocker:rules.bzl", "rootfs") go_library( name = "go_default_library", diff --git a/rules.bzl b/rules.bzl new file mode 100644 index 0000000..bc48244 --- /dev/null +++ b/rules.bzl @@ -0,0 +1,31 @@ +def _rootfs_impl(ctx): + ctx.actions.run( + executable = ctx.files._undocker, + arguments = [ + ctx.attr.src, + ctx.output, + ], + ) + +rootfs = rule( + doc = "Generate a rootfs from a docker container image", + implementation = _rootfs_impl, + attrs = { + "src": attr.label( + doc = "Input container tarball", + mandatory = True, + allow_single_file = [".tar"], + ), + "out": attr.output( + doc = "Output rootfs tarball", + mandatory = True, + ), + "_undocker": attr.label( + doc = "undocker cli; private and may not be overridden", + cfg = "host", + default = Label("//src/undocker:undocker"), + allow_single_file = True, + executable = True, + ), + }, +)