| # Copyright 2023 The ChromiumOS Authors |
| # Use of this source code is governed by a BSD-style license that can be |
| # found in the LICENSE file. |
| |
| load("@rules_pkg//pkg:mappings.bzl", "pkg_attributes", "pkg_filegroup", "pkg_files", "pkg_mkdirs", "pkg_mklink", "strip_prefix") |
| load("@rules_pkg//pkg:tar.bzl", "pkg_tar") |
| |
| pkg_files( |
| name = "__files_regular__", |
| srcs = glob( |
| ["**"], |
| exclude = [ |
| {%- for path in excludes %} |
| "{{ path }}", |
| {%- endfor %} |
| "BUILD.bazel", |
| "BUILD", |
| "WORKSPACE.bazel", |
| "WORKSPACE", |
| ], |
| ), |
| attributes = pkg_attributes( |
| {#- Make all files executable since some packages execute scripts in #} |
| {#- the source checkout directly. #} |
| {#- We considered adding executable bits per file, but we could't #} |
| {#- come up with a way that works well with repository regeneration #} |
| {#- logic. When the user runs "chmod +x" to some file, we would have #} |
| {#- to regenerate the repository, but how can it be efficient? #} |
| mode = "0755", |
| ), |
| renames = { |
| {%- for rename in renames %} |
| "{{ rename.output_path }}": "{{ rename.source_path }}", |
| {%- endfor %} |
| }, |
| strip_prefix = strip_prefix.from_pkg(), |
| visibility = ["//visibility:private"], |
| ) |
| {%- if dirs %} |
| |
| pkg_mkdirs( |
| name = "__dirs__", |
| dirs = [ |
| {%- for dir in dirs %} |
| "{{ dir }}", |
| {%- endfor %} |
| ], |
| ) |
| {%- endif %} |
| {%- for symlink in symlinks %} |
| |
| pkg_mklink( |
| name = "{{ symlink.name }}", |
| link_name = "{{ symlink.location }}", |
| target = "{{ symlink.target }}", |
| visibility = ["//visibility:private"], |
| ) |
| {%- endfor %} |
| |
| pkg_filegroup( |
| name = "__files__", |
| srcs = [ |
| ":__files_regular__", |
| {%- if dirs %} |
| ":__dirs__", |
| {%- endif %} |
| {%- for symlink in symlinks %} |
| ":{{ symlink.name }}", |
| {%- endfor %} |
| ], |
| prefix = "/mnt/host/source/{{ prefix }}", |
| visibility = ["//visibility:private"], |
| ) |
| |
| pkg_tar( |
| name = "__tarball__", |
| srcs = [ |
| ":__files__", |
| ], |
| compressor = "@//bazel/portage/repo_defs/zstd", |
| compressor_args = "--threads=0", |
| extension = "tar.zst", |
| visibility = ["//visibility:private"], |
| ) |
| |
| filegroup( |
| name = "__tarballs__", |
| srcs = [ |
| ":__tarball__", |
| {%- for child in children %} |
| "//internal/sources/{{ child }}:__tarballs__", |
| {%- endfor %} |
| ], |
| visibility = [ |
| "//internal/packages:__subpackages__", |
| "//internal/sources:__subpackages__", |
| ], |
| ) |