Skip to content
Verified Commit b07e4e17 authored by Matthew Clarkson's avatar Matthew Clarkson Committed by Matthew Clarkson
Browse files

feat: add `debian_launcher`/`patchelf_unpack` rules

Use `patchelf_unpack` to unpack the downloaded packages and patch the ELF interpreter path:

```py
patchelf_unpack(
    name = "patched",
    # `rules_distroless#apt` extension is *highly* recommended
    srcs = ["@debian-bookworm-qemu//:packages"],
    filters = [
        "usr/share/doc/**",       # No need to unpack documentation
        "lib64/ld-linux-*.so.?",  # Remove dangling symlink
    ],
)
```

Use `patchelf_launcher` to launch a binary from the unpacked directory:

```py
patchelf_launcher(
    name = "qemu-system-x86_64",
    srcs = [
        ":patched",
        "@rules_patchelf//patchelf/launcher/elf/interpreter/debian",
        "@rules_patchelf//patchelf/launcher/library/path/debian",
    ],
    env = {
        "TMPDIR": "./tmp",
    },
)
```

Run the binary:

```console
$ bazelisk run -- :qemu-system-x86_64 --version
QEMU emulator version 7.2.13 (Debian 1:7.2+dfsg-7+deb12u7)
Copyright (c) 2003-2022 Fabrice Bellard and the QEMU Project developers
```

Closes rfc#1
parents
Loading
Loading
Loading
Pipeline #22270 failed with stages
in 2 minutes and 50 seconds