#!/bin/sh export PATH=$PATH:/usr/sbin:/usr/bin:/sbin:/bin compile_packages (){ #for pkg in ${packages[@]};do n_packages=$(echo $packages | tr ' ' '\n') for pkg in $n_packages; do echo "Going to build: $pkg" cd /iglunix/pkgs/${pkg}/ ../../iglupkg.sh || exit 1 tar -xf out/${pkg}.*.tar.xz -C / || exit 1 tar -xf out/${pkg}-dev.*.tar.xz -C / 2> /dev/null tar -xf out/${pkg}-doc.*.tar.xz -C / 2> /dev/null done } #need to replace ln from busybox by toybox rm /bin/ln /bin/toybox ln -s /bin/toybox /bin/ln echo "replaced ln from busybox by toybox" ln -s /usr/bin/ld.lld /usr/bin/ld echo "Linked ld.lld (from llvm) to ld" ln -s /bin/busybox /usr/bin/fdisk echo "Added fdisk from busybox" mkdir /etc touch /etc/passwd echo "root:x:0:0::/root:/bin/sh" > /etc/passwd touch /etc/group echo "root:x:0:root" > /etc/group #---- # Building spooky #---- #--------- # Stage 1 #--------- #Stub lex printf "#!/bin/sh\necho lex go brr\n" > /usr/bin/lex chmod +x /usr/bin/lex #Yes om4 has to be build twice packages="mksh bmake gmake byacc om4 om4" compile_packages #--------- # Stage 2 #--------- rm /usr/bin/lex packages="flex zlib expat" compile_packages #Samurai|| exit 1 cd /iglunix/pkgs/samurai cd src/samurai-*/ clang *.c -o samu cp /iglunix/pkgs/samurai/out/samurai/bin/samu /usr/bin cd /iglunix/pkgs/samurai ../../iglupkg.sh rm /usr/bin/samu tar -xf out/samurai.*.tar.xz -C / # Libre ssl, a slight problem # lible ssl needs cmake, but cmake needs libre ssl. :( # and rsync needs cmake cd /iglunix/pkgs/libressl cd src/libressl-*/ ./configure --prefix=/usr && make -j12 && make install packages="rsync" compile_packages # Build the headers of linux. # No other solutions don't work well/at all. # NOTE: we need to clean up after ourselves. cd /iglunix/pkgs/linux cd src/linux-*/ gmake CC=cc CXX=c++ HOSTCC=cc HOSTCXX=c++ LEX=lex YACC=yacc LLVM_IAS=1 gmake CC=cc CXX=c++ HOSTCC=cc HOSTCXX=c++ YACC=yacc LLVM_IAS=1 INSTALL_HDR_PATH=/usr headers_install rm -r ./src ./out cd /iglunix/pkgs/cmake cd src/cmake-*/ ./bootstrap \ --prefix=/usr \ --mandir=/usr/share/man \ --datadir=/usr/share/cmake \ --docdir=/usr/share/doc/cmake \ --generator=Ninja \ --no-system-libs cd ../.. #NOTE: we recompile mksh, because now we have curl and it can download the man page! packages="cmake libressl busybox toybox libffi python ca-certificates curl zlib expat kati gettext-tiny git netbsd-curses kakoune mksh linux iglunix llvm musl e2fsprogs nasm util-linux tiny-linux-bootloader" compile_packages echo "finished" exit #-------------- #-------------- # GARBAGE #-------------- #-------------- # om4 and flex have a circular dependency # NOTE: THIS DOES NOT WORK # The lex file in om4 is compiled on the host :( # Solution: see prepare_chroot_iglunix # PLAN: # build https://github.com/ibara/baseutils lex # build om4 # b uild flex # rm baseutils lex cd /iglunix/tmp_pkgs/baseutils make -C libopenbsd make -C lex cp lex /usr/bin # Build m4 # bulid flex #make sure to overwrite /usr/bin/lex