galeb

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

чување e113cdc50aad6826dcd9fef30b64418a844540ef
родитељ 4c64e4b768b3a725d9679aa3e4ea2b9737be118e
Аутор: Страхиња Радић <contact@strahinja.org>
Датум:   Fri, 15 Jul 2022 18:17:39 +0200

Bootable system!

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

Diffstat:
M01-cross.sh | 100++++++++++++++++++++++++++++++++++++++++++++++++++-----------------------------
M02-chroot.sh | 57+++++++++++++++++++++++++++------------------------------
M03-packages.sh | 290+++++++++++++++++++++++++++++++++++++++++++++++++++++--------------------------
M04-finale.sh | 122++++++++++++++++++++++++++++++++++++++++++++++++++++---------------------------
MBUGS | 8+-------
MTODO | 19+++++++++++++------
Afil/rc.d/g_fun.sh | 62++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Afil/rc.d/mkshrc | 15+++++++++++++++
Afil/rc.d/profile | 21+++++++++++++++++++++
Afil/rc.d/rc.conf | 5+++++
Afil/rc.d/rc.init | 128+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Afil/rc.d/rc.local | 2++
Afil/rc.d/rc.shutdown | 64++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Mlib/fun.sh | 80+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++--------
Mlib/gensums | 2+-
Alib/perms.tsv | 6++++++
Mlib/pkgs.tsv | 5+++--
Alib/setperms | 44++++++++++++++++++++++++++++++++++++++++++++
Apat-11.2.1/perp-oasis/0001-tain_now-Use-clock_gettime.patch | 38++++++++++++++++++++++++++++++++++++++
Apat-11.2.1/perp-oasis/0002-perpd-Restore-umask-after-perpd_control_init.patch | 47+++++++++++++++++++++++++++++++++++++++++++++++
Apat-11.2.1/perp-oasis/0003-Remove-pointer-arithmetic-on-void.patch | 194+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Apat-11.2.1/perp-oasis/0004-Remove-obsolete-files.patch | 181+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Apat-11.2.1/perp-oasis/0005-Remove-unused-variable.patch | 34++++++++++++++++++++++++++++++++++
измењених датотека: 23, додавања: 1299(+), брисања: 225(-)

