| # 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_files") |
| load("@rules_pkg//pkg:tar.bzl", "pkg_tar") |
| load("@rules_python//python:defs.bzl", "py_library", "py_test") |
| load("@rules_rust//rust:defs.bzl", "rust_binary", "rust_test") |
| load("//bazel/portage/build_defs:common.bzl", "RUSTC_DEBUG_FLAGS") |
| |
| rust_binary( |
| name = "fast_install_packages", |
| srcs = glob(["src/**/*.rs"]), |
| data = [ |
| ":portageq_wrapper.py", |
| "@files//:bash-static_symlink", |
| ], |
| rustc_flags = RUSTC_DEBUG_FLAGS, |
| visibility = [ |
| "@portage//:__subpackages__", |
| ], |
| deps = [ |
| "//bazel/portage/common/cliutil", |
| "//bazel/portage/common/container", |
| "//bazel/portage/common/durabletree", |
| "//bazel/portage/common/fileutil", |
| "//bazel/portage/common/portage/binarypackage", |
| "//bazel/portage/common/portage/vdb", |
| "@alchemy_crates//:anyhow", |
| "@alchemy_crates//:clap", |
| "@alchemy_crates//:itertools", |
| "@alchemy_crates//:libc", |
| "@alchemy_crates//:nix", |
| "@alchemy_crates//:tracing", |
| "@rules_rust//tools/runfiles", |
| ], |
| ) |
| |
| rust_test( |
| name = "fast_install_packages_test", |
| size = "small", |
| srcs = glob(["tests/**/*.rs"]), |
| data = [ |
| ":fake_sdk_extras", |
| ":fast_install_packages", |
| "//bazel/portage/bin/extract_package", |
| "@alpine-minirootfs//file", |
| "@zstd", |
| ], |
| rustc_flags = RUSTC_DEBUG_FLAGS, |
| deps = [ |
| "//bazel/portage/common/container", |
| "//bazel/portage/common/durabletree", |
| "//bazel/portage/common/fileutil", |
| "//bazel/portage/common/portage/vdb", |
| "//bazel/portage/common/processes", |
| "//bazel/portage/common/testutil", |
| "@alchemy_crates//:anyhow", |
| "@alchemy_crates//:bytes", |
| "@alchemy_crates//:bzip2", |
| "@alchemy_crates//:itertools", |
| "@alchemy_crates//:tempfile", |
| "@rules_rust//tools/runfiles", |
| ], |
| ) |
| |
| pkg_files( |
| name = "fake_sdk_extras_files", |
| srcs = [ |
| "//bazel/portage/bin/drive_binary_package:drive_binary_package.sh", |
| "//bazel/portage/bin/fakefs", |
| "@files//:bash-static_alias", |
| ], |
| attributes = pkg_attributes( |
| mode = "0755", |
| ), |
| renames = { |
| "//bazel/portage/bin/drive_binary_package:drive_binary_package.sh": "usr/bin/drive_binary_package.sh", |
| "//bazel/portage/bin/fakefs": "usr/bin/fakeroot", |
| "@files//:bash-static_alias": "bin/bash", |
| }, |
| ) |
| |
| pkg_tar( |
| name = "fake_sdk_extras", |
| srcs = [":fake_sdk_extras_files"], |
| ) |
| |
| py_library( |
| name = "portageq", |
| srcs = ["portageq_wrapper.py"], |
| ) |
| |
| py_test( |
| name = "portageq_wrapper_test", |
| size = "small", |
| srcs = ["portageq_wrapper_test.py"], |
| data = [ |
| "portageq_wrapper.py", |
| "testdata/fake_portageq.py", |
| ], |
| python_version = "PY3", |
| deps = [":portageq"], |
| ) |