Simplify build.sh

This commit is contained in:
Julian Kornberger 2016-07-11 02:12:48 +02:00
parent 40d1dca32a
commit ddce710438
1 changed files with 8 additions and 88 deletions

View File

@ -1,9 +1,9 @@
#! /usr/bin/env sh #! /usr/bin/env sh
FIRMWARE_URL="http://downloads.bremen.freifunk.net/firmware/" LOCAL_SUFFIX="breminale"
LOCAL_SUFFIX="bremen"
GLUON_DIR="gluon/" GLUON_DIR="gluon/"
KEYFILE="$HOME/.ecdsakey" KEYFILE="$HOME/.ecdsakey"
local_version=1
set -eu set -eu
@ -24,21 +24,6 @@ get_GLUON_TAG() {
fi fi
} }
get_last_release() {
branch="$1"
wget -q -O- "${FIRMWARE_URL}/${branch}/sysupgrade/${branch}.manifest" | \
awk 'parse == 1 { print $2; exit } /^$/ { parse=1 }'
}
is_based_on() {
[ "${1#$2}" != "${1}" ]
return $?
}
extract_local_version() {
local_version_tmp="${1#*+${LOCAL_SUFFIX}}"
echo "${local_version_tmp%~testing}"
}
debug= debug=
if [ "$#" -gt 0 ]; then if [ "$#" -gt 0 ]; then
@ -64,53 +49,11 @@ GLUON_TAG="$(get_GLUON_TAG)"
# remove prefixed "v" # remove prefixed "v"
GLUON_TAG="${GLUON_TAG#v}" GLUON_TAG="${GLUON_TAG#v}"
statefile="${GLUON_SITEDIR}/.build.${GLUON_BRANCH}.${GLUON_TAG}"
cont=false
if [ -f "$statefile" ]; then
echo "A previous build for this version was aborted."
echo "These were the parameters:"
cat "$statefile"
echo "You can now either continue the previous build or begin a new one"
echo "and overwrite the old state file."
read -p "Do you want to continue the previous build? [Yn] " answer
case "${answer:-y}" in
[yY]*)
. "$statefile"
cont=true
;;
*)
rm "$statefile"
;;
esac
fi
if ! $cont; then
echo "Building Gluon ${GLUON_TAG} as ${GLUON_BRANCH}" echo "Building Gluon ${GLUON_TAG} as ${GLUON_BRANCH}"
last_release_testing="$(get_last_release testing)"
last_release_stable="$(get_last_release stable)"
last_release="$(/bin/echo -e "${last_release_testing}\n${last_release_stable}" | sort -V | tail -n1)"
echo "Last release was ${last_release}"
if is_based_on "$last_release" "$GLUON_TAG"; then
local_version="$(extract_local_version "$last_release")"
local_version="$(($local_version + 1))"
else
# new gluon version => reset local version number
local_version=1
fi
auto_determined_release="${GLUON_TAG}+${LOCAL_SUFFIX}${local_version}" auto_determined_release="${GLUON_TAG}+${LOCAL_SUFFIX}${local_version}"
read -p "Release name for this build [default: ${auto_determined_release}]: " GLUON_RELEASE read -p "Release name for this build [default: ${auto_determined_release}]: " GLUON_RELEASE
GLUON_RELEASE="${GLUON_RELEASE:-$auto_determined_release}" GLUON_RELEASE="${GLUON_RELEASE:-$auto_determined_release}"
cat > "$statefile" <<EOF
GLUON_TAG="${GLUON_TAG}"
GLUON_BRANCH="${GLUON_BRANCH}"
GLUON_RELEASE="${GLUON_RELEASE}"
EOF
fi
if [ "$GLUON_BRANCH" = "stable" ]; then
export GLUON_PRIORITY=7
fi
# calculate number of threads # calculate number of threads
if [ -z "$debug" ]; then if [ -z "$debug" ]; then
@ -121,32 +64,9 @@ fi
cd "$GLUON_DIR" cd "$GLUON_DIR"
export GLUON_BRANCH GLUON_RELEASE export GLUON_BRANCH GLUON_RELEASE
if ! $cont; then
make update ${debug:+V=s} make update ${debug:+V=s}
fi
for target in ar71xx-generic; do for target in ar71xx-generic; do
env_target="$(echo "$target" | tr '-' '_')" #make clean GLUON_TARGET="$target" ${debug:+V=s}
set +u
if eval "[ \"\$TARGET_${env_target}_DONE\" = 1 ]"; then
continue
fi
set -u
echo "Building target ${target}"
if $cont; then
cont=false
else
make clean GLUON_TARGET="$target" ${debug:+V=s}
fi
make -j${proc_num} GLUON_TARGET="$target" ${debug:+V=s} make -j${proc_num} GLUON_TARGET="$target" ${debug:+V=s}
echo "TARGET_${env_target}_DONE=1" >> "$statefile"
done done
make manifest
make manifest GLUON_BRANCH=testing GLUON_PRIORITY=0
cd ..
if [ -n "$KEYFILE" -a -r "$KEYFILE" ]; then
"${GLUON_DIR}/contrib/sign.sh" "$KEYFILE" "${GLUON_DIR}/output/images/sysupgrade/${GLUON_BRANCH}.manifest"
fi
rm "$statefile"