From: cat æscling <11325618-aescling@users.noreply.gitlab.com> Date: Thu, 3 Aug 2023 03:50:42 +0000 (-0400) Subject: Improve the build scripts X-Git-Tag: v1.0.0~2 X-Git-Url: https://git.xn--scling-oua.cat.family/?a=commitdiff_plain;h=aa4ac6f2a3fa20e3e1b3ff77a3ca35bd091b0ee7;p=httpd-execline.git Improve the build scripts --- diff --git a/dependencies/build-in-musl-chroot.sh b/dependencies/build-in-musl-chroot.sh index bb58036..980ed90 100644 --- a/dependencies/build-in-musl-chroot.sh +++ b/dependencies/build-in-musl-chroot.sh @@ -1,5 +1,23 @@ #!/bin/sh -x +# install a usable musl-linked chroot and run the build in there (linux-only!) +# intall the built rutime dependencies into the httpd.execline directory +# +# expected to run in this directory +# builds the result into `_build` in this directiory +fail() { + echo "${0}: fatal: ${@}" 1>&2 + exit 1 +} + +usage() { + fail "usage: HTTPD_EXECLINE_ROOT= ${0}" +} + +[ x"${HTTPD_EXECLINE_ROOT}" = x ] && usage +[ ! -r "${HTTPD_EXECLINE_ROOT}" ] && fail "HTTPD_EXECLINE_ROOT (${HTTPD_EXECLINE_ROOT}) is unreadable" + +export _CHROOT_BUILD="true" ARCH=${1:-x86_64} if [ "x${ARCH}" = aarch64 ] then @@ -10,6 +28,7 @@ fi XBPS_STATIC="https://repo-default.voidlinux.org/static/xbps-static-latest.${ARCH}-musl.tar.xz" CHROOT=xbps/_root +# prepare chroot for D in /var/db/xbps/keys /etc /proc /sys /dev /run; do mkdir -p ${CHROOT}${D} @@ -17,6 +36,7 @@ done cp -Lr /etc/hosts /etc/resolv.conf ${CHROOT}/etc cp -r build.sh _9base _toybox ${CHROOT} +# install into chroot ( cd xbps curl -Ss "${XBPS_STATIC}" | unxz -c | tar -xf - @@ -31,6 +51,9 @@ unmount() { umount ${CHROOT}${D} done } + +# chroot + # TODO: this behavior is strange trap unmount INT TERM EXIT @@ -42,3 +65,6 @@ mount --rbind /run ${CHROOT}/run chroot ${CHROOT} /build.sh unmount + +# intsall +cp -fv $(find -type f "${PREFIX}"/bin) "${HTTPD_EXECLINE_ROOT}"/binaries \ No newline at end of file diff --git a/dependencies/build.sh b/dependencies/build.sh index fac9109..9821640 100644 --- a/dependencies/build.sh +++ b/dependencies/build.sh @@ -1,8 +1,27 @@ #!/bin/sh -xe +# build the required runtime dependencies and install them into the +# httpd.execline directory +# +# TODO: most of the skarnet binaries are not required +# +# expected to run in this directory +# builds the result into `_build` in this directiory + +fail() { + echo "${0}: fatal: ${@}" 1>&2 + exit 1 +} + +usage() { + fail "usage: HTTPD_EXECLINE_ROOT= ${0}" +} + +[ ! x"${_CHROOT_BUILD}" = x -a x"${HTTPD_EXECLINE_ROOT}" = x ] && usage +[ ! -r "${HTTPD_EXECLINE_ROOT}" ] && fail "HTTPD_EXECLINE_ROOT (${HTTPD_EXECLINE_ROOT}) is unreadable" _PWD="$(pwd)" PREFIX=${_PWD}/_build -[ -d ${PREFIX} ] || mkdir ${PREFIX} +[ -d "${PREFIX}" ] || mkdir "${PREFIX}" SKARNET=git://git.skarnet.org SKALIBS=${SKARNET}/skalibs @@ -23,32 +42,32 @@ build() { case "${1}" in "9base") git checkout master # inelegant - cp -f ${_PWD}/_9base/Makefile . - make PREFIX=${PREFIX} install + cp -f "${PWD}"/_9base/Makefile . + make PREFIX="${PREFIX}" install ;; git) # toybox - cp -f ${_PWD}/_toybox/.config . - LDFLAGS=" -static" PREFIX=${PREFIX}/bin make install_flat + cp -f "${PWD}"/_toybox/.config . + LDFLAGS=" -static" PREFIX="${PREFIX}"/bin make install_flat ;; BearSSL) make ;; s6-networking) - ./configure --enable-static-libc --disable-shared --enable-ssl=bearssl --with-include=${_PWD}/BearSSL/inc --with-lib=${_PWD}/BearSSL/build --prefix=${PREFIX} --with-include=${PREFIX}/include --with-lib=${PREFIX}/lib --with-lib=${PREFIX}/lib/skalibs --with-lib=${PREFIX}/lib/s6-dns --with-lib=${PREFIX}/lib/s6 + ./configure --enable-static-libc --disable-shared --enable-ssl=bearssl --with-include="${PWD}"/BearSSL/inc --with-lib="${PWD}"/BearSSL/build --prefix="${PREFIX}" --with-include="${PREFIX}"/include --with-lib="${PREFIX}"/lib --with-lib="${PREFIX}"/lib/skalibs --with-lib="${PREFIX}"/lib/s6-dns --with-lib="${PREFIX}"/lib/s6 make install ;; s6) - ./configure --enable-static-libc --disable-shared --prefix=${PREFIX} --with-include=${PREFIX}/include --with-lib=${PREFIX}/lib --with-lib=${PREFIX}/lib/skalibs --with-lib=${PREFIX}/lib/execline + ./configure --enable-static-libc --disable-shared --prefix="${PREFIX}" --with-include="${PREFIX}"/include --with-lib="${PREFIX}"/lib --with-lib="${PREFIX}"/lib/skalibs --with-lib="${PREFIX}"/lib/execline make install ;; *) - ./configure --enable-static-libc --disable-shared --prefix=${PREFIX} --with-include=${PREFIX}/include --with-lib=${PREFIX}/lib --with-lib=${PREFIX}/lib/skalibs + ./configure --enable-static-libc --disable-shared --prefix="${PREFIX}" --with-include="${PREFIX}"/include --with-lib="${PREFIX}"/lib --with-lib="${PREFIX}"/lib/skalibs make install ;; esac } - +# build for URL in ${SKALIBS} ${EXECLINE} ${S6} ${S6_PORTABLE_UTILS} ${S6_DNS} ${BEARSSL} ${S6_NETWORKING} ${TOYBOX} ${_9BASE} do ( @@ -66,3 +85,9 @@ do ) done + +# install +if [ ! x"${_CHROOT_BUILD}" = x ] +then + cp -fv $(find -type f "${PREFIX}"/bin) "${HTTPD_EXECLINE_ROOT}"/binaries +fi