diff options
author | Andreas Fankhauser hiddenalpha.ch | 2023-08-26 13:06:41 +0200 |
---|---|---|
committer | Andreas Fankhauser hiddenalpha.ch | 2023-08-26 13:06:41 +0200 |
commit | e5fea8382b8cf32fa349d613df32afa187ae969c (patch) | |
tree | 14e2e0d18c44ee1d9a264bd0275758113373a5ac /contrib/build-env-setup | |
parent | 54d94d6c3318850c340d18f51343e1caf1ef56f4 (diff) | |
download | DeflateAndInflate-e5fea8382b8cf32fa349d613df32afa187ae969c.zip DeflateAndInflate-e5fea8382b8cf32fa349d613df32afa187ae969c.tar.gz |
Replace build env doc by qemu.
Diffstat (limited to 'contrib/build-env-setup')
-rw-r--r-- | contrib/build-env-setup/README.txt | 157 |
1 files changed, 157 insertions, 0 deletions
diff --git a/contrib/build-env-setup/README.txt b/contrib/build-env-setup/README.txt new file mode 100644 index 0000000..438ec5c --- /dev/null +++ b/contrib/build-env-setup/README.txt @@ -0,0 +1,157 @@ + +Showcase how to build and install +================================= + +WARN: Do NOT perform any of these steps on your host system! This script + MUST only be run on a system which is a + just-throw-it-away-if-broken system. + +Sometimes happy developers (like me) have no choice but using terribly +restricted systems where setting up tools to run even something as +trivial as configure/make/install becomes a nightmare if not impossible. +I found it to be very handy to have some independent qemu VM at hand +which lets me install whatever I need, neither with any special software +nor any annoying privileges on a host machine. Qemu runs portable and in +user mode even doesn't need any annoying permissions at all. + + + +## Setup a minimal system in your qemu VM + +This setup mainly targets debian. Nevertheless it tries to stay POSIX +compatible as far as possible. So setup a minimal install of your system +of choice and then as soon you've SSH access to a (posix) shell, you're +ready for the next step. + +Still not sure which system to use? Link below provides some candidates. +HINT: Windows IMHO is a terrible choice. So stop complaining if you go +this route. + +https://en.wikipedia.org/wiki/POSIX#POSIX-oriented_operating_systems + + + +## Start VM with SSH access + +Easiest way to work with your machine is via SSH. Therefore if you've +chosen to use a qemu VM, make sure you've setup and configured sshd +properly inside the VM. Then just pass args like those to qemu: + + --device e1000,netdev=n0 --netdev user,id=n0,hostfwd=tcp:127.0.0.1:2222-:22 + +Started this way, the SSHDaemon inside the VM is accessible from your +host via "localhost" at port "2222": + + ssh localhost -p2222 + +I strongly recommend using SSH paired with a well-designed +terminal-emulator in place of some fancy VGA/GUI emulators or similar. +Those commandline tools give immediate benefits like copy-pasting of +script snippets which becomes very handy with the scripts which follow, +or also with file transfers to get the final build result out the VM. My +condolence to users which still think windows is the only way to use a +computer. + + + +## Configure build environment + +Setup environ vars according to your chosen build system. Here are few examlpes: + +### Debian config +true \ + && PKGS_TO_ADD="ca-certificates curl gcc git make libc-dev tar" \ + && PKGS_TO_DEL="curl gcc git make libc-dev" \ + && SUDO=sudo \ + && PKGINIT="$SUDO apt update" \ + && PKGADD="$SUDO apt install -y --no-install-recommends" \ + && PKGDEL="$SUDO apt purge -y" \ + && PKGCLEAN="$SUDO apt clean" \ + && HOST= \ + && true + +### Alpine with w64 cross compiler setup +true \ + && PKGS_TO_ADD="curl mingw-w64-gcc git make tar" \ + && PKGS_TO_DEL="curl mingw-w64-gcc git make" \ + && printf '#!/bin/sh\nsu - root -c "$(echo "$@")"\n' >/home/user/mysudo \ + && chmod +x /home/user/mysudo \ + && SUDO="/home/user/mysudo" \ + && PKGINIT=true \ + && PKGADD="$SUDO apk add" \ + && PKGDEL="$SUDO apk del" \ + && PKGCLEAN=true \ + && HOST="x86_64-w64-mingw32" \ + && true + + +## make, install + +As soon environ is configured, we can trigger the build: + +true \ + && GIT_TAG="master" \ + && ZLIB_VERSION="1.2.11" \ + && WORKDIR="/home/${USER}/work" \ + && ZLIB_URL="https://downloads.sourceforge.net/project/libpng/zlib/${ZLIB_VERSION:?}/zlib-${ZLIB_VERSION:?}.tar.gz" \ + && ZLIB_LOCAL=zlib-${ZLIB_VERSION:?}.tgz \ + && if test -n "$HOST"; then true \ + && INSTALL_ROOT="/usr/${HOST:?}" \ + ;else true \ + && INSTALL_ROOT="/usr/local" \ + ;fi \ + && true \ + && mkdir -p "${WORKDIR:?}" && cd "${WORKDIR:?}" \ + && ${PKGINIT:?} && ${PKGADD:?} $PKGS_TO_ADD \ + && if test -f "/var/tmp/${ZLIB_LOCAL:?}"; then true \ + && echo "[DEBUG] Already have \"/var/tmp/${ZLIB_LOCAL:?}\"" \ + ;else true \ + && echo "[DEBUG] Downloading \"/var/tmp/${ZLIB_LOCAL:?}\"" \ + && echo "[DEBUG] from \"${ZLIB_URL:?}\"" \ + && curl -sSL "${ZLIB_URL:?}" -o "/var/tmp/${ZLIB_LOCAL:?}" \ + ;fi \ + && printf '\nMake zlib\n\n' \ + && (cd /tmp \ + && tar xzf "/var/tmp/${ZLIB_LOCAL:?}" \ + && export SRCDIR="/tmp/zlib-${ZLIB_VERSION:?}" \ + && mkdir ${SRCDIR:?}/build && cd ${SRCDIR:?} \ + && if test -n "$HOST"; then true \ + && export DESTDIR=./build BINARY_PATH=/bin INCLUDE_PATH=/include LIBRARY_PATH=/lib \ + && sed -i "s;^PREFIX =.\*\$;;" win32/Makefile.gcc \ + && make -e -j$(nproc) -fwin32/Makefile.gcc PREFIX=${HOST:?}- \ + && make -e -fwin32/Makefile.gcc install PREFIX=${HOST:?}- \ + && unset DESTDIR BINARY_PATH INCLUDE_PATH LIBRARY_PATH \ + ;else true \ + && ./configure --prefix=${SRCDIR:?}/build/ \ + && make -j$(nproc) && make install \ + ;fi \ + && cp README build/. \ + && (cd build \ + && rm -rf lib/pkgconfig \ + && find -type f -not -name MD5SUM -exec md5sum -b {} + > MD5SUM \ + && tar --owner=0 --group=0 -cz * > /var/tmp/zlib-${ZLIB_VERSION:?}-bin.tgz \ + ;) \ + && cd / && rm -rf /tmp/zlib-${ZLIB_VERSION:?} \ + && printf '\n\n zlib Done :)\n\n' \ + ;) \ + && $SUDO tar -C "${INSTALL_ROOT:?}" -f /var/tmp/zlib-${ZLIB_VERSION:?}-bin.tgz -x include lib \ + && printf '\n Build project itself\n\n' \ + && git clone --depth 42 --branch "${GIT_TAG:?}" https://github.com/hiddenalpha/DeflateAndInflate.git . \ + && git config advice.detachedHead false \ + && git checkout "${GIT_TAG:?}" \ + && ./configure \ + && if test -n "$HOST"; then true \ + && sed -Ei 's;^CC=gcc$;CC='"${HOST}"'-gcc;' Makefile \ + ;fi \ + && make clean && make -j$(nproc) \ + && if test -z "$HOST"; then $SUDO make install; fi \ + && find . -not -wholename './dist*' -delete \ + && ${PKGDEL:?} $PKGS_TO_DEL && ${PKGCLEAN:?} \ + && dirOfDistBundle="$(realpath dist)" \ + && printf '\n SUCCESS :) Distribution bundle is ready in:\n\n %s\n\n Tip: Before pulling out your hair about how to get that archive out of\n your qemu VM. STOP kluding around with silly tools and learn how\n basic tools do the job perfectly fine:\n\n ssh %s@localhost -p2222 -- sh -c '\''true && cd "%s" && tar c *'\'' | tar x\n\n BTW: In addition 'deflate' and 'inflate' got installed and are ready-to-use.\n\n' "${dirOfDistBundle:?}" "$USER" "${dirOfDistBundle:?}" \ + && true + + + + + |