build-bootenv

reproducible boot environment with LVM2 and cryptsetup
git clone https://ccx.te2000.cz/git/build-bootenv
Log | Files | Refs | Submodules

commit fc273cd54b47c48d220967eae402c6418de7603a
parent 6c2f343e1b959b36781533354c01e6b6936e4b3a
Author: Jan Pobříslo <ccx@te2000.cz>
Date:   Sun,  3 Jan 2021 01:01:08 +0100

First take at build scripts.

Diffstat:
A.gitignore | 2++
Abuild | 16++++++++++++++++
Amusl-cross-make.config.mak | 89+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Asabotage.config | 80+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
4 files changed, 187 insertions(+), 0 deletions(-)

diff --git a/.gitignore b/.gitignore @@ -0,0 +1,2 @@ +local +image diff --git a/build b/build @@ -0,0 +1,16 @@ +#!/bin/sh +set -x +case $0 in (*/*) cd "${0%/*}" || exit $?;; esac +JOBS=$(grep '^processor' /proc/cpuinfo | wc -l) +: ${JOBS:=1} +if test 1 -gt $JOBS; then + JOBS=1 +fi +awk -vPWD="$PWD" '{gsub(/@@PWD@@/,PWD); print}' musl-cross-make.config.mak >musl-cross-make/config.mak.new || exit $? +mv musl-cross-make/config.mak.new musl-cross-make/config.mak || exit $? +make -C musl-cross-make -j$JOBS -l$JOBS || exit $? +awk -vPWD="$PWD" -vJOBS="$JOBS" '{gsub(/@@PWD@@/,PWD); gsub(/@@JOBS@@/,JOBS); print}' sabotage.config >sabotage/config.new || exit $? +mv sabotage/config.new sabotage/config || exit $? +PATH=$PWD/sabotage/KEEP/bin:$PWD/local/bin:$PWD/local/x86_64-linux-musl/bin:$PATH +export CONFIG=$PWD/sabotage/config +butch install busybox lvm cryptsetup diff --git a/musl-cross-make.config.mak b/musl-cross-make.config.mak @@ -0,0 +1,89 @@ +# +# config.mak.dist - sample musl-cross-make configuration +# +# Copy to config.mak and edit as desired. +# + +# There is no default TARGET; you must select one here or on the make +# command line. Some examples: + +# TARGET = i486-linux-musl +TARGET = x86_64-linux-musl +# TARGET = arm-linux-musleabi +# TARGET = arm-linux-musleabihf +# TARGET = sh2eb-linux-muslfdpic +# ... + +# By default, cross compilers are installed to ./output under the top-level +# musl-cross-make directory and can later be moved wherever you want them. +# To install directly to a specific location, set it here. Multiple targets +# can safely be installed in the same location. Some examples: + +# OUTPUT = /opt/cross +# OUTPUT = /usr/local +OUTPUT = "@@PWD@@/prefix" + +# By default, latest supported release versions of musl and the toolchain +# components are used. You can override those here, but the version selected +# must be supported (under hashes/ and patches/) to work. For musl, you +# can use "git-refname" (e.g. git-master) instead of a release. Setting a +# blank version for gmp, mpc, mpfr and isl will suppress download and +# in-tree build of these libraries and instead depend on pre-installed +# libraries when available (isl is optional and not set by default). +# Setting a blank version for linux will suppress installation of kernel +# headers, which are not needed unless compiling programs that use them. + +# BINUTILS_VER = 2.25.1 +BINUTILS_VER = 2.27 +# GCC_VER = 5.2.0 +# MUSL_VER = git-master +# GMP_VER = +# MPC_VER = +# MPFR_VER = +# ISL_VER = +# LINUX_VER = + +# By default source archives are downloaded with wget. curl is also an option. + +# DL_CMD = wget -c -O +# DL_CMD = curl -C - -L -o + +# Check sha-1 hashes of downloaded source archives. On gnu systems this is +# usually done with sha1sum. + +# SHA1_CMD = sha1sum -c +# SHA1_CMD = sha1 -c +# SHA1_CMD = shasum -a 1 -c + +# Something like the following can be used to produce a static-linked +# toolchain that's deployable to any system with matching arch, using +# an existing musl-targeted cross compiler. This only works if the +# system you build on can natively (or via binfmt_misc and qemu) run +# binaries produced by the existing toolchain (in this example, i486). + +# COMMON_CONFIG += CC="i486-linux-musl-gcc -static --static" CXX="i486-linux-musl-g++ -static --static" + +# Recommended options for smaller build for deploying binaries: + +# COMMON_CONFIG += CFLAGS="-g0 -Os" CXXFLAGS="-g0 -Os" LDFLAGS="-s" + +# Options you can add for faster/simpler build at the expense of features: + +# COMMON_CONFIG += --disable-nls +# GCC_CONFIG += --disable-libquadmath --disable-decimal-float +# GCC_CONFIG += --disable-libitm +# GCC_CONFIG += --disable-fixed-point +# GCC_CONFIG += --disable-lto + +# By default C and C++ are the only languages enabled, and these are +# the only ones tested and known to be supported. You can uncomment the +# following and add other languages if you want to try getting them to +# work too. + +# GCC_CONFIG += --enable-languages=c,c++ + +# You can keep the local build path out of your toolchain binaries and +# target libraries with the following, but then gdb needs to be told +# where to look for source files. + +# COMMON_CONFIG += --with-debug-prefix-map=$(CURDIR)= diff --git a/sabotage.config b/sabotage.config @@ -0,0 +1,80 @@ +## set the arch you're building for +#export A=i386 +export A=x86_64 +#export A=x86_64-x32 +#export A=mips +#export A=powerpc +#export A=microblaze +#export A=sh +#export A=arm + +[ -z "$A" ] && { printf "ERROR: no arch set\n" ; exit 1 ; } + +# arch specific flags to pass to the gcc build +# your crosscompiler should be configured equivalently +# if not provided, will be derived from the crosscompiler config +#export GCC_ARCH_CONFIG_FLAGS="--with-float=soft --with-fpu=vfp" + +# set to basepath containing your musl-cross toolchains +# we assume there's a subdir equal to the triplet in there +#crosstoolchain=$HOME/musl-cross-make-6.5.0 +crosstoolchain="@@PWD@@/local" + +#set toolchain triplet +#triplet=x86_64-linux-muslx32 +#triplet=arm-linux-musleabihf +triplet=$A-linux-musl + +# point S to sabotage checkout or /src dir of an existing sabotage install +# path is used to lookup KEEP, pkg and tarballs dirs +#export S=/src +export S="@@PWD@@/sabotage" + +# set R to the rootfs path (where stuff gets installed to) +export R="@@PWD@@/image" + +# set number of parallel make processes +export MAKE_THREADS=@@JOBS@@ + +# set BRUTE to 1 to enable LTO in the standard etc/butch-optflags profile +# (slow to compile, but results in minimal binary size and very fast code) +#export BRUTE=1 +# set TESTBUILD to 1 to build everything without optimization/debug (much faster) +#export TESTBUILD=1 + +# typically, you shouldn't have to change any of the vars after this line + +export K=$S/KEEP +# where stuff gets built +export B=$R/src/build +export C=$S/tarballs +export LOGPATH=$R/src/logs +export BUTCHDB=$R/var/lib/butch.db +export butch_filelists=$R/src/filelists +export butch_tarballs_used=$R/src/tarballs_used.txt +export BUTCH_BUILD_TEMPLATE=$K/butch_build_template.txt +export BUTCH_DOWNLOAD_TEMPLATE=$K/butch_download_template.txt + +export PATH="$PATH":$crosstoolchain/$triplet/bin + +export CC="$triplet-gcc -L$R/lib -isystem $R/include" +export CXX="$triplet-g++ -L$R/lib -isystem $R/include" +export CROSS_COMPILE=$triplet- +export HOSTCC=gcc +export HOSTCXX=g++ + +export STAGE=1 +export PKG_CONFIG_SYSROOT_DIR=$R +export PKG_CONFIG_LIBDIR=$R/lib/pkgconfig +# do not build host/runtime deps +export DEPS=build + +if ! test -d "$R" ; then + echo "ERROR: R points to non-existing path $R">&2 + exit 1 +fi +if ! $CC --version >/dev/null 2>&1 ; then + echo "ERROR! toolchain $CC not found in PATH $PATH">&2 + exit 1 +fi +