Add bash based build harness.
This commit is contained in:
parent
6d51641b06
commit
707328a15c
|
@ -11,7 +11,7 @@ lint_task:
|
||||||
- apt-get -y install shellcheck
|
- apt-get -y install shellcheck
|
||||||
- apt-get -y clean
|
- apt-get -y clean
|
||||||
check_script:
|
check_script:
|
||||||
- shellcheck rootfs.sh
|
- shellcheck rootfs.sh sysa/run.sh sysa/helpers.sh
|
||||||
|
|
||||||
run_task:
|
run_task:
|
||||||
# Required background services
|
# Required background services
|
||||||
|
|
|
@ -41,6 +41,7 @@ mkdir -p tmp/after/include/linux/{x86,x86_64}
|
||||||
mkdir -p tmp/tmp
|
mkdir -p tmp/tmp
|
||||||
cp after.kaem tmp/
|
cp after.kaem tmp/
|
||||||
cp after.kaem.run tmp/after/kaem.run
|
cp after.kaem.run tmp/after/kaem.run
|
||||||
|
cp helpers.sh run.sh tmp/after/
|
||||||
|
|
||||||
# mescc-tools-extra
|
# mescc-tools-extra
|
||||||
cp -r mescc-tools-extra tmp/after/
|
cp -r mescc-tools-extra tmp/after/
|
||||||
|
|
|
@ -147,10 +147,4 @@ cd ${pkg}
|
||||||
kaem --file ${pkg}.kaem
|
kaem --file ${pkg}.kaem
|
||||||
cd ..
|
cd ..
|
||||||
|
|
||||||
# Part 21: m4
|
bash run.sh
|
||||||
pkg="m4-1.4"
|
|
||||||
cd ${pkg}
|
|
||||||
kaem --file ${pkg}.kaem
|
|
||||||
cd ..
|
|
||||||
|
|
||||||
echo "Bootstrapping completed."
|
|
||||||
|
|
|
@ -35,5 +35,7 @@ make
|
||||||
|
|
||||||
# Install
|
# Install
|
||||||
install bash /after/bin/
|
install bash /after/bin/
|
||||||
|
ln -s /after/bin/bash /bin/bash
|
||||||
|
ln -s /after/bin/bash /bin/sh
|
||||||
|
|
||||||
cd ../..
|
cd ../..
|
||||||
|
|
|
@ -0,0 +1,119 @@
|
||||||
|
#!/bin/bash -e
|
||||||
|
|
||||||
|
# SPDX-FileCopyrightText: 2021 Andrius Štikonas <andrius@stikonas.eu>
|
||||||
|
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
|
|
||||||
|
export PATH=/after/bin
|
||||||
|
|
||||||
|
# Common build steps
|
||||||
|
# Build function provides a few common stages with default implementation
|
||||||
|
# that can be overridden on per package basis in the build script.
|
||||||
|
# build takes two arguments:
|
||||||
|
# 1) name-version of the package
|
||||||
|
# 2) optionally specify build script. Default is name-version.sh
|
||||||
|
build () {
|
||||||
|
pkg=$1
|
||||||
|
script_name=${2:-${pkg}.sh}
|
||||||
|
|
||||||
|
cd "$pkg" || (echo "Cannot cd into ${pkg}!"; kill $$)
|
||||||
|
echo "${pkg}: beginning build"
|
||||||
|
base_dir="${PWD}"
|
||||||
|
patch_dir="${base_dir}/patches"
|
||||||
|
mk_dir="${base_dir}/mk"
|
||||||
|
|
||||||
|
rm -rf "build"
|
||||||
|
mkdir -p "build"
|
||||||
|
|
||||||
|
cd "build"
|
||||||
|
|
||||||
|
echo "${pkg}: unpacking source."
|
||||||
|
call src_unpack
|
||||||
|
|
||||||
|
build_script="${base_dir}/${script_name}"
|
||||||
|
if test -e "${build_script}"; then
|
||||||
|
# shellcheck source=/dev/null
|
||||||
|
. "${build_script}"
|
||||||
|
fi
|
||||||
|
cd "${pkg}" || (echo "Cannot cd into build/${pkg}!"; kill $$)
|
||||||
|
|
||||||
|
echo "${pkg}: preparing source."
|
||||||
|
call src_prepare
|
||||||
|
|
||||||
|
echo "${pkg}: configuring source."
|
||||||
|
call src_configure
|
||||||
|
|
||||||
|
echo "${pkg}: compiling source."
|
||||||
|
call src_compile
|
||||||
|
|
||||||
|
echo "${pkg}: installing."
|
||||||
|
call src_install
|
||||||
|
|
||||||
|
cd ../..
|
||||||
|
|
||||||
|
echo "${pkg}: build successful"
|
||||||
|
cd ..
|
||||||
|
}
|
||||||
|
|
||||||
|
# Default unpacking function that unpacks a single source tarball.
|
||||||
|
default_src_unpack() {
|
||||||
|
src_dir="${base_dir}/src"
|
||||||
|
|
||||||
|
for suf in gz bz2 xz; do
|
||||||
|
source="${src_dir}/${pkg}.tar.${suf}"
|
||||||
|
if test -e "${source}"; then
|
||||||
|
case "${suf}" in
|
||||||
|
gz) xtr="z" ;;
|
||||||
|
bz2) xtr="j" ;;
|
||||||
|
xz) xtr="J" ;;
|
||||||
|
esac
|
||||||
|
tar "-${xtr}" -xf "${source}"
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
# Default function to prepare source code.
|
||||||
|
# It applies all patches from patch_dir (at the moment only -p0 patches are supported).
|
||||||
|
# Then it copies our custom makefile.
|
||||||
|
default_src_prepare() {
|
||||||
|
if test -d "${patch_dir}"; then
|
||||||
|
for p in "${patch_dir}"/*.patch; do
|
||||||
|
patch -Np0 < "${p}"
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
|
||||||
|
makefile="${mk_dir}/main.mk"
|
||||||
|
if test -e "${makefile}"; then
|
||||||
|
cp "${makefile}" Makefile
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# Default function for configuring source.
|
||||||
|
default_src_configure() {
|
||||||
|
:
|
||||||
|
}
|
||||||
|
|
||||||
|
# Default function for compiling source. It simply runs make without any parameters.
|
||||||
|
default_src_compile() {
|
||||||
|
make
|
||||||
|
}
|
||||||
|
|
||||||
|
# Default installing function. PREFIX should be set by run.sh script.
|
||||||
|
# Note that upstream makefiles might ignore PREFIX and have to be configured in configure stage.
|
||||||
|
default_src_install() {
|
||||||
|
make install PREFIX="${PREFIX}"
|
||||||
|
}
|
||||||
|
|
||||||
|
# Check if bash function exists
|
||||||
|
fn_exists() {
|
||||||
|
test "$(type -t "$1")" == 'function'
|
||||||
|
}
|
||||||
|
|
||||||
|
# Call package specific function or default implementation.
|
||||||
|
call() {
|
||||||
|
if fn_exists "$1"; then
|
||||||
|
$1
|
||||||
|
else
|
||||||
|
default_"${1}"
|
||||||
|
fi
|
||||||
|
}
|
|
@ -1,26 +0,0 @@
|
||||||
#!/bin/sh
|
|
||||||
|
|
||||||
set -ex
|
|
||||||
|
|
||||||
mkdir build
|
|
||||||
cd build
|
|
||||||
|
|
||||||
# Extract
|
|
||||||
gunzip ../src/${pkg}.tar.gz
|
|
||||||
tar xf ../src/${pkg}.tar
|
|
||||||
cd ${pkg}
|
|
||||||
cp ../../mk/main.mk Makefile
|
|
||||||
|
|
||||||
# Patch and prepare
|
|
||||||
patch -Np0 -i ../../patches/signal-include.patch
|
|
||||||
|
|
||||||
# Build
|
|
||||||
make
|
|
||||||
|
|
||||||
# Install
|
|
||||||
install m4 /after/bin/
|
|
||||||
|
|
||||||
# Test
|
|
||||||
m4 --version
|
|
||||||
|
|
||||||
cd ../..
|
|
|
@ -26,3 +26,6 @@ m4: libm4.a $(M4_OBJ)
|
||||||
|
|
||||||
libm4.a: $(LIB_OBJECTS)
|
libm4.a: $(LIB_OBJECTS)
|
||||||
$(AR) cr $@ $^
|
$(AR) cr $@ $^
|
||||||
|
|
||||||
|
install: all
|
||||||
|
install m4 $(PREFIX)/bin
|
||||||
|
|
|
@ -0,0 +1,15 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# SPDX-FileCopyrightText: 2021 Andrius Štikonas <andrius@stikonas.eu>
|
||||||
|
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
|
|
||||||
|
set -e
|
||||||
|
# shellcheck source=sysa/helpers.sh
|
||||||
|
. helpers.sh
|
||||||
|
|
||||||
|
export PREFIX=/after
|
||||||
|
|
||||||
|
# Part 21
|
||||||
|
build m4-1.4
|
||||||
|
|
||||||
|
echo "Bootstrapping completed."
|
Loading…
Reference in New Issue