stargazing/notwa-util/cosmopolitan-install11
2023-09-07 19:05:00 -07:00

59 lines
2.6 KiB
Plaintext
Executable File

#!/usr/bin/false
# TODO: include these headers? https://0x0.st/Hcdi.c
if [ ! -e /cosmopolitan-install.done ]; then
: \
&& cd /root/cosmopolitan \
&& . ./env \
&& export mode \
\
&& { [ ! -d dist ] || rm -r dist ;} \
&& mkdir -p "dist/$flavor" \
&& expand cp -int "dist/$flavor" \
a//ape-copy-self.o a//ape-no-modify-self.o a//ape.elf \
a//ape.lds a//ape.macho a//ape.o \
o//cosmopolitan.a o//libc/crt/crt.o o/cosmopolitan.h \
\
&& install -m0755 "dist/$flavor/ape.elf" /usr/bin/ape \
&& install -m0755 -t /usr/bin bin/apecopy bin/cosmocc bin/cosmoc++ \
&& find libc -name '*.h' >headers.txt \
&& expand tar zcf /tmp/headers.tar.gz -T headers.txt \
libc/integral T//gdtoa/gdtoa.h T//getopt/long1.h \
T//getopt/long2.h T//linenoise/linenoise.h T//musl/crypt.h \
T//musl/fnmatch.h T//musl/lockf.h T//musl/passwd.h \
T//musl/rand48.h T//musl/tempnam.h T//regex/regex.h \
T//zlib/zconf.h T//zlib/zlib.h \
\
&& { ! [ -d "$COSMO" ] || rm -r "$COSMO" ;} \
&& mkdir -p "$COSMO" /tmp/bin \
&& find o -name '*.sym' -delete \
&& find o -name 'aarch64-linux-musl*' -exec rm -r '{}' + \
&& dedupe o/third_party/gcc "$COSMO/gcc/" \
bin/x86_64-linux-musl-gcc \
bin/x86_64-linux-musl-g++ \
bin/x86_64-linux-musl-ld.bfd \
&& dedupe dist "$COSMO/dist/" "$flavor/cosmopolitan.h" \
&& expand cp -int /tmp/bin \
t//make/make.com t//unzip/unzip.com t//zip/zip.com \
b//ar.com b//chmod.com b//cocmd.com \
b//compile.com b//cp.com b//echo.com \
b//fixupobj.com b//gzip.com b//mkdeps.com \
b//mkdir.com b//package.com b//pwd.com \
b//rm.com b//rollup.com b//symtab.com \
b//touch.com b//unbundle.com b//zipcopy.com \
b//zipobj.com \
&& dedupe /tmp/bin "$COSMO/bin/" \
&& cp "dist/$flavor/ape.elf" "$COSMO/bin/ape" \
&& cp /root/cosmopolitan/env "$COSMO/env" \
\
&& mkdir -p "$COSMO/lib" \
&& for lib in c dl gcc_s m pthread resolv rt dl z stdc++ \
;do : \
&& printf '\041\074\141\162\143\150\076\012' >"$COSMO/lib/lib$lib.a" \
;done \
\
&& rm -r /root/cosmopolitan/dist \
&& tar zxf "/tmp/headers.tar.gz" -C "$COSMO" \
&& touch /cosmopolitan-install.done \
|| exit $?
fi