1
Fork 0

add lxcconfig

main
Motiejus Jakštys 2021-05-24 00:11:58 +03:00
parent 8a5d9b636c
commit 4afc07bb65
1 changed files with 46 additions and 16 deletions

View File

@ -1,15 +1,28 @@
_undocker_cli = attr.label(
doc = "undocker cli; private and may not be overridden",
cfg = "host",
default = Label("//src/undocker:undocker"),
allow_single_file = True,
executable = True,
)
_input_container = attr.label(
doc = "Input container tarball",
mandatory = True,
allow_single_file = [".tar"],
)
def _rootfs_impl(ctx):
outf = ctx.attr.name + ".tar"
out = ctx.actions.declare_file(outf)
out = ctx.actions.declare_file(ctx.attr.name + ".tar")
ctx.actions.run(
outputs = [out],
inputs = ctx.files.src,
executable = ctx.files._undocker[0],
arguments = [
"rootfs",
ctx.files.src.to_list()[0].path,
outf,
ctx.files.src[0].path,
out.path,
],
mnemonic = "RootFS",
)
return [DefaultInfo(
files = depset([out]),
@ -20,17 +33,34 @@ 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"],
),
"_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,
),
"src": _input_container,
"_undocker": _undocker,
},
)
def _lxcconfig_impl(ctx):
out = ctx.actions.declare_file(ctx.attr.name + ".conf")
ctx.actions.run(
outputs = [out],
inputs = ctx.files.src,
executable = ctx.files._undocker[0],
arguments = [
"lxcconfig",
ctx.files.src[0].path,
out.path,
],
mnemonic = "LXCConfig",
)
return [DefaultInfo(
files = depset([out]),
runfiles = ctx.runfiles(files = ctx.files.src),
)]
lxcconfig = rule(
doc = "Generate lxc config from a docker container image",
implementation = _lxcconfig_impl,
attrs = {
"src": _input_container,
"_undocker": _undocker,
},
)