motiejus/undocker

extract docker archives
git clone https://git.jakstys.lt/motiejus/undocker.git
Log | Tree | Refs | README | LICENSE

commit 2fd92276547dcd3efd900b61904d24150692e379 (tree)
parent 64f6c53d607aebb4037e77632f1ece17b1f260d1
Author: Motiejus Jakštys <motiejus@jakstys.lt>
Date:   Mon, 24 May 2021 00:11:58 +0300

rootfs accepts output param

Diffstat:
Mrules.bzl | 31++++++++++++++++++-------------
1 file changed, 18 insertions(+), 13 deletions(-)

diff --git a/rules.bzl b/rules.bzl @@ -14,7 +14,9 @@ _input_container = attr.label( ) def _rootfs_impl(ctx): - out = ctx.actions.declare_file(ctx.attr.name + ".tar") + out = ctx.outputs.out + if out == None: + out = ctx.actions.declare_file(ctx.attr.name + ".tar") ctx.actions.run( outputs = [out], inputs = ctx.files.src, @@ -37,6 +39,7 @@ rootfs = rule( attrs = { "src": _input_container, "_undocker": _undocker_cli, + "out": attr.output(), }, ) @@ -58,6 +61,19 @@ def _lxcconfig_impl(ctx): runfiles = ctx.runfiles(files = ctx.files.src), ) + +def lxcbundle(name, src): + rootfsname = name+"-rootfs" + rootfsnametar = rootfsname+"-tar" + rootfs(name = rootfsnametar, src = src, out = rootfsname+".tar") + lxcconfig(name, src = src) + native.genrule( + name = rootfsnametar + "-xz", + srcs = [rootfsnametar], + outs = [rootfsname + ".tar.xz"], + cmd = "xz -cf $< > $@", + ) + _lxcconfig = rule( _lxcconfig_impl, doc = "Generate lxc config from a docker container image", @@ -67,6 +83,7 @@ _lxcconfig = rule( }, ) + def lxcconfig(name, src): _lxcconfig(name = name+"/config", src = src) pkg_tar( @@ -77,15 +94,3 @@ def lxcconfig(name, src): name: "", }, ) - - -def lxcbundle(name, src): - rootfsname = name+"-rootfs" - rootfs(name = rootfsname, src = src) - lxcconfig(name, src = src) - native.genrule( - name = rootfsname + ".xz", - srcs = [rootfsname], - outs = [rootfsname + ".xz"], - cmd = "xz -cf $< > $@", - )