build.sh: include the changes from master

This commit is contained in:
Daniel Frank 2019-08-17 23:23:14 +02:00
parent 1dc6507e8c
commit b52b3f961e
Signed by: tokudan
GPG key ID: 063CCCAD04182D32

View file

@ -2,12 +2,13 @@
set -e set -e
function announce () { function announce () {
echo '############################' $* >&2 echo '############################' "$@" >&2
} }
function usage () { function usage () {
echo "Usage: $0 -g GLUON_PATH" >&2 echo "Usage: $0 -g GLUON_PATH" >&2
echo " -g GLUON_PATH Path to a checkout of the gluon repository." >&2 echo " -g GLUON_PATH Path to a checkout of the gluon repository." >&2
echo " -t TARGETS Comma separated list of gluon targets to build" >&2 echo " -t TARGETS Comma separated list of gluon targets to build" >&2
echo " -a Automatically detect and build all targets." >&2
echo " -o OUT_PATH Path to the firmware output directory. Default: ${gluon_out}" >&2 echo " -o OUT_PATH Path to the firmware output directory. Default: ${gluon_out}" >&2
echo " -s SIGNATURE Sign firmware with signature" >&2 echo " -s SIGNATURE Sign firmware with signature" >&2
echo " -b BROKEN=1" >&2 echo " -b BROKEN=1" >&2
@ -20,6 +21,9 @@ gluon_out="${HOME}/firmware"
while [ $# -gt 0 ]; do while [ $# -gt 0 ]; do
case "$1" in case "$1" in
-a)
auto_targets=1
;;
-g) -g)
gluon_path="$2" gluon_path="$2"
shift shift
@ -60,41 +64,48 @@ if [ -z "$gluon_path" ]; then
exit 1 exit 1
fi fi
gluon_path=$(realpath $gluon_path) gluon_path=$(realpath "$gluon_path")
gluon_out=$(realpath $gluon_out) gluon_out=$(realpath "$gluon_out")
site_path=$(realpath $(dirname $BASH_SOURCE)) site_path=$(realpath "$(dirname "$BASH_SOURCE")")
announce GLUON: $gluon_path >&2 announce GLUON: "$gluon_path" >&2
announce FFHH SITE PATH: $site_path >&2 announce FFHH SITE PATH: "$site_path" >&2
pushd $site_path pushd "$site_path"
. ./build.conf . ./build.conf
[ "${GLUON_BRANCH}" = "experimental" ] && GLUON_RELEASE="${GLUON_RELEASE}~exp$(date +%Y%m%d)" [ "${GLUON_BRANCH}" = "experimental" ] && GLUON_RELEASE="${GLUON_RELEASE}~exp$(date +%Y%m%d)"
export GLUON_RELEASE export GLUON_RELEASE
export GLUON_BRANCH export GLUON_BRANCH
# if a list of build targets has been supplied, only build those export GLUON_SITEDIR="${site_path}"
targets="$(echo "${build_targets:-$targets}" | sed -e 's_,_ _g')" export GLUON_OUTPUTDIR="${gluon_out}/${GLUON_RELEASE}/${GLUON_BRANCH}"
announce The following targets will be generated: $targets >&2
popd popd
pushd "${gluon_path}" pushd "${gluon_path}"
announce Starting make update... announce Starting make update...
export GLUON_SITEDIR="${site_path}"
export GLUON_OUTPUTDIR="${gluon_out}/${GLUON_RELEASE}/${GLUON_BRANCH}"
rm -rf "${GLUON_OUTPUTDIR}" rm -rf "${GLUON_OUTPUTDIR}"
mkdir -p "${GLUON_OUTPUTDIR}" mkdir -p "${GLUON_OUTPUTDIR}"
make update make update
# Try to install patches. I wasn't able to figure out how patches in gluon/site/patches work. # 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 for p in "${site_path}"/patches/*.patch; do
if [ -e "$p" -a ! -f "${gluon_path}/${p##*/}" ]; then if [ -e "$p" ] && [ ! -f "${gluon_path}/${p##*/}" ]; then
announce Installing patch $p announce "Installing patch $p"
patch -p1 < $p patch -p1 < "$p"
touch "${gluon_path}/${p##*/}" touch "${gluon_path}/${p##*/}"
fi fi
done done
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
for t in $targets; do for t in $targets; do
announce Starting build for $t... >&2 announce "Starting build for $t..." >&2
make -j$(nproc) GLUON_TARGET=$t $verbose make "-j$(nproc)" "GLUON_TARGET=$t" "$verbose"
done done
# Generate the images.list # Generate the images.list
( 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 ) ( 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 )