galeb

Једноставна статичка дистрибуција заснована на musl-у
Дневник | Датотеке | Референце | ПРОЧИТАЈМЕ | ЛИЦЕНЦА

чување 96fffcff5ac7fc98cf5d0f6bc2a65ffab6ef0107
родитељ fe7ee8219bc46ff7e44e0650928ab6a840e8b0c3
Аутор: Страхиња Радић <contact@strahinja.org>
Датум:   Tue,  5 Jul 2022 20:04:29 +0200

Final system development; rudimentary package system

Signed-off-by: Страхиња Радић <contact@strahinja.org>

Diffstat:
M01-cross.sh | 623++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-----------------
M02-prep-chroot.sh | 28++++++++++++++++++++--------
M03-chroot.sh | 177+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Mlib/env.sh | 15+++++++++------
Mlib/fun.sh | 142+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++----------
Apat-11.2.1/musl-alpine/handle-aux-at_base.patch | 46++++++++++++++++++++++++++++++++++++++++++++++
Apat-11.2.1/musl-mlfs/change-scheduler-functions-Linux-compatib.patch | 52++++++++++++++++++++++++++++++++++++++++++++++++++++
Apat-11.2.1/musl-mlfs/fix-utmp-wtmp-paths.patch | 29+++++++++++++++++++++++++++++
Apat-11.2.1/musl-mlfs/i686-fix-rounding.patch | 12++++++++++++
измењених датотека: 9, додавања: 962(+), брисања: 162(-)

