{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://catalog.lintel.tools/schemas/schemastore/chisel-slices-json/latest.json",
  "title": "Canonical Chisel Slice Definition",
  "description": "A slice definition for Ubuntu Chisel tool. For details, see <https://github.com/canonical/chisel/tree/main#slice-definitions>.",
  "x-lintel": {
    "source": "https://www.schemastore.org/chisel-slices.json",
    "sourceSha256": "9c2c07047c6c948519cae172628693fb8677dbf54fc3ae9e55f8df5d3b2bad80",
    "fileMatch": [
      "**/slices/*.yaml"
    ],
    "parsers": [
      "yaml"
    ]
  },
  "type": "object",
  "properties": {
    "package": {
      "type": "string",
      "description": "The name of the package to use for the slice.",
      "pattern": "^[a-z0-9][a-z0-9+\\-\\.]+$",
      "examples": [
        "libgcc-s1",
        "libunwind-13"
      ]
    },
    "archive": {
      "type": "string",
      "description": "The name of the archive to use for the slice. Archives are defined in the chisel.yaml file.",
      "examples": [
        "ubuntu"
      ]
    },
    "essential": {
      "type": [
        "array",
        "object"
      ],
      "description": "A list of slices that are a dependency for all slices of this package. Each slice item is formatted as '<slice_name>_<slice_part>'.",
      "uniqueItems": true,
      "items": {
        "type": "string",
        "pattern": "^[a-z0-9][a-z0-9+\\-\\._]+$"
      },
      "examples": [
        {
          "slicename_copyright": {}
        },
        {
          "slicename_licenses": {}
        }
      ],
      "patternProperties": {
        "^.+$": {
          "description": "The name of the dependency slice part.",
          "type": [
            "object",
            "null"
          ],
          "properties": {
            "arch": {
              "type": "array",
              "description": "Only include this dependency on specific architectures.",
              "uniqueItems": true,
              "examples": [
                [
                  "amd64",
                  "arm64"
                ]
              ],
              "items": {
                "type": "string",
                "examples": [
                  "amd64",
                  "i386",
                  "armhf",
                  "arm64",
                  "powerpc",
                  "ppc64el",
                  "s390x",
                  "riscv64"
                ]
              }
            }
          },
          "additionalProperties": false
        }
      }
    },
    "slices": {
      "type": "object",
      "description": "Slice definitions for this package.",
      "patternProperties": {
        "^[_a-zA-Z][a-zA-Z0-9_-]*$": {
          "description": "The name of the slice part.",
          "type": "object",
          "properties": {
            "essential": {
              "type": [
                "array",
                "object"
              ],
              "description": "The name of the dependency slice part. The slice part is formatted as '<slice_name>_<slice_part>'.",
              "uniqueItems": true,
              "items": {
                "type": "string",
                "pattern": "^[a-z0-9][a-z0-9+\\-\\._]+$"
              },
              "examples": [
                {
                  "libgcc-s1_libs": {}
                },
                {
                  "ca-certificates_data": {}
                }
              ],
              "patternProperties": {
                "^.+$": {
                  "description": "The name of the dependency slice part.",
                  "type": [
                    "object",
                    "null"
                  ],
                  "properties": {
                    "arch": {
                      "type": "array",
                      "description": "Only include this dependency on specific architectures.",
                      "uniqueItems": true,
                      "examples": [
                        [
                          "amd64",
                          "arm64"
                        ]
                      ],
                      "items": {
                        "type": "string",
                        "examples": [
                          "amd64",
                          "i386",
                          "armhf",
                          "arm64",
                          "powerpc",
                          "ppc64el",
                          "s390x",
                          "riscv64"
                        ]
                      }
                    }
                  },
                  "additionalProperties": false
                }
              }
            },
            "mutate": {
              "type": "string",
              "description": "A Starlark expression to modify the file contents.",
              "examples": [
                "foo = content.read(\"/path/to/temporary/content\")"
              ]
            },
            "hint": {
              "type": "string",
              "description": "Concise and unopinionated discriminator to describe the slice. No special chars, trailing punctuation, and it must be sentence case.",
              "examples": [
                "Non-standard timezones"
              ],
              "pattern": "^(?=[A-Z])[a-zA-Z0-9.,;()\\s]*[^.,;!?: \\W]$"
            },
            "contents": {
              "type": "object",
              "description": "Files to include in the slice. Supports glob patterns.",
              "examples": [
                {
                  "/lib*/ld*.so.*": {}
                },
                {
                  "/usr/share/nodejs/cjs-module-lexer/**": {}
                },
                {
                  "/path/to/moved/content": {
                    "copy": "/bin/original"
                  }
                },
                {
                  "/path/to/link": {
                    "symlink": "/bin/mybin"
                  }
                },
                {
                  "/path/to/new/dir": {
                    "make": true
                  }
                },
                {
                  "/path/to/file/with/text": {
                    "text": "Some text"
                  }
                },
                {
                  "/path/to/mutable/file/with/default/text": {
                    "text": "FIXME",
                    "mutable": true
                  }
                },
                {
                  "/path/to/temporary/content": {
                    "until": "mutate"
                  }
                }
              ],
              "patternProperties": {
                "^.+$": {
                  "description": "Path description.",
                  "type": [
                    "object",
                    "null"
                  ],
                  "properties": {
                    "make": {
                      "type": "boolean",
                      "description": "Make this file or directory if it does not already exist.",
                      "default": true
                    },
                    "mode": {
                      "type": "integer",
                      "description": "File permissions to use.",
                      "examples": [
                        "0o755"
                      ]
                    },
                    "copy": {
                      "type": "string",
                      "description": "Copy this file or directory from this location.",
                      "examples": [
                        "/path/to/original/file.txt"
                      ]
                    },
                    "text": {
                      "type": "string",
                      "description": "The contents of the file.",
                      "examples": [
                        "FIXME"
                      ]
                    },
                    "symlink": {
                      "type": "string",
                      "description": "Make a symlink to this file or directory.",
                      "examples": [
                        "/path/to/source/file.txt"
                      ]
                    },
                    "mutable": {
                      "type": "boolean",
                      "description": "If true, the file is mutable.",
                      "default": true
                    },
                    "until": {
                      "$comment": "Valid values: 'mutate' and ''. But most editors will not accept an empty string.",
                      "type": "string",
                      "description": "Only keep this file until this stage.",
                      "examples": [
                        "mutate"
                      ],
                      "default": "",
                      "enum": [
                        "",
                        "mutate"
                      ]
                    },
                    "arch": {
                      "type": "array",
                      "description": "Only include this file on specific architectures.",
                      "uniqueItems": true,
                      "examples": [
                        [
                          "amd64",
                          "arm64"
                        ]
                      ],
                      "items": {
                        "type": "string",
                        "examples": [
                          "amd64",
                          "i386",
                          "armhf",
                          "arm64",
                          "powerpc",
                          "ppc64el",
                          "s390x",
                          "riscv64"
                        ]
                      }
                    }
                  },
                  "additionalProperties": false
                }
              }
            }
          },
          "additionalProperties": false
        }
      }
    }
  },
  "$comment": "https://github.com/canonical/chisel/tree/main#slice-definitions",
  "additionalProperties": false
}
