Skip to content

Commit

Permalink
restructure
Browse files Browse the repository at this point in the history
  • Loading branch information
nkraetzschmar committed Dec 5, 2023
1 parent c3e6abb commit de4a5c9
Show file tree
Hide file tree
Showing 15 changed files with 75 additions and 80 deletions.
30 changes: 0 additions & 30 deletions build.containerfile

This file was deleted.

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
32 changes: 32 additions & 0 deletions container/build.containerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
ARG image=debian:testing
ARG arch=amd64

FROM $arch/$image AS mini_sudo
WORKDIR /tmp
RUN apt-get update \
&& DEBIAN_FRONTEND=noninteractive apt-get install --no-install-recommends -y gcc libc-dev
COPY mini_sudo.c ./
RUN gcc -Wall -Werror -static -o sudo mini_sudo.c \
&& install -m 6755 sudo /usr/local/bin/sudo

FROM $arch/$image
WORKDIR /tmp
COPY bin /usr/local/bin
RUN mkdir /pkgs \
&& touch /pkgs/Packages \
&& echo 'deb [trusted=yes] file:/pkgs /' >> /etc/apt/sources.list \
&& echo -e 'Package: *\nPin: origin ""\nPin-Priority: 900' > /etc/apt/preferences.d/local-pkgs
COPY pkgs ./
RUN apt-get update \
&& DEBIAN_FRONTEND=noninteractive apt-get install --no-install-recommends -y build-essential ca-certificates debhelper devscripts git sudo yq $(awk '{ print $1 }' pkgs) \
&& apt-mark hold $(awk '{ print $1 }' pkgs)
RUN gcc --print-search-dir \
&& echo 'int main() { return 0; }' > main.c \
&& gcc -o main main.c \
&& ./main
RUN find /tmp -mindepth 1 -delete
COPY --from=mini_sudo /usr/local/bin/sudo /usr/local/bin/sudo
RUN groupadd dev && useradd -m -g dev dev
USER dev
RUN mkdir /home/dev/work
WORKDIR /home/dev/work
43 changes: 43 additions & 0 deletions container/crossbuild.containerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
ARG image=debian:testing
ARG native_arch=amd64
ARG target_arch=arm64v8

FROM $native_arch/$image AS mini_sudo
WORKDIR /tmp
RUN apt-get update \
&& DEBIAN_FRONTEND=noninteractive apt-get install --no-install-recommends -y gcc libc-dev
COPY mini_sudo.c ./
RUN gcc -Wall -Werror -static -o sudo mini_sudo.c \
&& install -m 6755 sudo /usr/local/bin/sudo

FROM $native_arch/$image AS native
ARG gnu_arch=aarch64
WORKDIR /tmp
COPY pkg setup_native ./
RUN apt-get update \
&& DEBIAN_FRONTEND=noninteractive apt-get install --no-install-recommends -y bbe patchelf $(sed 's/\$arch/'"$gnu_arch"'/' pkgs | awk '{ print $NF }') \
&& ./setup_native export $(sed 's/\$arch/'"$gnu_arch"'/' pkgs | awk '{ print $NF }')

FROM $target_arch/$image
WORKDIR /tmp
COPY bin /usr/local/bin
RUN mkdir /pkgs \
&& touch /pkgs/Packages \
&& echo 'deb [trusted=yes] file:/pkgs /' >> /etc/apt/sources.list \
&& echo -e 'Package: *\nPin: origin ""\nPin-Priority: 900' > /etc/apt/preferences.d/local-pkgs
COPY pkgs setup_native ./
RUN apt-get update \
&& DEBIAN_FRONTEND=noninteractive apt-get install --no-install-recommends -y build-essential ca-certificates debhelper devscripts git yq $(awk '{ print $1 }' pkgs) \
&& apt-mark hold $(awk '{ print $1 }' pkgs)
COPY --from=native /native /native
RUN [ "/native/bash", "-c", "PATH=/native:$PATH ./setup_native import $(awk '{ print $1 }' pkgs)" ]
RUN gcc --print-search-dir \
&& echo 'int main() { return 0; }' > main.c \
&& gcc -o main main.c \
&& ./main
RUN find /tmp -mindepth 1 -delete
COPY --from=mini_sudo /usr/local/bin/sudo /usr/local/bin/sudo
RUN groupadd dev && useradd -m -g dev dev
USER dev
RUN mkdir /home/dev/work
WORKDIR /home/dev/work
File renamed without changes.
File renamed without changes.
File renamed without changes.
42 changes: 0 additions & 42 deletions crossbuild.containerfile

This file was deleted.

4 changes: 0 additions & 4 deletions debian-src.sources

This file was deleted.

3 changes: 0 additions & 3 deletions local-pkgs

This file was deleted.

1 change: 0 additions & 1 deletion local-pkgs.list

This file was deleted.

Binary file removed sudo
Binary file not shown.

0 comments on commit de4a5c9

Please sign in to comment.