blob: 0dc46fa0afc89c7f045047fc0dcfb68f2a3c59d7 [file] [log] [blame]
Tim Windelschmidtbed76d92025-02-18 03:04:14 +01001load("//osbase/build/fsspec:def.bzl", "FSSpecInfo", "fsspec_core_impl")
2
3def _node_initramfs_impl(ctx):
4 initramfs_name = ctx.label.name + ".cpio.zst"
5 initramfs = ctx.actions.declare_file(initramfs_name)
6
7 fsspec_core_impl(ctx, ctx.executable._mkcpio, initramfs)
8
Tim Windelschmidtbed76d92025-02-18 03:04:14 +01009 return [DefaultInfo(runfiles = ctx.runfiles(files = [initramfs]), files = depset([initramfs]))]
10
11node_initramfs = rule(
12 implementation = _node_initramfs_impl,
13 doc = """
14 Build a node initramfs. The initramfs will contain a basic /dev directory and all the files specified by the
15 `files` attribute. Executable files will have their permissions set to 0755, non-executable files will have
16 their permissions set to 0444. All parent directories will be created with 0755 permissions.
17 """,
18 attrs = {
19 "files": attr.string_keyed_label_dict(
20 mandatory = True,
21 allow_files = True,
22 doc = """
23 Dictionary of Labels to String, placing a given Label's output file in the initramfs at the location
24 specified by the String value. The specified labels must only have a single output.
25 """,
Tim Windelschmidtbed76d92025-02-18 03:04:14 +010026 ),
27 "symlinks": attr.string_dict(
28 default = {},
29 doc = """
Jan Schär0fd36f42025-04-29 10:26:03 +000030 Symbolic links to create. Similar format as in `files`, so the key is the location of the
Tim Windelschmidtad4d9542025-03-24 20:20:13 +010031 symlink itself and the value of it is target of the symlink. Only raw strings are allowed as targets,
Jan Schär0fd36f42025-04-29 10:26:03 +000032 labels are not permitted. Include the file using `files`, then symlink to its location.
Tim Windelschmidtbed76d92025-02-18 03:04:14 +010033 """,
34 ),
35 "fsspecs": attr.label_list(
36 default = [],
37 doc = """
38 List of file system specs (osbase.build.fsspec.FSSpec) to also include in the resulting image.
39 These will be merged with all other given attributes.
40 """,
41 providers = [FSSpecInfo],
42 allow_files = True,
43 ),
44
45 # Tool
46 "_mkcpio": attr.label(
47 default = Label("//osbase/build/mkcpio"),
48 executable = True,
49 cfg = "exec",
50 ),
51 },
52)