2018-04-06 21:33:30 +02:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
set -e
|
2017-10-22 21:37:45 +02:00
|
|
|
|
|
|
|
function announce () {
|
2019-08-17 23:23:14 +02:00
|
|
|
echo '############################' "$@" >&2
|
2017-10-22 21:37:45 +02:00
|
|
|
}
|
2018-04-06 21:46:23 +02:00
|
|
|
function usage () {
|
2017-10-22 21:37:45 +02:00
|
|
|
echo "Usage: $0 -g GLUON_PATH" >&2
|
|
|
|
echo " -g GLUON_PATH Path to a checkout of the gluon repository." >&2
|
2018-09-07 21:07:51 +02:00
|
|
|
echo " -t TARGETS Comma separated list of gluon targets to build" >&2
|
2019-08-17 23:23:14 +02:00
|
|
|
echo " -a Automatically detect and build all targets." >&2
|
2017-12-19 03:00:34 +01:00
|
|
|
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
|
2017-10-22 21:37:45 +02:00
|
|
|
echo " -b BROKEN=1" >&2
|
|
|
|
echo " -v verbose" >&2
|
|
|
|
echo " -j JOBS Run build with -jJOBS. Default: ${proc}" >&2
|
2018-04-06 21:46:23 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
proc=$(nproc)
|
|
|
|
gluon_out="${HOME}/firmware"
|
|
|
|
|
|
|
|
while [ $# -gt 0 ]; do
|
|
|
|
case "$1" in
|
2019-08-17 23:23:14 +02:00
|
|
|
-a)
|
|
|
|
auto_targets=1
|
|
|
|
;;
|
2018-04-06 21:46:23 +02:00
|
|
|
-g)
|
|
|
|
gluon_path="$2"
|
|
|
|
shift
|
|
|
|
;;
|
2018-09-07 21:07:51 +02:00
|
|
|
-t)
|
|
|
|
build_targets="$2"
|
|
|
|
shift
|
|
|
|
;;
|
2018-04-06 21:46:23 +02:00
|
|
|
-o)
|
|
|
|
gluon_out="$2"
|
|
|
|
shift
|
|
|
|
;;
|
|
|
|
-s)
|
|
|
|
signature="$2"
|
|
|
|
shift
|
|
|
|
;;
|
|
|
|
-b)
|
|
|
|
export BROKEN=1
|
|
|
|
;;
|
|
|
|
-j)
|
|
|
|
proc="$2"
|
|
|
|
shift
|
|
|
|
;;
|
|
|
|
-v)
|
|
|
|
verbose=V=s
|
|
|
|
;;
|
|
|
|
*)
|
2018-10-01 21:37:30 +02:00
|
|
|
echo ERROR: Failed to parse: "${1}" >&2
|
2018-04-06 21:46:23 +02:00
|
|
|
usage
|
|
|
|
exit 1
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
shift
|
|
|
|
done
|
|
|
|
|
|
|
|
if [ -z "$gluon_path" ]; then
|
|
|
|
usage
|
2017-10-22 21:37:45 +02:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2019-08-17 23:23:14 +02:00
|
|
|
gluon_path=$(realpath "$gluon_path")
|
|
|
|
gluon_out=$(realpath "$gluon_out")
|
|
|
|
site_path=$(realpath "$(dirname "$BASH_SOURCE")")
|
2017-10-22 21:37:45 +02:00
|
|
|
|
2019-08-17 23:23:14 +02:00
|
|
|
announce GLUON: "$gluon_path" >&2
|
|
|
|
announce FFHH SITE PATH: "$site_path" >&2
|
2017-10-22 21:37:45 +02:00
|
|
|
|
2019-08-17 23:23:14 +02:00
|
|
|
pushd "$site_path"
|
2019-08-18 13:15:52 +02:00
|
|
|
# shellcheck source=/dev/null
|
2018-10-01 21:37:30 +02:00
|
|
|
. ./build.conf
|
2019-02-04 22:28:09 +01:00
|
|
|
[ "${GLUON_BRANCH}" = "experimental" ] && GLUON_RELEASE="${GLUON_RELEASE}~exp$(date +%Y%m%d)"
|
2017-10-22 21:37:45 +02:00
|
|
|
export GLUON_RELEASE
|
|
|
|
export GLUON_BRANCH
|
2019-08-17 23:23:14 +02:00
|
|
|
export GLUON_SITEDIR="${site_path}"
|
|
|
|
export GLUON_OUTPUTDIR="${gluon_out}/${GLUON_RELEASE}/${GLUON_BRANCH}"
|
2017-12-19 03:00:34 +01:00
|
|
|
popd
|
2017-10-22 21:37:45 +02:00
|
|
|
|
2017-12-19 03:00:34 +01:00
|
|
|
pushd "${gluon_path}"
|
2017-10-22 21:37:45 +02:00
|
|
|
announce Starting make update...
|
2018-10-01 21:37:30 +02:00
|
|
|
rm -rf "${GLUON_OUTPUTDIR}"
|
|
|
|
mkdir -p "${GLUON_OUTPUTDIR}"
|
|
|
|
make update
|
|
|
|
# Try to install patches. I wasn't able to figure out how patches in gluon/site/patches work.
|
2019-08-17 23:23:14 +02:00
|
|
|
for p in "${site_path}"/patches/*.patch; do
|
|
|
|
if [ -e "$p" ] && [ ! -f "${gluon_path}/${p##*/}" ]; then
|
|
|
|
announce "Installing patch $p"
|
|
|
|
patch -p1 < "$p"
|
2018-10-01 21:37:30 +02:00
|
|
|
touch "${gluon_path}/${p##*/}"
|
2017-10-30 21:08:43 +01:00
|
|
|
fi
|
2017-10-22 21:37:45 +02:00
|
|
|
done
|
2019-08-17 23:23:14 +02:00
|
|
|
|
|
|
|
if [ "$auto_targets" = "1" ]; then
|
|
|
|
# detect available targets
|
|
|
|
targets="$(make list-targets | sort | xargs)"
|
|
|
|
else
|
|
|
|
# if a list of build targets has been supplied, only build those
|
|
|
|
targets="$(echo "${build_targets:-$targets}" | sed -e 's_,_ _g')"
|
|
|
|
fi
|
|
|
|
announce "The following targets will be generated: $targets" >&2
|
|
|
|
|
2018-10-01 21:37:30 +02:00
|
|
|
for t in $targets; do
|
2019-08-17 23:23:14 +02:00
|
|
|
announce "Starting build for $t..." >&2
|
|
|
|
make "-j$(nproc)" "GLUON_TARGET=$t" "$verbose"
|
2018-10-01 21:37:30 +02:00
|
|
|
done
|
2019-08-18 13:16:31 +02:00
|
|
|
# Remove known-broken images
|
|
|
|
# shellcheck disable=SC2154
|
|
|
|
for broken_image in "${broken_images[@]}"; do
|
|
|
|
announce "Removing broken image ${broken_image}..."
|
2019-08-18 23:55:55 +02:00
|
|
|
find "${GLUON_OUTPUTDIR}/images" -iname "${broken_image}" \( -type f -o -type l \) -ls -exec rm -f {} \;
|
2019-08-18 13:16:31 +02:00
|
|
|
done
|
2019-03-22 20:56:30 +01:00
|
|
|
# Generate the images.list
|
2019-08-18 13:15:52 +02:00
|
|
|
# shellcheck disable=SC2094
|
|
|
|
( cd "${GLUON_OUTPUTDIR}/images" && ( find . -type f ! -iname '*.manifest' ! -iname images.list; find . -type l ! -iname '*.manifest' ) | sed -e 's!^\./\(.*\)$!\1!' -e 's!/! !g' | sort > images.list )
|
2018-10-01 21:37:30 +02:00
|
|
|
announce Building manifest...
|
|
|
|
make manifest
|
|
|
|
if [ -n "${signature}" ]; then
|
|
|
|
if [ "$GLUON_BRANCH" == "experimental" ]; then
|
|
|
|
announce Signing...
|
|
|
|
"${gluon_path}/contrib/sign.sh" "${signature}" "${GLUON_OUTPUTDIR}/images/sysupgrade/experimental.manifest"
|
|
|
|
else
|
|
|
|
echo ERROR: can only sign experimental branch >&2
|
|
|
|
exit 1
|
|
|
|
fi
|
2017-12-19 03:00:34 +01:00
|
|
|
fi
|
2018-10-01 21:37:30 +02:00
|
|
|
popd
|