diff --git a/01-cross.sh b/01-cross.sh @@ -3,6 +3,13 @@ . ./lib/env.sh . ./lib/fun.sh +HOST_COREUTILS=1 +HOST_FIND=1 +HOST_MD5SUM=1 +HOST_SED=1 +HOST_TAR=1 +export HOST_COREUTILS HOST_FIND HOST_MD5SUM HOST_SED HOST_TAR + mkdir -p ${G_LOG} :>${G_LOGFILE} :>${G_SHORTLOG} @@ -30,6 +37,10 @@ check_dir ${G_PAT} check_dir ${G_PKG} check_dir ${G_SRC} +check_dir ${TL} +check_dir ${TL}/bin +check_dir ${TL}/lib + check_dir ${G_SPKG} msg info "Setup root structure" @@ -88,7 +99,7 @@ do case ${url} in git:*|git+https:*) git_clone "${dirtb}" ${url##git+} ${delay};; - https:*) fetch_pkg ${url} "${dirtb}" ${delay};; + http:*|https:*) fetch_pkg ${url} "${dirtb}" ${delay};; *) ;; esac if [ -n "${md5}" ]; then @@ -350,7 +361,7 @@ end_step # cross-tools begin_step tools -totalsubsteps=26 +totalsubsteps=28 substep=1 begin_substep musl-1.2.3 @@ -458,28 +469,28 @@ extract_pkg ${G_SRC} ${pkg} ${pkg}.tar.xz ( cd_or_fail ${G_SRC}/${pkg} - subpkg=gmp-6.2.1 + subpkg=libgmp-6.2.1 if [ -d gmp ]; then msg info "Subpackage %s exists" "${subpkg}" else extract_pkg ${G_SRC}/${pkg} ${subpkg} ${subpkg}.tar.xz - mv_or_fail ${subpkg} gmp + mv_or_fail ${subpkg#lib} gmp fi - subpkg=mpc-1.2.1 + subpkg=libmpc-1.2.1 if [ -d mpc ]; then msg info "Subpackage %s exists" "${subpkg}" else extract_pkg ${G_SRC}/${pkg} ${subpkg} ${subpkg}.tar.gz - mv_or_fail ${subpkg} mpc + mv_or_fail ${subpkg#lib} mpc fi - subpkg=mpfr-4.1.0 + subpkg=libmpfr-4.1.0 if [ -d mpfr ]; then msg info "Subpackage %s exists" "${subpkg}" else extract_pkg ${G_SRC}/${pkg} ${subpkg} ${subpkg}.tar.xz - mv_or_fail ${subpkg} mpfr + mv_or_fail ${subpkg#lib} mpfr fi msg info "Applying patches" @@ -849,6 +860,9 @@ else fi end_substep +HOST_FIND=0 +export HOST_FIND + begin_substep gettext-tiny-0.3.2 if [ -x ${TL}/bin/msgfmt ]; then msg info "%s exists, skipping %s" ${TL}/bin/msgfmt ${pkg} @@ -971,7 +985,7 @@ gt_cv_int_divbyzero_sigfpe=yes --host=${G_TARGET} \ --cache-file=config.cache - run_make ${JN} + run_make -j1 run_make install ) || exit 1 remove_dir ${G_SRC}/${pkg} @@ -1070,6 +1084,7 @@ else fi end_substep +# Unfortunately needed for a lot of autohell stuff; keeping it in /tools though begin_substep coreutils-9.1 if [ -x ${TL}/bin/ls ]; then msg info "%s exists, skipping %s" ${TL}/bin/ls ${pkg} @@ -1098,6 +1113,9 @@ gl_cv_func_working_acl_get_file=yes fi end_substep +HOST_COREUTILS=0 +export HOST_COREUTILS + begin_substep sed-4.8 if [ -x ${TL}/bin/sed ]; then msg info "%s exists, skipping %s" ${TL}/bin/sed ${pkg} @@ -1117,6 +1135,9 @@ else fi end_substep +HOST_SED=0 +export HOST_SED + # begin_substep sbase-20220709 # if [ -x ${TL}/bin/ls ]; then # msg info "%s exists, skipping %s" ${TL}/bin/ls ${pkg} @@ -1136,32 +1157,35 @@ end_substep # fi # end_substep # -# begin_substep ubase-20220709 -# if [ -x ${TL}/bin/id ]; then -# msg info "%s exists, skipping %s" ${TL}/bin/id ${pkg} -# else -# ( -# CC=tcc -# export CC -# 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 ubase-20220709 +if [ -x ${TL}/bin/mount ]; then + msg info "%s exists, skipping %s" ${TL}/bin/mount ${pkg} +else + ( + cd_or_fail ${G_SRC}/${pkg} + + cp util.h util.h.orig + sed -i -z 's,"arg.h"\n,&#include <sys/sysmacros.h>\n,' util.h + + cp config.mk config.mk.orig + sed -i -e 's,/usr/local,,g;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} + + cp id mount umount /${TLD}/bin + #run_make install + + mv util.h.orig util.h + mv config.mk.orig config.mk + #remove_dir ${G_SRC}/${pkg} + ) || exit 1 +fi +end_substep begin_substep tar-1.34 if [ -x ${TL}/bin/tar ]; then @@ -1181,6 +1205,9 @@ else fi end_substep +HOST_TAR=0 +export HOST_TAR + begin_substep xz-5.2.5 if [ -x ${TL}/bin/xz ]; then msg info "%s exists, skipping %s" ${TL}/bin/xz ${pkg} @@ -1289,7 +1316,7 @@ begin_substep sled-0.10.8 if [ -x ${TL}/bin/sled ]; then msg info "%s exists, skipping %s" ${TL}/bin/sled ${pkg} else - extract_pkg ${G_SRC} ${pkg} ${pkg}.tar.gz + extract_pkg ${G_SRC} sled-v0.10.8 ${pkg}.tar.gz ${pkg} ( cd_or_fail ${G_SRC}/${pkg} SLED_CC=${CC}' -O2 -Wall -static -fcommon' @@ -1306,5 +1333,6 @@ msg info "Cleaning up environment" export PATH=${OLDPATH} unset OLDPATH CC CXX AR AS RANLIB LD STRIP unset WD +unset HOST_COREUTILS HOST_FIND HOST_MD5SUM HOST_SED HOST_TAR msg warn "Next run ./02-chroot.sh as root" diff --git a/02-chroot.sh b/02-chroot.sh @@ -22,6 +22,13 @@ if [ -n "$1" ]; then GR=$1 fi +HOST_COREUTILS=0 +HOST_FIND=0 +HOST_MD5SUM=0 +HOST_SED=0 +HOST_TAR=0 +export HOST_COREUTILS HOST_FIND HOST_MD5SUM HOST_SED HOST_TAR + trap exit_cleanup HUP PIPE INT QUIT TERM EXIT if [ "$(id -u)" -ne 0 ]; then @@ -45,10 +52,13 @@ check_dir ${GR}/run remove_file ${GR}/sbin link_if_ne bin ${GR}/sbin check_dir ${GR}/share +check_dir ${GR}/share/locale check_dir ${GR}/sucks/bin check_dir ${GR}/sucks/lib remove_file ${GR}/sucks/sbin link_if_ne bin ${GR}/sucks/sbin +check_dir ${GR}/share +check_dir ${GR}/share/locale check_dir ${GR}/sys check_dir ${GR}/tmp chmod +t ${GR}/tmp @@ -96,17 +106,14 @@ galeb:x:${GGID}:galeb ! fi -if [ -e ${GR}/etc/profile ]; then - msg info "%s exists" "${GR}/etc/profile" -else - msg info "Generating %s" "${GR}/etc/profile" - cat <<! >${GR}/etc/profile +msg info "Generating %s" "${GR}/etc/profile" +cat <<! >${GR}/etc/profile LC_ALL= LANG=C.UTF-8 PATH=/${TLD}/bin:/bin:/sbin:/sucks/bin:/sucks/sbin:/plan9/bin export LC_ALL LANG PATH -# A more familiar ls +# More like GNU ls lc() { if [ -x /tools/bin/ls ]; then @@ -118,36 +125,26 @@ lc() [ -e /etc/mkshrc ] && . /etc/mkshrc ! -fi - -if [ -e ${GR}/etc/mkshrc ]; then - msg info "%s exists" "${GR}/etc/mkshrc" -else - msg info "Generating %s" "${GR}/etc/mkshrc" - cat <<'!' >${GR}/etc/mkshrc -if [ "${KSHUID}" -eq 0 ]; then - PS1=$'\1\r\1\e]0;\1${PWD/#${HOME/\//\\\/}/\\~}\1\b\e[97m\1='\ -$'${HOSTNAME:=$(hostname)}=${PWD/#${HOME/\//\\\/}/\\~}= \1\e[1m\e[2m\e[31m\1\#\1\e[0m\1 ' -else - PS1=$'\1\r\1\e]0;\1${PWD/#${HOME/\//\\\/}/\\~}\1\b\e[97m\1='\ -$'${HOSTNAME:=$(hostname)}=${PWD/#${HOME/\//\\\/}/\\~}= \1\e[93m\1\$\1\e[0m\1 ' -fi - -bind '^L=clear-screen' -bind -m ^U='^[0^K' - -set -U -! -fi link_if_ne /${TLD}/bin/lksh ${GR}/bin/sh link_if_ne /${TLD}/bin/bash ${GR}/bin/bash cp_or_fail ${WD}/03-packages.sh ${GR}/bin/ cp_or_fail ${WD}/04-finale.sh ${GR}/bin/ check_dir ${G_LIB} -cp_or_fail ${WD}/lib/env.sh ${G_LIB}/env.sh -/bin/sed -i 's,^\(GR=\).*,\1,' ${G_LIB}/env.sh -cp_or_fail ${WD}/lib/fun.sh ${G_LIB}/fun.sh +cp_or_fail ${WD}/lib/env.sh ${GR}/lib/env.sh +/bin/sed -i 's,^\(GR=\).*,\1,' ${GR}/lib/env.sh +cp_or_fail ${WD}/lib/fun.sh ${GR}/lib/fun.sh +cp_or_fail ${WD}/${FLD}/rc.d/g_fun.sh ${GR}/lib/g_fun.sh +cp_or_fail ${WD}/lib/setperms ${GR}/lib/setperms +cp_or_fail ${WD}/lib/perms.tsv ${GR}/lib/perms.tsv + +cp_or_fail ${WD}/${FLD}/rc.d/profile ${GR}/etc/profile.final +cp_or_fail ${WD}/${FLD}/rc.d/mkshrc ${GR}/etc/mkshrc +cp_or_fail ${WD}/${FLD}/rc.d/rc.init ${GR}/bin/rc.init +cp_or_fail ${WD}/${FLD}/rc.d/rc.shutdown ${GR}/bin/rc.shutdown +cp_or_fail ${WD}/${FLD}/rc.d/rc.conf ${GR}/etc/rc.conf +cp_or_fail ${WD}/${FLD}/rc.d/rc.local ${GR}/etc/rc.local + msg warn "Next run 03-packages.sh" msg query "Run as root [Y/n]?" diff --git a/03-packages.sh b/03-packages.sh @@ -1,12 +1,17 @@ #!/bin/sh -if [ -d /src/lib ]; then - . /src/lib/env.sh - . /src/lib/fun.sh -else - . ./lib/env.sh - . ./lib/fun.sh -fi +. ./lib/env.sh +. ./lib/fun.sh + +HOST_COREUTILS=0 +HOST_FIND=0 +HOST_MD5SUM=0 +HOST_SED=0 +HOST_TAR=0 +export HOST_COREUTILS HOST_FIND HOST_MD5SUM HOST_SED HOST_TAR + +PATH=/${TLD}/bin:/bin:/sbin:/sucks/bin:/sucks/sbin:/plan9/bin +export PATH trap exit_cleanup HUP PIPE INT QUIT TERM EXIT @@ -18,6 +23,8 @@ elif [ "$(id -u)" -ne 0 ]; then exit 1 fi +export JN=-j1 + cat /etc/issue totalsteps=1 @@ -156,6 +163,11 @@ if [ -e /lib/ld-musl-${G_ARCH_EXT_ALT}.so.1 ]; then elif [ -e ${G_SPKG}/${pkg}.tar.xz ]; then unpack_pkg ${pkg} / else + if [ -e /${TLD}/bin/ld-old ]; then + msg err "ld-old exists, build will ultimately fail. " + msg err "Rotate back ld to ld-new and ld-old to ld and rerun." + exit 1 + fi extract_pkg ${G_SRC} ${pkg} ${pkg}.tar.gz ( cd_or_fail ${G_SRC}/${pkg} @@ -183,7 +195,7 @@ mkpk_install() ( CC=${G_TARGET}-gcc CXX=${G_TARGET}-g++ - CFLAGS='-O3 -march=native -mtune=native -pipe' + CFLAGS='-Os -pipe' PATH=/${TLD}/bin:${PATH} export CC CXX CFLAGS PATH @@ -248,6 +260,8 @@ if [ ! -e /${TLD}/bin/ld-old ]; then link_if_ne /${TLD}/bin/ld /${TLD}/${G_TARGET}/bin/ld fi +msg warn "After this point, builds are repeatable" + msg info "Adjusting specs" SPECFILE=$(realpath $(dirname $(gcc -print-libgcc-file-name)))/specs export SPECFILE @@ -278,7 +292,7 @@ mkpk_name() mkpk_install() { - CFLAGS='-O3 -march=native -mtune=native -pipe' + CFLAGS='-Os -pipe' export CFLAGS ./configure --prefix=/ \\ --libdir=/lib \\ @@ -316,7 +330,7 @@ mkpk_install() { ./configure --prefix=/ \\ --enable-static \\ - CFLAGS='-O3 -march=native -mtune=native -pipe -static --static -fcommon' \\ + CFLAGS='-Os -pipe -static --static -fcommon' \\ LDFLAGS='-static --static -fcommon' make ${JN} make DESTDIR=/build install-strip @@ -353,7 +367,7 @@ mkpk_install() ./configure --prefix=/sucks \\ --disable-static \\ --docdir=/sucks/share/doc/readline-8.1 \\ - CFLAGS='-O3 -march=native -mtune=native -pipe' + CFLAGS='-Os -pipe' make ${JN} SHLIB_LIBS='-L/'${TLD}'/lib -lncursesw' make SHLIB_LIBS='-L/'${TLD}'/lib -lncursesw' DESTDIR=/build install } @@ -387,7 +401,7 @@ mkpk_name() mkpk_install() { ./configure --prefix=/sucks \\ - CFLAGS='-O3 -march=native -mtune=native -pipe' + CFLAGS='-Os -pipe' make ${JN} make DESTDIR=/build install-strip } @@ -471,7 +485,7 @@ mkpk_install() timezones='africa antarctica asia australasia europe northamerica'\\ ' southamerica etcetera backward factory' make DESTDIR=../build prefix= \\ - CFLAGS='-O3 -march=native -mtune=native -pipe -static -fcommon -DHAVE_STDINT_H=1' \\ + CFLAGS='-Os -pipe -static -fcommon -DHAVE_STDINT_H=1' \\ LDFLAGS='-static -fcommon' \\ TZDIR=/share/zoneinfo make -C posixtz-0.5 posixtz @@ -533,6 +547,7 @@ mkpk_name() mkpk_install() { + make clean make DESTDIR=/build ${JN} install } ! @@ -542,6 +557,15 @@ mkpk_install() fi end_substep +msg info "Adjusting specs" +SPECFILE=$(realpath $(dirname $(gcc -print-libgcc-file-name)))/specs +export SPECFILE +remove_file ${SPECFILE} +gcc -dumpspecs | sed -e 's,/'${TLD}',,g' \ + -e '/\*startfile_prefix_spec:/{n;s,.*,/lib/ ,}' > specs +mv_or_fail specs ${SPECFILE} +unset SPECFILE + begin_substep binutils-2.38 if [ -x /sucks/bin/ar ]; then msg info "%s exists, skipping %s" /sucks/bin/ar ${pkg} @@ -551,6 +575,7 @@ else extract_pkg ${G_SRC} ${pkg} ${pkg}.tar.xz ( cd_or_fail ${G_SRC}/${pkg} + for patch in 0001-Revert-PR25882-.gnu.attributes-are-not-\ checked-for-s.patch \ binutils-ld-fix-static-linking.patch @@ -570,12 +595,17 @@ mkpk_name() mkpk_install() { - CFLAGS='-O3 -march=native -mtune=native -pipe' + CC=${G_TARGET}-gcc + CXX=${G_TARGET}-g++ + CFLAGS='-Os -pipe -I/include -I/sucks/include' CXXFLAGS=\${CFLAGS} + CPPFLAGS='' + PATH=/${TLD}/bin:${PATH} DESTDIR=/build EXTRA_CONFIG=' --enable-targets=x86_64-pep ' TARGET_LIB_PATH=/local/lib:/lib:/sucks/lib - export CFLAGS CXXFLAGS DESTDIR EXTRA_CONFIG TARGET_LIB_PATH + export CC CXX CFLAGS CXXFLAGS CPPFLAGS DESTDIR EXTRA_CONFIG + export TARGET_LIB_PATH PATH ./configure \\ --prefix=/sucks \\ @@ -595,7 +625,7 @@ mkpk_install() --disable-multilib \\ --with-mmap \\ --enable-64-bit-bfd \\ - --with-pic $EXTRA_CONFIG + --with-pic $EXTRA_CONFIG || exit 1 make ${JN} tooldir=/sucks || exit 1 make tooldir=/sucks install-strip @@ -803,7 +833,7 @@ mkpk_name() mkpk_install() { - CFLAGS='-O3 -march=native -mtune=native -pipe -static --static -fcommon '\ + CFLAGS='-Os -pipe -static --static -fcommon '\ '-DENCRYPTMETHOD_SELECT' LDFLAGS='-static --static -fcommon' DESTDIR=/build @@ -851,6 +881,7 @@ if [ -x /sucks/bin/gcc ]; then elif [ -e ${G_SPKG}/${pkg}.tar.xz ]; then unpack_pkg ${pkg} / else + remove_dir ${G_SRC}/${pkg} extract_pkg ${G_SRC} ${pkg} ${pkg}.tar.xz ( cd_or_fail ${G_SRC}/${pkg} @@ -871,10 +902,11 @@ mkpk_name() mkpk_install() { - CFLAGS='-O3 -march=native -mtune=native -pipe' - CXXFLAGS='-O3 -march=native -mtune=native -pipe' + CFLAGS='-Os -pipe -I/sucks/include -I/include -L/sucks/lib -L/lib' + CXXFLAGS=\${CFLAGS} + CPPFLAGS='' DESTDIR=/build - export CFLAGS CXXFLAGS DESTDIR + export CFLAGS CXXFLAGS CPPFLAGS DESTDIR SED=/${TLD}/bin/sed libat_cv_have_ifunc=no \\ ./configure \\ @@ -962,6 +994,18 @@ LD=ld STRIP=strip export CC CXX AR AS RANLIB LD STRIP +msg info "Adjusting specs" +SPECFILE=$(realpath $(dirname $(gcc -print-libgcc-file-name)))/specs +export SPECFILE +remove_file ${SPECFILE} +gcc -dumpspecs | sed -e 's,/'${TLD}',,g' \ + -e '/\*startfile_prefix_spec:/{n;s,.*,/local/lib/ /lib/ /sucks/lib/ '\ +',}' \ + -e '/\*cpp:/{n;s,$, -I /local/include -I /include -I /sucks/include '\ +',}' > specs +mv_or_fail specs ${SPECFILE} +unset SPECFILE + PATH=/bin:/sucks/bin:/${TLD}/bin export PATH @@ -986,7 +1030,7 @@ mkpk_name() mkpk_install() { - CFLAGS='-O3 -march=native -mtune=native -pipe -static --static -fcommon -fPIC' + CFLAGS='-Os -pipe -static --static -fcommon -fPIC' LDFLAGS='-static --static -fcommon' DESTDIR=/build export CFLAGS LDFLAGS DESTDIR @@ -1044,7 +1088,7 @@ mkpk_name() mkpk_install() { - CFLAGS='-O3 -march=native -mtune=native -pipe -static --static -fcommon -fPIC' + CFLAGS='-Os -pipe -static --static -fcommon -fPIC' LDFLAGS='-static --static -fcommon' DESTDIR=/build export CFLAGS LDFLAGS DESTDIR @@ -1089,7 +1133,7 @@ mkpk_name() mkpk_install() { - CFLAGS='-O3 -march=native -mtune=native -pipe' + CFLAGS='-Os -pipe' CXXFLAGS=\${CFLAGS} DESTDIR=/build LIBS=-lstdc++ @@ -1129,7 +1173,7 @@ mkpk_name() mkpk_install() { - CFLAGS='-O3 -march=native -mtune=native -pipe -static --static -fcommon' + CFLAGS='-Os -pipe -static --static -fcommon' LDFLAGS='-static --static -fcommon' DESTDIR=/build export CFLAGS DESTDIR LDFLAGS @@ -1162,7 +1206,7 @@ mkpk_name() mkpk_install() { - CFLAGS='-O3 -march=native -mtune=native -pipe -static --static -fcommon' + CFLAGS='-Os -pipe -static --static -fcommon' LDFLAGS='-static --static -fcommon' DESTDIR=/build export CFLAGS LDFLAGS DESTDIR @@ -1201,7 +1245,7 @@ mkpk_name() mkpk_install() { - CFLAGS='-O3 -march=native -mtune=native -pipe -static --static -fcommon' + CFLAGS='-Os -pipe -static --static -fcommon' LDFLAGS='-static --static -fcommon' DESTDIR=/build export CFLAGS LDFLAGS DESTDIR @@ -1240,7 +1284,7 @@ mkpk_name() mkpk_install() { - CFLAGS='-O3 -march=native -mtune=native -pipe' + CFLAGS='-Os -pipe' DESTDIR=/build export CFLAGS DESTDIR @@ -1273,7 +1317,7 @@ mkpk_name() mkpk_install() { - CFLAGS='-O3 -march=native -mtune=native -pipe -static --static -fcommon' + CFLAGS='-Os -pipe -static --static -fcommon' LDFLAGS='-static --static -fcommon' DESTDIR=/build export CFLAGS LDFLAGS DESTDIR @@ -1345,7 +1389,7 @@ mkpk_name() mkpk_install() { - CFLAGS='-O3 -march=native -mtune=native -pipe -static --static -fcommon' + CFLAGS='-Os -pipe -static --static -fcommon' LDFLAGS='-static --static -fcommon' DESTDIR=/build export CFLAGS LDFLAGS DESTDIR @@ -1381,7 +1425,7 @@ mkpk_name() mkpk_install() { - CFLAGS='-O3 -march=native -mtune=native -pipe -static --static -fcommon' + CFLAGS='-Os -pipe -static --static -fcommon' LDFLAGS='-static --static -fcommon' DESTDIR=/build export CFLAGS LDFLAGS DESTDIR @@ -1417,7 +1461,7 @@ mkpk_name() mkpk_install() { - CFLAGS='-O3 -march=native -mtune=native -pipe -static --static -fcommon' + CFLAGS='-Os -pipe -static --static -fcommon' LDFLAGS='-static --static -fcommon' export CFLAGS LDFLAGS @@ -1452,7 +1496,7 @@ mkpk_name() mkpk_install() { - CFLAGS='-O3 -march=native -mtune=native -pipe' + CFLAGS='-Os -pipe' LDFLAGS= DESTDIR=/build export CFLAGS LDFLAGS DESTDIR @@ -1490,8 +1534,8 @@ mkpk_name() mkpk_install() { - CFLAGS='-O3 -march=native -mtune=native -pipe' - CXXFLAGS='-O3 -march=native -mtune=native -pipe' + CFLAGS='-Os -pipe' + CXXFLAGS='-Os -pipe' LDFLAGS= DESTDIR=/build export CFLAGS CXXFLAGS LDFLAGS DESTDIR @@ -1528,7 +1572,7 @@ mkpk_name() mkpk_install() { - CFLAGS='-O3 -march=native -mtune=native -pipe' + CFLAGS='-Os -pipe' LDFLAGS= DESTDIR=/build export CFLAGS LDFLAGS DESTDIR @@ -1566,7 +1610,7 @@ mkpk_name() mkpk_install() { - CFLAGS='-O3 -march=native -mtune=native -pipe -static --static -fcommon' + CFLAGS='-Os -pipe -static --static -fcommon' LDFLAGS='-static --static -fcommon' DESTDIR=/build export CFLAGS LDFLAGS DESTDIR @@ -1638,7 +1682,7 @@ mkpk_install() sh Configure \ -des -Dprefix=/sucks \ - -Doptimize=-O3 \ + -Doptimize=-Os \ -Dvendorprefix=/sucks \ -Dprivlib=/sucks/lib/perl5/5.34/core_perl \ -Darchlib=/sucks/lib/perl5/5.34/core_perl \ @@ -1719,7 +1763,7 @@ mkpk_name() mkpk_install() { - CFLAGS='-O3 -march=native -mtune=native -pipe -static --static -fcommon' + CFLAGS='-Os -pipe -static --static -fcommon' LDFLAGS='-static --static -fcommon' DESTDIR=/build export CFLAGS LDFLAGS DESTDIR @@ -1760,7 +1804,7 @@ mkpk_name() mkpk_install() { - CFLAGS='-O3 -march=native -mtune=native -pipe' + CFLAGS='-Os -pipe' LDFLAGS= DESTDIR=/build export CFLAGS LDFLAGS DESTDIR @@ -1796,7 +1840,7 @@ mkpk_name() mkpk_install() { - CFLAGS='-O3 -march=native -mtune=native -pipe' + CFLAGS='-Os -pipe' LDFLAGS= DESTDIR=/build export CFLAGS LDFLAGS DESTDIR @@ -1832,7 +1876,7 @@ mkpk_name() mkpk_install() { - CFLAGS='-O3 -march=native -mtune=native -pipe' + CFLAGS='-Os -pipe' LDFLAGS= DESTDIR=/build export CFLAGS LDFLAGS DESTDIR @@ -1868,7 +1912,7 @@ mkpk_name() mkpk_install() { - CFLAGS='-O3 -march=native -mtune=native -pipe -fPIC' + CFLAGS='-Os -pipe -fPIC' LDFLAGS= DESTDIR=/build export CFLAGS LDFLAGS DESTDIR @@ -1907,7 +1951,7 @@ mkpk_name() mkpk_install() { - CFLAGS='-O3 -march=native -mtune=native -pipe -fPIC' + CFLAGS='-Os -pipe -fPIC' LDFLAGS= DESTDIR=/build export CFLAGS LDFLAGS DESTDIR @@ -1949,7 +1993,7 @@ mkpk_name() mkpk_install() { - CFLAGS='-O3 -march=native -mtune=native -pipe -static --static -fcommon' + CFLAGS='-Os -pipe -static --static -fcommon' LDFLAGS='-static --static -fcommon' DESTDIR=/build export CFLAGS LDFLAGS DESTDIR @@ -1985,7 +2029,7 @@ mkpk_name() mkpk_install() { - CFLAGS='-O3 -march=native -mtune=native -pipe -static --static -fcommon' + CFLAGS='-Os -pipe -static --static -fcommon' LDFLAGS='-static --static -fcommon' DESTDIR=/build export CFLAGS LDFLAGS DESTDIR @@ -2034,7 +2078,7 @@ mkpk_name() mkpk_install() { cat <<@ >config.mak -CFLAGS=-O3 -march=native -mtune=native -pipe -static --static -fcommon +CFLAGS=-Os -pipe -static --static -fcommon LDFLAGS=-static --static -fcommon @ sed -i 's,/usr/local,,g' Makefile @@ -2116,7 +2160,7 @@ mkpk_install() { chmod +x configure - CFLAGS='-O3 -march=native -mtune=native -pipe -fPIC' \\ + CFLAGS='-Os -pipe -fPIC' \\ ./configure --prefix=/ \\ --sysconfdir=/etc \\ --localstatedir=/var @@ -2156,7 +2200,7 @@ mkpk_name() mkpk_install() { - CFLAGS='-O3 -march=native -mtune=native -pipe' + CFLAGS='-Os -pipe' CFLAGS+=' -DFNM_EXTMATCH=0 -Wno-error -Wno-error=null-dereference' CFLAGS+=' -Wl,-z,stack-size=2097152' LDFLAGS='' @@ -2205,7 +2249,7 @@ mkpk_name() mkpk_install() { - CFLAGS='-O3 -march=native -mtune=native -pipe' + CFLAGS='-Os -pipe' LDFLAGS='' DESTDIR=/build export CFLAGS LDFLAGS DESTDIR @@ -2248,7 +2292,7 @@ mkpk_name() mkpk_install() { - CFLAGS='-O3 -march=native -mtune=native -pipe' + CFLAGS='-Os -pipe' LDFLAGS='' DESTDIR=/build export CFLAGS LDFLAGS DESTDIR @@ -2299,7 +2343,7 @@ mkpk_name() mkpk_install() { - CFLAGS='-O3 -march=native -mtune=native -pipe' + CFLAGS='-Os -pipe' LDFLAGS='' DESTDIR=/build export CFLAGS LDFLAGS DESTDIR @@ -2358,7 +2402,7 @@ mkpk_name() mkpk_install() { - CFLAGS='-O3 -march=native -mtune=native -pipe -static --static -fcommon' + CFLAGS='-Os -pipe -static --static -fcommon' LDFLAGS='-static --static -fcommon' DESTDIR=/build export CFLAGS LDFLAGS DESTDIR @@ -2394,7 +2438,7 @@ mkpk_name() mkpk_install() { - CFLAGS='-O3 -march=native -mtune=native -pipe' + CFLAGS='-Os -pipe' LDFLAGS='' export CFLAGS LDFLAGS @@ -2427,7 +2471,7 @@ mkpk_name() mkpk_install() { - CFLAGS='-O3 -march=native -mtune=native -pipe' + CFLAGS='-Os -pipe' # Fix utmp CFLAGS+=' -DUT_NAMESIZE=0 -DUT_LINESIZE=0 -DUT_HOSTSIZE=0' CFLAGS+=' -D__UT_NAMESIZE=0 -D__UT_LINESIZE=0 -D__UT_HOSTSIZE=0' @@ -2491,7 +2535,7 @@ mkpk_name() mkpk_install() { - CFLAGS='-O3 -march=native -mtune=native -pipe -static --static -fcommon' + CFLAGS='-Os -pipe -static --static -fcommon' LDFLAGS='-static --static -fcommon' DESTDIR=/build export CFLAGS LDFLAGS DESTDIR @@ -2536,7 +2580,7 @@ mkpk_name() mkpk_install() { - CFLAGS='-O3 -march=native -mtune=native -pipe' + CFLAGS='-Os -pipe' LDFLAGS='' DESTDIR=/build export CFLAGS LDFLAGS DESTDIR @@ -2574,7 +2618,7 @@ mkpk_name() mkpk_install() { - CFLAGS='-O3 -march=native -mtune=native -pipe' + CFLAGS='-Os -pipe' LDFLAGS='' DESTDIR=/build export CFLAGS LDFLAGS DESTDIR @@ -2610,7 +2654,7 @@ mkpk_name() mkpk_install() { - CFLAGS='-O3 -march=native -mtune=native -pipe' + CFLAGS='-Os -pipe' LDFLAGS='' DESTDIR=/build export CFLAGS LDFLAGS DESTDIR @@ -2656,8 +2700,8 @@ mkpk_name() mkpk_install() { - CFLAGS='-march=native -mtune=native -pipe ' - CFLAGS+='-O3 -ffat-lto-objects -flto=4 ' + CFLAGS='-pipe ' + CFLAGS+='-Os -ffat-lto-objects -flto=4 ' LDFLAGS='-flto=4 -Wl,-O2 -Wl,--as-needed -pthread ' DESTDIR=/build export CFLAGS LDFLAGS DESTDIR @@ -2695,8 +2739,8 @@ mkpk_name() mkpk_install() { - CFLAGS='-march=native -mtune=native -pipe ' - CFLAGS+='-O3 -ffat-lto-objects -flto=auto ' + CFLAGS='-pipe ' + CFLAGS+='-Os -ffat-lto-objects -flto=auto ' CXXFLAGS=\${CFLAGS} LDFLAGS='-flto=auto -Wl,-O2 -Wl,--as-needed ' DESTDIR=/build @@ -2750,7 +2794,7 @@ mkpk_name() mkpk_install() { - CFLAGS='-O3 -march=native -mtune=native -pipe -static --static -fcommon' + CFLAGS='-Os -pipe -static --static -fcommon' LDFLAGS='-static --static -fcommon' DESTDIR=/build export CFLAGS LDFLAGS DESTDIR @@ -2813,7 +2857,7 @@ mkpk_name() mkpk_install() { - CFLAGS='-O3 -march=native -mtune=native -pipe -static --static -fcommon' + CFLAGS='-Os -pipe -static --static -fcommon' LDFLAGS='-static --static -fcommon' DESTDIR=/build export CFLAGS LDFLAGS DESTDIR @@ -2827,7 +2871,7 @@ SBINDIR=/bin MANDIR=/share/man BINM_SOELIM=msoelim MANM_ROFF=mandoc_roff -CFLAGS='-O3 -march=native -mtune=native -pipe' +CFLAGS='-Os -pipe' LDFLAGS='-Wl,-z,relro' STATIC='-static --static -fcommon' BUILD_CATMAN=1 @@ -2866,7 +2910,7 @@ mkpk_name() mkpk_install() { - CFLAGS='-O3 -march=native -mtune=native -pipe -static --static -fcommon' + CFLAGS='-Os -pipe -static --static -fcommon' CXXFLAGS=\${CFLAGS} LDFLAGS='-static --static -fcommon' DESTDIR=/build @@ -2903,7 +2947,7 @@ mkpk_name() mkpk_install() { - CFLAGS='-O3 -march=native -mtune=native -pipe -static --static -fcommon' + CFLAGS='-Os -pipe -static --static -fcommon' LDSTATIC='-static --static -fcommon' TARGET_OS=Linux DESTDIR=/build @@ -2954,6 +2998,7 @@ if [ -x /bin/sled ]; then elif [ -e ${G_SPKG}/${pkg}.tar.xz ]; then unpack_pkg ${pkg} / else + remove_dir ${G_SRC}/${pkg} extract_pkg ${G_SRC} sled-v0.10.8 ${pkg}.tar.gz ${pkg} ( cd_or_fail ${G_SRC}/${pkg} @@ -2966,10 +3011,17 @@ mkpk_name() mkpk_install() { - SLED_CC='tcc -O2 -static -fcommon' + SLED_CC='tcc -Os -static -fcommon' FALLBACKVER=${pkg##*-} PREFIX=/build export SLED_CC FALLBACKVER PREFIX + printf "SLED_CC=[%s] FALLBACKVER=[%s] PREFIX=[%s]\n" "\${SLED_CC}" \ + "\${FALLBACKVER}" "\${PREFIX}" + + if [ ! -e do.orig ]; then + cp do do.orig + /${TLD}/bin/sed -i -e "s,\\<xargs\\>,/${TLD}/bin/xargs,g" do + fi ./do -c install } ! @@ -2998,7 +3050,7 @@ mkpk_name() mkpk_install() { - CFLAGS='-O3 -march=native -mtune=native -pipe -static --static -fcommon' + CFLAGS='-Os -pipe -static --static -fcommon' LDFLAGS='-static --static -fcommon' DESTDIR=/build YACC=yacc @@ -3069,7 +3121,7 @@ mkpk_name() mkpk_install() { - CFLAGS='-O3 -march=native -mtune=native -pipe -static --static -fcommon' + CFLAGS='-Os -pipe -static --static -fcommon' LDFLAGS='-static --static -fcommon' DESTDIR=/build YACC=yacc @@ -3118,7 +3170,7 @@ mkpk_name() mkpk_install() { - CFLAGS='-O3 -march=native -mtune=native' + CFLAGS='-Os ' LDFLAGS='' DESTDIR=/build export CFLAGS LDFLAGS DESTDIR @@ -3153,7 +3205,7 @@ mkpk_name() mkpk_install() { - CFLAGS='-O3 -march=native -mtune=native' + CFLAGS='-Os ' LDFLAGS='' DESTDIR=/build export CFLAGS LDFLAGS DESTDIR @@ -3188,7 +3240,7 @@ mkpk_name() mkpk_install() { - CFLAGS='-O3 -march=native -mtune=native -static --static -fcommon' + CFLAGS='-Os -static --static -fcommon' LDFLAGS='-static --static -fcommon' DESTDIR=/build export CFLAGS LDFLAGS DESTDIR @@ -3225,7 +3277,7 @@ mkpk_name() mkpk_install() { - CFLAGS='-O3 -march=native -mtune=native' + CFLAGS='-Os ' LDFLAGS='' DESTDIR=/build export CFLAGS LDFLAGS DESTDIR @@ -3260,7 +3312,7 @@ mkpk_name() mkpk_install() { - CFLAGS='-O3 -march=native -mtune=native -static --static -fcommon' + CFLAGS='-Os -static --static -fcommon' LDFLAGS='-static --static -fcommon' DESTDIR=/build export CFLAGS LDFLAGS DESTDIR @@ -3299,7 +3351,7 @@ end_substep # # mkpk_install() # { -# CFLAGS='-O3 -march=native -mtune=native -static --static -fcommon' +# CFLAGS='-Os -static --static -fcommon' # LDFLAGS='-static --static -fcommon' # DESTDIR=/build # export CFLAGS LDFLAGS DESTDIR @@ -3346,7 +3398,7 @@ mkpk_name() mkpk_install() { - CFLAGS='-O3 -march=native -mtune=native' + CFLAGS='-Os ' LDFLAGS='' DESTDIR=/build export CFLAGS LDFLAGS DESTDIR @@ -3382,7 +3434,7 @@ mkpk_name() mkpk_install() { - CFLAGS='-O3 -march=native -mtune=native -static --static -fcommon' + CFLAGS='-Os -static --static -fcommon' LDFLAGS='-static --static -fcommon' DESTDIR=/build export CFLAGS LDFLAGS DESTDIR @@ -3430,7 +3482,7 @@ mkpk_name() mkpk_install() { - CFLAGS='-O3 -march=native -mtune=native -pipe -static --static -fcommon -fPIC' + CFLAGS='-Os -pipe -static --static -fcommon -fPIC' LDFLAGS='-static --static -fcommon' DESTDIR=/build YACC=/${TLD}/bin/yacc @@ -3522,7 +3574,7 @@ mkpk_name() mkpk_install() { - CFLAGS='-O3 -march=native -mtune=native' + CFLAGS='-Os ' LDFLAGS='' DESTDIR=/build export CFLAGS LDFLAGS DESTDIR @@ -3578,7 +3630,7 @@ mkpk_name() mkpk_install() { - CFLAGS='-O3 -march=native -mtune=native -static --static -fcommon' + CFLAGS='-Os -static --static -fcommon' LDFLAGS='-static --static -fcommon' DESTDIR=/build export CFLAGS LDFLAGS DESTDIR @@ -3634,20 +3686,69 @@ mkpk_install() config.mk fi + make clean make ${JN} || exit 1 make DESTDIR=/build install - ln -s bin /build/sbin - ln -s sinit /build/sbin/init + ln -sfv bin ../build/sbin + cd ../build/sbin + ln -sfv sinit init } ! mkpk ${pkg} #remove_dir ${G_SRC}/${pkg} - #unpack_pkg ${pkg} / + unpack_pkg ${pkg} / ) || exit 1 fi end_substep +# begin_substep perp-2.07 +# if [ -x /sbin/perp ]; then +# msg info "%s exists, skipping %s" /sbin/perp ${pkg} +# elif [ -e ${G_SPKG}/${pkg}.tar.xz ]; then +# unpack_pkg ${pkg} / +# else +# ( +# cd_or_fail ${G_SRC}/${pkg} +# +# cat <<! >MKPK +# mkpk_name() +# { +# printf "%s" "${pkg}" +# } +# +# mkpk_install() +# { +# AR=ar +# CC=tcc +# CFLAGS='-static -fcommon' +# LDFLAGS='-static -fcommon' +# LDLIBS=-lc +# export AR CC CFLAGS LDFLAGS LDLIBS +# +# if [ ! -e config.mk.orig ]; then +# cp config.mk config.mk.orig +# /${TLD}/bin/sed -i -e "s,^\\(PREFIX\\s*=\\s*\\).*,PREFIX = ," \\ +# -e "s,^\\(CC\\s*=\\s*\\).*,CC = \${CC}," \\ +# config.mk +# fi +# +# make clean +# make ${JN} || exit 1 +# make DESTDIR=/build install +# +# ln -sfv bin ../build/sbin +# cd ../build/sbin +# ln -sfv sinit init +# } +# ! +# mkpk ${pkg} +# #remove_dir ${G_SRC}/${pkg} +# unpack_pkg ${pkg} / +# ) || exit 1 +# fi +# end_substep + # Needed for efibootmgr begin_substep popt-1.18 if [ -x /sucks/lib/libpopt.so.0.0.1 ]; then @@ -3667,7 +3768,7 @@ mkpk_name() mkpk_install() { - CFLAGS='-Os -fdata-sections -ffunction-sections -march=native ' + CFLAGS='-Os -fdata-sections -ffunction-sections ' CFLAGS+='-fno-lto -fno-semantic-interposition ' LDFLAGS='' DESTDIR=/build @@ -3717,7 +3818,7 @@ mkpk_name() mkpk_install() { - CFLAGS='-O3 -march=native -mtune=native ' + CFLAGS='-Os ' CFLAGS+='-D_GNU_SOURCE -Wno-error=address-of-packed-member ' LDFLAGS='' DESTDIR=/build @@ -3756,7 +3857,7 @@ mkpk_name() mkpk_install() { - CFLAGS='-O3 -march=native -mtune=native ' + CFLAGS='-Os ' LDFLAGS='' DESTDIR=/build EFI_LOADER='grubx64.efi' @@ -3791,15 +3892,18 @@ begin_substep linux-5.17.13 cp_or_fail ${G_FIL}/linux/config-20220714-gl20 .config msg warn "Next, configure Linux using: " -msg warn " make LEX=/${TLD}/bin/flex menuconfig " -msg warn " make CFLAGS=-fPIE LDFLAGS=-fPIE LEX=/${TLD}/bin/flex \\" -msg warn " BC=/${TLD}/bin/bc vmlinux modules modules_install " -msg warn " cp arch/x86/boot/bzImage /boot/vmlinuz " -msg warn " cp System.map /boot/ " +msg warn " make LEX=/${TLD}/bin/flex menuconfig && \\\\ " +msg warn " make CFLAGS=-fPIE LDFLAGS=-fPIE LEX=/${TLD}/bin/flex \\\\" +msg warn " BC=/${TLD}/bin/bc vmlinux modules modules_install && \\\\ " +msg warn " cp arch/x86/boot/bzImage /boot/vmlinuz && \\\\ " +msg warn " cp System.map /boot/ && \\\\ " msg warn " cp .config /boot/config " msg warn "You might want to then use efibootmgr to add vmlinuz to EFI. " /bin/mksh -l +h -end_step +end_substep end_step + +cd / +04-finale.sh diff --git a/04-finale.sh b/04-finale.sh @@ -1,12 +1,7 @@ #!/bin/sh -if [ -d /src/lib ]; then - . /src/lib/env.sh - . /src/lib/fun.sh -else - . ./lib/env.sh - . ./lib/fun.sh -fi +. ./lib/env.sh +. ./lib/fun.sh trap exit_cleanup HUP PIPE INT QUIT TERM EXIT @@ -18,10 +13,8 @@ elif [ "$(id -u)" -ne 0 ]; then exit 1 fi -cat /etc/issue - -msg warn "Note: once you run this script, previous build scripts won't run " -msg warn "correctly until you uninstall packages installed here " +msg warn "Note: once you run this script, previous build scripts won't run" +msg warn "correctly until you uninstall packages installed here " msg query "Run %s [y/N]?" ${0##*/} read -r run_script case "${run_script}" in @@ -43,6 +36,7 @@ if [ -x /bin/yacc ]; then elif [ -e ${G_SPKG}/${pkg}.tar.xz ]; then unpack_pkg ${pkg} / else + remove_dir ${G_SRC}/${pkg} extract_pkg ${G_SRC} ${pkg} ${pkg}.tgz ( cd_or_fail ${G_SRC}/${pkg} @@ -57,18 +51,69 @@ mkpk_install() { AR=ar CC=tcc - export AR CC + CFLAGS='-Os -static -fcommon' + LDFLAGS='-static -fcommon' + DESTDIR=/build + export AR CC CFLAGS LDFLAGS DESTDIR - run_configure . \ - --prefix=/${TLD} \ - --build=${G_HOST} \ - --host=${G_TARGET} - run_make ${JN} - run_make install + ./configure --prefix=/ || exit 1 + make ${JN} || exit 1 + make install } ! + mkpk ${pkg} + remove_dir ${G_SRC}/${pkg} + unpack_pkg ${pkg} / + ) || exit 1 +fi +end_substep + +begin_substep smdev-20220715 +if [ -x /bin/smdev ]; then + msg info "%s exists, skipping %s" /bin/smdev ${pkg} +elif [ -e ${G_SPKG}/${pkg}.tar.xz ]; then + unpack_pkg ${pkg} / +else + ( + cd_or_fail ${G_SRC}/${pkg} + + cat <<! >MKPK +mkpk_name() +{ + printf "%s" "${pkg}" +} + +mkpk_install() +{ + CC=tcc + CFLAGS='-Os -static -fcommon' + LDFLAGS='-static -fcommon' + DESTDIR=/build + export AR CC CFLAGS LDFLAGS DESTDIR + + if [ ! -e util.h.orig ]; then + cp util.h util.h.orig + /${TLD}/bin/sed -i -z 's,"arg.h"\\n,&#include '\\ +'<sys/sysmacros.h>\\n,' util.h + fi + + if [ ! -e config.mk.orig ]; then + cp config.mk config.mk.orig + /${TLD}/bin/sed -i -e "s,/usr/local,,g;s, \\<cc\\>, "\\ +"\${CC},g" \\ + -e "s,^CFLAGS\\s\\+= ,& \${CFLAGS} ,g" \\ + -e "s,^LDFLAGS\\s\\+= ,& \${LDFLAGS} ,g" config.mk + fi + + make clean + make ${JN} || exit 1 + make install +} +! + mkpk ${pkg} + #remove_dir ${G_SRC}/${pkg} + unpack_pkg ${pkg} / ) || exit 1 - remove_dir ${G_SRC}/${pkg} fi end_substep @@ -102,6 +147,7 @@ mkpk_install() -e "s,^LDFLAGS\\s\\+= ,&-static -fcommon ,g" config.mk fi + make clean make ${JN} || exit 1 make DESTDIR=/build install } @@ -157,6 +203,7 @@ mkpk_install() -e "s,^LDLIBS\\s\\+= ,&-lc ,g" config.mk fi + make clean make ${JN} || exit 1 make DESTDIR=/build install @@ -173,34 +220,25 @@ mkpk_install() fi end_substep -msg info "Regenerating /etc/profile" -cat <<! >/etc/profile -EDITOR=/bin/sledv -LC_ALL= -LANG=C.UTF-8 -PATH=/local/bin:/bin:/sucks/bin:/plan9/bin -export LC_ALL LANG PATH - -for script in /etc/profile.d/*; do - [ -x \${script} ] && . \${script} -done +msg info "Setting permissions" +/lib/setperms -# A more familiar ls -lc() -{ - /bin/ls \$* | cols -} +msg info "Cleaning up" +remove_file /lib/env.sh +remove_file /lib/fun.sh +remove_file /bin/03-packages.sh +remove_file /bin/04-finale.sh +remove_file /lib/setperms +remove_file /lib/perms.tsv -[ -e /etc/mkshrc ] && . /etc/mkshrc -! +mv_or_fail /etc/profile.final /etc/profile -msg info "Generating /etc/galeb-release (neofetch fluff)" +msg info "Generating /etc/galeb-release" cat <<! >/etc/galeb-release -Galeb musl/Linux 2.0 +Galeb musl/Linux ${G_VER} ! -msg warn "Create a partition and copy files from %s to it, then setup booting" \ - "${GR}" -msg warn "(For example using efibootmgr and efistub kernel)" +msg warn "Create a partition and copy files from here to it, then setup booting" +msg warn "(For example using efibootmgr and efistub kernel) " end_step diff --git a/BUGS b/BUGS @@ -1,13 +1,7 @@ Known bugs/Errata ================= -* Some of the programs in the GCC binary package have been errorneously compiled - as dynamic instead of static and still went to /bin instead of /sucks/bin. I - have corrected the error in the build script, but I'm too lazy to recompile - everything from the start just because of that. If you are compiling from - source, they will be compiled statically and go to /bin as intended. - -* Other packages having dynamic binaries in /bin (only until a workaround): +* Packages having dynamic binaries in /bin (only until a workaround): - LibreSSL - mandoc See lib/impostors for a current report when building (needs table(1)). diff --git a/TODO b/TODO @@ -1,13 +1,20 @@ TODO ==== -[ ] Add || exit 1 to mkpk_install scripts; revise () || exit 1 +[ ] Fix init scripts + [ ] shutdown, poweroff, reboot + [ ] git://r-36.net/stali-init -[~] Add /etc/issue support to suckless getty - [ ] Test +[ ] Add packages + [ ] Add git + [ ] Add dhcp + [ ] Add curl -[ ] git://r-36.net/stali-init +[ ] Linux + [ ] /proc/sys/kernel/hotplug/create - Add hotplugging to Linux + [ ] Remove ram disks from Linux -< > Need to check build from scratch as there were changes in the fundamentals - during the addition of packages +[ ] Fix filesystem + [ ] stty broken link to /tools/bin/stty? + [ ] Remove /bin/bash in final system diff --git a/fil/rc.d/g_fun.sh b/fil/rc.d/g_fun.sh @@ -0,0 +1,62 @@ +#!/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') +bgyellow=$(printf '\033[103m') +bgwhite=$(printf '\033[107m') + +G_LOGFILE='' + +msg() +{ + local fmt icon icon_plain kind log newline tstamp + + icon= + icon_plain= + kind=$1 + shift + fmt=$1 + shift + tstamp=$(date +%T) + + log=1 + newline=1 + case ${kind} in + err) icon_plain="=E=" + icon="${bold}${white}${bgred}${icon_plain}";; + info) icon_plain="=I=" + icon="${green}${icon_plain}";; + query) icon_plain="=Q=" + icon="${bold}${yellow}${icon_plain}" + log=0 + newline=0;; + warn) icon_plain="=W=" + icon="${bgyellow}${bold}${faint}${black}${icon_plain}";; + *) ;; + esac + printf "%s %s " "${icon}" ${tstamp} + if [ -n "${G_LOGFILE}" ]; then + printf "%s %s " "${icon_plain}" ${tstamp} >>${G_LOGFILE} + fi + printf "${fmt}${norm}" "$@" + if [ ${newline} -eq 1 ]; then + echo + else + printf ' ' + fi + if [ ${log} -eq 1 ] && [ -n "${G_LOGFILE}" ]; then + printf "$(echo "${fmt}" | \ + sed 's/'$(printf '\033')'\[[0-9]\+m//g')\n" \ + "$@" >>${G_LOGFILE} + fi +} + diff --git a/fil/rc.d/mkshrc b/fil/rc.d/mkshrc @@ -0,0 +1,15 @@ +#!/bin/mksh + +if [ "${KSHUID}" -eq 0 ]; then + PS1=$'\1\r\1\e]0;\1${PWD/#${HOME/\//\\\/}/\\~}\1\b\e[97m\1='\ +$'${HOSTNAME:=$(hostname)}=${PWD/#${HOME/\//\\\/}/\\~}= \1\e[1;31m\1\#'\ +$'\1\e[0m\1 ' +else + PS1=$'\1\r\1\e]0;\1${PWD/#${HOME/\//\\\/}/\\~}\1\b\e[97m\1='\ +$'${HOSTNAME:=$(hostname)}=${PWD/#${HOME/\//\\\/}/\\~}= \1\e[93m\1\$\1\e[0m\1 ' +fi + +bind '^L=clear-screen' +bind -m ^U='^[0^K' + +set -U diff --git a/fil/rc.d/profile b/fil/rc.d/profile @@ -0,0 +1,21 @@ +#!/bin/sh + +EDITOR=/bin/sledv +LC_ALL= +LANG=C.UTF-8 +PATH=/local/bin:/bin:/sucks/bin:/plan9/bin +export LC_ALL LANG PATH + +for script in /etc/profile.d/*; do + [ -x ${script} ] && . ${script} +done + +# More like GNU ls +lc() +{ + /bin/ls $* | cols +} + +[ -e /etc/mkshrc ] && . /etc/mkshrc +[ -e ${HOME}/.profile ] && . ${HOME}/.profile +[ -e ${HOME}/.mkshrc ] && . ${HOME}/.mkshrc diff --git a/fil/rc.d/rc.conf b/fil/rc.d/rc.conf @@ -0,0 +1,5 @@ +HOSTNAME=galeb +INTERFACE=eth0 +HARDWARECLOCK=UTC +TIMEZONE=Europe/Belgrade +FONT=LatArCyrHeb-16 diff --git a/fil/rc.d/rc.init b/fil/rc.d/rc.init @@ -0,0 +1,128 @@ +#!/bin/sh + +umask 022 + +. /etc/rc.conf +. /lib/g_fun.sh + +PATH=/local/bin:/bin:/sucks/bin +export PATH + +clear +printf "${green}===( ${bold}${white}%s${norm}${green} )=== booting${norm}\n" \ + "$(cat /etc/galeb-release)" + +ctrlaltdel -s + +msg info "Mounting essential filesystems" +mount -n -t proc -o nosuid,noexec,nodev proc /proc +mount -n -t sysfs -o nosuid,noexec,nodev sysfs /sys +mount -n -t tmpfs -o nosuid,mode=0755 dev /dev +mkdir -p /dev/pts +mount -n -t devpts -o gid=5,mode=0020 devpts /dev/pts + +if grep -q verbose /proc/cmdline; then + dmesg -n 8 +else + dmesg -n 3 +fi + +mount -o ro,remount / + +msg info "Running smdev" +smdev -s + +mkdir -p /proc/sys/kernel +echo /bin/smdev >/proc/sys/kernel/hotplug + +cd /dev +ln -sf /proc/self/fd/0 stdin +ln -sf /proc/self/fd/1 stdout +ln -sf /proc/self/fd/2 stderr +ln -sf /proc/self/fd fd +cd - >/dev/null + +msg info "Checking filesystems" +fsck -ATa +if [ $? -eq 1 ]; then + msg err "Filesystem errors, fix manually" + sh + msg warn "Rebooting" + halt -r +fi + +msg info "Remounting / read-write" +mount -o rw,remount / + +msg info "Mounting filesystems" +mount -a + +ln -sf /proc/mounts /etc/mtab + +msg info "Setting font" +setfont ${FONT} + +msg info "Setting hostname" +hostname ${HOSTNAME} + +msg info "Bringing up lo interface" +ip addr add 127.0.0.1/8 dev lo broadcast + scope host +ip link set lo up + +HWCLOCK_PARAMS=-s +case "${HARDWARECLOCK}" in + '') ;; + UTC) HWCLOCK_PARAMS="-u ${HWCLOCK_PARAMS}";; + localtime) ;;#HWCLOCK_PARAMS="-l ${HWCLOCK_PARAMS}";; + *) ;; +esac + +if [ -n "${HWCLOCK_PARAMS}" ]; then + msg info "Setting hwclock" + if [ -n "${TIMEZONE}" ]; then + TZ=":${TIMEZONE}" + export TZ + fi + # ubase hwclock only has UTC support currently + hwclock ${HWCLOCK_PARAMS} /dev/rtc0 + unset TZ +fi + +msg info "Setting random seed" +if [ -f /etc/random-seed ]; then + cat /etc/random-seed >/dev/urandom +fi + +dd if=/dev/urandom of=/etc/random-seed count=1 bs=512 2>/dev/null + +msg info "Storing dmesg output to /var/log/dmesg.log" +dmesg >/var/log/dmesg.log + +if [ -e /proc/sys/kernel/dmesg_restrict ] && \ + [ "$(cat /proc/sys/kernel/dmesg_restrict)" = "1" ] +then + chmod 0666 /var/log/dmesg.log +else + chmod 0644 /var/log/dmesg.log +fi + +if [ -x /bin/rc.modules ]; then + msg info "Starting /bin/rc.modules" +fi + +if [ -x /bin/rc.svc ]; then + msg info "Starting /bin/rc.svc" +fi + +if [ -x /bin/rc.local ]; then + msg info "Starting /bin/rc.local" +fi + +:>/var/run/utmp + +unset PATH + +echo +for n in 1 2 3 4; do + /bin/sh -c '/bin/respawn /bin/getty /dev/tty'$n' linux' &>/dev/null & +done diff --git a/fil/rc.d/rc.local b/fil/rc.d/rc.local @@ -0,0 +1,2 @@ +#!/bin/sh +# Local initialization commands diff --git a/fil/rc.d/rc.shutdown b/fil/rc.d/rc.shutdown @@ -0,0 +1,64 @@ +#!/bin/sh + +umask 022 + +. /etc/rc.conf +. /lib/g_fun.sh + +PATH=/local/bin:/bin:/sucks/bin +export PATH + +case "$1" in + reboot|poweroff) ;; + *) msg err "Invalid action '%s'" "$1" + exit 1;; +esac + +echo; stty onlcr + +msg info "Shutting down" + +HWCLOCK_PARAMS='-w' +case "${HARDWARECLOCK}" in + "") ;; + UTC) HWCLOCK_PARAMS="-u ${HWCLOCK_PARAMS}";; + localtime) HWCLOCK_PARAMS="-l ${HWCLOCK_PARAMS}";; + *) HWCLOCK_PARAMS='';; +esac + +if [ -n "${HWCLOCK_PARAMS}" ]; then + msg info "Saving system clock" + if [ -n "${TIMEZONE}" ]; then + TZ=${TIMEZONE} + export TZ + fi + hwclock ${HWCLOCK_PARAMS}/dev/rtc0 + unset TZ +fi + +msg info "Storing random seed" +dd if=/dev/urandom of=/etc/random-seed count=1 bs=512 2>/dev/null + +svc -k + +msg info "Sending processes the TERM signal..." +killall5 -s TERM +sleep 3 +msg info "Sending processes the KILL signal..." +killall5 -s KILL + +msg info "Remounting / as read-only" +mount -o ro,remount / + +msg info "Unmounting filesystems" +umount -a +sync; sync; sync +sleep 3 +wait + +msg info "Done rc.shutdown" + +case "$1" in + reboot) halt -r;; + poweroff) halt -p;; +esac diff --git a/lib/fun.sh b/lib/fun.sh @@ -14,6 +14,70 @@ white=$(printf '\033[97m') bgyellow=$(printf '\033[103m') bgwhite=$(printf '\033[107m') + +g_find() +{ + if [ "${HOST_FIND}" -eq 1 ]; then + find $* + else + /${TLD}/bin/find $* + fi +} + +g_ln() +{ + if [ "${HOST_COREUTILS}" -eq 1 ]; then + ln $* + else + /${TLD}/bin/ln $* + fi +} + +g_md5sum() +{ + if [ "${HOST_MD5SUM}" -eq 1 ]; then + md5sum $* + else + /${TLD}/bin/md5sum $* + fi +} + +g_mv() +{ + if [ "${HOST_COREUTILS}" -eq 1 ]; then + mv $* + else + /${TLD}/bin/mv $* + fi +} + +g_rm() +{ + if [ "${HOST_COREUTILS}" -eq 1 ]; then + rm $* + else + /${TLD}/bin/rm $* + fi +} + +g_sed() +{ + if [ "${HOST_SED}" -eq 1 ]; then + sed $* + else + /${TLD}/bin/sed $* + fi +} + +g_tar() +{ + if [ "${HOST_TAR}" -eq 1 ]; then + tar $* + else + /${TLD}/bin/tar $* + fi +} + apply_patch() { local substepid pat @@ -185,7 +249,7 @@ extract_pkg() if [ "${touch}" = "touch" ]; then mopt=-m fi - if ! ${prog} "${G_PKG}/${tarball}" | /${TLD}/bin/tar -x ${mopt} -f - + if ! ${prog} "${G_PKG}/${tarball}" | g_tar -x ${mopt} -f - then msg err "Extracting %s failed" "${tarball}" exit 1 @@ -250,7 +314,7 @@ link_if_ne() return fi msg info "Symlinking %s" "${dest}" - if ! /${TLD}/bin/ln -s $*; then + if ! g_ln -s $*; then msg err "Symlinking %s failed" "${dest}" exit 1 fi @@ -294,7 +358,7 @@ mkpk() mount -B /sucks ./sucks -o ro mount -B /tmp ./tmp -o ro mount -B /tools ./tools -o ro - ln -s . usr + g_ln -s . usr cd ${pkg} :>../timestamp @@ -347,12 +411,12 @@ mkpk() if [ ${fail} -eq 0 ]; then msg info "mkpk packing..." cd ../build - tar -c $(/${TLD}/bin/find . \( -type b -o -type c -o \ + tar -c $(g_find . \( -type b -o -type c -o \ -type f -o -type l \) \ -cnewer ../timestamp | sort | uniq) | \ xz -9 > ${G_SPKG}/$(mkpk_name).tar.xz && \ cd ${G_SPKG} && \ - /${TLD}/bin/md5sum $(mkpk_name).tar.xz >$(mkpk_name).md5 && \ + g_md5sum $(mkpk_name).tar.xz >$(mkpk_name).md5 && \ { cd - >/dev/null 2>&1; } rm ../timestamp fi @@ -435,7 +499,7 @@ remove_dir() { msg info "Removing directory %s" "$1" if [ -d "$1" ]; then - /${TLD}/bin/rm -fr "$1" + g_rm -fr "$1" fi } @@ -443,7 +507,7 @@ remove_file() { msg info "Removing %s" "$1" if [ -e "$1" ] || [ -L "$1" ]; then - /${TLD}/bin/rm -f "$1" + g_rm -f "$1" fi } @@ -493,7 +557,7 @@ unpack_pkg() local pkg=$1 shift cd_or_fail ${G_SPKG} - if ! /${TLD}/bin/md5sum -c ${pkg}.md5 >/dev/null 2>&1; then + if ! g_md5sum -c ${pkg}.md5 >/dev/null 2>&1; then msg err "md5sum -c %s failed" ${G_SPKG}/${pkg}.tar.xz exit 1 fi diff --git a/lib/gensums b/lib/gensums @@ -25,7 +25,7 @@ do fi case ${url} in - https:*) md5=$(md5sum ${G_PKG}/${tarball} | \ + http:*|https:*) md5=$(md5sum ${G_PKG}/${tarball} | \ cut -d ' ' -f1);; *) md5='';; esac diff --git a/lib/perms.tsv b/lib/perms.tsv @@ -0,0 +1,6 @@ +/bin/mksh 555 root bin +/bin/lksh 555 root bin +/var/run/utmp 664 root utmp +/tmp 1777 root root +/bin/rc.init 555 root root +/bin/rc.shutdown 555 root root diff --git a/lib/pkgs.tsv b/lib/pkgs.tsv @@ -4,6 +4,7 @@ git+https://github.com/mirbsd/mksh mksh-20220709 git+https://github.com/onetrueawk/awk awk-20220709 git://git.suckless.org/9base 9base-20220706 git://git.suckless.org/sbase sbase-20220709 +git://git.suckless.org/smdev smdev-20220715 git://git.suckless.org/sinit sinit-20220713 git://git.suckless.org/ubase ubase-20220709 git://repo.or.cz/tinycc.git tinycc-20220708 @@ -53,6 +54,7 @@ https://github.com/Mic92/iana-etc/releases/download/20210611/iana-etc-20210611.t https://github.com/arsv/perl-cross/releases/download/1.4/perl-cross-1.4.tar.gz 73c246c20766d027c3dc9f606418c22c https://github.com/ericonr/argp-standalone/archive/refs/tags/1.4.1.tar.gz argp-standalone-1.4.1.tar.gz 7f391d52161e7fe8e8d3df4f850bc7ee https://github.com/facebook/zstd/releases/download/v1.5.0/zstd-1.5.0.tar.gz a6eb7fb1f2c21fa80030a47993853e92 +https://github.com/gavinhoward/bc/releases/download/5.0.0/bc-5.0.0.tar.xz 8345bb81c576ddfc8c27e0842370603c https://github.com/libcheck/check/releases/download/0.15.2/check-0.15.2.tar.gz 50fcafcecde5a380415b12e9c574e0b2 https://github.com/libffi/libffi/releases/download/v3.4.2/libffi-3.4.2.tar.gz 294b921e6cf9ab0fbaea4b639f8fdbe8 https://github.com/martanne/vis/releases/download/v0.7/vis-0.7.tar.gz a45ba03d1fa4785ee5693f9619f22e85 @@ -66,6 +68,7 @@ https://github.com/rpm-software-management/popt/archive/refs/tags/popt-1.18-rele https://github.com/shadow-maint/shadow/releases/download/v4.11.1/shadow-4.11.1.tar.xz 5a95ec069aa91508167d02fecafaa912 https://github.com/strace/strace/releases/download/v5.18/strace-5.18.tar.xz a563875472463638c19d6639e1c14875 https://github.com/util-linux/util-linux/archive/refs/tags/v2.38.tar.gz util-linux-2.38.tar.gz d6f945e504db53c9cdea43a38c226d94 +https://github.com/westes/flex/releases/download/v2.6.4/flex-2.6.4.tar.gz 2882e3179748cc9f9c23ec593d6adc8d https://github.com/zlib-ng/zlib-ng/archive/refs/tags/2.0.6.tar.gz zlib-ng-2.0.6.tar.gz 4ba0da231291632799948c5568906ce4 https://invisible-island.net/archives/byacc/byacc-20220128.tgz c861b313fb59857a5ca3475ce9d62c4e https://invisible-island.net/archives/reflex/reflex-20210808.tgz 31ed4340e8b636cb2c1de2ad378a14e9 @@ -93,5 +96,3 @@ https://www.kernel.org/pub/linux/utils/kernel/kmod/kmod-29.tar.xz e81e63acd8069 https://www.kernel.org/pub/linux/utils/net/iproute2/iproute2-5.17.0.tar.xz 8ade96ee93f37fba7e1beec89f1a54bf https://www.leonerd.org.uk/code/libtermkey/libtermkey-0.22.tar.gz 08bf514d59660391c3a21b3977a16c8c https://www.python.org/ftp/python/3.9.9/Python-3.9.9.tar.xz 11d12076311563252a995201248d17e5 -https://github.com/westes/flex/releases/download/v2.6.4/flex-2.6.4.tar.gz 2882e3179748cc9f9c23ec593d6adc8d -https://github.com/gavinhoward/bc/releases/download/5.0.0/bc-5.0.0.tar.xz 8345bb81c576ddfc8c27e0842370603c diff --git a/lib/setperms b/lib/setperms @@ -0,0 +1,44 @@ +#!/bin/sh + +. ./lib/env.sh +. ./lib/fun.sh + +permdb=/lib/perms.tsv + +if [ ! -d /sucks ]; then + msg err "You must run this script from inside chroot" + exit 1 +elif [ "$(id -u)" -ne 0 ]; then + msg err "You must run this script as root" + exit 1 +fi + +recno=0 +( +IFS=$(printf '\n') +while read -r record +do + recno=$((recno+1)) + path=$(printf "${record}" | cut -d "$(printf '\t')" -f1) + mode=$(printf "${record}" | cut -sd "$(printf '\t')" -f2) + owner=$(printf "${record}" | cut -sd "$(printf '\t')" -f3) + group=$(printf "${record}" | cut -sd "$(printf '\t')" -f4) + + if [ -z "${path}" ]; then + msg warn "Empty path at record #%d; skipping" "${recno}" + continue + fi + #printf "Record #%d: path=[%s] mode=[%s] [%s:%s]\n" \ + # "${recno}" "${path}" "${mode}" "${owner}" "${group}" + + if [ -n "${mode}" ]; then + msg info "chmod %s %s" "${mode}" "${path}" + chmod "${mode}" "${path}" + fi + + if [ -n "${owner}" ] && [ -n "${group}" ]; then + msg info "chown %s:%s %s" "${owner}" "${group}" "${path}" + chown ${owner}:${group} "${path}" + fi +done <${permdb} +) diff --git a/pat-11.2.1/perp-oasis/0001-tain_now-Use-clock_gettime.patch b/pat-11.2.1/perp-oasis/0001-tain_now-Use-clock_gettime.patch @@ -0,0 +1,38 @@ +From dc52122121b078efbfc914ab256848cc0007c14e Mon Sep 17 00:00:00 2001 +From: Michael Forney <mforney@mforney.org> +Date: Sun, 26 Mar 2017 17:12:30 -0700 +Subject: [PATCH] tain_now: Use clock_gettime + +--- + lasagna/tain/tain_now.c | 7 +++---- + 1 file changed, 3 insertions(+), 4 deletions(-) + +diff --git a/lasagna/tain/tain_now.c b/lasagna/tain/tain_now.c +index 3c790be..ba53864 100644 +--- a/lasagna/tain/tain_now.c ++++ b/lasagna/tain/tain_now.c +@@ -6,18 +6,17 @@ + + #include <stdlib.h> + #include <time.h> +-#include <sys/time.h> + + #include "tain.h" + + struct tain * + tain_now(struct tain *t) + { +- struct timeval now; ++ struct timespec now; + +- gettimeofday(&now, NULL); ++ clock_gettime(CLOCK_REALTIME, &now); + tain_load_utc(t, now.tv_sec); +- t->nsec = (1000 * now.tv_usec) + 500; ++ t->nsec = now.tv_nsec; + + return t; + } +-- +2.12.1 + diff --git a/pat-11.2.1/perp-oasis/0002-perpd-Restore-umask-after-perpd_control_init.patch b/pat-11.2.1/perp-oasis/0002-perpd-Restore-umask-after-perpd_control_init.patch @@ -0,0 +1,47 @@ +From dc80561853acb99cbd29e555546dfa77ac10d8e1 Mon Sep 17 00:00:00 2001 +From: Michael Forney <mforney@mforney.org> +Date: Sun, 26 Mar 2017 17:28:36 -0700 +Subject: [PATCH] perpd: Restore umask after perpd_control_init + +--- + perp/perpd.c | 10 +++++++--- + 1 file changed, 7 insertions(+), 3 deletions(-) + +diff --git a/perp/perpd.c b/perp/perpd.c +index 2bf5553..1b29577 100644 +--- a/perp/perpd.c ++++ b/perp/perpd.c +@@ -217,8 +217,9 @@ static + void + perpd_control_init(void) + { +- int fdbase; +- int fd = -1; ++ int fdbase; ++ int fd = -1; ++ mode_t umask_orig; + + /* setup for return to base directory: */ + if((fdbase = open(".", O_RDONLY)) == -1){ +@@ -226,7 +227,7 @@ perpd_control_init(void) + } + + /* setup umask for intentional mode on file creation: */ +- umask(0); ++ umask_orig = umask(0); + + /* initialize .control directory: */ + if(mkdir(PERP_CONTROL, 0700) == -1){ +@@ -286,6 +287,9 @@ perpd_control_init(void) + } + close(fdbase); + ++ /* restore umask: */ ++ umask(umask_orig); ++ + return; + } + +-- +2.12.1 + diff --git a/pat-11.2.1/perp-oasis/0003-Remove-pointer-arithmetic-on-void.patch b/pat-11.2.1/perp-oasis/0003-Remove-pointer-arithmetic-on-void.patch @@ -0,0 +1,194 @@ +From fa651ab426b8c6be7398799ebab26e87918cc5f1 Mon Sep 17 00:00:00 2001 +From: Michael Forney <mforney@mforney.org> +Date: Thu, 21 Feb 2019 23:28:17 -0800 +Subject: [PATCH] Remove pointer arithmetic on void * + +--- + lasagna/cdb/cdb_dynread.c | 2 +- + lasagna/dynbuf/dynbuf_pack.c | 2 +- + lasagna/dynbuf/dynbuf_put.c | 5 +++-- + lasagna/hdb/hdb_dynread.c | 2 +- + lasagna/ioq/ioq_put.c | 10 +++++----- + lasagna/packet/packet_write.c | 5 +++-- + perp/tinylog.c | 4 ++-- + runtools/runchoom.c | 4 ++-- + 8 files changed, 18 insertions(+), 16 deletions(-) + +diff --git a/lasagna/cdb/cdb_dynread.c b/lasagna/cdb/cdb_dynread.c +index b7135c5..f5e7ab8 100644 +--- a/lasagna/cdb/cdb_dynread.c ++++ b/lasagna/cdb/cdb_dynread.c +@@ -23,7 +23,7 @@ cdb_dynread(struct cdb *C, struct dynbuf *B, size_t len, uint32_t offset) + if(dynbuf_grow(B, len) == -1) + return -1; + +- if(cdb_read(C, dynbuf_BUF(B) + dynbuf_LEN(B), len, offset) == -1) ++ if(cdb_read(C, (uchar_t *)dynbuf_BUF(B) + dynbuf_LEN(B), len, offset) == -1) + return -1; + + dynbuf_LEN(B) += len; +diff --git a/lasagna/dynbuf/dynbuf_pack.c b/lasagna/dynbuf/dynbuf_pack.c +index 84727cb..4543a0a 100644 +--- a/lasagna/dynbuf/dynbuf_pack.c ++++ b/lasagna/dynbuf/dynbuf_pack.c +@@ -46,7 +46,7 @@ dynbuf_pack(struct dynbuf *D, const char *fmt, ...) + } + + /* with need satisfied, append directly into buf: */ +- b = (D->buf + D->p); ++ b = (uchar_t *)D->buf + D->p; + + va_start(args, fmt); + w = upak_vpack(b, fmt, args); +diff --git a/lasagna/dynbuf/dynbuf_put.c b/lasagna/dynbuf/dynbuf_put.c +index 6ff7bdb..46989c4 100644 +--- a/lasagna/dynbuf/dynbuf_put.c ++++ b/lasagna/dynbuf/dynbuf_put.c +@@ -19,10 +19,11 @@ dynbuf_putbuf(struct dynbuf *d, const void *buf, size_t len) + if(dynbuf_grow(d, (len + 1)) != 0) + return -1; /* error! */ + +- buf_copy((d->buf + d->p), buf, len); ++ b = d->buf; ++ buf_copy(b + d->p, buf, len); + + d->p += len; +- b = d->buf; b[d->p] = 'Q'; /* "offensive programming" */ ++ b[d->p] = 'Q'; /* "offensive programming" */ + + return 0; /* no error */ + } +diff --git a/lasagna/hdb/hdb_dynread.c b/lasagna/hdb/hdb_dynread.c +index cd818bc..82d20d2 100644 +--- a/lasagna/hdb/hdb_dynread.c ++++ b/lasagna/hdb/hdb_dynread.c +@@ -23,7 +23,7 @@ hdb_dynread(struct hdb *H, struct dynbuf *B, size_t len, uint32_t offset) + if(dynbuf_grow(B, len) == -1) + return -1; + +- if(hdb_read(H, dynbuf_BUF(B) + dynbuf_LEN(B), len, offset) == -1) ++ if(hdb_read(H, (uchar_t *)dynbuf_BUF(B) + dynbuf_LEN(B), len, offset) == -1) + return -1; + + dynbuf_LEN(B) += len; +diff --git a/lasagna/ioq/ioq_put.c b/lasagna/ioq/ioq_put.c +index 47f4897..20737a6 100644 +--- a/lasagna/ioq/ioq_put.c ++++ b/lasagna/ioq/ioq_put.c +@@ -44,7 +44,7 @@ + + + /* internal declarations: */ +-static int write_all(int fd, void *buf, size_t to_write, ssize_t (*op)()); ++static int write_all(int fd, uchar_t *buf, size_t to_write, ssize_t (*op)()); + + + /* +@@ -63,13 +63,13 @@ static int write_all(int fd, void *buf, size_t to_write, ssize_t (*op)()); + */ + static + int +-write_all(int fd, void *buf, size_t to_write, ssize_t (*op)()) ++write_all(int fd, uchar_t *buf, size_t to_write, ssize_t (*op)()) + { + ssize_t w = 0; + + while(to_write){ + do{ +- w = op(fd, buf, to_write); ++ w = op(fd, (void *)buf, to_write); + }while((w == -1) && (errno == EINTR)); + + if(w == -1) return -1; /* error! */ +@@ -137,7 +137,7 @@ ioq_put(ioq_t *ioq, const uchar_t *data, size_t len) + while(len > ioq->n){ + /* don't write more than len! */ + if(len < n) n = len; +- if(write_all(ioq->fd, (void *)data, n, ioq->op) == -1){ ++ if(write_all(ioq->fd, (uchar_t *)data, n, ioq->op) == -1){ + /* write() error: */ + return -1; + } +@@ -178,7 +178,7 @@ ioq_putflush(ioq_t *ioq, const uchar_t *data, size_t len) + if(ioq_flush(ioq) == -1) return -1; + + /* write() the rest */ +- return write_all(ioq->fd, (void *)data, len, ioq->op); ++ return write_all(ioq->fd, (uchar_t *)data, len, ioq->op); + } + + +diff --git a/lasagna/packet/packet_write.c b/lasagna/packet/packet_write.c +index 66c5f8c..6af6a94 100644 +--- a/lasagna/packet/packet_write.c ++++ b/lasagna/packet/packet_write.c +@@ -50,11 +50,12 @@ packet_write(int fd, const void *packet, size_t n) + { + ssize_t w = 0; + size_t to_write = n; ++ const char *b = packet; + + while(to_write > 0){ + + do{ +- w = write(fd, packet, to_write); ++ w = write(fd, b, to_write); + }while((w == -1) && (errno == EINTR)); + + if(w == -1) +@@ -63,7 +64,7 @@ packet_write(int fd, const void *packet, size_t n) + if(w == 0) + continue; + +- packet += w; ++ b += w; + to_write -= w; + } + +diff --git a/perp/tinylog.c b/perp/tinylog.c +index 8df6283..a593a66 100644 +--- a/perp/tinylog.c ++++ b/perp/tinylog.c +@@ -124,7 +124,7 @@ const char *gzip_path = NULL; + /* + ** declarations in scope: + */ +-static void write_all(int fd, void *buf, size_t len); ++static void write_all(int fd, char *buf, size_t len); + static void stamp8601_make(char *stamp_buf); + static void init_logdir(struct tinylog *tinylog); + static void init_current(struct tinylog *tinylog, int resume); +@@ -182,7 +182,7 @@ ssize_t read_op(int fd, void *buf, size_t len) + */ + static + void +-write_all(int fd, void *buf, size_t len) ++write_all(int fd, char *buf, size_t len) + { + ssize_t w = 0; + tain_t epause = tain_INIT(0, EPAUSE); +diff --git a/runtools/runchoom.c b/runtools/runchoom.c +index e318e2a..0682ad3 100644 +--- a/runtools/runchoom.c ++++ b/runtools/runchoom.c +@@ -59,7 +59,7 @@ static char setbuf[256]; + static char pidfmt[NFMT_SIZE]; + + /* functions in scope: */ +-static int write_all(int fd, void *buf, size_t to_write); ++static int write_all(int fd, char *buf, size_t to_write); + static void do_choom(void); + + /* syserr_warn() macro: */ +@@ -77,7 +77,7 @@ static void do_choom(void); + + static + int +-write_all(int fd, void *buf, size_t to_write) ++write_all(int fd, char *buf, size_t to_write) + { + ssize_t w = 0; + +-- +2.20.1 + diff --git a/pat-11.2.1/perp-oasis/0004-Remove-obsolete-files.patch b/pat-11.2.1/perp-oasis/0004-Remove-obsolete-files.patch @@ -0,0 +1,181 @@ +From 365cc1632a912a7ab6ab2b4f43207b070315798a Mon Sep 17 00:00:00 2001 +From: Michael Forney <mforney@mforney.org> +Date: Thu, 21 Feb 2019 23:33:20 -0800 +Subject: [PATCH] Remove obsolete files + +--- + lasagna/ioq/iobuf_getnets.c | 104 ------------------------------------ + lasagna/ioq/iobuf_getrec.c | 50 ----------------- + 2 files changed, 154 deletions(-) + delete mode 100644 lasagna/ioq/iobuf_getnets.c + delete mode 100644 lasagna/ioq/iobuf_getrec.c + +diff --git a/lasagna/ioq/iobuf_getnets.c b/lasagna/ioq/iobuf_getnets.c +deleted file mode 100644 +index 55447ee..0000000 +--- a/lasagna/ioq/iobuf_getnets.c ++++ /dev/null +@@ -1,104 +0,0 @@ +-/* +-** iobuf_getnets.c +-** wcm, 2004.04.28 - 2004.04.29 +-** === +-*/ +-#include "iobuf.h" +- +-#include "buf.h" +-#include "dynbuf.h" +- +- +-static +-int +-get_netslen(iobuf *ibuf, size_t *len, size_t max) +-{ +- char c; +- size_t n = 0; +- int digits = 0; +- +-/* +-** returns length in len and: +-** -3, netstring format error +-** -1, io error +-** 0, EOF +-** 1, ok +-*/ +- +- for(;;){ +- switch(iobuf_GETC(ibuf, &c)){ +- case -1: return -1; /* io error */ +- case 0: return 0; /* EOF */ +- default: break; /* ok */ +- } +- if(c == ':'){ +- if(digits){ +- *len = n; +- return 1; +- } +- else break; +- } +- if((c < '0') || (c > '9')) break; +- n = 10 * n + (c - '0'); +- if((digits && (n == 0)) || (n > max)) break; +- ++digits; +- } +- +- /* netstring format error: */ +- return -3; +-} +- +- +-int iobuf_getnets(iobuf *ibuf, dynbuf *b, size_t max) +-{ +- int r; +- size_t len = 0; +- char *buf; +- char c; +- +-/* +-** returns netstring in dynbuf: +-** -3, netstring format error +-** -1, error (io or malloc) +-** 0, EOF +-** 1, ok +-*/ +- +- switch(get_netslen(ibuf, &len, max)){ +- case -3: return -3; +- case -1: return -1; +- case 0: return 0; +- default: break; +- } +- +- if(dynbuf_grow(b, len) != 0) +- return -1; /* malloc error */ +- +- buf = dynbuf_BUF(b); +- while(len){ +- r = iobuf_get(ibuf, buf, len); +- switch(r){ +- case -1: return -1; /* io error */ +- case 0: return -3; /* eof before complete */ +- default: break; +- } +- dynbuf_LEN(b) += r; +- if(r == len) break; +- /* else: */ +- buf += r; +- len -= r; +- } +- +- /* so far, so good; now comma? */ +- switch(iobuf_GETC(ibuf, &c)){ +- case -1: return -1; /* io error */ +- case 0: return -3; /* eof before comma */ +- default: break; +- } +- if(c != ',') return -3; +- +- /* success: */ +- return 1; +-} +- +-/* that's all, folks! */ +diff --git a/lasagna/ioq/iobuf_getrec.c b/lasagna/ioq/iobuf_getrec.c +deleted file mode 100644 +index 6462452..0000000 +--- a/lasagna/ioq/iobuf_getrec.c ++++ /dev/null +@@ -1,50 +0,0 @@ +-/* +-** iobuf_getrec.c +-** wcm, 2004.04.28 - 2004.04.29 +-** === +-*/ +-#include "iobuf.h" +- +-#include "buf.h" +-#include "dynbuf.h" +- +-int iobuf_getrec(iobuf *ibuf, dynbuf *b, int sep) +-{ +- int r; +- int n; +- char *x; +- +-/* +-** returns: +-** -1, error (io or malloc) +-** 0, EOF +-** 1, ok +-*/ +- +- for(;;){ +- r = iobuf_feed(ibuf); +- if(r <= 0) return r; /* EOF (0) or io error (-1) */ +- +- x = (char *)iobuf_PEEK(ibuf); +- n = buf_ndx(x, r, sep); +- if(n < r){ /* sep found */ +- if(dynbuf_putbuf(b, x, n) == 0) { /* ok */ +- /* strip contents out of ibuf */ +- iobuf_SEEK(ibuf, (n+1)); +- /* success: */ +- return 1; +- } +- else /* dynbuf malloc failure: */ +- return -1; +- } +- /* else: */ +- if(dynbuf_grow(b, r) != 0) +- return -1; +- dynbuf_LEN(b) += iobuf_get(ibuf, dynbuf_BUF(b)+dynbuf_LEN(b), r); +- } +- +- /* not here: */ +- return -1; +-} +- +-/* that's all, folks! */ +-- +2.20.1 + diff --git a/pat-11.2.1/perp-oasis/0005-Remove-unused-variable.patch b/pat-11.2.1/perp-oasis/0005-Remove-unused-variable.patch @@ -0,0 +1,34 @@ +From 2cc852e07038ee17d56ec6a54ae9b1c19b598289 Mon Sep 17 00:00:00 2001 +From: Michael Forney <mforney@mforney.org> +Date: Thu, 21 Feb 2019 23:57:15 -0800 +Subject: [PATCH] Remove unused variable + +--- + perp/perpd_svdef.c | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/perp/perpd_svdef.c b/perp/perpd_svdef.c +index 82fb0a0..7b5e87f 100644 +--- a/perp/perpd_svdef.c ++++ b/perp/perpd_svdef.c +@@ -186,7 +186,7 @@ void + perpd_svdef_checkfail(struct svdef *svdef) + { + struct subsv *subsv; +- int target, r = 0; ++ int target; + + /* insanity? */ + if(!(svdef->bitflags & SVDEF_FLAG_ACTIVE)) +@@ -201,7 +201,7 @@ perpd_svdef_checkfail(struct svdef *svdef) + subsv = (svdef->bitflags & SVDEF_FLAG_HASLOG) ? &svdef->svpair[SUBSV_LOG] : NULL; + if((subsv != NULL) && (subsv->bitflags & SUBSV_FLAG_FAILING)){ + target = (subsv->bitflags & SUBSV_FLAG_ISRESET) ? SVRUN_RESET : SVRUN_START; +- r = perpd_svdef_run(svdef, SUBSV_LOG, target); ++ perpd_svdef_run(svdef, SUBSV_LOG, target); + } + + /* XXX, bail here if log is failing? */ +-- +2.20.1 +