site-ffhh/build.sh

103 lines
3.1 KiB
Bash
Raw Normal View History

2017-10-22 21:37:45 +02:00
#!/bin/bash -e
function announce () {
echo '############################' $* >&2
}
proc=$(nproc)
gluon_out="${HOME}/firmware"
while getopts g:j:l:o:s:u:bmv opt; do
2017-10-22 21:37:45 +02:00
case "$opt" in
g) gluon_path="$OPTARG" ;;
l) sites="$OPTARG" ;;
2017-10-22 21:37:45 +02:00
o) gluon_out="$OPTARG" ;;
2017-10-30 21:08:43 +01:00
s) signature="$OPTARG" ;;
u) uploadscript="$OPTARG" ;;
2017-10-22 21:37:45 +02:00
b) export BROKEN=1 ;;
m) dont_make_sites=1 ;;
2017-10-22 21:37:45 +02:00
j) proc="$OPTARG" ;;
v) verbose=V=s ;;
esac
done
if [ -z "${gluon_path}" ]; then
echo "Usage: $0 -g GLUON_PATH" >&2
echo " -g GLUON_PATH Path to a checkout of the gluon repository." >&2
echo " -l SITES Comma separated list of sites to build" >&2
echo " -o OUT_PATH Path to the firmware output directory. Default: ${gluon_out}" >&2
2017-10-30 21:08:43 +01:00
echo " -s SIGNATURE Sign firmware with signature" >&2
echo " -u UPLOADSCRIPT Run UPLOADSCRIPT after building. Argument: $gluon_out/<GLUON_RELEASE>" >&2
2017-10-22 21:37:45 +02:00
echo " -b BROKEN=1" >&2
echo " -m Do not regenerate the sites" >&2
2017-10-22 21:37:45 +02:00
echo " -v verbose" >&2
echo " -j JOBS Run build with -jJOBS. Default: ${proc}" >&2
exit 1
fi
gluon_path=$(realpath $gluon_path)
gluon_out=$(realpath $gluon_out)
site_path=$(realpath $(dirname $BASH_SOURCE))
announce GLUON: $gluon_path >&2
announce FFHH SITE PATH: $site_path >&2
2017-10-22 21:37:45 +02:00
pushd $site_path
if [ "$dont_make_sites" == "" ]; then
# Build the site repo and generate all site configs
announce Building site repo and reading data >&2
make
fi
2017-10-30 21:08:43 +01:00
. ./info
2017-10-22 21:37:45 +02:00
export GLUON_RELEASE
export GLUON_BRANCH
# get the available sites...
sites="$(echo "$sites" | sed -e 's_,_ _g')"
2017-10-30 21:08:43 +01:00
if [ "$sites" == "" ]; then
for s in sites/*; do sites="${sites} ${s##*/}"; done
fi
2017-10-22 21:37:45 +02:00
announce Gluon will be built for the following sites:$sites >&2
announce The following targets will be generated: $targets >&2
popd
2017-10-22 21:37:45 +02:00
pushd "${gluon_path}"
2017-10-22 21:37:45 +02:00
announce Starting make update...
for s in $sites; do
export GLUON_SITEDIR="${site_path}/sites/${s}"
2017-10-30 21:08:43 +01:00
export GLUON_OUTPUTDIR="${gluon_out}/${GLUON_RELEASE}/${GLUON_BRANCH}/${s}"
2017-10-22 21:37:45 +02:00
export GLUON_IMAGEDIR="${GLUON_OUTPUTDIR}/images"
export GLUON_MODULEDIR="${GLUON_OUTPUTDIR}/modules"
rm -rf "${GLUON_OUTPUTDIR}"
mkdir -p "${GLUON_IMAGEDIR}" "${GLUON_MODULEDIR}"
make update
# Try to install patches. I wasn't able to figure out how patches in gluon/site/patches work.
for p in ${site_path}/patches/*.patch; do
if [ -e "$p" -a ! -f "${gluon_path}/${p##*/}" ]; then
announce Installing patch $p
patch -p1 < $p
touch "${gluon_path}/${p##*/}"
fi
done
for t in $targets; do
2017-10-30 21:08:43 +01:00
announce make clean for $s/$t... >&2
make -j1 clean GLUON_TARGET=$t
2017-10-22 21:37:45 +02:00
announce Starting build for $s/$t... >&2
make -j$(nproc) GLUON_TARGET=$t $verbose
done
announce Building manifest...
make manifest
2017-10-30 21:08:43 +01:00
if [ -n "${signature}" ]; then
if [ "$GLUON_BRANCH" == "experimental" ]; then
announce Signing
"${gluon_path}/contrib/sign.sh" "${signature}" "${GLUON_IMAGEDIR}/sysupgrade/experimental.manifest"
else
echo ERROR: can only sign experimental branch >&2
exit 1
fi
fi
2017-10-22 21:37:45 +02:00
done
popd
if [ -n "$uploadscript" ]; then
announce Starting upload. Executing: $uploadscript $gluon_out/$GLUON_RELEASE
"$uploadscript" "$gluon_out/$GLUON_RELEASE"
fi