]> cat aescling's git repositories - httpd-execline.git/commitdiff
Improve the build scripts
authorcat æscling <11325618-aescling@users.noreply.gitlab.com>
Thu, 3 Aug 2023 03:50:42 +0000 (23:50 -0400)
committercat æscling <11325618-aescling@users.noreply.gitlab.com>
Thu, 3 Aug 2023 03:50:42 +0000 (23:50 -0400)
dependencies/build-in-musl-chroot.sh
dependencies/build.sh

index bb58036c868fe1c0b5a649e8bba7d1988383f331..980ed907bbf14ecbdcbfeee2e5b812940ae7c2d1 100644 (file)
@@ -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=<chroot jail directory> ${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
index fac910959000d79719c2df97cd4f13c811d14cec..98216402dfa844222babc0913fc36a034f2eba0c 100644 (file)
@@ -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=<chroot jail directory> ${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