| Tim Windelschmidt | bed76d9 | 2025-02-18 03:04:14 +0100 | [diff] [blame] | 1 | load("//osbase/build/fsspec:def.bzl", "FSSpecInfo", "fsspec_core_impl") |
| 2 | |
| 3 | def _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 Windelschmidt | bed76d9 | 2025-02-18 03:04:14 +0100 | [diff] [blame] | 9 | return [DefaultInfo(runfiles = ctx.runfiles(files = [initramfs]), files = depset([initramfs]))] |
| 10 | |
| 11 | node_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 Windelschmidt | bed76d9 | 2025-02-18 03:04:14 +0100 | [diff] [blame] | 26 | ), |
| 27 | "symlinks": attr.string_dict( |
| 28 | default = {}, |
| 29 | doc = """ |
| Jan Schär | 0fd36f4 | 2025-04-29 10:26:03 +0000 | [diff] [blame] | 30 | Symbolic links to create. Similar format as in `files`, so the key is the location of the |
| Tim Windelschmidt | ad4d954 | 2025-03-24 20:20:13 +0100 | [diff] [blame] | 31 | symlink itself and the value of it is target of the symlink. Only raw strings are allowed as targets, |
| Jan Schär | 0fd36f4 | 2025-04-29 10:26:03 +0000 | [diff] [blame] | 32 | labels are not permitted. Include the file using `files`, then symlink to its location. |
| Tim Windelschmidt | bed76d9 | 2025-02-18 03:04:14 +0100 | [diff] [blame] | 33 | """, |
| 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 | ) |