138 lines
3.9 KiB
Docker
138 lines
3.9 KiB
Docker
FROM localhost/notwa-util AS downloader
|
|
|
|
# MAIN: https://www.perl.org/
|
|
# REPO: https://github.com/Perl/perl5
|
|
# FORK: https://github.com/G4Vi/perl5/tree/cosmo
|
|
ARG PERL_COMMIT=66baebd8320a90ddf2c90de14b83f7eee4f6b143
|
|
ARG PERL_SHA256=0e6731efb5f25589116340b4e861abd43fb47520669fe903569b1489339dcddb
|
|
# MAIN: https://computoid.com/APPerl/
|
|
# REPO: https://github.com/G4Vi/Perl-Dist-APPerl
|
|
|
|
# MAIN: https://metacpan.org/pod/perltidy
|
|
# REPO: https://github.com/perltidy/perltidy
|
|
ARG PERLTIDY_VERSION=20220613
|
|
ARG PERLTIDY_SHA256=50496a6952904ef28f495919fc0a67801a63c87779c61308ce1ca5b32467c5d4
|
|
|
|
RUN --mount=type=cache,id=common,target=/media/common,sharing=locked \
|
|
--mount=type=tmpfs,target=/tmp : \
|
|
&& acquire from=github repo=G4Vi/perl5 dest=/perl env=PERL \
|
|
\
|
|
&& name=perltidy \
|
|
&& remote_fn="Perl-Tidy-$PERLTIDY_VERSION.tar.gz" \
|
|
&& export local_fn="$name-$PERLTIDY_VERSION.tar.gz" \
|
|
&& export remote_url="https://cpan.metacpan.org/authors/id/S/SH/SHANCOCK/$remote_fn" \
|
|
&& export dest=/$name \
|
|
&& export sha256="$PERLTIDY_SHA256" \
|
|
&& acquire \
|
|
;
|
|
|
|
FROM localhost/cosmo-base AS builder
|
|
|
|
COPY --from=downloader /perl /perl
|
|
RUN : \
|
|
&& cd cosmopolitan \
|
|
&& . ./env \
|
|
&& a="dist/$flavor" \
|
|
&& mkdir o o/ape o/ape/public o/libc o/libc/crt \
|
|
&& cp -t o/ape \
|
|
"$a/ape-copy-self.o" \
|
|
"$a/ape-no-modify-self.o" \
|
|
"$a/ape.elf" \
|
|
"$a/ape.lds" \
|
|
"$a/ape.o" \
|
|
&& cp -t o/ape/public \
|
|
"$a/public/ape.lds" \
|
|
&& cp -t o/libc/crt \
|
|
"$a/crt.o" \
|
|
&& cp -t o \
|
|
"$a/cosmopolitan.a" \
|
|
"$a/cosmopolitan.h" \
|
|
\
|
|
&& tar zxf dist/headers.tar.gz \
|
|
\
|
|
&& for f in \
|
|
bin/make.com \
|
|
bin/unzip.com \
|
|
bin/zip.com \
|
|
;do : \
|
|
&& cp -- "$f" /a.out \
|
|
&& bin/ape bin/assimilate.com /a.out \
|
|
&& install -m0755 /a.out "/usr/bin/$(basename "${f%.com}")" \
|
|
|| exit \
|
|
;done \
|
|
\
|
|
&& rm /usr/bin/strings \
|
|
&& for f in gcc/bin/* \
|
|
;do : \
|
|
&& g="$(basename "$f")" \
|
|
&& ln -s "$(realpath "$f")" "/usr/bin/${g#x86_64-linux-musl-}" \
|
|
|| exit \
|
|
;done \
|
|
;
|
|
|
|
WORKDIR perl
|
|
|
|
COPY --chmod=0755 --from=localhost/notwa-util /nu/shed /usr/bin/
|
|
RUN : \
|
|
&& shed hints/cosmo.sh '/x86_64-linux-musl/d' \
|
|
&& shed Makefile.SH 's/.*-musl-objcopy/\tobjcopy/g' \
|
|
\
|
|
&& COSMO_MODE= COSMO_REPO=/cosmopolitan sh Configure -d -e \
|
|
-Dprefix=/zip \
|
|
-Dusedevel \
|
|
-Uversiononly \
|
|
-Doptimize=-Os \
|
|
-Dmyhostname=cosmo \
|
|
-Dmydomain=invalid \
|
|
-Dcf_by=cosmo \
|
|
;
|
|
|
|
RUN make -j2
|
|
|
|
RUN make -j2 minitest devtty=/dev/zero | tee minitest_results.txt
|
|
|
|
RUN : \
|
|
&& mkdir /perl/cosmo \
|
|
&& mkdir /perl/cosmo/o \
|
|
&& mkdir /perl/cosmo/o/tmp \
|
|
&& cp /perl/perl.com /perl/cosmo/o/tmp/perl.com \
|
|
&& make DESTDIR=/perl/cosmo/o/tmp install.perl \
|
|
;
|
|
RUN : \
|
|
&& cd /perl/cosmo/o/tmp/zip \
|
|
&& rm bin/perl bin/perl5.36.0 \
|
|
&& find lib -name '*.a' -delete \
|
|
&& find lib -name '*.h' -delete \
|
|
&& find -name '*.pod' -delete \
|
|
&& cp ../perl.com ../perl.com.bak \
|
|
&& chmod u+w ../perl.com \
|
|
&& zip -qr ../perl.com lib \
|
|
&& mv ../perl.com ../../perl.com \
|
|
;
|
|
COPY --from=downloader /perltidy /perltidy
|
|
RUN : \
|
|
&& cd /perltidy \
|
|
&& /perl/cosmo/o/perl.com pm2pl \
|
|
&& mv perltidy-*.pl /perl/perltidy.pl \
|
|
&& cd /perl/cosmo/o/tmp/zip \
|
|
&& find -type f -name '*.pm' -exec \
|
|
/cosmopolitan/o/ape/ape.elf ../../perl.com /perl/perltidy.pl \
|
|
--mangle --delete-all-comments --backup-and-modify-in-place --backup-file-extension=/ {} \
|
|
+ \
|
|
;
|
|
RUN : \
|
|
&& cd /perl/cosmo/o/tmp/zip \
|
|
&& cp ../perl.com.bak ../perl.com \
|
|
&& chmod u+w ../perl.com \
|
|
&& zip -qr ../perl.com bin \
|
|
&& zip -qr ../perl.com lib \
|
|
&& mv ../perl.com ../../perl.com \
|
|
;
|
|
|
|
FROM scratch AS runner
|
|
COPY --chmod=0755 --from=localhost/notwa-util /nu/busybox /bin/busybox
|
|
COPY --chmod=0755 --from=builder /cosmopolitan/bin/ape /bin/ape
|
|
COPY --chmod=0755 --from=builder /perl/cosmo/o/perl.com /bin/perl.com
|
|
COPY --chmod=0755 --from=builder /perl/perl.elf /bin/perl.com.dbg
|
|
COPY --from=builder /perl/minitest_results.txt /minitest_results.txt
|
|
ENTRYPOINT ["/bin/ape", "/bin/perl.com"]
|