From ea3eff4a39314d298467e3a50d6eac951fcdfcf1 Mon Sep 17 00:00:00 2001 From: Luke Hackwell Date: Thu, 22 Aug 2024 17:13:32 +0100 Subject: [PATCH 01/18] test(qemu): Provide example QEMU runner --- e2e/qemu/BUILD.bazel | 112 ++++++++++++++++++++++ e2e/qemu/data/install_debian.sh | 63 +++++++++++++ e2e/qemu/data/preseed.cfg | 162 ++++++++++++++++++++++++++++++++ e2e/qemu/manager.py | 18 ++++ e2e/qemu/ssh.py | 107 +++++++++++++++++++++ e2e/qemu/version.txt | 9 ++ e2e/qemu/x86-ubuntu-24.04.yaml | 15 +++ 7 files changed, 486 insertions(+) create mode 100644 e2e/qemu/BUILD.bazel create mode 100755 e2e/qemu/data/install_debian.sh create mode 100755 e2e/qemu/data/preseed.cfg create mode 100644 e2e/qemu/manager.py create mode 100755 e2e/qemu/ssh.py create mode 100644 e2e/qemu/version.txt create mode 100644 e2e/qemu/x86-ubuntu-24.04.yaml diff --git a/e2e/qemu/BUILD.bazel b/e2e/qemu/BUILD.bazel new file mode 100644 index 00000000..c9ab7dc6 --- /dev/null +++ b/e2e/qemu/BUILD.bazel @@ -0,0 +1,112 @@ +load("@rules_python//python:defs.bzl", "py_binary", "py_library") +load("@rules_labgrid//labgrid/genrule:defs.bzl", "labgrid_genrule") +load("@rules_labgrid//labgrid/executor:defs.bzl", "labgrid_executor") +load("@rules_labgrid//labgrid/transition:defs.bzl", "labgrid_transition") +load("@rules_diff//diff/file/test:defs.bzl", "diff_file_test") +load("@toolchain_utils//toolchain/info:defs.bzl", "toolchain_info") + +genrule( + name = "install_debian", + srcs = ["data/preseed.cfg"], + outs = ["debian.qcow2"], + cmd_bash = "./qemu/data/install_debian.sh $@ $(location data/preseed.cfg)", + tools = ["data/install_debian.sh"], +) + +py_binary( + name = "ssh", + srcs = ["ssh.py"], + args = [ + "--lg-env=$(location x86-ubuntu-24.04.yaml)", + "--lg-qemu-hda=$(location debian.qcow2)", + ], + data = [ + "x86-ubuntu-24.04.yaml", + "debian.qcow2", + ], + tags = ["manual"], + deps = [ + "@rules_labgrid//labgrid/python", + "@rules_python//python/runfiles", + ], +) + +# An execution manager that is responsible for setting up the LabGrid environment +py_library( + name = "manager", + srcs = ["manager.py"], + data = ["x86-ubuntu-24.04.yaml"], + deps = ["@rules_labgrid//labgrid/executor:manager"], +) + +# Create the LabGrid executor binary using our manager +labgrid_executor( + name = "executor", + deps = [":manager"], +) + +# Create toolchain information around the executor +toolchain_info( + name = "info", + target = ":executor", +) + +# A constraint to register the toolchain to +constraint_setting(name = "device") + +# This value would usually be shared in a common definitions module +constraint_value( + name = "constraint", + constraint_setting = ":device", +) + +# A platform that describes the Docker "platform" +platform( + name = "platform", + constraint_values = [ + ":constraint", + "@toolchain_utils//toolchain/constraint/os:linux", + ], +) + +# Provide the toolchain with Bazel +toolchain( + name = "toolchain", + target_compatible_with = [ + ":constraint", + "@toolchain_utils//toolchain/constraint/os:linux", + ], + toolchain = ":info", + toolchain_type = "@rules_labgrid//labgrid/toolchain/executor:type", +) + +# Run within the LabGrid environment +# This shows a few things: +# - It resolves the executor registered above to set up the `LG_ENV` enviroment variable +# - `:ssh` target uses `LG_ENV` to start the Docker container +# - `@ape//:cat` is provided to +labgrid_genrule( + name = "echo", + srcs = ["@ape//:cat"], + outs = ["stdout.log"], + cmd = "$(location :ssh) $(location @ape//:cat) /etc/os-release > $@", + tags = ["manual"], + tools = [":ssh"], +) + +# Transition the above `genrule` to the Docker platform +labgrid_transition( + name = "transition", + srcs = [":stdout.log"], + platforms = [":platform"], + tags = ["manual"], +) + +# Check that the output of `/proc/version` from within the container is what we expect +diff_file_test( + name = "test", + size = "small", + a = ":version.txt", + b = ":transition", + tags = ["manual"], +) diff --git a/e2e/qemu/data/install_debian.sh b/e2e/qemu/data/install_debian.sh new file mode 100755 index 00000000..cf485777 --- /dev/null +++ b/e2e/qemu/data/install_debian.sh @@ -0,0 +1,63 @@ +#!/bin/bash -e + +rm -rf +BUILD_DIR=build_dir +rm -rf $BUILD_DIR +mkdir $BUILD_DIR +cp $2 $BUILD_DIR +pushd $BUILD_DIR + +eval `ssh-agent` +ssh-add +AUTHORIZED_KEYS="$(ssh-add -L)" +echo $AUTHORIZED_KEYS +if [ -n "$AUTHORIZED_KEYS" ] +then + echo "Pre-populating authorized_keys for image" + echo "$AUTHORIZED_KEYS" > authorized_keys +fi + +PASS="asdf" + +echo "Running simple webserver on port 4321 for host files..." +PYTHON_PID=$(sh -c 'echo $$ ; exec >/dev/null 2>&1 ; exec python3 -m http.server 4321' &) + +echo "Downloading Debian Buster x86_64 netboot installer..." +curl --location --output netboot.tar.gz https://deb.debian.org/debian/dists/buster/main/installer-amd64/current/images/netboot/netboot.tar.gz +mkdir -p tftpserver +pushd tftpserver +tar xzvf ../netboot.tar.gz + +echo "Customising network boot parameters..." +cat > debian-installer/amd64/pxelinux.cfg/default < Iterator[Run]: + runfiles = Runfiles.Create() + config = runfiles.Rlocation("_main/qemu/x86-ubuntu-24.04.yaml") + env = { + "LG_ENV": config, + } + yield Data(env=env) diff --git a/e2e/qemu/ssh.py b/e2e/qemu/ssh.py new file mode 100755 index 00000000..f57ecc6a --- /dev/null +++ b/e2e/qemu/ssh.py @@ -0,0 +1,107 @@ +#! /usr/bin/env python3 + +from argparse import ArgumentParser +from os import environ, linesep +import os +from pathlib import Path, PurePath +from shlex import join +from sys import argv, stderr, stdout +from typing import Collection, Protocol, Tuple +import logging +import time +import shutil + +from labgrid import Environment + + +class Shell(Protocol): + def run(cmd: str) -> Tuple[Collection[str], Collection[str], int]: ... + + +def arguments(prsr: ArgumentParser) -> None: + prsr.add_argument( + "program", + metavar="PROG", + help="The program to run on the device.", + type=Path, + ) + prsr.add_argument( + "arguments", metavar="ARG", nargs="*", help="Command to run over SSH." + ) + prsr.add_argument( + "--lg-env", + help="The LabGrid environment configuration.", + dest="config", + default=PurePath(environ.get("LG_ENV", "config.yaml")), + type=PurePath, + ) + prsr.add_argument( + "--lg-qemu-hda", + help="The QEMU hard drive file", + dest="qemu_hda", + type=PurePath, + ) + + +def main(exe: Path, *args: str) -> int: + prsr = ArgumentParser( + prog=str(exe), description="TODO" + ) + arguments(prsr) + parsed = prsr.parse_args(args) + + if parsed.qemu_hda: + hda = parsed.qemu_hda + else: + hda = str(PurePath(os.environ["RUNFILES_DIR"]) / PurePath("_main/qemu/debian.qcow2")) + + # Set the hard drive that the QEMU will read + os.environ['LG_QEMU_HDA'] = 'debian.qcow2' + + env = Environment(str(parsed.config)) + target = env.get_target() + + # Copy the hard drive. This makes it read-writable + shutil.copyfile(hda, 'debian.qcow2') + + # Start the QEMU instance + qemu_driver = target.get_driver("QEMUDriver") + qemu_driver.on() + + # Wait until the VM has booted + console = target.get_driver("ConsoleProtocol") + for _ in range(300): + time.sleep(1) + try: + msg = console.read(timeout=0.1).decode('utf-8') + except: + pass + logging.error(msg) + if "login:" in msg: + break + + # Copy the program to run onto VM + program = "/tmp/{}".format(parsed.program.name) + transfer = target.get_driver("FileTransferProtocol") + transfer.put(parsed.program, program) + + # Run the transferred program + shell = target.get_driver("CommandProtocol") + out, err, code = shell.run(join((program, *parsed.arguments))) + for line in out: + logging.error(f"{line}{linesep}") + stdout.write(f"{line}{linesep}") + for line in err: + stderr.write(f"{line}{linesep}") + + qemu_driver.off() + + return code + + +def entry(): + exit(main(Path(argv[0]), *argv[1:])) + + +if __name__ == "__main__": + entry() diff --git a/e2e/qemu/version.txt b/e2e/qemu/version.txt new file mode 100644 index 00000000..9b5419df --- /dev/null +++ b/e2e/qemu/version.txt @@ -0,0 +1,9 @@ +PRETTY_NAME="Debian GNU/Linux 10 (buster)" +NAME="Debian GNU/Linux" +VERSION_ID="10" +VERSION="10 (buster)" +VERSION_CODENAME=buster +ID=debian +HOME_URL="https://www.debian.org/" +SUPPORT_URL="https://www.debian.org/support" +BUG_REPORT_URL="https://bugs.debian.org/" diff --git a/e2e/qemu/x86-ubuntu-24.04.yaml b/e2e/qemu/x86-ubuntu-24.04.yaml new file mode 100644 index 00000000..2a4286e3 --- /dev/null +++ b/e2e/qemu/x86-ubuntu-24.04.yaml @@ -0,0 +1,15 @@ +targets: + main: + resources: + NetworkService: + address: 'localhost' + port: 2222 + username: 'root' + drivers: + QEMUDriver: + qemu_bin: 'qemu-system-x86_64' + machine: 'pc' + cpu: 'max' + memory: '12G' + extra_args: !template '-hda $LG_QEMU_HDA -net nic -net user,hostfwd=tcp::2222-:22' + SSHDriver: {} -- GitLab From 98280d531e5014efc3def4247d23b517ecb45b51 Mon Sep 17 00:00:00 2001 From: Jordan Bonser Date: Tue, 17 Sep 2024 14:29:10 +0100 Subject: [PATCH 02/18] feat: add debian cloud download --- .bazelrc | 4 ++++ e2e/MODULE.bazel | 18 +++++++++++++++++- e2e/qemu/debian/BUILD.bazel | 14 ++++++++++++++ 3 files changed, 35 insertions(+), 1 deletion(-) create mode 100644 e2e/qemu/debian/BUILD.bazel diff --git a/.bazelrc b/.bazelrc index 1eb348b6..a2a173d4 100644 --- a/.bazelrc +++ b/.bazelrc @@ -25,5 +25,9 @@ common --@rules_labgrid//python:bootstrap=script # Enable built Zstandard toolchain common --extra_toolchains=@rules_zstd//zstd/toolchain/zstd:built +# Download utils +common --registry https://bcr.bazel.build +common --registry=https://gitlab.arm.com/bazel/download_utils/-/releases/v1.0.0-alpha.1/downloads + # User-specific .bazelrc try-import %workspace%/.bazelrc.user diff --git a/e2e/MODULE.bazel b/e2e/MODULE.bazel index 73bb474f..9575bbc4 100644 --- a/e2e/MODULE.bazel +++ b/e2e/MODULE.bazel @@ -5,6 +5,7 @@ module( ], ) +bazel_dep(name = "download_utils", version = "1.0.0-beta.2") bazel_dep(name = "bazel_skylib", version = "1.7.1") bazel_dep(name = "toolchain_utils", version = "1.0.0-beta.14") bazel_dep(name = "rules_python", version = "0.33.2") @@ -43,4 +44,19 @@ pip.parse( python_version = "3.11", requirements_lock = "//python:requirements.txt", ) -use_repo(pip, "pip") \ No newline at end of file +use_repo(pip, "pip") + +# Download QEMU images +download_file = use_repo_rule("@download_utils//download/file:defs.bzl", "download_file") +[ + download_file( + name = "{}-debian.12-gnu-qemu".format(cpu), + output = "image.qcow2", + executable = False, + urls = ["https://cloud.debian.org/images/cloud/bookworm/latest/debian-12-generic-{}.qcow2".format(cpu)], + ) + for cpu, integrity in ( + ("amd64", ""), + ("arm64", ""), + ) +] diff --git a/e2e/qemu/debian/BUILD.bazel b/e2e/qemu/debian/BUILD.bazel new file mode 100644 index 00000000..9b4ddc86 --- /dev/null +++ b/e2e/qemu/debian/BUILD.bazel @@ -0,0 +1,14 @@ +load("@bazel_skylib//rules:build_test.bzl", "build_test") + +alias( + name = "image", + 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.") +) + +build_test( + name = "download", + targets = [":image"], +) \ No newline at end of file -- GitLab From f9b8fe81adcc99f1a01fc21407ddfe4a0fbaccd1 Mon Sep 17 00:00:00 2001 From: Jordan Bonser Date: Tue, 17 Sep 2024 15:40:05 +0100 Subject: [PATCH 03/18] fix: add integrity shas for debian images --- e2e/MODULE.bazel | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/e2e/MODULE.bazel b/e2e/MODULE.bazel index 9575bbc4..5bf59a1a 100644 --- a/e2e/MODULE.bazel +++ b/e2e/MODULE.bazel @@ -56,7 +56,7 @@ download_file = use_repo_rule("@download_utils//download/file:defs.bzl", "downlo urls = ["https://cloud.debian.org/images/cloud/bookworm/latest/debian-12-generic-{}.qcow2".format(cpu)], ) for cpu, integrity in ( - ("amd64", ""), - ("arm64", ""), + ("amd64", "sha256-p9rCK1tT7V/uDBI70LR3UoT8vK1aaJ9rWpL0jgXp+1I="), + ("arm64", "sha256-gxjqgasbjKLrLUtVJYz/MTiPbttisBz3Y4HglSRRspo="), ) -] +] \ No newline at end of file -- GitLab From 6c8b6aea67d6f1ba9e49ed47a72b44e221664e9d Mon Sep 17 00:00:00 2001 From: Jordan Bonser Date: Tue, 17 Sep 2024 16:34:37 +0100 Subject: [PATCH 04/18] fix: remove unnecessary registry override --- .bazelrc | 1 - 1 file changed, 1 deletion(-) diff --git a/.bazelrc b/.bazelrc index a2a173d4..73a93c5b 100644 --- a/.bazelrc +++ b/.bazelrc @@ -27,7 +27,6 @@ common --extra_toolchains=@rules_zstd//zstd/toolchain/zstd:built # Download utils common --registry https://bcr.bazel.build -common --registry=https://gitlab.arm.com/bazel/download_utils/-/releases/v1.0.0-alpha.1/downloads # User-specific .bazelrc try-import %workspace%/.bazelrc.user -- GitLab From d108a60c1668b02200b8a7a266b9b8552f7504cd Mon Sep 17 00:00:00 2001 From: Jordan Bonser Date: Tue, 17 Sep 2024 16:36:27 +0100 Subject: [PATCH 05/18] fix: move debian cloud download to top level --- e2e/qemu/BUILD.bazel | 112 ---------------------- e2e/qemu/data/install_debian.sh | 63 ------------- e2e/qemu/data/preseed.cfg | 162 -------------------------------- e2e/qemu/debian/BUILD.bazel | 14 --- e2e/qemu/manager.py | 18 ---- e2e/qemu/ssh.py | 107 --------------------- e2e/qemu/version.txt | 9 -- e2e/qemu/x86-ubuntu-24.04.yaml | 15 --- qemu/debian/MODULE.bazel | 23 +++++ qemu/debian/MODULE.bazel.lock | 84 +++++++++++++++++ qemu/debian/bazel-bin | 1 + qemu/debian/bazel-debian | 1 + qemu/debian/bazel-out | 1 + qemu/debian/bazel-testlogs | 1 + 14 files changed, 111 insertions(+), 500 deletions(-) delete mode 100644 e2e/qemu/BUILD.bazel delete mode 100755 e2e/qemu/data/install_debian.sh delete mode 100755 e2e/qemu/data/preseed.cfg delete mode 100644 e2e/qemu/debian/BUILD.bazel delete mode 100644 e2e/qemu/manager.py delete mode 100755 e2e/qemu/ssh.py delete mode 100644 e2e/qemu/version.txt delete mode 100644 e2e/qemu/x86-ubuntu-24.04.yaml create mode 100644 qemu/debian/MODULE.bazel create mode 100644 qemu/debian/MODULE.bazel.lock create mode 120000 qemu/debian/bazel-bin create mode 120000 qemu/debian/bazel-debian create mode 120000 qemu/debian/bazel-out create mode 120000 qemu/debian/bazel-testlogs diff --git a/e2e/qemu/BUILD.bazel b/e2e/qemu/BUILD.bazel deleted file mode 100644 index c9ab7dc6..00000000 --- a/e2e/qemu/BUILD.bazel +++ /dev/null @@ -1,112 +0,0 @@ -load("@rules_python//python:defs.bzl", "py_binary", "py_library") -load("@rules_labgrid//labgrid/genrule:defs.bzl", "labgrid_genrule") -load("@rules_labgrid//labgrid/executor:defs.bzl", "labgrid_executor") -load("@rules_labgrid//labgrid/transition:defs.bzl", "labgrid_transition") -load("@rules_diff//diff/file/test:defs.bzl", "diff_file_test") -load("@toolchain_utils//toolchain/info:defs.bzl", "toolchain_info") - -genrule( - name = "install_debian", - srcs = ["data/preseed.cfg"], - outs = ["debian.qcow2"], - cmd_bash = "./qemu/data/install_debian.sh $@ $(location data/preseed.cfg)", - tools = ["data/install_debian.sh"], -) - -py_binary( - name = "ssh", - srcs = ["ssh.py"], - args = [ - "--lg-env=$(location x86-ubuntu-24.04.yaml)", - "--lg-qemu-hda=$(location debian.qcow2)", - ], - data = [ - "x86-ubuntu-24.04.yaml", - "debian.qcow2", - ], - tags = ["manual"], - deps = [ - "@rules_labgrid//labgrid/python", - "@rules_python//python/runfiles", - ], -) - -# An execution manager that is responsible for setting up the LabGrid environment -py_library( - name = "manager", - srcs = ["manager.py"], - data = ["x86-ubuntu-24.04.yaml"], - deps = ["@rules_labgrid//labgrid/executor:manager"], -) - -# Create the LabGrid executor binary using our manager -labgrid_executor( - name = "executor", - deps = [":manager"], -) - -# Create toolchain information around the executor -toolchain_info( - name = "info", - target = ":executor", -) - -# A constraint to register the toolchain to -constraint_setting(name = "device") - -# This value would usually be shared in a common definitions module -constraint_value( - name = "constraint", - constraint_setting = ":device", -) - -# A platform that describes the Docker "platform" -platform( - name = "platform", - constraint_values = [ - ":constraint", - "@toolchain_utils//toolchain/constraint/os:linux", - ], -) - -# Provide the toolchain with Bazel -toolchain( - name = "toolchain", - target_compatible_with = [ - ":constraint", - "@toolchain_utils//toolchain/constraint/os:linux", - ], - toolchain = ":info", - toolchain_type = "@rules_labgrid//labgrid/toolchain/executor:type", -) - -# Run within the LabGrid environment -# This shows a few things: -# - It resolves the executor registered above to set up the `LG_ENV` enviroment variable -# - `:ssh` target uses `LG_ENV` to start the Docker container -# - `@ape//:cat` is provided to -labgrid_genrule( - name = "echo", - srcs = ["@ape//:cat"], - outs = ["stdout.log"], - cmd = "$(location :ssh) $(location @ape//:cat) /etc/os-release > $@", - tags = ["manual"], - tools = [":ssh"], -) - -# Transition the above `genrule` to the Docker platform -labgrid_transition( - name = "transition", - srcs = [":stdout.log"], - platforms = [":platform"], - tags = ["manual"], -) - -# Check that the output of `/proc/version` from within the container is what we expect -diff_file_test( - name = "test", - size = "small", - a = ":version.txt", - b = ":transition", - tags = ["manual"], -) diff --git a/e2e/qemu/data/install_debian.sh b/e2e/qemu/data/install_debian.sh deleted file mode 100755 index cf485777..00000000 --- a/e2e/qemu/data/install_debian.sh +++ /dev/null @@ -1,63 +0,0 @@ -#!/bin/bash -e - -rm -rf -BUILD_DIR=build_dir -rm -rf $BUILD_DIR -mkdir $BUILD_DIR -cp $2 $BUILD_DIR -pushd $BUILD_DIR - -eval `ssh-agent` -ssh-add -AUTHORIZED_KEYS="$(ssh-add -L)" -echo $AUTHORIZED_KEYS -if [ -n "$AUTHORIZED_KEYS" ] -then - echo "Pre-populating authorized_keys for image" - echo "$AUTHORIZED_KEYS" > authorized_keys -fi - -PASS="asdf" - -echo "Running simple webserver on port 4321 for host files..." -PYTHON_PID=$(sh -c 'echo $$ ; exec >/dev/null 2>&1 ; exec python3 -m http.server 4321' &) - -echo "Downloading Debian Buster x86_64 netboot installer..." -curl --location --output netboot.tar.gz https://deb.debian.org/debian/dists/buster/main/installer-amd64/current/images/netboot/netboot.tar.gz -mkdir -p tftpserver -pushd tftpserver -tar xzvf ../netboot.tar.gz - -echo "Customising network boot parameters..." -cat > debian-installer/amd64/pxelinux.cfg/default < Iterator[Run]: - runfiles = Runfiles.Create() - config = runfiles.Rlocation("_main/qemu/x86-ubuntu-24.04.yaml") - env = { - "LG_ENV": config, - } - yield Data(env=env) diff --git a/e2e/qemu/ssh.py b/e2e/qemu/ssh.py deleted file mode 100755 index f57ecc6a..00000000 --- a/e2e/qemu/ssh.py +++ /dev/null @@ -1,107 +0,0 @@ -#! /usr/bin/env python3 - -from argparse import ArgumentParser -from os import environ, linesep -import os -from pathlib import Path, PurePath -from shlex import join -from sys import argv, stderr, stdout -from typing import Collection, Protocol, Tuple -import logging -import time -import shutil - -from labgrid import Environment - - -class Shell(Protocol): - def run(cmd: str) -> Tuple[Collection[str], Collection[str], int]: ... - - -def arguments(prsr: ArgumentParser) -> None: - prsr.add_argument( - "program", - metavar="PROG", - help="The program to run on the device.", - type=Path, - ) - prsr.add_argument( - "arguments", metavar="ARG", nargs="*", help="Command to run over SSH." - ) - prsr.add_argument( - "--lg-env", - help="The LabGrid environment configuration.", - dest="config", - default=PurePath(environ.get("LG_ENV", "config.yaml")), - type=PurePath, - ) - prsr.add_argument( - "--lg-qemu-hda", - help="The QEMU hard drive file", - dest="qemu_hda", - type=PurePath, - ) - - -def main(exe: Path, *args: str) -> int: - prsr = ArgumentParser( - prog=str(exe), description="TODO" - ) - arguments(prsr) - parsed = prsr.parse_args(args) - - if parsed.qemu_hda: - hda = parsed.qemu_hda - else: - hda = str(PurePath(os.environ["RUNFILES_DIR"]) / PurePath("_main/qemu/debian.qcow2")) - - # Set the hard drive that the QEMU will read - os.environ['LG_QEMU_HDA'] = 'debian.qcow2' - - env = Environment(str(parsed.config)) - target = env.get_target() - - # Copy the hard drive. This makes it read-writable - shutil.copyfile(hda, 'debian.qcow2') - - # Start the QEMU instance - qemu_driver = target.get_driver("QEMUDriver") - qemu_driver.on() - - # Wait until the VM has booted - console = target.get_driver("ConsoleProtocol") - for _ in range(300): - time.sleep(1) - try: - msg = console.read(timeout=0.1).decode('utf-8') - except: - pass - logging.error(msg) - if "login:" in msg: - break - - # Copy the program to run onto VM - program = "/tmp/{}".format(parsed.program.name) - transfer = target.get_driver("FileTransferProtocol") - transfer.put(parsed.program, program) - - # Run the transferred program - shell = target.get_driver("CommandProtocol") - out, err, code = shell.run(join((program, *parsed.arguments))) - for line in out: - logging.error(f"{line}{linesep}") - stdout.write(f"{line}{linesep}") - for line in err: - stderr.write(f"{line}{linesep}") - - qemu_driver.off() - - return code - - -def entry(): - exit(main(Path(argv[0]), *argv[1:])) - - -if __name__ == "__main__": - entry() diff --git a/e2e/qemu/version.txt b/e2e/qemu/version.txt deleted file mode 100644 index 9b5419df..00000000 --- a/e2e/qemu/version.txt +++ /dev/null @@ -1,9 +0,0 @@ -PRETTY_NAME="Debian GNU/Linux 10 (buster)" -NAME="Debian GNU/Linux" -VERSION_ID="10" -VERSION="10 (buster)" -VERSION_CODENAME=buster -ID=debian -HOME_URL="https://www.debian.org/" -SUPPORT_URL="https://www.debian.org/support" -BUG_REPORT_URL="https://bugs.debian.org/" diff --git a/e2e/qemu/x86-ubuntu-24.04.yaml b/e2e/qemu/x86-ubuntu-24.04.yaml deleted file mode 100644 index 2a4286e3..00000000 --- a/e2e/qemu/x86-ubuntu-24.04.yaml +++ /dev/null @@ -1,15 +0,0 @@ -targets: - main: - resources: - NetworkService: - address: 'localhost' - port: 2222 - username: 'root' - drivers: - QEMUDriver: - qemu_bin: 'qemu-system-x86_64' - machine: 'pc' - cpu: 'max' - memory: '12G' - extra_args: !template '-hda $LG_QEMU_HDA -net nic -net user,hostfwd=tcp::2222-:22' - SSHDriver: {} diff --git a/qemu/debian/MODULE.bazel b/qemu/debian/MODULE.bazel new file mode 100644 index 00000000..d6eaaa16 --- /dev/null +++ b/qemu/debian/MODULE.bazel @@ -0,0 +1,23 @@ +############################################################################### +# Bazel now uses Bzlmod by default to manage external dependencies. +# Please consider migrating your external dependencies from WORKSPACE to MODULE.bazel. +# +# For more details, please check https://github.com/bazelbuild/bazel/issues/18958 +############################################################################### + +bazel_dep(name = "download_utils", version = "1.0.0-beta.2") + +# Download QEMU images +download_file = use_repo_rule("@download_utils//download/file:defs.bzl", "download_file") +[ + download_file( + name = "{}-debian.12-gnu-qemu".format(cpu), + output = "image.qcow2", + executable = False, + urls = ["https://cloud.debian.org/images/cloud/bookworm/latest/debian-12-generic-{}.qcow2".format(cpu)], + ) + for cpu, integrity in ( + ("amd64", "sha256-p9rCK1tT7V/uDBI70LR3UoT8vK1aaJ9rWpL0jgXp+1I="), + ("arm64", "sha256-gxjqgasbjKLrLUtVJYz/MTiPbttisBz3Y4HglSRRspo="), + ) +] \ No newline at end of file diff --git a/qemu/debian/MODULE.bazel.lock b/qemu/debian/MODULE.bazel.lock new file mode 100644 index 00000000..43e29a9d --- /dev/null +++ b/qemu/debian/MODULE.bazel.lock @@ -0,0 +1,84 @@ +{ + "lockFileVersion": 11, + "registryFileHashes": { + "https://bcr.bazel.build/bazel_registry.json": "8a28e4aff06ee60aed2a8c281907fb8bcbf3b753c91fb5a5c57da3215d5b3497", + "https://bcr.bazel.build/modules/abseil-cpp/20210324.2/MODULE.bazel": "7cd0312e064fde87c8d1cd79ba06c876bd23630c83466e9500321be55c96ace2", + "https://bcr.bazel.build/modules/abseil-cpp/20211102.0/MODULE.bazel": "70390338f7a5106231d20620712f7cccb659cd0e9d073d1991c038eb9fc57589", + "https://bcr.bazel.build/modules/abseil-cpp/20211102.0/source.json": "7e3a9adf473e9af076ae485ed649d5641ad50ec5c11718103f34de03170d94ad", + "https://bcr.bazel.build/modules/apple_support/1.5.0/MODULE.bazel": "50341a62efbc483e8a2a6aec30994a58749bd7b885e18dd96aa8c33031e558ef", + "https://bcr.bazel.build/modules/apple_support/1.5.0/source.json": "eb98a7627c0bc486b57f598ad8da50f6625d974c8f723e9ea71bd39f709c9862", + "https://bcr.bazel.build/modules/bazel_features/1.11.0/MODULE.bazel": "f9382337dd5a474c3b7d334c2f83e50b6eaedc284253334cf823044a26de03e8", + "https://bcr.bazel.build/modules/bazel_features/1.11.0/source.json": "c9320aa53cd1c441d24bd6b716da087ad7e4ff0d9742a9884587596edfe53015", + "https://bcr.bazel.build/modules/bazel_skylib/1.0.3/MODULE.bazel": "bcb0fd896384802d1ad283b4e4eb4d718eebd8cb820b0a2c3a347fb971afd9d8", + "https://bcr.bazel.build/modules/bazel_skylib/1.2.1/MODULE.bazel": "f35baf9da0efe45fa3da1696ae906eea3d615ad41e2e3def4aeb4e8bc0ef9a7a", + "https://bcr.bazel.build/modules/bazel_skylib/1.3.0/MODULE.bazel": "20228b92868bf5cfc41bda7afc8a8ba2a543201851de39d990ec957b513579c5", + "https://bcr.bazel.build/modules/bazel_skylib/1.6.1/MODULE.bazel": "8fdee2dbaace6c252131c00e1de4b165dc65af02ea278476187765e1a617b917", + "https://bcr.bazel.build/modules/bazel_skylib/1.6.1/source.json": "082ed5f9837901fada8c68c2f3ddc958bb22b6d654f71dd73f3df30d45d4b749", + "https://bcr.bazel.build/modules/buildozer/7.1.2/MODULE.bazel": "2e8dd40ede9c454042645fd8d8d0cd1527966aa5c919de86661e62953cd73d84", + "https://bcr.bazel.build/modules/buildozer/7.1.2/source.json": "c9028a501d2db85793a6996205c8de120944f50a0d570438fcae0457a5f9d1f8", + "https://bcr.bazel.build/modules/download_utils/1.0.0-beta.2/MODULE.bazel": "bced1551849a5d1ca00b985c0d267ab690af840f04c685f2c62f40e92f66fac0", + "https://bcr.bazel.build/modules/download_utils/1.0.0-beta.2/source.json": "0ab7ebbc57f39a7fe96190e01fe9773482bc4e3d465e9cd9b239bb44ad57791d", + "https://bcr.bazel.build/modules/googletest/1.11.0/MODULE.bazel": "3a83f095183f66345ca86aa13c58b59f9f94a2f81999c093d4eeaa2d262d12f4", + "https://bcr.bazel.build/modules/googletest/1.11.0/source.json": "c73d9ef4268c91bd0c1cd88f1f9dfa08e814b1dbe89b5f594a9f08ba0244d206", + "https://bcr.bazel.build/modules/platforms/0.0.4/MODULE.bazel": "9b328e31ee156f53f3c416a64f8491f7eb731742655a47c9eec4703a71644aee", + "https://bcr.bazel.build/modules/platforms/0.0.5/MODULE.bazel": "5733b54ea419d5eaf7997054bb55f6a1d0b5ff8aedf0176fef9eea44f3acda37", + "https://bcr.bazel.build/modules/platforms/0.0.6/MODULE.bazel": "ad6eeef431dc52aefd2d77ed20a4b353f8ebf0f4ecdd26a807d2da5aa8cd0615", + "https://bcr.bazel.build/modules/platforms/0.0.7/MODULE.bazel": "72fd4a0ede9ee5c021f6a8dd92b503e089f46c227ba2813ff183b71616034814", + "https://bcr.bazel.build/modules/platforms/0.0.9/MODULE.bazel": "4a87a60c927b56ddd67db50c89acaa62f4ce2a1d2149ccb63ffd871d5ce29ebc", + "https://bcr.bazel.build/modules/platforms/0.0.9/source.json": "cd74d854bf16a9e002fb2ca7b1a421f4403cda29f824a765acd3a8c56f8d43e6", + "https://bcr.bazel.build/modules/protobuf/21.7/MODULE.bazel": "a5a29bb89544f9b97edce05642fac225a808b5b7be74038ea3640fae2f8e66a7", + "https://bcr.bazel.build/modules/protobuf/21.7/source.json": "bbe500720421e582ff2d18b0802464205138c06056f443184de39fbb8187b09b", + "https://bcr.bazel.build/modules/protobuf/3.19.0/MODULE.bazel": "6b5fbb433f760a99a22b18b6850ed5784ef0e9928a72668b66e4d7ccd47db9b0", + "https://bcr.bazel.build/modules/protobuf/3.19.6/MODULE.bazel": "9233edc5e1f2ee276a60de3eaa47ac4132302ef9643238f23128fea53ea12858", + "https://bcr.bazel.build/modules/rules_cc/0.0.1/MODULE.bazel": "cb2aa0747f84c6c3a78dad4e2049c154f08ab9d166b1273835a8174940365647", + "https://bcr.bazel.build/modules/rules_cc/0.0.2/MODULE.bazel": "6915987c90970493ab97393024c156ea8fb9f3bea953b2f3ec05c34f19b5695c", + "https://bcr.bazel.build/modules/rules_cc/0.0.8/MODULE.bazel": "964c85c82cfeb6f3855e6a07054fdb159aced38e99a5eecf7bce9d53990afa3e", + "https://bcr.bazel.build/modules/rules_cc/0.0.9/MODULE.bazel": "836e76439f354b89afe6a911a7adf59a6b2518fafb174483ad78a2a2fde7b1c5", + "https://bcr.bazel.build/modules/rules_cc/0.0.9/source.json": "1f1ba6fea244b616de4a554a0f4983c91a9301640c8fe0dd1d410254115c8430", + "https://bcr.bazel.build/modules/rules_java/4.0.0/MODULE.bazel": "5a78a7ae82cd1a33cef56dc578c7d2a46ed0dca12643ee45edbb8417899e6f74", + "https://bcr.bazel.build/modules/rules_java/7.6.5/MODULE.bazel": "481164be5e02e4cab6e77a36927683263be56b7e36fef918b458d7a8a1ebadb1", + "https://bcr.bazel.build/modules/rules_java/7.6.5/source.json": "a805b889531d1690e3c72a7a7e47a870d00323186a9904b36af83aa3d053ee8d", + "https://bcr.bazel.build/modules/rules_jvm_external/4.4.2/MODULE.bazel": "a56b85e418c83eb1839819f0b515c431010160383306d13ec21959ac412d2fe7", + "https://bcr.bazel.build/modules/rules_jvm_external/4.4.2/source.json": "a075731e1b46bc8425098512d038d416e966ab19684a10a34f4741295642fc35", + "https://bcr.bazel.build/modules/rules_license/0.0.3/MODULE.bazel": "627e9ab0247f7d1e05736b59dbb1b6871373de5ad31c3011880b4133cafd4bd0", + "https://bcr.bazel.build/modules/rules_license/0.0.7/MODULE.bazel": "088fbeb0b6a419005b89cf93fe62d9517c0a2b8bb56af3244af65ecfe37e7d5d", + "https://bcr.bazel.build/modules/rules_license/0.0.7/source.json": "355cc5737a0f294e560d52b1b7a6492d4fff2caf0bef1a315df5a298fca2d34a", + "https://bcr.bazel.build/modules/rules_pkg/0.7.0/MODULE.bazel": "df99f03fc7934a4737122518bb87e667e62d780b610910f0447665a7e2be62dc", + "https://bcr.bazel.build/modules/rules_pkg/0.7.0/source.json": "c2557066e0c0342223ba592510ad3d812d4963b9024831f7f66fd0584dd8c66c", + "https://bcr.bazel.build/modules/rules_proto/4.0.0/MODULE.bazel": "a7a7b6ce9bee418c1a760b3d84f83a299ad6952f9903c67f19e4edd964894e06", + "https://bcr.bazel.build/modules/rules_proto/5.3.0-21.7/MODULE.bazel": "e8dff86b0971688790ae75528fe1813f71809b5afd57facb44dad9e8eca631b7", + "https://bcr.bazel.build/modules/rules_proto/5.3.0-21.7/source.json": "d57902c052424dfda0e71646cb12668d39c4620ee0544294d9d941e7d12bc3a9", + "https://bcr.bazel.build/modules/rules_python/0.10.2/MODULE.bazel": "cc82bc96f2997baa545ab3ce73f196d040ffb8756fd2d66125a530031cd90e5f", + "https://bcr.bazel.build/modules/rules_python/0.22.1/MODULE.bazel": "26114f0c0b5e93018c0c066d6673f1a2c3737c7e90af95eff30cfee38d0bbac7", + "https://bcr.bazel.build/modules/rules_python/0.22.1/source.json": "57226905e783bae7c37c2dd662be078728e48fa28ee4324a7eabcafb5a43d014", + "https://bcr.bazel.build/modules/rules_python/0.4.0/MODULE.bazel": "9208ee05fd48bf09ac60ed269791cf17fb343db56c8226a720fbb1cdf467166c", + "https://bcr.bazel.build/modules/stardoc/0.5.1/MODULE.bazel": "1a05d92974d0c122f5ccf09291442580317cdd859f07a8655f1db9a60374f9f8", + "https://bcr.bazel.build/modules/stardoc/0.5.1/source.json": "a96f95e02123320aa015b956f29c00cb818fa891ef823d55148e1a362caacf29", + "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", + "https://bcr.bazel.build/modules/zlib/1.2.11/MODULE.bazel": "07b389abc85fdbca459b69e2ec656ae5622873af3f845e1c9d80fe179f3effa0", + "https://bcr.bazel.build/modules/zlib/1.2.12/MODULE.bazel": "3b1a8834ada2a883674be8cbd36ede1b6ec481477ada359cd2d3ddc562340b27", + "https://bcr.bazel.build/modules/zlib/1.3.1.bcr.3/MODULE.bazel": "af322bc08976524477c79d1e45e241b6efbeb918c497e8840b8ab116802dda79", + "https://bcr.bazel.build/modules/zlib/1.3.1.bcr.3/source.json": "2be409ac3c7601245958cd4fcdff4288be79ed23bd690b4b951f500d54ee6e7d" + }, + "selectedYankedVersions": {}, + "moduleExtensions": { + "@@platforms//host:extension.bzl%host_platform": { + "general": { + "bzlTransitiveDigest": "xelQcPZH8+tmuOHVjL9vDxMnnQNMlwj0SlvgoqBkm4U=", + "usagesDigest": "meSzxn3DUCcYEhq4HQwExWkWtU4EjriRBQLsZN+Q0SU=", + "recordedFileInputs": {}, + "recordedDirentsInputs": {}, + "envVariables": {}, + "generatedRepoSpecs": { + "host_platform": { + "bzlFile": "@@platforms//host:extension.bzl", + "ruleClassName": "host_platform_repo", + "attributes": {} + } + }, + "recordedRepoMappingEntries": [] + } + } + } +} diff --git a/qemu/debian/bazel-bin b/qemu/debian/bazel-bin new file mode 120000 index 00000000..2ee86581 --- /dev/null +++ b/qemu/debian/bazel-bin @@ -0,0 +1 @@ +/home/jorbon01/.cache/bazel/_bazel_jorbon01/a71b5c810287cc02bd9f8646c775a961/execroot/_main/bazel-out/k8-fastbuild/bin \ No newline at end of file diff --git a/qemu/debian/bazel-debian b/qemu/debian/bazel-debian new file mode 120000 index 00000000..a5077c68 --- /dev/null +++ b/qemu/debian/bazel-debian @@ -0,0 +1 @@ +/home/jorbon01/.cache/bazel/_bazel_jorbon01/a71b5c810287cc02bd9f8646c775a961/execroot/_main \ No newline at end of file diff --git a/qemu/debian/bazel-out b/qemu/debian/bazel-out new file mode 120000 index 00000000..fc5e7cb3 --- /dev/null +++ b/qemu/debian/bazel-out @@ -0,0 +1 @@ +/home/jorbon01/.cache/bazel/_bazel_jorbon01/a71b5c810287cc02bd9f8646c775a961/execroot/_main/bazel-out \ No newline at end of file diff --git a/qemu/debian/bazel-testlogs b/qemu/debian/bazel-testlogs new file mode 120000 index 00000000..41222e7c --- /dev/null +++ b/qemu/debian/bazel-testlogs @@ -0,0 +1 @@ +/home/jorbon01/.cache/bazel/_bazel_jorbon01/a71b5c810287cc02bd9f8646c775a961/execroot/_main/bazel-out/k8-fastbuild/testlogs \ No newline at end of file -- GitLab From d524c64f8c2257ae2b5c721b46b40a032c2acd98 Mon Sep 17 00:00:00 2001 From: Jordan Bonser Date: Wed, 18 Sep 2024 09:31:56 +0100 Subject: [PATCH 06/18] refactor: modules and bazelrc changes. --- .bazelrc | 3 -- MODULE.bazel | 3 ++ e2e/MODULE.bazel | 18 +------- qemu/debian/MODULE.bazel | 23 ---------- qemu/debian/MODULE.bazel.lock | 84 ----------------------------------- 5 files changed, 4 insertions(+), 127 deletions(-) delete mode 100644 qemu/debian/MODULE.bazel delete mode 100644 qemu/debian/MODULE.bazel.lock diff --git a/.bazelrc b/.bazelrc index 73a93c5b..1eb348b6 100644 --- a/.bazelrc +++ b/.bazelrc @@ -25,8 +25,5 @@ common --@rules_labgrid//python:bootstrap=script # Enable built Zstandard toolchain common --extra_toolchains=@rules_zstd//zstd/toolchain/zstd:built -# Download utils -common --registry https://bcr.bazel.build - # User-specific .bazelrc try-import %workspace%/.bazelrc.user diff --git a/MODULE.bazel b/MODULE.bazel index 9d9576b9..b732bf77 100644 --- a/MODULE.bazel +++ b/MODULE.bazel @@ -305,7 +305,10 @@ download_file = use_repo_rule("@download_utils//download/file:defs.bzl", "downlo output = "image.qcow2", executable = False, urls = ["https://cloud.debian.org/images/cloud/bookworm/latest/debian-12-generic-{}.qcow2".format(cpu)], +<<<<<<< HEAD integrity = integrity +======= +>>>>>>> refactor: modules and bazelrc changes. ) for cpu, integrity in ( ("amd64", "sha256-p9rCK1tT7V/uDBI70LR3UoT8vK1aaJ9rWpL0jgXp+1I="), diff --git a/e2e/MODULE.bazel b/e2e/MODULE.bazel index 5bf59a1a..73bb474f 100644 --- a/e2e/MODULE.bazel +++ b/e2e/MODULE.bazel @@ -5,7 +5,6 @@ module( ], ) -bazel_dep(name = "download_utils", version = "1.0.0-beta.2") bazel_dep(name = "bazel_skylib", version = "1.7.1") bazel_dep(name = "toolchain_utils", version = "1.0.0-beta.14") bazel_dep(name = "rules_python", version = "0.33.2") @@ -44,19 +43,4 @@ pip.parse( python_version = "3.11", requirements_lock = "//python:requirements.txt", ) -use_repo(pip, "pip") - -# Download QEMU images -download_file = use_repo_rule("@download_utils//download/file:defs.bzl", "download_file") -[ - download_file( - name = "{}-debian.12-gnu-qemu".format(cpu), - output = "image.qcow2", - executable = False, - urls = ["https://cloud.debian.org/images/cloud/bookworm/latest/debian-12-generic-{}.qcow2".format(cpu)], - ) - for cpu, integrity in ( - ("amd64", "sha256-p9rCK1tT7V/uDBI70LR3UoT8vK1aaJ9rWpL0jgXp+1I="), - ("arm64", "sha256-gxjqgasbjKLrLUtVJYz/MTiPbttisBz3Y4HglSRRspo="), - ) -] \ No newline at end of file +use_repo(pip, "pip") \ No newline at end of file diff --git a/qemu/debian/MODULE.bazel b/qemu/debian/MODULE.bazel deleted file mode 100644 index d6eaaa16..00000000 --- a/qemu/debian/MODULE.bazel +++ /dev/null @@ -1,23 +0,0 @@ -############################################################################### -# Bazel now uses Bzlmod by default to manage external dependencies. -# Please consider migrating your external dependencies from WORKSPACE to MODULE.bazel. -# -# For more details, please check https://github.com/bazelbuild/bazel/issues/18958 -############################################################################### - -bazel_dep(name = "download_utils", version = "1.0.0-beta.2") - -# Download QEMU images -download_file = use_repo_rule("@download_utils//download/file:defs.bzl", "download_file") -[ - download_file( - name = "{}-debian.12-gnu-qemu".format(cpu), - output = "image.qcow2", - executable = False, - urls = ["https://cloud.debian.org/images/cloud/bookworm/latest/debian-12-generic-{}.qcow2".format(cpu)], - ) - for cpu, integrity in ( - ("amd64", "sha256-p9rCK1tT7V/uDBI70LR3UoT8vK1aaJ9rWpL0jgXp+1I="), - ("arm64", "sha256-gxjqgasbjKLrLUtVJYz/MTiPbttisBz3Y4HglSRRspo="), - ) -] \ No newline at end of file diff --git a/qemu/debian/MODULE.bazel.lock b/qemu/debian/MODULE.bazel.lock deleted file mode 100644 index 43e29a9d..00000000 --- a/qemu/debian/MODULE.bazel.lock +++ /dev/null @@ -1,84 +0,0 @@ -{ - "lockFileVersion": 11, - "registryFileHashes": { - "https://bcr.bazel.build/bazel_registry.json": "8a28e4aff06ee60aed2a8c281907fb8bcbf3b753c91fb5a5c57da3215d5b3497", - "https://bcr.bazel.build/modules/abseil-cpp/20210324.2/MODULE.bazel": "7cd0312e064fde87c8d1cd79ba06c876bd23630c83466e9500321be55c96ace2", - "https://bcr.bazel.build/modules/abseil-cpp/20211102.0/MODULE.bazel": "70390338f7a5106231d20620712f7cccb659cd0e9d073d1991c038eb9fc57589", - "https://bcr.bazel.build/modules/abseil-cpp/20211102.0/source.json": "7e3a9adf473e9af076ae485ed649d5641ad50ec5c11718103f34de03170d94ad", - "https://bcr.bazel.build/modules/apple_support/1.5.0/MODULE.bazel": "50341a62efbc483e8a2a6aec30994a58749bd7b885e18dd96aa8c33031e558ef", - "https://bcr.bazel.build/modules/apple_support/1.5.0/source.json": "eb98a7627c0bc486b57f598ad8da50f6625d974c8f723e9ea71bd39f709c9862", - "https://bcr.bazel.build/modules/bazel_features/1.11.0/MODULE.bazel": "f9382337dd5a474c3b7d334c2f83e50b6eaedc284253334cf823044a26de03e8", - "https://bcr.bazel.build/modules/bazel_features/1.11.0/source.json": "c9320aa53cd1c441d24bd6b716da087ad7e4ff0d9742a9884587596edfe53015", - "https://bcr.bazel.build/modules/bazel_skylib/1.0.3/MODULE.bazel": "bcb0fd896384802d1ad283b4e4eb4d718eebd8cb820b0a2c3a347fb971afd9d8", - "https://bcr.bazel.build/modules/bazel_skylib/1.2.1/MODULE.bazel": "f35baf9da0efe45fa3da1696ae906eea3d615ad41e2e3def4aeb4e8bc0ef9a7a", - "https://bcr.bazel.build/modules/bazel_skylib/1.3.0/MODULE.bazel": "20228b92868bf5cfc41bda7afc8a8ba2a543201851de39d990ec957b513579c5", - "https://bcr.bazel.build/modules/bazel_skylib/1.6.1/MODULE.bazel": "8fdee2dbaace6c252131c00e1de4b165dc65af02ea278476187765e1a617b917", - "https://bcr.bazel.build/modules/bazel_skylib/1.6.1/source.json": "082ed5f9837901fada8c68c2f3ddc958bb22b6d654f71dd73f3df30d45d4b749", - "https://bcr.bazel.build/modules/buildozer/7.1.2/MODULE.bazel": "2e8dd40ede9c454042645fd8d8d0cd1527966aa5c919de86661e62953cd73d84", - "https://bcr.bazel.build/modules/buildozer/7.1.2/source.json": "c9028a501d2db85793a6996205c8de120944f50a0d570438fcae0457a5f9d1f8", - "https://bcr.bazel.build/modules/download_utils/1.0.0-beta.2/MODULE.bazel": "bced1551849a5d1ca00b985c0d267ab690af840f04c685f2c62f40e92f66fac0", - "https://bcr.bazel.build/modules/download_utils/1.0.0-beta.2/source.json": "0ab7ebbc57f39a7fe96190e01fe9773482bc4e3d465e9cd9b239bb44ad57791d", - "https://bcr.bazel.build/modules/googletest/1.11.0/MODULE.bazel": "3a83f095183f66345ca86aa13c58b59f9f94a2f81999c093d4eeaa2d262d12f4", - "https://bcr.bazel.build/modules/googletest/1.11.0/source.json": "c73d9ef4268c91bd0c1cd88f1f9dfa08e814b1dbe89b5f594a9f08ba0244d206", - "https://bcr.bazel.build/modules/platforms/0.0.4/MODULE.bazel": "9b328e31ee156f53f3c416a64f8491f7eb731742655a47c9eec4703a71644aee", - "https://bcr.bazel.build/modules/platforms/0.0.5/MODULE.bazel": "5733b54ea419d5eaf7997054bb55f6a1d0b5ff8aedf0176fef9eea44f3acda37", - "https://bcr.bazel.build/modules/platforms/0.0.6/MODULE.bazel": "ad6eeef431dc52aefd2d77ed20a4b353f8ebf0f4ecdd26a807d2da5aa8cd0615", - "https://bcr.bazel.build/modules/platforms/0.0.7/MODULE.bazel": "72fd4a0ede9ee5c021f6a8dd92b503e089f46c227ba2813ff183b71616034814", - "https://bcr.bazel.build/modules/platforms/0.0.9/MODULE.bazel": "4a87a60c927b56ddd67db50c89acaa62f4ce2a1d2149ccb63ffd871d5ce29ebc", - "https://bcr.bazel.build/modules/platforms/0.0.9/source.json": "cd74d854bf16a9e002fb2ca7b1a421f4403cda29f824a765acd3a8c56f8d43e6", - "https://bcr.bazel.build/modules/protobuf/21.7/MODULE.bazel": "a5a29bb89544f9b97edce05642fac225a808b5b7be74038ea3640fae2f8e66a7", - "https://bcr.bazel.build/modules/protobuf/21.7/source.json": "bbe500720421e582ff2d18b0802464205138c06056f443184de39fbb8187b09b", - "https://bcr.bazel.build/modules/protobuf/3.19.0/MODULE.bazel": "6b5fbb433f760a99a22b18b6850ed5784ef0e9928a72668b66e4d7ccd47db9b0", - "https://bcr.bazel.build/modules/protobuf/3.19.6/MODULE.bazel": "9233edc5e1f2ee276a60de3eaa47ac4132302ef9643238f23128fea53ea12858", - "https://bcr.bazel.build/modules/rules_cc/0.0.1/MODULE.bazel": "cb2aa0747f84c6c3a78dad4e2049c154f08ab9d166b1273835a8174940365647", - "https://bcr.bazel.build/modules/rules_cc/0.0.2/MODULE.bazel": "6915987c90970493ab97393024c156ea8fb9f3bea953b2f3ec05c34f19b5695c", - "https://bcr.bazel.build/modules/rules_cc/0.0.8/MODULE.bazel": "964c85c82cfeb6f3855e6a07054fdb159aced38e99a5eecf7bce9d53990afa3e", - "https://bcr.bazel.build/modules/rules_cc/0.0.9/MODULE.bazel": "836e76439f354b89afe6a911a7adf59a6b2518fafb174483ad78a2a2fde7b1c5", - "https://bcr.bazel.build/modules/rules_cc/0.0.9/source.json": "1f1ba6fea244b616de4a554a0f4983c91a9301640c8fe0dd1d410254115c8430", - "https://bcr.bazel.build/modules/rules_java/4.0.0/MODULE.bazel": "5a78a7ae82cd1a33cef56dc578c7d2a46ed0dca12643ee45edbb8417899e6f74", - "https://bcr.bazel.build/modules/rules_java/7.6.5/MODULE.bazel": "481164be5e02e4cab6e77a36927683263be56b7e36fef918b458d7a8a1ebadb1", - "https://bcr.bazel.build/modules/rules_java/7.6.5/source.json": "a805b889531d1690e3c72a7a7e47a870d00323186a9904b36af83aa3d053ee8d", - "https://bcr.bazel.build/modules/rules_jvm_external/4.4.2/MODULE.bazel": "a56b85e418c83eb1839819f0b515c431010160383306d13ec21959ac412d2fe7", - "https://bcr.bazel.build/modules/rules_jvm_external/4.4.2/source.json": "a075731e1b46bc8425098512d038d416e966ab19684a10a34f4741295642fc35", - "https://bcr.bazel.build/modules/rules_license/0.0.3/MODULE.bazel": "627e9ab0247f7d1e05736b59dbb1b6871373de5ad31c3011880b4133cafd4bd0", - "https://bcr.bazel.build/modules/rules_license/0.0.7/MODULE.bazel": "088fbeb0b6a419005b89cf93fe62d9517c0a2b8bb56af3244af65ecfe37e7d5d", - "https://bcr.bazel.build/modules/rules_license/0.0.7/source.json": "355cc5737a0f294e560d52b1b7a6492d4fff2caf0bef1a315df5a298fca2d34a", - "https://bcr.bazel.build/modules/rules_pkg/0.7.0/MODULE.bazel": "df99f03fc7934a4737122518bb87e667e62d780b610910f0447665a7e2be62dc", - "https://bcr.bazel.build/modules/rules_pkg/0.7.0/source.json": "c2557066e0c0342223ba592510ad3d812d4963b9024831f7f66fd0584dd8c66c", - "https://bcr.bazel.build/modules/rules_proto/4.0.0/MODULE.bazel": "a7a7b6ce9bee418c1a760b3d84f83a299ad6952f9903c67f19e4edd964894e06", - "https://bcr.bazel.build/modules/rules_proto/5.3.0-21.7/MODULE.bazel": "e8dff86b0971688790ae75528fe1813f71809b5afd57facb44dad9e8eca631b7", - "https://bcr.bazel.build/modules/rules_proto/5.3.0-21.7/source.json": "d57902c052424dfda0e71646cb12668d39c4620ee0544294d9d941e7d12bc3a9", - "https://bcr.bazel.build/modules/rules_python/0.10.2/MODULE.bazel": "cc82bc96f2997baa545ab3ce73f196d040ffb8756fd2d66125a530031cd90e5f", - "https://bcr.bazel.build/modules/rules_python/0.22.1/MODULE.bazel": "26114f0c0b5e93018c0c066d6673f1a2c3737c7e90af95eff30cfee38d0bbac7", - "https://bcr.bazel.build/modules/rules_python/0.22.1/source.json": "57226905e783bae7c37c2dd662be078728e48fa28ee4324a7eabcafb5a43d014", - "https://bcr.bazel.build/modules/rules_python/0.4.0/MODULE.bazel": "9208ee05fd48bf09ac60ed269791cf17fb343db56c8226a720fbb1cdf467166c", - "https://bcr.bazel.build/modules/stardoc/0.5.1/MODULE.bazel": "1a05d92974d0c122f5ccf09291442580317cdd859f07a8655f1db9a60374f9f8", - "https://bcr.bazel.build/modules/stardoc/0.5.1/source.json": "a96f95e02123320aa015b956f29c00cb818fa891ef823d55148e1a362caacf29", - "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", - "https://bcr.bazel.build/modules/zlib/1.2.11/MODULE.bazel": "07b389abc85fdbca459b69e2ec656ae5622873af3f845e1c9d80fe179f3effa0", - "https://bcr.bazel.build/modules/zlib/1.2.12/MODULE.bazel": "3b1a8834ada2a883674be8cbd36ede1b6ec481477ada359cd2d3ddc562340b27", - "https://bcr.bazel.build/modules/zlib/1.3.1.bcr.3/MODULE.bazel": "af322bc08976524477c79d1e45e241b6efbeb918c497e8840b8ab116802dda79", - "https://bcr.bazel.build/modules/zlib/1.3.1.bcr.3/source.json": "2be409ac3c7601245958cd4fcdff4288be79ed23bd690b4b951f500d54ee6e7d" - }, - "selectedYankedVersions": {}, - "moduleExtensions": { - "@@platforms//host:extension.bzl%host_platform": { - "general": { - "bzlTransitiveDigest": "xelQcPZH8+tmuOHVjL9vDxMnnQNMlwj0SlvgoqBkm4U=", - "usagesDigest": "meSzxn3DUCcYEhq4HQwExWkWtU4EjriRBQLsZN+Q0SU=", - "recordedFileInputs": {}, - "recordedDirentsInputs": {}, - "envVariables": {}, - "generatedRepoSpecs": { - "host_platform": { - "bzlFile": "@@platforms//host:extension.bzl", - "ruleClassName": "host_platform_repo", - "attributes": {} - } - }, - "recordedRepoMappingEntries": [] - } - } - } -} -- GitLab From 99ce3466034b28632195268d457580ee780e9567 Mon Sep 17 00:00:00 2001 From: Jordan Bonser Date: Wed, 18 Sep 2024 09:43:51 +0100 Subject: [PATCH 07/18] refactor: remove the generated bazel files --- qemu/debian/bazel-bin | 1 - qemu/debian/bazel-debian | 1 - qemu/debian/bazel-out | 1 - qemu/debian/bazel-testlogs | 1 - 4 files changed, 4 deletions(-) delete mode 120000 qemu/debian/bazel-bin delete mode 120000 qemu/debian/bazel-debian delete mode 120000 qemu/debian/bazel-out delete mode 120000 qemu/debian/bazel-testlogs diff --git a/qemu/debian/bazel-bin b/qemu/debian/bazel-bin deleted file mode 120000 index 2ee86581..00000000 --- a/qemu/debian/bazel-bin +++ /dev/null @@ -1 +0,0 @@ -/home/jorbon01/.cache/bazel/_bazel_jorbon01/a71b5c810287cc02bd9f8646c775a961/execroot/_main/bazel-out/k8-fastbuild/bin \ No newline at end of file diff --git a/qemu/debian/bazel-debian b/qemu/debian/bazel-debian deleted file mode 120000 index a5077c68..00000000 --- a/qemu/debian/bazel-debian +++ /dev/null @@ -1 +0,0 @@ -/home/jorbon01/.cache/bazel/_bazel_jorbon01/a71b5c810287cc02bd9f8646c775a961/execroot/_main \ No newline at end of file diff --git a/qemu/debian/bazel-out b/qemu/debian/bazel-out deleted file mode 120000 index fc5e7cb3..00000000 --- a/qemu/debian/bazel-out +++ /dev/null @@ -1 +0,0 @@ -/home/jorbon01/.cache/bazel/_bazel_jorbon01/a71b5c810287cc02bd9f8646c775a961/execroot/_main/bazel-out \ No newline at end of file diff --git a/qemu/debian/bazel-testlogs b/qemu/debian/bazel-testlogs deleted file mode 120000 index 41222e7c..00000000 --- a/qemu/debian/bazel-testlogs +++ /dev/null @@ -1 +0,0 @@ -/home/jorbon01/.cache/bazel/_bazel_jorbon01/a71b5c810287cc02bd9f8646c775a961/execroot/_main/bazel-out/k8-fastbuild/testlogs \ No newline at end of file -- GitLab From 743946ff82ced51b2a133ca2c5e4a51c8bdf770f Mon Sep 17 00:00:00 2001 From: Jordan Bonser Date: Wed, 18 Sep 2024 11:53:15 +0100 Subject: [PATCH 08/18] fix: use integrity in download_file --- MODULE.bazel | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/MODULE.bazel b/MODULE.bazel index b732bf77..f97025a8 100644 --- a/MODULE.bazel +++ b/MODULE.bazel @@ -305,12 +305,9 @@ download_file = use_repo_rule("@download_utils//download/file:defs.bzl", "downlo output = "image.qcow2", executable = False, urls = ["https://cloud.debian.org/images/cloud/bookworm/latest/debian-12-generic-{}.qcow2".format(cpu)], -<<<<<<< HEAD integrity = integrity -======= ->>>>>>> refactor: modules and bazelrc changes. ) - for cpu, integrity in ( + for cpu, integrity_sha in ( ("amd64", "sha256-p9rCK1tT7V/uDBI70LR3UoT8vK1aaJ9rWpL0jgXp+1I="), ("arm64", "sha256-gxjqgasbjKLrLUtVJYz/MTiPbttisBz3Y4HglSRRspo="), ) -- GitLab From cb6b6f9dc540526283f6a667c0260a62fe814e6c Mon Sep 17 00:00:00 2001 From: Jordan Bonser Date: Wed, 18 Sep 2024 13:36:52 +0100 Subject: [PATCH 09/18] refactor: integrity variable naming --- MODULE.bazel | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MODULE.bazel b/MODULE.bazel index f97025a8..9d9576b9 100644 --- a/MODULE.bazel +++ b/MODULE.bazel @@ -307,7 +307,7 @@ download_file = use_repo_rule("@download_utils//download/file:defs.bzl", "downlo urls = ["https://cloud.debian.org/images/cloud/bookworm/latest/debian-12-generic-{}.qcow2".format(cpu)], integrity = integrity ) - for cpu, integrity_sha in ( + for cpu, integrity in ( ("amd64", "sha256-p9rCK1tT7V/uDBI70LR3UoT8vK1aaJ9rWpL0jgXp+1I="), ("arm64", "sha256-gxjqgasbjKLrLUtVJYz/MTiPbttisBz3Y4HglSRRspo="), ) -- GitLab From 56ba9b105ea69aaedeafe4abe119bf9784a89c88 Mon Sep 17 00:00:00 2001 From: Jordan Bonser Date: Fri, 20 Sep 2024 14:45:40 +0100 Subject: [PATCH 10/18] fix: boot debian image --- debian/amd64/qemu-system-arm/BUILD.bazel | 6 ++++++ debian/amd64/qemu-system-x86/BUILD.bazel | 8 ++++++++ debian/arm64/qemu-system-arm/BUILD.bazel | 8 ++++++++ debian/arm64/qemu-system-x86/BUILD.bazel | 8 ++++++++ debian/launcher/posix.tmpl.sh | 2 ++ qemu/debian/BUILD.bazel | 2 +- 6 files changed, 33 insertions(+), 1 deletion(-) diff --git a/debian/amd64/qemu-system-arm/BUILD.bazel b/debian/amd64/qemu-system-arm/BUILD.bazel index 59e9a88f..c6b0ecd3 100644 --- a/debian/amd64/qemu-system-arm/BUILD.bazel +++ b/debian/amd64/qemu-system-arm/BUILD.bazel @@ -18,12 +18,18 @@ tar_unpack( debian_launcher( name = "qemu-system-arm", + env = { + "QEMU_MODULE_DIR": "$(location :unpack)/usr/lib/aarch64-linux-gnu/qemu/", + }, src = ":unpack", visibility = ["//:__subpackages__"], ) debian_launcher( name = "qemu-system-aarch64", + env = { + "QEMU_MODULE_DIR": "$(location :unpack)/usr/lib/aarch64-linux-gnu/qemu/", + }, src = ":unpack", visibility = ["//:__subpackages__"], ) diff --git a/debian/amd64/qemu-system-x86/BUILD.bazel b/debian/amd64/qemu-system-x86/BUILD.bazel index 03e88f94..ee6f078e 100644 --- a/debian/amd64/qemu-system-x86/BUILD.bazel +++ b/debian/amd64/qemu-system-x86/BUILD.bazel @@ -17,12 +17,20 @@ tar_unpack( debian_launcher( name = "qemu-system-i386", + env = { + "QEMU_MODULE_DIR": "$(location :unpack)/usr/lib/x86_64-linux-gnu/qemu/", + }, src = ":unpack", + data = [":unpack"], visibility = ["//:__subpackages__"], ) debian_launcher( name = "qemu-system-x86_64", + env = { + "QEMU_MODULE_DIR": "$(location :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 7e03bba4..3187503c 100644 --- a/debian/arm64/qemu-system-arm/BUILD.bazel +++ b/debian/arm64/qemu-system-arm/BUILD.bazel @@ -17,12 +17,20 @@ tar_unpack( debian_launcher( name = "qemu-system-arm", + env = { + "QEMU_MODULE_DIR": "$(location :unpack)/usr/lib/aarch64-linux-gnu/qemu/", + }, src = ":unpack", + data = [":unpack"], visibility = ["//:__subpackages__"], ) debian_launcher( name = "qemu-system-aarch64", + env = { + "QEMU_MODULE_DIR": "$(location :unpack)/usr/lib/aarch64-linux-gnu/qemu/", + }, src = ":unpack", + data = [":unpack"], visibility = ["//:__subpackages__"], ) diff --git a/debian/arm64/qemu-system-x86/BUILD.bazel b/debian/arm64/qemu-system-x86/BUILD.bazel index 03e88f94..c2c96b27 100644 --- a/debian/arm64/qemu-system-x86/BUILD.bazel +++ b/debian/arm64/qemu-system-x86/BUILD.bazel @@ -17,12 +17,20 @@ tar_unpack( debian_launcher( name = "qemu-system-i386", + env = { + "QEMU_MODULE_DIR": "$(location :unpack)/usr/lib/x86_64-linux-gnu/qemu/", + }, src = ":unpack", + data = [":unpack"], visibility = ["//:__subpackages__"], ) debian_launcher( name = "qemu-system-x86_64", + env = { + "QEMU_MODULE_DIR": "$(location :unpack)/usr/lib/x86_64-linux-gnu/qemu/", + }, src = ":unpack", + data = [":unpack"], visibility = ["//:__subpackages__"], ) diff --git a/debian/launcher/posix.tmpl.sh b/debian/launcher/posix.tmpl.sh index 815a1dfb..4ee25993 100644 --- a/debian/launcher/posix.tmpl.sh +++ b/debian/launcher/posix.tmpl.sh @@ -29,6 +29,8 @@ elif ! test -x "${BINARY}"; then exit 1 fi +printf >&2 "$(env)" + # Check the interpreter is executable if ! test -e "${INTERPRETER}"; then printf >&2 "ELF interpreter does not exist: %s\n" "${INTERPRETER}" diff --git a/qemu/debian/BUILD.bazel b/qemu/debian/BUILD.bazel index eec1fb2e..24c2bd7a 100644 --- a/qemu/debian/BUILD.bazel +++ b/qemu/debian/BUILD.bazel @@ -12,4 +12,4 @@ alias( build_test( name = "download", targets = [":image"], -) \ No newline at end of file +) -- GitLab From 8f69deac7081d2e0fbb9840e60346a1a5cf49960 Mon Sep 17 00:00:00 2001 From: Jordan Bonser Date: Mon, 23 Sep 2024 11:00:37 +0100 Subject: [PATCH 11/18] fix: adding QEMU_MODULE_DIR changes --- .bazelrc | 3 ++- MODULE.bazel | 2 +- MODULE.bazel.lock | 12 ++++++------ debian/amd64/qemu-system-x86/BUILD.bazel | 7 +++++-- debian/launcher/library/path/BUILD.bazel | 2 ++ debian/launcher/posix.tmpl.sh | 5 +++++ 6 files changed, 21 insertions(+), 10 deletions(-) diff --git a/.bazelrc b/.bazelrc index 1eb348b6..56a109dc 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 9d9576b9..0f2eeeff 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 bdaad19e..b4098ff3 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-x86/BUILD.bazel b/debian/amd64/qemu-system-x86/BUILD.bazel index ee6f078e..63577092 100644 --- a/debian/amd64/qemu-system-x86/BUILD.bazel +++ b/debian/amd64/qemu-system-x86/BUILD.bazel @@ -18,7 +18,8 @@ tar_unpack( debian_launcher( name = "qemu-system-i386", env = { - "QEMU_MODULE_DIR": "$(location :unpack)/usr/lib/x86_64-linux-gnu/qemu/", + # "QEMU_MODULE_DIR": "$(location :unpack)/usr/lib/x86_64-linux-gnu/qemu/", + "QEMU_MODULE_DIR": "~/rules_labgrid/bazel-bin/debian/amd64/qemu-system-x86/unpack/usr/lib/", }, src = ":unpack", data = [":unpack"], @@ -28,7 +29,9 @@ debian_launcher( debian_launcher( name = "qemu-system-x86_64", env = { - "QEMU_MODULE_DIR": "$(location :unpack)/usr/lib/x86_64-linux-gnu/qemu/", + # "QEMU_MODULE_DIR": "$(location :unpack)/usr/lib/x86_64-linux-gnu/qemu/", + "QEMU_MODULE_DIR": "~/rules_labgrid/bazel-bin/debian/amd64/qemu-system-x86/unpack/usr/lib/x86_64-linux-gnu/qemu/", + "QEMU_LD_PREFIX": "~/rules_labgrid/bazel-bin/debian/amd64/qemu-system-x86/unpack/lib/x86_64-linux-gnu/" }, data = [":unpack"], src = ":unpack", diff --git a/debian/launcher/library/path/BUILD.bazel b/debian/launcher/library/path/BUILD.bazel index 1053821d..70ed232c 100644 --- a/debian/launcher/library/path/BUILD.bazel +++ b/debian/launcher/library/path/BUILD.bazel @@ -5,6 +5,8 @@ debian_launcher_library_path( paths = [ "${ORIGIN}/../lib/x86_64-linux-gnu", "${ORIGIN}/../../lib/x86_64-linux-gnu", + "${ORIGIN}/../lib/x86_64-linux-gnu/qemu", + "${ORIGIN}/../../lib/x86_64-linux-gnu/qemu", ], ) diff --git a/debian/launcher/posix.tmpl.sh b/debian/launcher/posix.tmpl.sh index 4ee25993..a03623fe 100644 --- a/debian/launcher/posix.tmpl.sh +++ b/debian/launcher/posix.tmpl.sh @@ -17,6 +17,11 @@ if ! test -d "${ROOT}"; then exit 1 fi +printf >&2 "$(realpath "$ROOT")\n" +printf >&2 "$(realpath "$BINARY")\n" +printf >&2 "$(realpath "$LLP")\n" +printf >&2 "$(realpath "$INTERPRETER")\n\n\n" + # Check the binary is executable if ! test -e "${BINARY}"; then printf >&2 "Binary does not exist: %s\n" "${BINARY}" -- GitLab From 68f340073c2252e795119bdf74438572cd748bb4 Mon Sep 17 00:00:00 2001 From: Jordan Bonser Date: Wed, 25 Sep 2024 16:26:14 +0100 Subject: [PATCH 12/18] fix: use of llp, bios_dirs and module_dir --- debian/amd64/qemu-system-arm/BUILD.bazel | 16 +++++++++----- debian/amd64/qemu-system-x86/BUILD.bazel | 23 +++++++++---------- debian/arm64/qemu-system-arm/BUILD.bazel | 18 ++++++++------- debian/arm64/qemu-system-x86/BUILD.bazel | 18 ++++++++------- debian/launcher/library/path/BUILD.bazel | 2 -- debian/launcher/posix.tmpl.sh | 28 +++++++++++++++++++----- debian/launcher/rule.bzl | 21 +++++++++--------- 7 files changed, 76 insertions(+), 50 deletions(-) diff --git a/debian/amd64/qemu-system-arm/BUILD.bazel b/debian/amd64/qemu-system-arm/BUILD.bazel index c6b0ecd3..65be1598 100644 --- a/debian/amd64/qemu-system-arm/BUILD.bazel +++ b/debian/amd64/qemu-system-arm/BUILD.bazel @@ -18,18 +18,22 @@ tar_unpack( debian_launcher( name = "qemu-system-arm", - env = { - "QEMU_MODULE_DIR": "$(location :unpack)/usr/lib/aarch64-linux-gnu/qemu/", - }, + module_dir = "usr/lib/x86_64-linux-gnu/qemu", + bios_link_dirs = [ + "usr/share/qemu", + "usr/share/seabios" + ], src = ":unpack", visibility = ["//:__subpackages__"], ) debian_launcher( name = "qemu-system-aarch64", - env = { - "QEMU_MODULE_DIR": "$(location :unpack)/usr/lib/aarch64-linux-gnu/qemu/", - }, + module_dir = "usr/lib/x86_64-linux-gnu/qemu", + bios_link_dirs = [ + "usr/share/qemu", + "usr/share/seabios" + ], src = ":unpack", visibility = ["//:__subpackages__"], ) diff --git a/debian/amd64/qemu-system-x86/BUILD.bazel b/debian/amd64/qemu-system-x86/BUILD.bazel index 63577092..c07b17c7 100644 --- a/debian/amd64/qemu-system-x86/BUILD.bazel +++ b/debian/amd64/qemu-system-x86/BUILD.bazel @@ -17,23 +17,24 @@ tar_unpack( debian_launcher( name = "qemu-system-i386", - env = { - # "QEMU_MODULE_DIR": "$(location :unpack)/usr/lib/x86_64-linux-gnu/qemu/", - "QEMU_MODULE_DIR": "~/rules_labgrid/bazel-bin/debian/amd64/qemu-system-x86/unpack/usr/lib/", - }, + module_dir = "usr/lib/x86_64-linux-gnu/qemu", + bios_link_dirs = [ + "usr/share/qemu", + "usr/share/seabios", + "usr/lib/ipxe/qemu" + ], src = ":unpack", - data = [":unpack"], visibility = ["//:__subpackages__"], ) debian_launcher( name = "qemu-system-x86_64", - env = { - # "QEMU_MODULE_DIR": "$(location :unpack)/usr/lib/x86_64-linux-gnu/qemu/", - "QEMU_MODULE_DIR": "~/rules_labgrid/bazel-bin/debian/amd64/qemu-system-x86/unpack/usr/lib/x86_64-linux-gnu/qemu/", - "QEMU_LD_PREFIX": "~/rules_labgrid/bazel-bin/debian/amd64/qemu-system-x86/unpack/lib/x86_64-linux-gnu/" - }, - data = [":unpack"], + module_dir = "usr/lib/x86_64-linux-gnu/qemu", + bios_link_dirs = [ + "usr/share/qemu", + "usr/share/seabios", + "usr/lib/ipxe/qemu" + ], src = ":unpack", visibility = ["//:__subpackages__"], ) diff --git a/debian/arm64/qemu-system-arm/BUILD.bazel b/debian/arm64/qemu-system-arm/BUILD.bazel index 3187503c..1a43c245 100644 --- a/debian/arm64/qemu-system-arm/BUILD.bazel +++ b/debian/arm64/qemu-system-arm/BUILD.bazel @@ -17,20 +17,22 @@ tar_unpack( debian_launcher( name = "qemu-system-arm", - env = { - "QEMU_MODULE_DIR": "$(location :unpack)/usr/lib/aarch64-linux-gnu/qemu/", - }, + module_dir = "usr/lib/aarch64-linux-gnu/qemu", + bios_link_dirs = [ + "usr/share/qemu-firmware", + "usr/share/qemu", + ], src = ":unpack", - data = [":unpack"], visibility = ["//:__subpackages__"], ) debian_launcher( name = "qemu-system-aarch64", - env = { - "QEMU_MODULE_DIR": "$(location :unpack)/usr/lib/aarch64-linux-gnu/qemu/", - }, + module_dir = "usr/lib/aarch64-linux-gnu/qemu", + bios_link_dirs = [ + "usr/share/qemu-firmware", + "usr/share/qemu", + ], src = ":unpack", - data = [":unpack"], visibility = ["//:__subpackages__"], ) diff --git a/debian/arm64/qemu-system-x86/BUILD.bazel b/debian/arm64/qemu-system-x86/BUILD.bazel index c2c96b27..721cf47e 100644 --- a/debian/arm64/qemu-system-x86/BUILD.bazel +++ b/debian/arm64/qemu-system-x86/BUILD.bazel @@ -17,20 +17,22 @@ tar_unpack( debian_launcher( name = "qemu-system-i386", - env = { - "QEMU_MODULE_DIR": "$(location :unpack)/usr/lib/x86_64-linux-gnu/qemu/", - }, + module_dir = "usr/lib/x86_64-linux-gnu/qemu", + bios_link_dirs = [ + "usr/share/qemu-firmware", + "usr/share/qemu", + ], src = ":unpack", - data = [":unpack"], visibility = ["//:__subpackages__"], ) debian_launcher( name = "qemu-system-x86_64", - env = { - "QEMU_MODULE_DIR": "$(location :unpack)/usr/lib/x86_64-linux-gnu/qemu/", - }, + module_dir = "usr/lib/x86_64-linux-gnu/qemu", + bios_link_dirs = [ + "usr/share/qemu-firmware", + "usr/share/qemu", + ], src = ":unpack", - data = [":unpack"], visibility = ["//:__subpackages__"], ) diff --git a/debian/launcher/library/path/BUILD.bazel b/debian/launcher/library/path/BUILD.bazel index 70ed232c..1053821d 100644 --- a/debian/launcher/library/path/BUILD.bazel +++ b/debian/launcher/library/path/BUILD.bazel @@ -5,8 +5,6 @@ debian_launcher_library_path( paths = [ "${ORIGIN}/../lib/x86_64-linux-gnu", "${ORIGIN}/../../lib/x86_64-linux-gnu", - "${ORIGIN}/../lib/x86_64-linux-gnu/qemu", - "${ORIGIN}/../../lib/x86_64-linux-gnu/qemu", ], ) diff --git a/debian/launcher/posix.tmpl.sh b/debian/launcher/posix.tmpl.sh index a03623fe..dcf4e4d0 100644 --- a/debian/launcher/posix.tmpl.sh +++ b/debian/launcher/posix.tmpl.sh @@ -7,8 +7,26 @@ set -o nounset # Substitutions ROOT="{{root}}" BINARY="{{binary}}" -LLP="{{llp}}" +LLP='{{llp}}' INTERPRETER="{{interpreter}}" +MODULE_DIR="{{module_dir}}" +BIOS_DIRS_STRING="{{bios_link_dir_string}}" + +printf >&2 "'$BIOS_DIRS_STRING'\n\n" + +# Parsing the bios directories as a space separated string so we can iterate over them +# adding the '-L' and realpath to the beginning of the relative paths. +# This constructs the full list of -L parameters to be passed to the binary. +BIOS_LINK_PARAMS="" +for I in $BIOS_DIRS_STRING +do + if test "$(realpath "$I")"; then + BIOS_LINK_PARAMS=$(printf "%s-L %s " "$BIOS_LINK_PARAMS" "$(realpath "$I")") + fi +done + +printf >&2 "'$BIOS_LINK_PARAMS'\n\n" + readonly ROOT BINARY LLP INTERPRETER # Check the root is available @@ -19,9 +37,11 @@ fi printf >&2 "$(realpath "$ROOT")\n" printf >&2 "$(realpath "$BINARY")\n" -printf >&2 "$(realpath "$LLP")\n" +printf >&2 "$(realpath "$MODULE_DIR")\n" printf >&2 "$(realpath "$INTERPRETER")\n\n\n" +printf >&2 ''$LLP'\n\n\n' + # Check the binary is executable if ! test -e "${BINARY}"; then printf >&2 "Binary does not exist: %s\n" "${BINARY}" @@ -34,8 +54,6 @@ elif ! test -x "${BINARY}"; then exit 1 fi -printf >&2 "$(env)" - # Check the interpreter is executable if ! test -e "${INTERPRETER}"; then printf >&2 "ELF interpreter does not exist: %s\n" "${INTERPRETER}" @@ -77,4 +95,4 @@ fi # issues where the absolute root path has been baked into the executable. # Run the binary -LD_LIBRARY_PATH="${LLP}" "${INTERPRETER}" "${BINARY}" "${@}" +QEMU_MODULE_DIR="${MODULE_DIR}" LD_LIBRARY_PATH="${LLP}" "${INTERPRETER}" "${BINARY}" ${BIOS_LINK_PARAMS} "${@}" \ No newline at end of file diff --git a/debian/launcher/rule.bzl b/debian/launcher/rule.bzl index fdc2a436..693ef738 100644 --- a/debian/launcher/rule.bzl +++ b/debian/launcher/rule.bzl @@ -21,6 +21,13 @@ ATTRS = { "env": attr.string_dict( doc = "Environment variables to provide to the launcher. Supports Make function expansions.", ), + "module_dir": attr.string( + doc = "The relative path to the module dir from the binary.", + default = "usr/lib/x86_64-linux-gnu/qemu" + ), + "bios_link_dirs": attr.string_list( + doc = "The relative path to bios directories from the binary", + ), "_llp": attr.label( doc = "The library load path.", providers = [DebianLauncherLibraryPathInfo], @@ -46,18 +53,10 @@ 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) - + bios_link_dirs = ['"{}/{}"'.format(root, path) for path in ctx.attr.bios_link_dirs] + bios_link_dir_string = " ".join(bios_link_dirs) interpreter = ctx.attr._interpreter[DebianLauncherELFInterpreterInfo].path rendered = ctx.actions.declare_file("{}.{}".format(ctx.label.name, ctx.file._template.extension)) @@ -66,6 +65,8 @@ def implementation(ctx): substitutions.add("{{binary}}", "{}/{}".format(root, relative)) substitutions.add("{{interpreter}}", "{}/{}".format(root, interpreter)) substitutions.add("{{llp}}", llp) + substitutions.add("{{module_dir}}", "{}/{}".format(root, ctx.attr.module_dir)) + substitutions.add("{{bios_link_dir_string}}", bios_link_dir_string) ctx.actions.expand_template( output = rendered, template = ctx.file._template, -- GitLab From 70c853499a593325d12e5f350321852671f4fd9c Mon Sep 17 00:00:00 2001 From: Jordan Bonser Date: Thu, 26 Sep 2024 16:11:09 +0100 Subject: [PATCH 13/18] fix: add missin all srcs's --- debian/amd64/qemu-system-arm/BUILD.bazel | 3 ++- debian/amd64/qemu-system-arm/srcs.bzl | 3 +++ debian/arm64/qemu-system-arm/srcs.bzl | 2 ++ 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/debian/amd64/qemu-system-arm/BUILD.bazel b/debian/amd64/qemu-system-arm/BUILD.bazel index 65be1598..b7766a52 100644 --- a/debian/amd64/qemu-system-arm/BUILD.bazel +++ b/debian/amd64/qemu-system-arm/BUILD.bazel @@ -32,7 +32,8 @@ debian_launcher( module_dir = "usr/lib/x86_64-linux-gnu/qemu", bios_link_dirs = [ "usr/share/qemu", - "usr/share/seabios" + "usr/share/seabios", + "usr/lib/ipxe/qemu" ], src = ":unpack", visibility = ["//:__subpackages__"], diff --git a/debian/amd64/qemu-system-arm/srcs.bzl b/debian/amd64/qemu-system-arm/srcs.bzl index cf10ee25..d6860b0e 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/arm64/qemu-system-arm/srcs.bzl b/debian/arm64/qemu-system-arm/srcs.bzl index 55e1acea..53b54a24 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", -- GitLab From 0aa0e9f71fb489205c06d2d3c3aee32800d38308 Mon Sep 17 00:00:00 2001 From: Luke Hackwell Date: Thu, 3 Oct 2024 15:04:53 +0100 Subject: [PATCH 14/18] fix: qemu boots from image target --- debian/amd64/qemu-system-x86/BUILD.bazel | 2 ++ debian/launcher/posix.tmpl.sh | 3 ++- debian/launcher/rule.bzl | 5 +++++ qemu/debian/BUILD.bazel | 3 ++- 4 files changed, 11 insertions(+), 2 deletions(-) diff --git a/debian/amd64/qemu-system-x86/BUILD.bazel b/debian/amd64/qemu-system-x86/BUILD.bazel index c07b17c7..6b52964e 100644 --- a/debian/amd64/qemu-system-x86/BUILD.bazel +++ b/debian/amd64/qemu-system-x86/BUILD.bazel @@ -30,11 +30,13 @@ debian_launcher( 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", "usr/share/seabios", "usr/lib/ipxe/qemu" ], + data = ["//qemu/debian:image"], src = ":unpack", visibility = ["//:__subpackages__"], ) diff --git a/debian/launcher/posix.tmpl.sh b/debian/launcher/posix.tmpl.sh index dcf4e4d0..ec70cb54 100644 --- a/debian/launcher/posix.tmpl.sh +++ b/debian/launcher/posix.tmpl.sh @@ -11,6 +11,7 @@ LLP='{{llp}}' INTERPRETER="{{interpreter}}" MODULE_DIR="{{module_dir}}" BIOS_DIRS_STRING="{{bios_link_dir_string}}" +IMAGE="{{image}}" printf >&2 "'$BIOS_DIRS_STRING'\n\n" @@ -95,4 +96,4 @@ fi # issues where the absolute root path has been baked into the executable. # Run the binary -QEMU_MODULE_DIR="${MODULE_DIR}" LD_LIBRARY_PATH="${LLP}" "${INTERPRETER}" "${BINARY}" ${BIOS_LINK_PARAMS} "${@}" \ No newline at end of file +QEMU_MODULE_DIR="${MODULE_DIR}" LD_LIBRARY_PATH="${LLP}" "${INTERPRETER}" "${BINARY}" ${BIOS_LINK_PARAMS} -drive driver=qcow2,file=${IMAGE} "${@}" \ No newline at end of file diff --git a/debian/launcher/rule.bzl b/debian/launcher/rule.bzl index 693ef738..07db3ca3 100644 --- a/debian/launcher/rule.bzl +++ b/debian/launcher/rule.bzl @@ -28,6 +28,10 @@ ATTRS = { "bios_link_dirs": attr.string_list( doc = "The relative path to bios directories from the binary", ), + "image": attr.label( + doc = "The image to boot", + allow_single_file = True, + ), "_llp": attr.label( doc = "The library load path.", providers = [DebianLauncherLibraryPathInfo], @@ -67,6 +71,7 @@ def implementation(ctx): substitutions.add("{{llp}}", llp) substitutions.add("{{module_dir}}", "{}/{}".format(root, ctx.attr.module_dir)) substitutions.add("{{bios_link_dir_string}}", bios_link_dir_string) + substitutions.add("{{image}}", ctx.file.image.short_path) ctx.actions.expand_template( output = rendered, template = ctx.file._template, diff --git a/qemu/debian/BUILD.bazel b/qemu/debian/BUILD.bazel index 24c2bd7a..e373b085 100644 --- a/qemu/debian/BUILD.bazel +++ b/qemu/debian/BUILD.bazel @@ -6,7 +6,8 @@ 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."), + visibility = ["//debian:__subpackages__"], ) build_test( -- GitLab From acc37b033ce5bd4f30ba458fc73b80f41423bda4 Mon Sep 17 00:00:00 2001 From: Luke Hackwell Date: Mon, 7 Oct 2024 14:52:10 +0100 Subject: [PATCH 15/18] fix: Remove 32 bit emulators --- debian/amd64/qemu-system-arm/BUILD.bazel | 13 ++----------- debian/amd64/qemu-system-x86/BUILD.bazel | 12 ------------ debian/arm64/qemu-system-arm/BUILD.bazel | 13 ++----------- debian/arm64/qemu-system-x86/BUILD.bazel | 13 ++----------- debian/launcher/posix.tmpl.sh | 11 ----------- 5 files changed, 6 insertions(+), 56 deletions(-) diff --git a/debian/amd64/qemu-system-arm/BUILD.bazel b/debian/amd64/qemu-system-arm/BUILD.bazel index b7766a52..41a8895b 100644 --- a/debian/amd64/qemu-system-arm/BUILD.bazel +++ b/debian/amd64/qemu-system-arm/BUILD.bazel @@ -16,25 +16,16 @@ tar_unpack( visibility = ["//debian/qemu-system-aarch64/amd64:__pkg__"], ) -debian_launcher( - name = "qemu-system-arm", - module_dir = "usr/lib/x86_64-linux-gnu/qemu", - bios_link_dirs = [ - "usr/share/qemu", - "usr/share/seabios" - ], - src = ":unpack", - visibility = ["//:__subpackages__"], -) - debian_launcher( name = "qemu-system-aarch64", module_dir = "usr/lib/x86_64-linux-gnu/qemu", + image = "//qemu/debian:image", bios_link_dirs = [ "usr/share/qemu", "usr/share/seabios", "usr/lib/ipxe/qemu" ], + data = ["//qemu/debian:image"], src = ":unpack", visibility = ["//:__subpackages__"], ) diff --git a/debian/amd64/qemu-system-x86/BUILD.bazel b/debian/amd64/qemu-system-x86/BUILD.bazel index 6b52964e..48072687 100644 --- a/debian/amd64/qemu-system-x86/BUILD.bazel +++ b/debian/amd64/qemu-system-x86/BUILD.bazel @@ -15,18 +15,6 @@ tar_unpack( src = ":data.tar.zst", ) -debian_launcher( - name = "qemu-system-i386", - module_dir = "usr/lib/x86_64-linux-gnu/qemu", - bios_link_dirs = [ - "usr/share/qemu", - "usr/share/seabios", - "usr/lib/ipxe/qemu" - ], - src = ":unpack", - visibility = ["//:__subpackages__"], -) - debian_launcher( name = "qemu-system-x86_64", module_dir = "usr/lib/x86_64-linux-gnu/qemu", diff --git a/debian/arm64/qemu-system-arm/BUILD.bazel b/debian/arm64/qemu-system-arm/BUILD.bazel index 1a43c245..b46eb27b 100644 --- a/debian/arm64/qemu-system-arm/BUILD.bazel +++ b/debian/arm64/qemu-system-arm/BUILD.bazel @@ -15,24 +15,15 @@ tar_unpack( src = ":data.tar.zst", ) -debian_launcher( - name = "qemu-system-arm", - module_dir = "usr/lib/aarch64-linux-gnu/qemu", - bios_link_dirs = [ - "usr/share/qemu-firmware", - "usr/share/qemu", - ], - 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-x86/BUILD.bazel b/debian/arm64/qemu-system-x86/BUILD.bazel index 721cf47e..b2effec2 100644 --- a/debian/arm64/qemu-system-x86/BUILD.bazel +++ b/debian/arm64/qemu-system-x86/BUILD.bazel @@ -15,24 +15,15 @@ tar_unpack( src = ":data.tar.zst", ) -debian_launcher( - name = "qemu-system-i386", - module_dir = "usr/lib/x86_64-linux-gnu/qemu", - bios_link_dirs = [ - "usr/share/qemu-firmware", - "usr/share/qemu", - ], - 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 ec70cb54..0269cd8a 100644 --- a/debian/launcher/posix.tmpl.sh +++ b/debian/launcher/posix.tmpl.sh @@ -13,8 +13,6 @@ MODULE_DIR="{{module_dir}}" BIOS_DIRS_STRING="{{bios_link_dir_string}}" IMAGE="{{image}}" -printf >&2 "'$BIOS_DIRS_STRING'\n\n" - # Parsing the bios directories as a space separated string so we can iterate over them # adding the '-L' and realpath to the beginning of the relative paths. # This constructs the full list of -L parameters to be passed to the binary. @@ -26,8 +24,6 @@ do fi done -printf >&2 "'$BIOS_LINK_PARAMS'\n\n" - readonly ROOT BINARY LLP INTERPRETER # Check the root is available @@ -36,13 +32,6 @@ if ! test -d "${ROOT}"; then exit 1 fi -printf >&2 "$(realpath "$ROOT")\n" -printf >&2 "$(realpath "$BINARY")\n" -printf >&2 "$(realpath "$MODULE_DIR")\n" -printf >&2 "$(realpath "$INTERPRETER")\n\n\n" - -printf >&2 ''$LLP'\n\n\n' - # Check the binary is executable if ! test -e "${BINARY}"; then printf >&2 "Binary does not exist: %s\n" "${BINARY}" -- GitLab From 257831744b6f44fd7f86f38c505e1962f1f8b992 Mon Sep 17 00:00:00 2001 From: Luke Hackwell Date: Thu, 10 Oct 2024 15:32:53 +0100 Subject: [PATCH 16/18] fix: Add "args" attr to debian_launcher This enables us to provide arguments which support make function expansions. --- debian/amd64/qemu-system-x86/BUILD.bazel | 17 ++++++++++------- debian/launcher/posix.tmpl.sh | 19 +++---------------- debian/launcher/rule.bzl | 21 +++++---------------- 3 files changed, 18 insertions(+), 39 deletions(-) diff --git a/debian/amd64/qemu-system-x86/BUILD.bazel b/debian/amd64/qemu-system-x86/BUILD.bazel index 48072687..e8c6590c 100644 --- a/debian/amd64/qemu-system-x86/BUILD.bazel +++ b/debian/amd64/qemu-system-x86/BUILD.bazel @@ -17,14 +17,17 @@ tar_unpack( 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", - "usr/share/seabios", - "usr/lib/ipxe/qemu" + 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", ], - data = ["//qemu/debian:image"], src = ":unpack", visibility = ["//:__subpackages__"], ) diff --git a/debian/launcher/posix.tmpl.sh b/debian/launcher/posix.tmpl.sh index 0269cd8a..6137f01b 100644 --- a/debian/launcher/posix.tmpl.sh +++ b/debian/launcher/posix.tmpl.sh @@ -9,22 +9,9 @@ ROOT="{{root}}" BINARY="{{binary}}" LLP='{{llp}}' INTERPRETER="{{interpreter}}" -MODULE_DIR="{{module_dir}}" -BIOS_DIRS_STRING="{{bios_link_dir_string}}" -IMAGE="{{image}}" +ARGS="{{args}}" -# Parsing the bios directories as a space separated string so we can iterate over them -# adding the '-L' and realpath to the beginning of the relative paths. -# This constructs the full list of -L parameters to be passed to the binary. -BIOS_LINK_PARAMS="" -for I in $BIOS_DIRS_STRING -do - if test "$(realpath "$I")"; then - BIOS_LINK_PARAMS=$(printf "%s-L %s " "$BIOS_LINK_PARAMS" "$(realpath "$I")") - fi -done - -readonly ROOT BINARY LLP INTERPRETER +readonly ROOT BINARY LLP INTERPRETER ARGS # Check the root is available if ! test -d "${ROOT}"; then @@ -85,4 +72,4 @@ fi # issues where the absolute root path has been baked into the executable. # Run the binary -QEMU_MODULE_DIR="${MODULE_DIR}" LD_LIBRARY_PATH="${LLP}" "${INTERPRETER}" "${BINARY}" ${BIOS_LINK_PARAMS} -drive driver=qcow2,file=${IMAGE} "${@}" \ No newline at end of file +LD_LIBRARY_PATH="${LLP}" "${INTERPRETER}" "${BINARY}" ${ARGS} "${@}" diff --git a/debian/launcher/rule.bzl b/debian/launcher/rule.bzl index 07db3ca3..0733d305 100644 --- a/debian/launcher/rule.bzl +++ b/debian/launcher/rule.bzl @@ -21,17 +21,6 @@ ATTRS = { "env": attr.string_dict( doc = "Environment variables to provide to the launcher. Supports Make function expansions.", ), - "module_dir": attr.string( - doc = "The relative path to the module dir from the binary.", - default = "usr/lib/x86_64-linux-gnu/qemu" - ), - "bios_link_dirs": attr.string_list( - doc = "The relative path to bios directories from the binary", - ), - "image": attr.label( - doc = "The image to boot", - allow_single_file = True, - ), "_llp": attr.label( doc = "The library load path.", providers = [DebianLauncherLibraryPathInfo], @@ -59,8 +48,9 @@ def implementation(ctx): paths = ctx.attr._llp[DebianLauncherLibraryPathInfo].paths llp = ":".join(paths) - bios_link_dirs = ['"{}/{}"'.format(root, path) for path in ctx.attr.bios_link_dirs] - bios_link_dir_string = " ".join(bios_link_dirs) + + 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)) @@ -69,9 +59,8 @@ def implementation(ctx): substitutions.add("{{binary}}", "{}/{}".format(root, relative)) substitutions.add("{{interpreter}}", "{}/{}".format(root, interpreter)) substitutions.add("{{llp}}", llp) - substitutions.add("{{module_dir}}", "{}/{}".format(root, ctx.attr.module_dir)) - substitutions.add("{{bios_link_dir_string}}", bios_link_dir_string) - substitutions.add("{{image}}", ctx.file.image.short_path) + substitutions.add("{{args}}", args) + ctx.actions.expand_template( output = rendered, template = ctx.file._template, -- GitLab From cb21bb14d8a13c5525e933761624ec9941128b42 Mon Sep 17 00:00:00 2001 From: Luke Hackwell Date: Thu, 10 Oct 2024 15:37:29 +0100 Subject: [PATCH 17/18] fix: revert //qemu/debian:image visibility --- qemu/debian/BUILD.bazel | 1 - 1 file changed, 1 deletion(-) diff --git a/qemu/debian/BUILD.bazel b/qemu/debian/BUILD.bazel index e373b085..afb650e1 100644 --- a/qemu/debian/BUILD.bazel +++ b/qemu/debian/BUILD.bazel @@ -7,7 +7,6 @@ alias( "@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."), - visibility = ["//debian:__subpackages__"], ) build_test( -- GitLab From a494b8274fe9c89935651d88d41baca42a9bd2b7 Mon Sep 17 00:00:00 2001 From: Luke Hackwell Date: Thu, 10 Oct 2024 16:04:49 +0100 Subject: [PATCH 18/18] fix: Update //debian/amd64/qemu-system-arm:qemu-system-aarch64 to work with args --- debian/amd64/qemu-system-arm/BUILD.bazel | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/debian/amd64/qemu-system-arm/BUILD.bazel b/debian/amd64/qemu-system-arm/BUILD.bazel index 41a8895b..862cafbf 100644 --- a/debian/amd64/qemu-system-arm/BUILD.bazel +++ b/debian/amd64/qemu-system-arm/BUILD.bazel @@ -18,14 +18,17 @@ tar_unpack( debian_launcher( name = "qemu-system-aarch64", - module_dir = "usr/lib/x86_64-linux-gnu/qemu", - image = "//qemu/debian:image", - bios_link_dirs = [ - "usr/share/qemu", - "usr/share/seabios", - "usr/lib/ipxe/qemu" + 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", ], - data = ["//qemu/debian:image"], src = ":unpack", visibility = ["//:__subpackages__"], ) -- GitLab