diff --git a/01-cross.sh b/01-cross.sh @@ -39,6 +39,9 @@ fi cd_or_fail ${G_SRC} +msg info "Copying patches to %s" ${G_PAT} +cp_or_fail -r ${WD}/pat/* ${G_PAT}/ + # begin_substep musl-cross-make # msg info "Setting up musl-cross-make" # if [ -x ${CT}/bin/${CT_TRI}-gcc ]; then @@ -67,7 +70,7 @@ else extract_pkg ${G_SRC} ${pkg} ${pkg}.tar.xz ( cd_or_fail ${G_SRC}/${pkg} - run_make ARCH=${G_ARCH} headers + run_make ${JN} ARCH=${G_ARCH} headers check_dir ${CT}/${G_TARGET}/include cp_or_fail -r "usr/include/*" ${CT}/${G_TARGET}/include/ msg info "Removing *.cmd" @@ -99,7 +102,7 @@ else --disable-werror \ --enable-deterministic-archives \ --disable-compressed-debug-sections - run_make + run_make ${JN} run_make install-strip ) || exit 1 #remove_dir ${G_SRC}/${pkg} @@ -176,7 +179,7 @@ extract_pkg ${G_SRC} ${pkg} ${pkg}.tar.xz --disable-decimal-float \ --enable-clocale-generic - run_make all-gcc all-target-libgcc + run_make ${JN} all-gcc all-target-libgcc run_make install-gcc install-target-libgcc unset CFLAGS CXXFLAGS @@ -203,7 +206,7 @@ else CROSS_COMPILE=${G_TARGET}- \ --prefix=/ \ --target=${G_TARGET} - run_make + run_make ${JN} DESTDIR=/${CTD} export DESTDIR run_make install @@ -281,7 +284,7 @@ begin_substep gcc-11-20220101 "final GCC" --disable-libssp run_make AS_FOR_TARGET=${G_TARGET}-as \ - LD_FOR_TARGET=${G_TARGET}-ld + LD_FOR_TARGET=${G_TARGET}-ld ${JN} run_make install unset AR LDFLAGS @@ -300,9 +303,10 @@ else run_configure . \ --prefix=/${CTD} --disable-libseccomp - run_make + run_make ${JN} run_make install ) || exit 1 + remove_dir ${G_SRC}/${pkg} fi end_substep @@ -327,13 +331,13 @@ else CROSS_COMPILE=${G_TARGET}- \ --prefix=/ \ --target=${G_TARGET} - run_make + run_make ${JN} run_make DESTDIR=/${TLD} install remove_file ${TL}/lib/ld-musl-${G_ARCH_EXT_ALT}.so.1 link_if_ne libc.so ${TL}/lib/ld-musl-${G_ARCH_EXT_ALT}.so.1 - #link_if_ne ../lib/ld-musl-${G_ARCH_EXT_ALT}.so.1 ${CT}/bin/ldd + link_if_ne ../lib/ld-musl-${G_ARCH_EXT_ALT}.so.1 ${TL}/bin/ldd check_dir ${TL}/etc msg info "Generating %s" \ @@ -349,7 +353,7 @@ msg info "Adjusting cross-tools" SPECFILE=$(realpath $(dirname $(${G_TARGET}-gcc -print-libgcc-file-name)))/specs msg info "Specfile at %s" "${SPECFILE}" ${G_TARGET}-gcc -dumpspecs > specs -sed -i 's,:\(/lib/ld-musl-'${G_ARCH_EXT_ALT}'.so.1\),:/'${TLD}'\1,g' specs +/bin/sed -i 's,:\(/lib/ld-musl-'${G_ARCH_EXT_ALT}'.so.1\),:/'${TLD}'\1,g' specs cat specs >>${G_LOG} mv_or_fail specs ${SPECFILE} unset SPECFILE @@ -402,10 +406,10 @@ else --disable-nls \ --disable-werror \ --with-sysroot - run_make + run_make ${JN} run_make install-strip run_make -C ld clean - run_make -C ld LIB_PATH=/usr/lib:/lib + run_make -C ld ${JN} LIB_PATH=/usr/lib:/lib cp_or_fail ld/ld-new /${TLD}/bin ) || exit 1 fi @@ -473,7 +477,7 @@ extract_pkg ${G_SRC} ${pkg} ${pkg}.tar.xz gcc/config/i386/linux64.h do cp -u $f $f.orig - sed -e 's,/lib\(64\)\?\(32\)\?/ld,/'${TLD}'&,g' \ + /bin/sed -e 's,/lib\(64\)\?\(32\)\?/ld,/'${TLD}'&,g' \ -e 's,/usr,/'${TLD}',g' $f.orig > $f cat <<'!' >>$f #undef STANDARD_STARTFILE_PREFIX_1 @@ -514,7 +518,7 @@ extract_pkg ${G_SRC} ${pkg} ${pkg}.tar.xz LOCALOLDPATH=${PATH} PATH=/bin:/usr/bin:/${CTD}/bin:/${TLD}/bin export PATH - run_make + run_make ${JN} run_make install-strip link_if_ne gcc /${TLD}/bin/cc @@ -571,7 +575,7 @@ msg info "Adjusting tools" SPECFILE=$(realpath $(dirname $(${G_TARGET}-gcc -print-libgcc-file-name)))/specs msg info "Specfile at %s" "${SPECFILE}" ${G_TARGET}-gcc -dumpspecs > specs -sed -i 's,:\(/lib/ld-musl-'${G_ARCH_EXT_ALT}'.so.1\),:/'${TLD}'\1,g' specs +/bin/sed -i 's,:\(/lib/ld-musl-'${G_ARCH_EXT_ALT}'.so.1\),:/'${TLD}'\1,g' specs cat specs >>${G_LOG} mv_or_fail specs ${SPECFILE} unset SPECFILE @@ -621,15 +625,477 @@ else --disable-libstdcxx-pch \ --with-gxx-include-dir=/${TLD}/${G_TARGET}/include/c++/11.2.1 + run_make ${JN} + run_make install + ) || exit 1 +fi +end_substep + +begin_substep make-4.3 +if [ -x ${TL}/bin/make ]; then + msg info "%s exists, skipping %s" ${TL}/bin/make ${pkg} +else + fetch_pkg https://ftp.gnu.org/gnu/make/${pkg}.tar.gz + extract_pkg ${G_SRC} ${pkg} ${pkg}.tar.gz + ( + cd_or_fail ${G_SRC}/${pkg} + run_configure . \ + --prefix=/${TLD} \ + --build=${G_HOST} \ + --host=${G_TARGET} \ + --without-guile + run_make ${JN} + run_make install + ) || exit 1 + remove_dir ${pkg} +fi +end_substep + +begin_substep tcl8.6.12 +if [ -e ${TL}/lib/libtcl8.6.so ]; then + msg info "%s exists, skipping %s" ${TL}/lib/libtcl8.6.so ${pkg} +else + fetch_pkg https://sourceforge.net/projects/tcl/files/Tcl/8.6.12/${pkg}-src.tar.gz + extract_pkg ${G_SRC} ${pkg} ${pkg}-src.tar.gz + ( + cd_or_fail ${G_SRC}/${pkg} + cd_or_fail unix + + ac_cv_func_strtod=yes + tcl_cv_strtod_buggy=1 + export ac_cv_func_strtod tcl_cv_strtod_buggy + + run_configure . \ + --build=${G_HOST} \ + --host=${G_TARGET} \ + --prefix=/${TLD} + + run_make ${JN} + run_make install + chmod u+w ${TL}/lib/libtcl8.6.so + run_make install-private-headers + link_if_ne tclsh8.6 ${TL}/bin/tclsh + + unset ac_cv_func_strtod tcl_cv_strtod_buggy + ) || exit 1 + remove_dir ${G_SRC}/${pkg} +fi +end_substep + +begin_substep m4-1.4.19 +if [ -x ${TL}/bin/m4 ]; then + msg info "%s exists, skipping %s" ${TL}/bin/m4 ${pkg} +else + fetch_pkg https://ftp.gnu.org/gnu/m4/${pkg}.tar.xz + extract_pkg ${G_SRC} ${pkg} ${pkg}.tar.xz + ( + cd_or_fail ${G_SRC}/${pkg} + run_configure . \ + --prefix=/${TLD} \ + --build=${G_HOST} \ + --target=${G_TARGET} + run_make ${JN} + run_make install + ) || exit 1 + remove_dir ${G_SRC}/${pkg} +fi +end_substep + +begin_substep bzip2-1.0.8 +if [ -x ${TL}/bin/bzip2 ]; then + msg info "%s exists, skipping %s" ${TL}/bin/bzip2 ${pkg} +else + fetch_pkg https://sourceware.org/pub/bzip2/${pkg}.tar.gz + extract_pkg ${G_SRC} ${pkg} ${pkg}.tar.gz + ( + cd_or_fail ${G_SRC}/${pkg} + cp_or_fail Makefile Makefile.orig + /bin/sed '/^all:/s/ test//' Makefile.orig > Makefile + /bin/sed -i 's,\(ln -s -f \)$(PREFIX)/bin/,\1,' Makefile + /bin/sed -i 's,(PREFIX)/man,(PREFIX)/share/man,g' Makefile + + run_make -f Makefile-libbz2_so CC=${CC} AR=${AR} \ + RANLIB=${RANLIB} CFLAGS=-fPIC + run_make clean + run_make ${JN} CC=${CC} AR=${AR} RANLIB=${RANLIB} \ + STRIP=${STRIP} CFLAGS=-fPIC + run_make PREFIX=/${TLD} install + ) || exit 1 + remove_dir ${G_SRC}/${pkg} +fi +end_substep + +begin_substep byacc-20220128 +if [ -x ${TL}/bin/yacc ]; then + msg info "%s exists, skipping %s" ${TL}/bin/yacc ${pkg} +else + fetch_pkg https://invisible-island.net/archives/byacc/${pkg}.tgz + extract_pkg ${G_SRC} ${pkg} ${pkg}.tgz + ( + cd_or_fail ${G_SRC}/${pkg} + run_configure . \ + --prefix=/${TLD} \ + --build=${G_HOST} \ + --host=${G_TARGET} + run_make ${JN} + run_make install + ) || exit 1 + remove_dir ${G_SRC}/${pkg} +fi +end_substep + +begin_substep diffutils-3.8 +if [ -x ${TL}/bin/diff ]; then + msg info "%s exists, skipping %s" ${TL}/bin/diff ${pkg} +else + fetch_pkg https://ftp.gnu.org/gnu/diffutils/${pkg}.tar.xz + extract_pkg ${G_SRC} ${pkg} ${pkg}.tar.xz + ( + cd_or_fail ${G_SRC}/${pkg} + run_configure . \ + --prefix=/${TLD} \ + --build=${G_HOST} \ + --host=${G_TARGET} + run_make ${JN} + run_make install + ) || exit 1 + remove_dir ${G_SRC}/${pkg} +fi +end_substep + +begin_substep file-5.41 +if [ -x ${TL}/bin/file ]; then + msg info "%s exists, skipping %s" ${TL}/bin/file ${pkg} +else + fetch_pkg https://astron.com/pub/file/${pkg}.tar.gz + extract_pkg ${G_SRC} ${pkg} ${pkg}.tar.gz + ( + cd_or_fail ${G_SRC}/${pkg} + + run_configure . \ + --prefix=/${TLD} \ + --build=${G_HOST} \ + --host=${G_TARGET} + + run_make ${JN} + run_make install + ) || exit 1 + remove_dir ${G_SRC}/${pkg} +fi +end_substep + +begin_substep findutils-4.9.0 +if [ -x ${TL}/bin/find ]; then + msg info "%s exists, skipping %s" ${TL}/bin/find ${pkg} +else + fetch_pkg https://ftp.gnu.org/gnu/findutils/${pkg}.tar.xz + extract_pkg ${G_SRC} ${pkg} ${pkg}.tar.xz + ( + cd_or_fail ${G_SRC}/${pkg} + /bin/sed -i 's/IO_ftrylockfile/IO_EOF_SEEN/' gl/lib/*.c + /bin/sed -i '/unistd/a #include <sys/sysmacros.h>' \ + gl/lib/mountlist.c + echo '#define _IO_IN_BACKUP 0x100' >>gl/lib/stdio-impl.h + run_configure . \ + --prefix=/${TLD} \ + --build=${G_HOST} \ + --host=${G_TARGET} + run_make ${JN} + run_make install + ) || exit 1 + remove_dir ${G_SRC}/${pkg} +fi +end_substep + +begin_substep gettext-tiny-0.3.2 +if [ -x ${TL}/bin/msgfmt ]; then + msg info "%s exists, skipping %s" ${TL}/bin/msgfmt ${pkg} +else + fetch_pkg https://ftp.barfooze.de/pub/sabotage/tarballs/${pkg}.tar.xz + extract_pkg ${G_SRC} ${pkg} ${pkg}.tar.xz + ( + cd_or_fail ${G_SRC}/${pkg} + run_make ${JN} LIBINTL=MUSL prefix=/${TLD} + cp_or_fail msgfmt msgmerge xgettext ${TL}/bin + ) || exit 1 + remove_dir ${G_SRC}/${pkg} +fi +end_substep + +begin_substep gzip-1.12 +if [ -x ${TL}/bin/gzip ]; then + msg info "%s exists, skipping %s" ${TL}/bin/gzip ${pkg} +else + fetch_pkg https://ftp.gnu.org/gnu/gzip/${pkg}.tar.xz + extract_pkg ${G_SRC} ${pkg} ${pkg}.tar.xz + ( + cd_or_fail ${G_SRC}/${pkg} + run_configure . \ + --prefix=/${TLD} \ + --build=${G_HOST} \ + --host=${G_TARGET} + run_make ${JN} + run_make install + ) || exit 1 + remove_dir ${G_SRC}/${pkg} +fi +end_substep + +begin_substep netbsd-curses-0.3.2 +if [ -e ${TL}/lib/libncurses.so ]; then + msg info "%s exists, skipping %s" ${TL}/lib/libncurses.so ${pkg} +else + fetch_pkg https://ftp.barfooze.de/pub/sabotage/tarballs/${pkg}.tar.xz + extract_pkg ${G_SRC} ${pkg} ${pkg}.tar.xz + ( + cd_or_fail ${G_SRC}/${pkg} + run_make ${JN} PREFIX=/${TLD} all install + ) || exit 1 + remove_dir ${pkg} +fi +end_substep + +begin_substep patch-2.7.6 +if [ -x ${TL}/bin/patch ]; then + msg info "%s exists, skipping %s" ${TL}/bin/patch ${pkg} +else + fetch_pkg https://ftp.gnu.org/gnu/patch/${pkg}.tar.xz + extract_pkg ${G_SRC} ${pkg} ${pkg}.tar.xz + ( + cd_or_fail ${G_SRC}/${pkg} + run_configure . \ + --prefix=/${TLD} \ + --build=${G_HOST} \ + --host=${G_TARGET} + run_make ${JN} + run_make install + ) || exit 1 + remove_dir ${G_SRC}/${pkg} +fi +end_substep + +begin_substep reflex-20210808 +if [ -x ${TL}/bin/flex ]; then + msg info "%s exists, skipping %s" ${TL}/bin/flex ${pkg} +else + fetch_pkg https://invisible-island.net/archives/reflex/${pkg}.tgz + extract_pkg ${G_SRC} ${pkg} ${pkg}.tgz + ( + cd_or_fail ${G_SRC}/${pkg} + run_configure . \ + --prefix=/${TLD} \ + --build=${G_HOST} \ + --host=${G_TARGET} + run_make ${JN} + run_make install + link_if_ne reflex ${TL}/bin/flex + ) || exit 1 + remove_dir ${G_SRC}/${pkg} +fi +end_substep + +begin_substep awk +if [ -x ${TL}/bin/awk ]; then + msg info "%s exists, skipping %s" ${TL}/bin/awk ${pkg} +else + ( + cd_or_fail ${G_SRC} + git_clone ${pkg} https://github.com/onetrueawk/${pkg} + cd_or_fail ${pkg} run_make + mv_or_fail a.out ${TL}/bin/awk + ) || exit 1 +fi +end_substep + +begin_substep tinycc +if [ -x ${TL}/bin/tcc ]; then + msg info "%s exists, skipping %s" ${TL}/bin/tcc ${pkg} +else + git_clone tinycc git://repo.or.cz/tinycc.git + ( + cd_or_fail ${G_SRC}/${pkg} + CFLAGS='-static --static -fcommon' + LDFLAGS='-static --static -fcommon' + export CFLAGS LDFLAGS + run_configure . \ + --prefix=/${TLD} \ + --bindir=/${TLD}/bin \ + --libdir=/${TLD}/lib \ + --tccdir=/${TLD}/lib/tcc \ + --includedir=/${TLD}/include \ + --sharedir=/${TLD}/share \ + --config-musl \ + --sysincludepaths=/${TLD}/include \ + --crtprefix=/${TLD}/lib \ + --libpaths=/${TLD}/lib:/lib + run_make + run_make install + unset CFLAGS LDFLAGS + ) || exit 1 +fi +end_substep + +begin_substep coreutils-9.1 +if [ -x ${TL}/bin/ls ]; then + msg info "%s exists, skipping %s" ${TL}/bin/ls ${pkg} +else + fetch_pkg https://ftp.gnu.org/gnu/coreutils/${pkg}.tar.xz + extract_pkg ${G_SRC} ${pkg} ${pkg}.tar.xz + ( + cd_or_fail ${G_SRC}/${pkg} + autoreconf -vif + cat <<! >config.cache +fu_cv_sys_stat_statfs2_bsize=no +ac_cv_func_syncfs=no +gl_cv_func_working_mkstemp=yes +gl_cv_func_working_acl_get_file=yes +! + sed -i '/test.lock/s/^/#/' gnulib-tests/gnulib.mk + run_configure . \ + --prefix=/${TLD} \ + --build=${G_HOST} \ + --target=${G_TARGET} \ + --enable-install-program=hostname \ + --cache-file=config.cache + run_make ${JN} + run_make install-strip + ) || exit 1 + remove_dir ${G_SRC}/${pkg} +fi +end_substep + +# begin_substep sbase +# if [ -x ${TL}/bin/ls ]; then +# msg info "%s exists, skipping %s" ${TL}/bin/ls ${pkg} +# else +# ( +# CC=tcc +# export CC +# git_clone ${pkg} git://git.suckless.org/sbase +# cd_or_fail ${G_SRC}/${pkg} +# /bin/sed -i -e 's,/usr/local,/'${TLD}',g;s, \<cc\>, '${CC}',g' \ +# -e 's, \<ar\>, '${AR}',g' \ +# -e 's,CFLAGS\s\+= ,&-static -fcommon ,g' \ +# -e 's,LDFLAGS\s\+= ,&-static -fcommon ,g' config.mk +# run_make ${JN} CC=${CC} +# run_make install +# #remove_dir ${G_SRC}/${pkg} +# ) || exit 1 +# fi +# end_substep +# +# begin_substep ubase +# if [ -x ${TL}/bin/id ]; then +# msg info "%s exists, skipping %s" ${TL}/bin/id ${pkg} +# else +# ( +# CC=tcc +# export CC +# git_clone ${pkg} git://git.suckless.org/ubase +# cd_or_fail ${G_SRC}/${pkg} +# /bin/sed -i -z 's,<sys/types.h>\n,&#include <sys/sysmacros.h>\n,' \ +# mknod.c +# /bin/sed -i -z 's,"arg.h"\n,&#include <sys/sysmacros.h>\n,' \ +# util.h +# /bin/sed -i -e 's,/usr/local,/'${TLD}',g' \ +# -e 's, \<cc\>, '${CC}',g' \ +# -e 's, \<ar\>, '${AR}',g' \ +# -e 's,CFLAGS\s\+= ,&-static -fcommon ,g' \ +# -e 's,LDFLAGS\s\+= ,&-static -fcommon ,g' \ +# -e 's,LDLIBS\s\+= ,&-lc ,g' \ +# config.mk +# run_make ${JN} CC=${CC} +# run_make install +# #remove_dir ${G_SRC}/${pkg} +# ) || exit 1 +# fi +# end_substep +# + +begin_substep tar-1.34 +if [ -x ${TL}/bin/tar ]; then + msg info "%s exists, skipping %s" ${TL}/bin/tar ${pkg} +else + fetch_pkg https://ftp.gnu.org/gnu/tar/${pkg}.tar.xz + extract_pkg ${G_SRC} ${pkg} ${pkg}.tar.xz + ( + cd_or_fail ${G_SRC}/${pkg} + FORCE_UNSAFE_CONFIGURE=1 + gl_cv_struct_dirent_d_ino=yes + export FORCE_UNSAFE_CONFIGURE gl_cv_struct_dirent_d_ino + run_configure . \ + --prefix=/${TLD} \ + --bindir=/${TLD}/bin + run_make ${JN} run_make install + unset FORCE_UNSAFE_CONFIGURE gl_cv_struct_dirent_d_ino + ) || exit 1 + remove_dir ${G_SRC}/${pkg} +fi +end_substep + +begin_substep xz-5.2.5 +if [ -x ${TL}/bin/xz ]; then + msg info "%s exists, skipping %s" ${TL}/bin/xz ${pkg} +else + fetch_pkg https://tukaani.org/xz/${pkg}.tar.xz + extract_pkg ${G_SRC} ${pkg} ${pkg}.tar.xz + ( + cd_or_fail ${G_SRC}/${pkg} + run_configure . \ + --prefix=/${TLD} \ + --build=${G_HOST} \ + --host=${G_TARGET} + run_make ${JN} + run_make install + ) || exit 1 + remove_dir ${G_SRC}/${pkg} +fi +end_substep + +begin_substep perl-5.32.1 +if [ -x ${TL}/bin/perl ]; then + msg info "%s exists, skipping %s" ${TL}/bin/perl ${pkg} +else + fetch_pkg https://github.com/arsv/perl-cross/releases/download/1.4/\ +perl-cross-1.4.tar.gz + fetch_pkg https://www.cpan.org/src/5.0/${pkg}.tar.xz + extract_pkg ${G_SRC} perl-cross-1.4 perl-cross-1.4.tar.gz + extract_pkg ${G_SRC} ${pkg} ${pkg}.tar.xz + ( + cd_or_fail ${G_SRC}/${pkg} + cp_or_fail -fr ${G_SRC}/perl-cross-1.4/* ./ + run_configure . \ + --prefix=/${TLD} \ + --target=${G_TARGET} + run_make ${JN} + cp_or_fail perl cpan/podlators/scripts/pod2man ${TL}/bin + mkdir -p ${TL}/lib/perl5/5.32.1 + cp_or_fail -R lib/* ${TL}/lib/perl5/5.32.1 ) || exit 1 + remove_dir ${G_SRC}/${pkg} fi end_substep +msg info "Removing unneeded documentation" +remove_dir ${TL}/doc +remove_dir ${TL}/info +remove_dir ${TL}/man +remove_dir ${TL}/share/doc +remove_dir ${TL}/share/info +remove_dir ${TL}/share/man + +end_step # tools + +begin_step utilities + +totalsubsteps=2 +substep=1 + begin_substep mksh -if [ -x ${GR}/bin/mksh ]; then - msg info "%s exists, skipping %s" ${GR}/bin/mksh ${pkg} +if [ -x ${TL}/bin/mksh ]; then + msg info "%s exists, skipping %s" ${TL}/bin/mksh ${pkg} else ( git_clone mksh https://github.com/mirbsd/mksh @@ -646,10 +1112,10 @@ else sh ../Build.sh -r > ${G_FIFO} rm ${G_FIFO} - check_dir ${GR}/share/doc/mksh/examples - check_dir ${GR}/share/man/man1 + #check_dir ${TL}/share/doc/mksh/examples + #check_dir ${TL}/share/man/man1 - install -c -s -m 555 mksh ${GR}/bin/mksh + install -c -s -m 555 mksh ${TL}/bin/mksh install -c -m 444 ../dot.mkshrc \ ${GR}/share/doc/mksh/examples/ install -c -m 444 ../lksh.1 ../mksh.1 \ @@ -670,137 +1136,34 @@ else sh ../Build.sh -r -L > ${G_FIFO} rm ${G_FIFO} - install -c -s -m 555 lksh ${GR}/bin/lksh - link_if_ne lksh ${GR}/bin/sh + install -c -s -m 555 lksh ${TL}/bin/lksh + link_if_ne lksh ${TL}/bin/sh unset CFLAGS CPPFLAGS LDSTATIC TARGET_OS ) || exit 1 fi end_substep -end_step # tools - -msg info "Cleaning up environment" -export PATH=${OLDPATH} -unset OLDPATH CC CXX AR AS RANLIB LD STRIP -unset WD - -exit 1 - -#OLDPATH=${PATH} -#PATH=${CT}/bin:${OLDPATH} - begin_substep sled -if [ -x ${GR}/bin/sled ]; then - msg info "%s exists, skipping %s" ${GR}/bin/sled ${pkg} +if [ -x ${TL}/bin/sled ]; then + msg info "%s exists, skipping %s" ${TL}/bin/sled ${pkg} else ( git_clone ${pkg} https://git.sr.ht/~strahinja/sled cd_or_fail ${G_SRC}/${pkg} SLED_CC=${CC}' -O2 -Wall -static -fcommon' - PREFIX=${GR} + PREFIX=/${TLD} export SLED_CC PREFIX run_do -c install ) || exit 1 fi end_substep -begin_substep sbase -if [ -x ${GR}/bin/ls ]; then - msg info "%s exists, skipping %s" ${GR}/bin/ls ${pkg} -else - ( - git_clone ${pkg} git://git.suckless.org/sbase - cd_or_fail ${G_SRC}/${pkg} - sed -i -e 's,/usr/local,'${GR}',g;s, \<cc\>,' ${CC}',g' \ - -e 's, \<ar\>,' ${AR}',g' \ - -e 's,CFLAGS\s\+= ,&-static -fcommon ,g' \ - -e 's,LDFLAGS\s\+= ,&-static -fcommon ,g' config.mk - run_make - run_make install - #remove_dir ${G_SRC}/${pkg} - ) || exit 1 -fi -end_substep - -begin_substep ubase -if [ -x ${GR}/bin/id ]; then - msg info "%s exists, skipping %s" ${GR}/bin/id ${pkg} -else - ( - git_clone ${pkg} git://git.suckless.org/ubase - cd_or_fail ${G_SRC}/${pkg} - sed -i -z 's,<sys/types.h>\n,&#include <sys/sysmacros.h>\n,' \ - mknod.c - sed -i -z 's,"arg.h"\n,&#include <sys/sysmacros.h>\n,' \ - util.h - sed -i -e 's,/usr/local,'${GR}',g' \ - -e 's, \<cc\>, '${CC}',g' \ - -e 's, \<ar\>, '${AR}',g' \ - -e 's,CFLAGS\s\+= ,&-static -fcommon ,g' \ - -e 's,LDFLAGS\s\+= ,&-static -fcommon ,g' \ - -e 's,LDLIBS\s\+= ,&-lc ,g' \ - config.mk - run_make - run_make install - #remove_dir ${G_SRC}/${pkg} - ) || exit 1 -fi -end_substep - -# msg info "${white}[%d/%d]: tinycc" ${step} ${totalsteps} -# git_clone tinycc git://repo.or.cz/tinycc.git -# pkg=tinycc -# if [ -x ${GR}/bin/tcc ]; then -# msg info "%s exists, skipping %s" ${GR}/bin/tcc ${pkg} -# else -# ( -# cd_or_fail ${G_SRC}/${pkg} -# CFLAGS='-static --static -fcommon' -# LDFLAGS='-static --static -fcommon' -# export CFLAGS LDFLAGS -# run_configure . \ -# --prefix=/ \ -# --bindir=/bin \ -# --libdir=/lib \ -# --tccdir=/lib/tcc \ -# --includedir=/include \ -# --sharedir=/share \ -# --config-musl \ -# --sysincludepaths=/include \ -# --crtprefix=/lib \ -# --libpaths=/sucks/lib:/lib -# run_make -# run_make install -# unset CFLAGS LDFLAGS -# ) || exit 1 -# fi -# -# msg info "${white}[%d/%d]: Done tinycc" ${step} ${totalsteps} -# step=$((step+1)) +end_step # utilities msg info "Cleaning up environment" export PATH=${OLDPATH} -unset OLDPATH CC CXX AR AS RANLIB STRIP +unset OLDPATH CC CXX AR AS RANLIB LD STRIP unset WD -msg info "Next run 02-prep-chroot.sh as root" - -# exit 0 -# -# skip=1 -# if [ ${skip} != 1 ]; then -# fetch_pkg https://www.kernel.org/pub/linux/kernel/v5.x/linux-5.17.13.tar.xz -# pkg=linux-5.17.13 -# extract_pkg ${G_SRC} ${pkg} ${pkg}.tar.xz -# { -# cd_or_fail ${G_SRC}/${pkg} -# run_make ARCH=${G_ARCH} ${JN} headers -# check_dir ${CT}/${G_TARGET}/include -# cp_or_fail -r "usr/include/*" ${CT}/${G_TARGET}/include/ -# msg info "Removing *.cmd" -# find ${CT}/${G_TARGET}/include -name '.*.cmd' -exec rm -f {} \; -# rm ${CT}/${G_TARGET}/include/Makefile -# remove_dir ${G_SRC}/${pkg} -# } -# fi +msg warn "Next run ./02-prep-chroot.sh as root" diff --git a/02-prep-chroot.sh b/02-prep-chroot.sh @@ -3,6 +3,8 @@ . ./lib/env.sh . ./lib/fun.sh +WD=${PWD} + trap exit_cleanup HUP PIPE INT QUIT TERM EXIT if [ "$(id -u)" -ne 0 ]; then @@ -42,7 +44,7 @@ mount_or_fail -t devpts devpts ${GR}/dev/pts -o gid=5,mode=620 mount_or_fail -t proc proc ${GR}/proc mount_or_fail -t sysfs sysfs ${GR}/sys mount_or_fail -t tmpfs tmpfs ${GR}/run -#mount_or_fail -t tmpfs tmpfs ${GR}/tmp +mount_or_fail -t tmpfs tmpfs ${GR}/tmp if [ -h ${GR}/dev/shm ]; then check_dir ${GR}/$(readlink ${GR}/dev/shm) @@ -53,8 +55,8 @@ if [ -e ${GR}/etc/passwd ]; then else msg info "Generating %s" "${GR}/etc/passwd" cat <<! >${GR}/etc/passwd -root:x:0:0:root:/root:/bin/mksh -galeb:x:${GUID}:${GGID}:Temporary User Account:/src:/bin/mksh +root:x:0:0:root:/root:/tools/bin/mksh +galeb:x:${GUID}:${GGID}:Temporary User Account:/src:/tools/bin/mksh ! fi @@ -79,7 +81,11 @@ export PATH # A more familiar ls lc() { - /bin/ls \$* | cols + if [ -x /tools/bin/ls ]; then + /tools/bin/ls \$* | cols + else + /bin/ls \$* | cols + fi } [ -e /etc/mkshrc ] && . /etc/mkshrc @@ -106,16 +112,22 @@ set -U ! fi -msg info "Next run 03-chroot.sh" +link_if_ne /${TLD}/bin/lksh ${GR}/bin/sh +cp_or_fail ${WD}/03-chroot.sh ${GR}/bin/ +check_dir ${GR}/galeb +cp_or_fail ${WD}/lib/env.sh ${GR}/galeb/env.sh +/bin/sed -i 's,^\(GR=\).*,\1,' ${GR}/galeb/env.sh +cp_or_fail ${WD}/lib/fun.sh ${GR}/galeb/fun.sh +msg warn "Next run 03-chroot.sh" msg query "Run as root [y/N]?" read -r run_as_root case "${run_as_root}" in - y|Y) chroot ${GR} /bin/mksh -l +h;; - *) chroot --userspec=${GUID}:${GGID} ${GR} /bin/mksh -l +h;; + y|Y) chroot ${GR} /${TLD}/bin/mksh -l +h;; + *) chroot --userspec=${GUID}:${GGID} ${GR} /${TLD}/bin/mksh -l +h;; esac -#umount ${GR}/tmp +umount ${GR}/tmp umount ${GR}/run umount ${GR}/sys umount ${GR}/proc diff --git a/03-chroot.sh b/03-chroot.sh @@ -0,0 +1,177 @@ +. /galeb/env.sh +. /galeb/fun.sh + +trap exit_cleanup HUP PIPE INT QUIT TERM EXIT + +totalsteps=1 +step=1 + +begin_step "final system" + +totalsubsteps=20 +substep=1 + +msg info "Creating temporary links" +for cmd in cat dd echo mksh lksh ln pwd rm stty install perl +do + link_if_ne /${TLD}/bin/${cmd} /bin/${cmd} +done +link_if_ne lksh /bin/sh +for lib in gcc_s.so gcc_s.so.1 stdc++.a stdc++.so stdc++.so.6 +do + link_if_ne /${TLD}/lib/lib${lib} /lib/lib${lib} +done +link_if_ne /proc/self/mounts /etc/mtab + +msg info "Regenerating /etc/passwd" +cat <<! >/etc/passwd +root:x:0:0:root:/root:/bin/mksh +daemon:x:6:6:Daemon User:/dev/null:/bin/false +nobody:x:99:99:Unprivileged User:/dev/null:/bin/false +! + +msg info "Regenerating /etc/group" +cat <<! >/etc/group +root:x:0:root +bin:x:1: +sys:x:2: +kmem:x:3: +tape:x:4: +tty:x:5: +daemon:x:6: +floppy:x:7: +disk:x:8: +lp:x:9: +dialout:x:10: +audio:x:11: +video:x:12: +utmp:x:13: +usb:x:14: +cdrom:x:15: +adm:x:16: +messagebus:x:18: +input:x:24: +mail:x:34: +nogroup:x:99: +users:x:999: +! + +for log in btmp lastlog faillog wtmp +do + :>/var/log/${log} +done +chgrp utmp /var/log/lastlog +chgrp 664 /var/log/lastlog +chgrp 600 /var/log/btmp + +begin_substep linux-5.17.13 "Linux headers" +if [ -e /include/linux/stddef.h ]; then + msg info "%s exists, skipping %s" \ + /include/linux/stddef.h "${substepname}" +else + fetch_pkg https://www.kernel.org/pub/linux/kernel/v5.x/linux-5.17.13.tar.xz + extract_pkg ${G_SRC} ${pkg} ${pkg}.tar.xz + ( + cd_or_fail ${G_SRC}/${pkg} + run_make ${JN} ARCH=${G_ARCH} headers + check_dir /include + cp_or_fail -r "usr/include/*" /include/ + msg info "Removing *.cmd" + find /include -name '.*.cmd' -exec rm -f {} \; + remove_file /include/Makefile + #remove_dir ${G_SRC}/${pkg} + ) || exit 1 +fi +end_substep + +begin_substep man-pages-5.13 +if [ -e /share/man/man2/fork.2 ]; then + msg info "%s exists, skipping %s" /share/man/man2/fork.2 ${pkg} +elif [ -e ${G_SPKG}/${pkg}.tar.xz ]; then + unpack_pkg ${pkg} / +else + fetch_pkg https://mirrors.edge.kernel.org/pub/linux/docs/man-pages/${pkg}.tar.xz + extract_pkg ${G_SRC} ${pkg} ${pkg}.tar.xz + ( + cd_or_fail ${G_SRC}/${pkg} + cat <<! >MKPK +mkpk_name() +{ + printf "%s" "${pkg}" +} + +mkpk_install() +{ + make DESTDIR=../build prefix= install +} +! + mkpk ${pkg} + remove_dir ${G_SRC}/${pkg} + unpack_pkg ${pkg} / + ) || exit 1 +fi +end_substep + +begin_substep musl-1.2.3 +if [ -e /lib/ld-musl-${G_ARCH_EXT_ALT}.so.1 ]; then + msg info "%s exists, skipping %s" /lib/ld-musl-${G_ARCH_EXT_ALT}.so.1 \ + ${pkg} +elif [ -e ${G_SPKG}/${pkg}.tar.xz ]; then + unpack_pkg ${pkg} / +else + fetch_pkg https://musl.libc.org/releases/${pkg}.tar.gz + extract_pkg ${G_SRC} ${pkg} ${pkg}.tar.gz + ( + cd_or_fail ${G_SRC}/${pkg} + for patch in i686-fix-rounding.patch \ + change-scheduler-functions-Linux-compatib.patch + do + apply_patch final-system -Np1 -i \ + ${G_PAT}/musl-mlfs/${patch} + done + + for patch in handle-aux-at_base.patch + do + apply_patch final-system -Np1 -i \ + ${G_PAT}/musl-alpine/${patch} + done + + cat <<! >MKPK +mkpk_name() +{ + printf "%s" "${pkg}" +} + +mkpk_install() +{ + ( + CC=${G_TARGET}-gcc + CXX=${G_TARGET}-g++ + CFLAGS='-O3 -march=native' + export CC CXX CFLAGS + + DESTDIR=../build + LDFLAGS='-Wl,-soname,libc.musl-${G_ARCH_EXT_ALT}.so.1' + export DESTDIR LDFLAGS + + ./configure \ + --prefix=/ \ + --sysconfdir=/etc \ + --localstatedir=/var \ + --disable-gcc-wrapper + + make ${JN} + make install + mkdir -p ../build/bin + ln -sf ../lib/ld-musl-${G_ARCH_EXT_ALT}.so.1 ../build/bin/ldd + ) || exit 1 +} +! + mkpk ${pkg} + remove_dir ${G_SRC}/${pkg} + unpack_pkg ${pkg} / + ) || exit 1 +fi +end_substep + +end_step diff --git a/lib/env.sh b/lib/env.sh @@ -5,8 +5,8 @@ GUSER=strajder GHOME=/home/${GUSER} -GUID=$(getent passwd ${GUSER} | cut -d : -f 3) -GGID=$(getent group ${GUSER} | cut -d : -f 3) +GUID=$(grep ^${GUSER}: /etc/passwd | sed 1q | cut -d : -f 3) +GGID=$(grep ^${GUSER}: /etc/group | sed 1q | cut -d : -f 3) CT_TRI=x86_64-cross-linux-musl GR=${GHOME}/galeb-root @@ -21,12 +21,15 @@ G_ARCH_EXT_ALT=x86_64 G_FIFO=${GR}/fifo G_HOST=$(gcc -dumpmachine | sed 's/\([^-]\+-\)[^-]\+\(-.*\)/\1cross\2/g') G_LOG=${GR}/log -G_PAT=${GR}/pat -G_PKG=${GR}/pkg G_SRC=${GR}/src +G_SHORTLOG=${GR}/shortlog +G_SPKG=${GR}/pkg + +G_PAT=${G_SRC}/pat +G_PKG=${G_SRC}/pkg G_TARGET=x86_64-galeb-linux-musl G_VER=2.0 -JN=-j$(($(nproc) * 3)) +JN=-j$(($(grep ^processor /proc/cpuinfo | wc -l) * 3)) export CT_TRI GHOME GUID GGID GR CTD TLD CT TL G_ARCH G_ARCH_EXT G_ARCH_EXT_ALT -export G_FIFO G_LOG G_PAT G_PKG G_SRC G_TARGET G_VER JN +export G_FIFO G_LOG G_PAT G_PKG G_SHORTLOG G_SPKG G_SRC G_TARGET G_VER JN diff --git a/lib/fun.sh b/lib/fun.sh @@ -1,17 +1,18 @@ #!/bin/sh -norm=$(printf '\033[0m') -bold=$(printf '\033[1m') -faint=$(printf '\033[2m') -black=$(printf '\033[30m') -green=$(printf '\033[32m') -gray=$(printf '\033[37m') -bgred=$(printf '\033[41m') -lred=$(printf '\033[91m') -yellow=$(printf '\033[93m') -lblue=$(printf '\033[94m') -white=$(printf '\033[97m') -bgwhite=$(printf '\033[107m') +norm=$(printf '\033[0m') +bold=$(printf '\033[1m') +faint=$(printf '\033[2m') +black=$(printf '\033[30m') +green=$(printf '\033[32m') +gray=$(printf '\033[37m') +bgred=$(printf '\033[41m') +lred=$(printf '\033[91m') +yellow=$(printf '\033[93m') +lblue=$(printf '\033[94m') +white=$(printf '\033[97m') +bgyellow=$(printf '\033[103m') +bgwhite=$(printf '\033[107m') apply_patch() { @@ -40,7 +41,10 @@ apply_patch() begin_step() { stepname=$1 - msg info "${bgwhite}${black}[%d/%d]: %s" ${step} ${totalsteps} ${stepname} + msg info "${bgwhite}${black}[%d/%d]: %s" \ + ${step} ${totalsteps} "${stepname}" + printf "[%d/%d]: %s\n" ${step} ${totalsteps} "${stepname}" \ + >>${G_SHORTLOG} } begin_substep() @@ -52,10 +56,17 @@ begin_substep() msg info "${white}[%d/%d]-[%d/%d]: %s" \ ${step} ${totalsteps} \ ${substep} ${totalsubsteps} "${substepname}" + printf "[%d/%d]-[%d/%d]: %s\n" \ + ${step} ${totalsteps} \ + ${substep} ${totalsubsteps} "${substepname}" \ + >>${G_SHORTLOG} else msg info "${white}[%d/%d]-[%d/%d]: %s" \ ${step} ${totalsteps} \ ${substep} ${totalsubsteps} ${pkg} + printf "[%d/%d]-[%d/%d]: %s\n" \ + ${step} ${totalsteps} \ + ${substep} ${totalsubsteps} ${pkg} >>${G_SHORTLOG} fi } @@ -111,8 +122,11 @@ cp_or_fail() end_step() { - msg info "${bgwhite}${black}[%d/%d]: Done %s" ${step} ${totalsteps} ${stepname} + msg info "${bgwhite}${black}[%d/%d]: Done %s" \ + ${step} ${totalsteps} "${stepname}" step=$((step+1)) + printf "[%d/%d]: Done %s\n" ${step} ${totalsteps} "${stepname}" \ + >>${G_SHORTLOG} } end_substep() @@ -121,11 +135,18 @@ end_substep() msg info "${white}[%d/%d]-[%d/%d]: Done %s" \ ${step} ${totalsteps} \ ${substep} ${totalsubsteps} "${substepname}" + printf "[%d/%d]-[%d/%d]: Done %s\n" \ + ${step} ${totalsteps} \ + ${substep} ${totalsubsteps} "${substepname}" \ + >>${G_SHORTLOG} unset substepname else msg info "${white}[%d/%d]-[%d/%d]: Done %s" \ ${step} ${totalsteps} \ ${substep} ${totalsubsteps} ${pkg} + printf "[%d/%d]-[%d/%d]: Done %s\n" \ + ${step} ${totalsteps} \ + ${substep} ${totalsubsteps} ${pkg} >>${G_SHORTLOG} fi substep=$((substep+1)) } @@ -134,7 +155,8 @@ exit_cleanup() { [ -p ${G_FIFO} ] && rm ${G_FIFO} unset CT_TRI GHOME GUID GGID GR CTD TLD CT TL G_ARCH G_ARCH_EXT - unset G_ARCH_EXT_ALT G_FIFO G_LOG G_PAT G_PKG G_SRC G_TARGET G_VER JN + unset G_ARCH_EXT_ALT G_FIFO G_LOG G_PAT G_PKG G_SHORTLOG G_SPKG G_SRC + unset G_TARGET G_VER JN } extract_pkg() @@ -159,7 +181,7 @@ extract_pkg() *) msg err "Unsupported archive format" exit 1;; esac - if ! ${prog} "${G_PKG}/$1" | pv | tar xf -; then + if ! ${prog} "${G_PKG}/$1" | tar -xf -; then msg err "Extracting %s failed" "$1" exit 1 fi @@ -202,7 +224,7 @@ git_clone() link_if_ne() { eval dest=\$$# - if [ -e "${dest}" ]; then + if [ -L "${dest}" ]; then msg info "Symlink %s exists" "${dest}" return fi @@ -213,6 +235,78 @@ link_if_ne() fi } +mkpk() +{ + local pkg=$1 +# MKPK should be a script which should define two functions: +# +# 1. mkpk_name, which should print out the versioned name of the archive to be +# created. This function is called in the subdirectory "build" under the +# parent directory of the source tree. +# +# 2. mkpk_install, which should contain the commands to configure, build and +# install the program. This function is called in the base directory of the +# source tree. +# +# Examples of commands to be used in mkpk_install: +# +# make --prefix=../build/usr install +# PREFIX=../build/usr/local make install + + ( + local fail=0 + + if test ! -f MKPK; then + msg err "mkpk called without MKPK" + exit 1 + fi + + cd .. + mkdir -p build dev bin include lib tools tmp + msg info "mkpk mounting..." + mount -B /dev ./dev + mount -B /bin ./bin -o ro + mount -B /include ./include -o ro + mount -B /lib ./lib -o ro + mount -B /tools ./tools -o ro + mount -B /tmp ./tmp -o ro + ln -s . usr + cd ${pkg} + + msg info "mkpk chrooting..." + . ./MKPK + chroot .. sh -c "cd ${pkg}; . ./MKPK; mkpk_install" + fail=$? + + msg info "mkpk umounting..." + umount ../tmp + umount ../tools + umount ../lib + umount ../include + umount ../bin + umount ../dev + + if [ ${fail} -ne 1 ]; then + msg info "mkpk packing..." + cd ../build + tar -cf ${G_SPKG}/$(mkpk_name).tar * + xz -9f ${G_SPKG}/$(mkpk_name).tar + md5sum ${G_SPKG}/$(mkpk_name).tar.xz >${G_SPKG}/$(mkpk_name).md5 + fi + + cd .. + + msg info "Cleaning up in %s" $(pwd) + rm -fr build + rm usr + rmdir dev bin include lib tools tmp + exit ${fail} + ) || { + msg err "mkpk failed" + exit 1 + } +} + mount_or_fail() { msg info "mount %s" "$*" @@ -246,7 +340,7 @@ msg() log=0 newline=0;; warn) icon_plain="=W=" - icon="${bold}${yellow}${icon_plain}";; + icon="${bgyellow}${bold}${faint}${black}${icon_plain}";; *) ;; esac printf "%s %s " "${icon}" ${tstamp} @@ -329,3 +423,15 @@ setup_fifo() tee -a ${G_LOG} < ${G_FIFO} & } +unpack_pkg() +{ + local pkg=$1 + shift + if ! md5sum -c ${G_SPKG}/${pkg}.md5; then + msg err "md5sum -c %s failed" ${G_SPKG}/${pkg}.tar.xz + exit 1 + fi + cd_or_fail $1 + msg info "Unpacking %s" ${G_SPKG}/${pkg}.tar.xz + xz -dc ${G_SPKG}/${pkg}.tar.xz | tar -xf - +} diff --git a/pat-11.2.1/musl-alpine/handle-aux-at_base.patch b/pat-11.2.1/musl-alpine/handle-aux-at_base.patch @@ -0,0 +1,46 @@ +This is required to make the gcompat ELF interpreter stub work with some +packed binaries. + +diff --git a/src/env/__init_tls.c b/src/env/__init_tls.c +index b125eb1..616c6a6 100644 +--- a/src/env/__init_tls.c ++++ b/src/env/__init_tls.c +@@ -66,8 +66,10 @@ void *__copy_tls(unsigned char *mem) + } + + #if ULONG_MAX == 0xffffffff ++typedef Elf32_Ehdr Ehdr; + typedef Elf32_Phdr Phdr; + #else ++typedef Elf64_Ehdr Ehdr; + typedef Elf64_Phdr Phdr; + #endif + +@@ -77,15 +79,23 @@ extern const size_t _DYNAMIC[]; + static void static_init_tls(size_t *aux) + { + unsigned char *p; +- size_t n; ++ size_t n, e; + Phdr *phdr, *tls_phdr=0; + size_t base = 0; + void *mem; + +- for (p=(void *)aux[AT_PHDR],n=aux[AT_PHNUM]; n; n--,p+=aux[AT_PHENT]) { ++ if (aux[AT_BASE]) { ++ Ehdr *ehdr = (void *)aux[AT_BASE]; ++ p = (unsigned char *)aux[AT_BASE] + ehdr->e_phoff; ++ n = ehdr->e_phnum; ++ e = ehdr->e_phentsize; ++ } else { ++ p = (void *)aux[AT_PHDR]; ++ n = aux[AT_PHNUM]; ++ e = aux[AT_PHENT]; ++ } ++ for (; n; n--, p+=e) { + phdr = (void *)p; +- if (phdr->p_type == PT_PHDR) +- base = aux[AT_PHDR] - phdr->p_vaddr; + if (phdr->p_type == PT_DYNAMIC && _DYNAMIC) + base = (size_t)_DYNAMIC - phdr->p_vaddr; + if (phdr->p_type == PT_TLS) diff --git a/pat-11.2.1/musl-mlfs/change-scheduler-functions-Linux-compatib.patch b/pat-11.2.1/musl-mlfs/change-scheduler-functions-Linux-compatib.patch @@ -0,0 +1,52 @@ +diff -uNr musl-1.2.2.orig/src/sched/sched_getparam.c musl-1.2.2/src/sched/sched_getparam.c +--- musl-1.2.2.orig/src/sched/sched_getparam.c 2021-01-15 02:26:00.000000000 +0000 ++++ musl-1.2.2/src/sched/sched_getparam.c 2021-12-23 00:31:16.590518270 +0000 +@@ -1,8 +1,7 @@ + #include <sched.h> +-#include <errno.h> + #include "syscall.h" + + int sched_getparam(pid_t pid, struct sched_param *param) + { +- return __syscall_ret(-ENOSYS); ++ return syscall(SYS_sched_getparam, pid, param); + } +diff -uNr musl-1.2.2.orig/src/sched/sched_getscheduler.c musl-1.2.2/src/sched/sched_getscheduler.c +--- musl-1.2.2.orig/src/sched/sched_getscheduler.c 2021-01-15 02:26:00.000000000 +0000 ++++ musl-1.2.2/src/sched/sched_getscheduler.c 2021-12-23 00:33:32.949520644 +0000 +@@ -1,8 +1,7 @@ + #include <sched.h> +-#include <errno.h> + #include "syscall.h" + + int sched_getscheduler(pid_t pid) + { +- return __syscall_ret(-ENOSYS); ++ return syscall(SYS_sched_getscheduler, pid); + } +diff -uNr musl-1.2.2.orig/src/sched/sched_setparam.c musl-1.2.2/src/sched/sched_setparam.c +--- musl-1.2.2.orig/src/sched/sched_setparam.c 2021-01-15 02:26:00.000000000 +0000 ++++ musl-1.2.2/src/sched/sched_setparam.c 2021-12-23 00:35:12.277522374 +0000 +@@ -1,8 +1,7 @@ + #include <sched.h> +-#include <errno.h> + #include "syscall.h" + + int sched_setparam(pid_t pid, const struct sched_param *param) + { +- return __syscall_ret(-ENOSYS); ++ return syscall(SYS_sched_setparam, pid, param); + } +diff -uNr musl-1.2.2.orig/src/sched/sched_setscheduler.c musl-1.2.2/src/sched/sched_setscheduler.c +--- musl-1.2.2.orig/src/sched/sched_setscheduler.c 2021-01-15 02:26:00.000000000 +0000 ++++ musl-1.2.2/src/sched/sched_setscheduler.c 2021-12-23 00:36:37.548523859 +0000 +@@ -1,8 +1,7 @@ + #include <sched.h> +-#include <errno.h> + #include "syscall.h" + + int sched_setscheduler(pid_t pid, int sched, const struct sched_param *param) + { +- return __syscall_ret(-ENOSYS); ++ return syscall(SYS_sched_setscheduler, pid, sched, param); + } diff --git a/pat-11.2.1/musl-mlfs/fix-utmp-wtmp-paths.patch b/pat-11.2.1/musl-mlfs/fix-utmp-wtmp-paths.patch @@ -0,0 +1,29 @@ +diff -uNr musl-1.2.2.orig/include/paths.h musl-1.2.2/include/paths.h +--- musl-1.2.2.orig/include/paths.h 2021-01-14 20:26:00.000000000 -0600 ++++ musl-1.2.2/include/paths.h 2021-08-26 16:39:31.355618388 -0500 +@@ -18,9 +18,9 @@ + #define _PATH_SHADOW "/etc/shadow" + #define _PATH_SHELLS "/etc/shells" + #define _PATH_TTY "/dev/tty" +-#define _PATH_UTMP "/dev/null/utmp" ++#define _PATH_UTMP "/run/utmps/utmp" + #define _PATH_VI "/usr/bin/vi" +-#define _PATH_WTMP "/dev/null/wtmp" ++#define _PATH_WTMP "/var/log/wtmp" + + #define _PATH_DEV "/dev/" + #define _PATH_TMP "/tmp/" +diff -uNr musl-1.2.2.orig/include/utmp.h musl-1.2.2/include/utmp.h +--- musl-1.2.2.orig/include/utmp.h 2021-01-14 20:26:00.000000000 -0600 ++++ musl-1.2.2/include/utmp.h 2021-08-26 16:37:11.567365982 -0500 +@@ -37,8 +37,8 @@ + + int login_tty(int); + +-#define _PATH_UTMP "/dev/null/utmp" +-#define _PATH_WTMP "/dev/null/wtmp" ++#define _PATH_UTMP "/run/utmps/utmp" ++#define _PATH_WTMP "/var/log/wtmp" + + #define UTMP_FILE _PATH_UTMP + #define WTMP_FILE _PATH_WTMP diff --git a/pat-11.2.1/musl-mlfs/i686-fix-rounding.patch b/pat-11.2.1/musl-mlfs/i686-fix-rounding.patch @@ -0,0 +1,12 @@ +diff -uNr musl-1.1.23.orig/src/math/round.c musl-1.1.23/src/math/round.c +--- musl-1.1.23.orig/src/math/round.c 2019-07-16 14:30:39.000000000 -0500 ++++ musl-1.1.23/src/math/round.c 2019-09-07 14:26:53.555422685 -0500 +@@ -22,7 +22,7 @@ + FORCE_EVAL(x + toint); + return 0*u.f; + } +- y = x + toint - toint - x; ++ y = (double)(x + 0x1p52) - 0x1p52 - x; + if (y > 0.5) + y = y + x - 1; + else if (y <= -0.5)