Skip to content

Commit

Permalink
init
Browse files Browse the repository at this point in the history
  • Loading branch information
nkraetzschmar committed Oct 9, 2023
0 parents commit 410c33a
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 0 deletions.
16 changes: 16 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
on: push
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- run: |
podman build --squash-all -t "ghcr.io/${{ github.repository }}" .
podman login -u token -p "${{ github.token }}" ghcr.io
podman push "ghcr.io/${{ github.repository }}"
test:
needs: build
runs-on: ubuntu-latest
steps:
- run: sudo podman run --privileged "ghcr.io/${{ github.repository }}"
- run: podman run arm64v8/debian true
11 changes: 11 additions & 0 deletions Containerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
FROM debian:testing AS build
RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends build-essential ca-certificates git libglib2.0-dev ninja-build pkg-config python3 python3-venv
RUN git clone --depth 1 https://gitlab.com/qemu-project/qemu.git
RUN cd qemu && mkdir build && cd build && ../configure --target-list=aarch64-linux-user --static --disable-pie && make -j $(nproc) && cp qemu-aarch64 /aarch64-binfmt-P
COPY register.c register.c
RUN gcc -Wall -Wextra -Werror -static -o /register-aarch64-binfmt-P register.c

FROM scratch
COPY --from=build /aarch64-binfmt-P /aarch64-binfmt-P
COPY --from=build /register-aarch64-binfmt-P /register-aarch64-binfmt-P
CMD [ "/register-aarch64-binfmt-P" ]
4 changes: 4 additions & 0 deletions include
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
usr/bin/dd
usr/bin/qemu-aarch64-static
usr/lib/binfmt.d/qemu-aarch64.conf
usr/libexec/qemu-binfmt/aarch64-binfmt-P
26 changes: 26 additions & 0 deletions register.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#include <fcntl.h>
#include <unistd.h>
#include <err.h>
#include <stddef.h>

#include <sys/mount.h>
#include <sys/stat.h>

int main()
{
int fd;

if (mkdir("/binfmt_misc", 0700) == -1) err(1, "mkdir /binfmt_misc");
if (mount("", "/binfmt_misc", "binfmt_misc", 0, 0) == -1) err(1, "mount binfmt_misc");

if ((fd = open("/binfmt_misc/register", O_WRONLY)) == -1) err(1, "open /binfmt_misc/register");
char str[] = ":qemu-aarch64:M::\\x7f\\x45\\x4c\\x46\\x02\\x01\\x01\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x02\\x00\\xb7\\x00:\\xff\\xff\\xff\\xff\\xff\\xff\\xff\\x00\\xff\\xff\\xff\\xff\\xff\\xff\\xff\\xff\\xfe\\xff\\xff\\xff:/aarch64-binfmt-P:POCF";
size_t len = sizeof(str) - 1;
if (write(fd, str, len) != (ssize_t) len) err(1, "write /binfmt_misc/register");

close(fd);

umount("/binfmt_misc");
rmdir("/binfmt_misc");
return 0;
}

0 comments on commit 410c33a

Please sign in to comment.