diff --git a/build.containerfile b/build.containerfile deleted file mode 100755 index a6a4b45..0000000 --- a/build.containerfile +++ /dev/null @@ -1,30 +0,0 @@ -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 -RUN install -m 6755 sudo /usr/local/bin/sudo - -FROM $arch/$image -WORKDIR /tmp -COPY debian-src.sources /etc/apt/sources.list.d/ -COPY local-pkgs.list /etc/apt/sources.list.d/ -COPY local-pkgs /etc/apt/preferences.d/ -RUN mkdir /pkgs && touch /pkgs/Packages -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) -RUN 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 -COPY build_source /usr/local/bin/ -COPY build_indep /usr/local/bin/ -COPY build_archdep /usr/local/bin/ -COPY build /usr/local/bin/ -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 diff --git a/build b/container/bin/build similarity index 100% rename from build rename to container/bin/build diff --git a/build_archdep b/container/bin/build_archdep similarity index 100% rename from build_archdep rename to container/bin/build_archdep diff --git a/build_indep b/container/bin/build_indep similarity index 100% rename from build_indep rename to container/bin/build_indep diff --git a/build_source b/container/bin/build_source similarity index 100% rename from build_source rename to container/bin/build_source diff --git a/container/build.containerfile b/container/build.containerfile new file mode 100755 index 0000000..5589788 --- /dev/null +++ b/container/build.containerfile @@ -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 diff --git a/container/crossbuild.containerfile b/container/crossbuild.containerfile new file mode 100644 index 0000000..5af43de --- /dev/null +++ b/container/crossbuild.containerfile @@ -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 diff --git a/mini_sudo.c b/container/mini_sudo.c similarity index 100% rename from mini_sudo.c rename to container/mini_sudo.c diff --git a/pkgs b/container/pkgs similarity index 100% rename from pkgs rename to container/pkgs diff --git a/setup_native b/container/setup_native similarity index 100% rename from setup_native rename to container/setup_native diff --git a/crossbuild.containerfile b/crossbuild.containerfile deleted file mode 100644 index bee134e..0000000 --- a/crossbuild.containerfile +++ /dev/null @@ -1,42 +0,0 @@ -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 -RUN install -m 6755 sudo /usr/local/bin/sudo - -FROM $native_arch/$image AS native -ARG gnu_arch=aarch64 -WORKDIR /tmp -COPY pkgs ./ -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 }') -COPY setup_native ./ -RUN ./setup_native export $(sed 's/\$arch/'"$gnu_arch"'/' pkgs | awk '{ print $NF }') - -FROM $target_arch/$image -WORKDIR /tmp -COPY debian-src.sources /etc/apt/sources.list.d/ -COPY local-pkgs.list /etc/apt/sources.list.d/ -COPY local-pkgs /etc/apt/preferences.d/ -RUN mkdir /pkgs && touch /pkgs/Packages -COPY pkgs ./ -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) -RUN apt-mark hold $(awk '{ print $1 }' pkgs) -COPY --from=native /native /native -COPY setup_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 -COPY build_source /usr/local/bin/ -COPY build_indep /usr/local/bin/ -COPY build_archdep /usr/local/bin/ -COPY build /usr/local/bin/ -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 diff --git a/debian-src.sources b/debian-src.sources deleted file mode 100644 index 0fe7d16..0000000 --- a/debian-src.sources +++ /dev/null @@ -1,4 +0,0 @@ -Types: deb-src -URIs: http://deb.debian.org/debian -Suites: bullseye bookworm trixie sid -Components: main diff --git a/local-pkgs b/local-pkgs deleted file mode 100644 index d711250..0000000 --- a/local-pkgs +++ /dev/null @@ -1,3 +0,0 @@ -Package: * -Pin: origin "" -Pin-Priority: 900 diff --git a/local-pkgs.list b/local-pkgs.list deleted file mode 100644 index 09f19db..0000000 --- a/local-pkgs.list +++ /dev/null @@ -1 +0,0 @@ -deb [trusted=yes] file:/pkgs / diff --git a/sudo b/sudo deleted file mode 100755 index 4cc412d..0000000 Binary files a/sudo and /dev/null differ