99 lines
3.8 KiB
Docker
99 lines
3.8 KiB
Docker
ARG CC=cosmocc CFLAGS="-fdiagnostics-color=always -Os -g -Wall -Wextra -Wwrite-strings -Wno-unused"
|
|
FROM localhost/notwa-util AS downloader
|
|
|
|
# MAIN: https://nullprogram.com/blog/2019/03/22/
|
|
# REPO: https://github.com/skeeto/endlessh
|
|
ARG ENDLESSH_COMMIT=dfe44eb2c5b6fc3c48a39ed826fe0e4459cdf6ef
|
|
ARG ENDLESSH_SHA256=c8989988af0a8c848d1a4979962f008c504a12ed6fe6a12e032c37feaa0ae5f8
|
|
|
|
# MAIN: n/a
|
|
# REPO: https://github.com/leahneukirchen/lr
|
|
ARG LR_COMMIT=5af9b79e4ecd07a600ded1a801023536cde97f95
|
|
ARG LR_SHA256=3901287cdcf09d0d8f77f8aaa19ca24e9a873d904e201ab8e7bf102426607dcc
|
|
|
|
# MAIN: n/a
|
|
# REPO: https://github.com/leahneukirchen/xe
|
|
ARG XE_COMMIT=8a2a4899769335bc14c62aef12cdf26f2f487f2a
|
|
ARG XE_SHA256=f1ac997912c9be92a74a67a766dde74d1f9b6b20e48d7c7e71598ad4b787b37d
|
|
|
|
# MAIN: http://selfie.cs.uni-salzburg.at/
|
|
# REPO: https://github.com/cksystemsteaching/selfie
|
|
ARG SELFIE_COMMIT=f34e6136930b29eb7401c9e56b1f878251206998
|
|
ARG SELFIE_SHA256=e20a04a0ffb5262c49eea1e025fbe2991370d6e6131ae99b2c36ccc5f8606d5e
|
|
|
|
# MAIN: n/a
|
|
# REPO: https://github.com/atomicobject/heatshrink
|
|
ARG HEATSHRINK_COMMIT=7d419e1fa4830d0b919b9b6a91fe2fb786cf3280
|
|
ARG HEATSHRINK_SHA256=b18a1b7ad6f51eac7ac1a81ca072703bd21d6d8727c05cd505843643705af65d
|
|
|
|
RUN --mount=type=cache,id=common,target=/media/common,sharing=locked \
|
|
--mount=type=tmpfs,target=/tmp : \
|
|
&& acquire from=github repo=skeeto/endlessh dest=/endlessh env=ENDLESSH \
|
|
&& acquire from=github repo=leahneukirchen/lr dest=/lr env=LR \
|
|
&& acquire from=github repo=leahneukirchen/xe dest=/xe env=XE \
|
|
&& acquire from=github repo=cksystemsteaching/selfie dest=/selfie env=SELFIE \
|
|
&& acquire from=github repo=atomicobject/heatshrink dest=/heatshrink env=HEATSHRINK \
|
|
;
|
|
|
|
FROM localhost/cosmo-base AS mini
|
|
RUN tar zxf /cosmopolitan/dist/headers.tar.gz -C /cosmopolitan
|
|
COPY --chmod=0755 --from=localhost/notwa-util /nu/ /usr/bin/
|
|
WORKDIR /o
|
|
|
|
FROM mini AS mini_endlessh
|
|
COPY --from=downloader /endlessh /o
|
|
ARG CC CFLAGS
|
|
RUN : \
|
|
&& shed endlessh.c \
|
|
's/\bINET6_ADDRSTRLEN\b/65/g' \
|
|
'/\bswitch (errno) {/,/default:/s/\bcase \([A-Z]\+\):/} else if (errno == \1) {/g' \
|
|
'/\bswitch (errno) {/,/default:/s/default\:/} else {/' \
|
|
's/\bswitch (errno) {/if (0) {/' \
|
|
'/ENDLESSH_VERSION/i\static const struct in6_addr in6addr_any = {0};' \
|
|
's/int fd = accept(server, 0, 0);/struct sockaddr_in dummy1; unsigned int dummy2 = sizeof(dummy1); int fd = accept(server, (struct sockaddr *)\&dummy1, \&dummy2);/' \
|
|
&& ofc endlessh.c \
|
|
;
|
|
|
|
FROM mini AS mini_lr
|
|
COPY --from=downloader /lr /o
|
|
COPY lr.patch /o/
|
|
ARG CC CFLAGS
|
|
RUN : \
|
|
&& /usr/bin/busybox patch -p1 -i lr.patch \
|
|
&& shed lr.c \
|
|
'/_GNU_SOURCE/a\\#include "libc/dce.h"' \
|
|
's/\bnlink_t\b/uint32_t/g' \
|
|
's/\bdefined(__/&sometimes_/g' \
|
|
's/\b__linux__\b/__sometimes_linux__/g' \
|
|
'/#warning fstype/d' \
|
|
&& ofc lr.c \
|
|
;
|
|
|
|
FROM mini AS mini_xe
|
|
COPY --from=downloader /xe /o
|
|
ARG CC CFLAGS
|
|
RUN ofc xe.c
|
|
|
|
FROM mini AS mini_selfie
|
|
COPY --from=downloader /selfie /o
|
|
ARG CC CFLAGS
|
|
RUN shed selfie.c '/\bPAGESIZE\b/i\\#undef PAGESIZE' && ofc selfie.c
|
|
|
|
FROM mini AS mini_heatshrink
|
|
COPY --from=downloader /heatshrink /o
|
|
ARG CC CFLAGS
|
|
RUN : \
|
|
&& shed heatshrink.c '/encoder\.h/a\\#include "heatshrink_encoder.c"' \
|
|
&& shed heatshrink.c '/decoder\.h/a\\#include "heatshrink_decoder.c"' \
|
|
&& shed heatshrink_encoder.c 's/\b\(output_info\|st_yield_literal\)\b/&_e/g' \
|
|
&& shed heatshrink_decoder.c 's/\b\(output_info\|st_yield_literal\)\b/&_d/g' \
|
|
&& CFLAGS="$CFLAGS -Wno-implicit-fallthrough" ofc heatshrink.c \
|
|
;
|
|
|
|
FROM localhost/rescue AS runner
|
|
COPY --chmod=0755 --from=mini_endlessh /o/*.com /o/*.com.dbg /bin/
|
|
COPY --chmod=0755 --from=mini_heatshrink /o/*.com /o/*.com.dbg /bin/
|
|
COPY --chmod=0755 --from=mini_lr /o/*.com /o/*.com.dbg /bin/
|
|
COPY --chmod=0755 --from=mini_selfie /o/*.com /o/*.com.dbg /bin/
|
|
COPY --chmod=0755 --from=mini_xe /o/*.com /o/*.com.dbg /bin/
|
|
ENTRYPOINT ["/bin/busybox", "sh"]
|