diff --git a/.bazelrc b/.bazelrc index 1eb348b6cb4eca1abfbc6bd375c0a13910cf48d1..56a109dc87c1e7b0f1f8e045dd582f496d28d3ed 100644 --- a/.bazelrc +++ b/.bazelrc @@ -2,7 +2,7 @@ common --registry https://bcr.bazel.build common --registry=https://gitlab.arm.com/bazel/rules_tar/-/releases/v1.0.0-beta.3/downloads common --registry=https://gitlab.arm.com/bazel/rules_zstd/-/releases/v1.0.0-beta.3/downloads -common --registry=https://gitlab.arm.com/bazel/toolchain_utils/-/releases/v1.0.0-beta.14/downloads +common --registry=https://gitlab.arm.com/bazel/toolchain_utils/-/releases/v1.0.0-beta.15/downloads # Build cache build --experimental_guard_against_concurrent_changes @@ -25,5 +25,6 @@ common --@rules_labgrid//python:bootstrap=script # Enable built Zstandard toolchain common --extra_toolchains=@rules_zstd//zstd/toolchain/zstd:built + # User-specific .bazelrc try-import %workspace%/.bazelrc.user diff --git a/MODULE.bazel b/MODULE.bazel index 9d9576b9a82adc781521d76e556c11ad57c1c112..0f2eeeff0025b96ff88bc9df60aebde33d694014 100644 --- a/MODULE.bazel +++ b/MODULE.bazel @@ -7,7 +7,7 @@ module( ) bazel_dep(name = "bazel_skylib", version = "1.7.1") -bazel_dep(name = "toolchain_utils", version = "1.0.0-beta.14") +bazel_dep(name = "toolchain_utils", version = "1.0.0-beta.15") bazel_dep(name = "rules_python", version = "0.33.2") bazel_dep(name = "ape", version = "1.0.0-beta.12") bazel_dep(name = "download_utils", version = "1.0.0-beta.2") diff --git a/MODULE.bazel.lock b/MODULE.bazel.lock index bdaad19e027b38249c82c7c4f62363395686478c..b4098ff3910cb33977ce2ced572b827f08d70e82 100644 --- a/MODULE.bazel.lock +++ b/MODULE.bazel.lock @@ -104,7 +104,7 @@ "https://bcr.bazel.build/modules/stardoc/0.5.4/MODULE.bazel": "6569966df04610b8520957cb8e97cf2e9faac2c0309657c537ab51c16c18a2a4", "https://bcr.bazel.build/modules/stardoc/0.5.4/source.json": "a961f58a71e735aa9dcb2d79b288e06b0a2d860ba730302c8f11be411b76631e", "https://bcr.bazel.build/modules/toolchain_utils/1.0.0-beta.12/MODULE.bazel": "947cf935fa609c91b05bd8c8c1be38b9e10b7bc8949cf3092ee416ed30995078", - "https://bcr.bazel.build/modules/toolchain_utils/1.0.0-beta.14/MODULE.bazel": "not found", + "https://bcr.bazel.build/modules/toolchain_utils/1.0.0-beta.15/MODULE.bazel": "not found", "https://bcr.bazel.build/modules/toolchain_utils/1.0.0-beta.9/MODULE.bazel": "9a8edfa6905229b899225489cbd6db36f073d9455c77238bd6ae6c52da5256d8", "https://bcr.bazel.build/modules/upb/0.0.0-20220923-a547704/MODULE.bazel": "7298990c00040a0e2f121f6c32544bab27d4452f80d9ce51349b1a28f3005c43", "https://bcr.bazel.build/modules/upb/0.0.0-20220923-a547704/source.json": "f1ef7d3f9e0e26d4b23d1c39b5f5de71f584dd7d1b4ef83d9bbba6ec7a6a6459", @@ -118,14 +118,14 @@ "https://gitlab.arm.com/bazel/rules_tar/-/releases/v1.0.0-beta.3/downloads/modules/rules_tar/1.0.0-beta.3/MODULE.bazel": "64e7c453ec8915d362017208ca94fc204526032a4847ae4e3af94d2b368e30d3", "https://gitlab.arm.com/bazel/rules_tar/-/releases/v1.0.0-beta.3/downloads/modules/rules_tar/1.0.0-beta.3/source.json": "c83aaf04a1abcd6cd88e3a017ff7041c4b059d984a9839e7ef327142904c1fb3", "https://gitlab.arm.com/bazel/rules_tar/-/releases/v1.0.0-beta.3/downloads/modules/rules_zstd/1.0.0-beta.3/MODULE.bazel": "not found", - "https://gitlab.arm.com/bazel/rules_tar/-/releases/v1.0.0-beta.3/downloads/modules/toolchain_utils/1.0.0-beta.14/MODULE.bazel": "not found", + "https://gitlab.arm.com/bazel/rules_tar/-/releases/v1.0.0-beta.3/downloads/modules/toolchain_utils/1.0.0-beta.15/MODULE.bazel": "not found", "https://gitlab.arm.com/bazel/rules_zstd/-/releases/v1.0.0-beta.3/downloads/bazel_registry.json": "not found", "https://gitlab.arm.com/bazel/rules_zstd/-/releases/v1.0.0-beta.3/downloads/modules/rules_zstd/1.0.0-beta.3/MODULE.bazel": "a1386815d57563c8288e12bff7195e59f898f82aa39251291f088b4696ce265c", "https://gitlab.arm.com/bazel/rules_zstd/-/releases/v1.0.0-beta.3/downloads/modules/rules_zstd/1.0.0-beta.3/source.json": "03c5addba144297bf0905f6a4a807f1c8f829cdb7a6a355e1822a5711f70584a", - "https://gitlab.arm.com/bazel/rules_zstd/-/releases/v1.0.0-beta.3/downloads/modules/toolchain_utils/1.0.0-beta.14/MODULE.bazel": "not found", - "https://gitlab.arm.com/bazel/toolchain_utils/-/releases/v1.0.0-beta.14/downloads/bazel_registry.json": "not found", - "https://gitlab.arm.com/bazel/toolchain_utils/-/releases/v1.0.0-beta.14/downloads/modules/toolchain_utils/1.0.0-beta.14/MODULE.bazel": "ed32c210fdf14321f9adf35a298c87fcc2b6f10ca5afe250b9733f9f98e80d5e", - "https://gitlab.arm.com/bazel/toolchain_utils/-/releases/v1.0.0-beta.14/downloads/modules/toolchain_utils/1.0.0-beta.14/source.json": "6825c725c14949bb7b55c79fc9e3ba39938ebfc07f475d0d6d86eaf4f435a54c" + "https://gitlab.arm.com/bazel/rules_zstd/-/releases/v1.0.0-beta.3/downloads/modules/toolchain_utils/1.0.0-beta.15/MODULE.bazel": "not found", + "https://gitlab.arm.com/bazel/toolchain_utils/-/releases/v1.0.0-beta.15/downloads/bazel_registry.json": "not found", + "https://gitlab.arm.com/bazel/toolchain_utils/-/releases/v1.0.0-beta.15/downloads/modules/toolchain_utils/1.0.0-beta.15/MODULE.bazel": "21da9cdc3c99f8f254ebea589ff9af1d526416cabadd65dc8b64bf74faa1eb8a", + "https://gitlab.arm.com/bazel/toolchain_utils/-/releases/v1.0.0-beta.15/downloads/modules/toolchain_utils/1.0.0-beta.15/source.json": "e269889ba8445670cd9aba3751a6ba246e1d73f16a7ec156235a32b2a516fdd6" }, "selectedYankedVersions": {}, "moduleExtensions": { diff --git a/debian/amd64/qemu-system-arm/BUILD.bazel b/debian/amd64/qemu-system-arm/BUILD.bazel index 59e9a88fcb5d7803b542d5b574a370c30b282967..862cafbf7ca7ebfe51eaa78e21a234368df18417 100644 --- a/debian/amd64/qemu-system-arm/BUILD.bazel +++ b/debian/amd64/qemu-system-arm/BUILD.bazel @@ -16,14 +16,19 @@ tar_unpack( visibility = ["//debian/qemu-system-aarch64/amd64:__pkg__"], ) -debian_launcher( - name = "qemu-system-arm", - src = ":unpack", - visibility = ["//:__subpackages__"], -) - debian_launcher( name = "qemu-system-aarch64", + env = { + "QEMU_MODULE_DIR": "$(rootpath :unpack)/usr/lib/x86_64-linux-gnu/qemu/", + }, + args = [ + "-L $(rootpath :unpack)/usr/share/qemu", + "-L $(rootpath :unpack)/usr/share/seabios", + "-L $(rootpath :unpack)/usr/lib/ipxe/qemu", + ], + data = [ + ":unpack", + ], src = ":unpack", visibility = ["//:__subpackages__"], ) diff --git a/debian/amd64/qemu-system-arm/srcs.bzl b/debian/amd64/qemu-system-arm/srcs.bzl index cf10ee25cdef864b0c0f858eb976dac311fc3f37..d6860b0eece3356f78abd85a479a3344d02b2981 100644 --- a/debian/amd64/qemu-system-arm/srcs.bzl +++ b/debian/amd64/qemu-system-arm/srcs.bzl @@ -1,10 +1,12 @@ visibility("//debian/amd64/qemu-system-arm/...") + SRCS = ( "//debian/amd64/libc6:data.tar.zst", "//debian/amd64/tar:data.tar.zst", "@all-adduser//:data.tar.xz", "@all-debconf//:data.tar.xz", + "@all-ipxe-qemu//:data.tar.xz", "@all-iso-codes//:data.tar.xz", "@all-libasound2-data//:data.tar.xz", "@all-libaudit-common//:data.tar.xz", @@ -12,6 +14,7 @@ SRCS = ( "@all-libsemanage-common//:data.tar.xz", "@all-qemu-system-data//:data.tar.xz", "@all-readline-common//:data.tar.xz", + "@all-seabios//:data.tar.xz", "@amd64-cdebconf//:data.tar.xz", "@amd64-dpkg//:data.tar.xz", "@amd64-gcc-12-base//:data.tar.xz", diff --git a/debian/amd64/qemu-system-x86/BUILD.bazel b/debian/amd64/qemu-system-x86/BUILD.bazel index 03e88f94770e2a546613b7311caa6b0cf99b889e..e8c6590c14bf7c34b461134cbd38eb380fa8f3c8 100644 --- a/debian/amd64/qemu-system-x86/BUILD.bazel +++ b/debian/amd64/qemu-system-x86/BUILD.bazel @@ -15,14 +15,19 @@ tar_unpack( src = ":data.tar.zst", ) -debian_launcher( - name = "qemu-system-i386", - src = ":unpack", - visibility = ["//:__subpackages__"], -) - debian_launcher( name = "qemu-system-x86_64", + args = [ + "-L $(rootpath :unpack)/usr/share/qemu", + "-L $(rootpath :unpack)/usr/share/seabios", + "-L $(rootpath :unpack)/usr/lib/ipxe/qemu", + ], + env = { + "QEMU_MODULE_DIR": "$(rootpath :unpack)/usr/lib/x86_64-linux-gnu/qemu/", + }, + data = [ + ":unpack", + ], src = ":unpack", visibility = ["//:__subpackages__"], ) diff --git a/debian/arm64/qemu-system-arm/BUILD.bazel b/debian/arm64/qemu-system-arm/BUILD.bazel index 7e03bba4279f2786222c5a7a40f4412d7eff030b..b46eb27b676a0251a984e72442f7cdabb3ef99e8 100644 --- a/debian/arm64/qemu-system-arm/BUILD.bazel +++ b/debian/arm64/qemu-system-arm/BUILD.bazel @@ -15,14 +15,15 @@ tar_unpack( src = ":data.tar.zst", ) -debian_launcher( - name = "qemu-system-arm", - src = ":unpack", - visibility = ["//:__subpackages__"], -) - debian_launcher( name = "qemu-system-aarch64", + module_dir = "usr/lib/aarch64-linux-gnu/qemu", + image = "//qemu/debian:image", + bios_link_dirs = [ + "usr/share/qemu-firmware", + "usr/share/qemu", + ], + data = ["//qemu/debian:image"], src = ":unpack", visibility = ["//:__subpackages__"], ) diff --git a/debian/arm64/qemu-system-arm/srcs.bzl b/debian/arm64/qemu-system-arm/srcs.bzl index 55e1aceaeab34bb2e0deb65d66e5ce272babe242..53b54a247020af9e86b3bc3c80cbbed67e48f3e8 100644 --- a/debian/arm64/qemu-system-arm/srcs.bzl +++ b/debian/arm64/qemu-system-arm/srcs.bzl @@ -5,6 +5,7 @@ SRCS = ( "//debian/arm64/tar:data.tar.zst", "@all-adduser//:data.tar.xz", "@all-debconf//:data.tar.xz", + "@all-ipxe-qemu//:data.tar.xz", "@all-iso-codes//:data.tar.xz", "@all-libasound2-data//:data.tar.xz", "@all-libaudit-common//:data.tar.xz", @@ -12,6 +13,7 @@ SRCS = ( "@all-libsemanage-common//:data.tar.xz", "@all-qemu-system-data//:data.tar.xz", "@all-readline-common//:data.tar.xz", + "@all-seabios//:data.tar.xz", "@arm64-cdebconf//:data.tar.xz", "@arm64-dpkg//:data.tar.xz", "@arm64-gcc-12-base//:data.tar.xz", diff --git a/debian/arm64/qemu-system-x86/BUILD.bazel b/debian/arm64/qemu-system-x86/BUILD.bazel index 03e88f94770e2a546613b7311caa6b0cf99b889e..b2effec27ae6d6532e9fb7f4ec31c5132e58c916 100644 --- a/debian/arm64/qemu-system-x86/BUILD.bazel +++ b/debian/arm64/qemu-system-x86/BUILD.bazel @@ -15,14 +15,15 @@ tar_unpack( src = ":data.tar.zst", ) -debian_launcher( - name = "qemu-system-i386", - src = ":unpack", - visibility = ["//:__subpackages__"], -) - debian_launcher( name = "qemu-system-x86_64", + module_dir = "usr/lib/x86_64-linux-gnu/qemu", + image = "//qemu/debian:image", + bios_link_dirs = [ + "usr/share/qemu-firmware", + "usr/share/qemu", + ], + data = ["//qemu/debian:image"], src = ":unpack", visibility = ["//:__subpackages__"], ) diff --git a/debian/launcher/posix.tmpl.sh b/debian/launcher/posix.tmpl.sh index 815a1dfb973a83f958fffa352850b03f3c7c8213..6137f01bf1115fa41bb3b8e04b3a4a01ca3f1f54 100644 --- a/debian/launcher/posix.tmpl.sh +++ b/debian/launcher/posix.tmpl.sh @@ -7,9 +7,11 @@ set -o nounset # Substitutions ROOT="{{root}}" BINARY="{{binary}}" -LLP="{{llp}}" +LLP='{{llp}}' INTERPRETER="{{interpreter}}" -readonly ROOT BINARY LLP INTERPRETER +ARGS="{{args}}" + +readonly ROOT BINARY LLP INTERPRETER ARGS # Check the root is available if ! test -d "${ROOT}"; then @@ -70,4 +72,4 @@ fi # issues where the absolute root path has been baked into the executable. # Run the binary -LD_LIBRARY_PATH="${LLP}" "${INTERPRETER}" "${BINARY}" "${@}" +LD_LIBRARY_PATH="${LLP}" "${INTERPRETER}" "${BINARY}" ${ARGS} "${@}" diff --git a/debian/launcher/rule.bzl b/debian/launcher/rule.bzl index fdc2a436f81e91e6d3c0433aee7ce9a6d070e389..0733d3052127020687a4d5818703ca0d61fd9960 100644 --- a/debian/launcher/rule.bzl +++ b/debian/launcher/rule.bzl @@ -46,18 +46,11 @@ def implementation(ctx): relative = ctx.attr.executable or "usr/bin/{}".format(ctx.label.name) relative = relative.removeprefix("/") - def _escape(p): - split = p.split("\\$") - escaped = [s.replace("$", "\\$") for s in split] - joined = "\\$".join(escaped) - if not joined.startswith(("/", "\\$")): - return "{}/{}".format(root, joined) - return joined - paths = ctx.attr._llp[DebianLauncherLibraryPathInfo].paths - paths = [_escape(p) for p in paths] llp = ":".join(paths) + args = " ".join([ctx.expand_location(item, targets = ctx.attr.data) for item in ctx.attr.args]) + interpreter = ctx.attr._interpreter[DebianLauncherELFInterpreterInfo].path rendered = ctx.actions.declare_file("{}.{}".format(ctx.label.name, ctx.file._template.extension)) @@ -66,6 +59,8 @@ def implementation(ctx): substitutions.add("{{binary}}", "{}/{}".format(root, relative)) substitutions.add("{{interpreter}}", "{}/{}".format(root, interpreter)) substitutions.add("{{llp}}", llp) + substitutions.add("{{args}}", args) + ctx.actions.expand_template( output = rendered, template = ctx.file._template, diff --git a/qemu/debian/BUILD.bazel b/qemu/debian/BUILD.bazel index eec1fb2e6aba9ae32d350ff98cb8ac7cc606baa9..afb650e185462b492b0499232db5ee61a27384c2 100644 --- a/qemu/debian/BUILD.bazel +++ b/qemu/debian/BUILD.bazel @@ -6,10 +6,10 @@ alias( actual = select({ "@platforms//cpu:aarch64": "@arm64-debian.12-gnu-qemu//:image.qcow2", "@platforms//cpu:x86_64": "@amd64-debian.12-gnu-qemu//:image.qcow2", - }, no_match_error = "No QEMU Debian image for platform.") + }, no_match_error = "No QEMU Debian image for platform."), ) build_test( name = "download", targets = [":image"], -) \ No newline at end of file +)