Verified Commit 538374eb authored by Matt Devillier's avatar Matt Devillier
Browse files

build_release.sh: add script to build a release



Change-Id: I5e35580a5960705fe14fc27d9f5cf0f6f660f99d
Signed-off-by: Matt Devillier's avatarMatt DeVillier <matt.devillier@puri.sm>
parent 743c33bf
#!/usr/bin/bash
set -e
# use TERM to exit on error
trap "exit 1" TERM
export TOP_PID=$$
die () {
local msg=$1
if [ ! -z "$msg" ]; then
echo ""
echo -e "$msg"
echo ""
fi
kill -s TERM $TOP_PID
exit 1
}
# boards to build
boards=("librem_13v1" "librem_15v2" "librem_13v2" "librem_15v3" "librem_13v4" \
"librem_15v4" "librem_mini" "librem_mini_v2")
# check release tags
TAG=$(git describe --tags --dirty)
if [[ "$TAG" == *"dirty"* ]]; then
echo "Error: branch must be clean to perform a release build"
exit 1
fi
echo "Creating new branches..."
# create branch in releases repo
(
cd ../releases
if ! git checkout -b $TAG >/dev/null ; then
die "Error creating release branch $TAG -- already exists?"
fi
git fetch >/dev/null 2>&1
git reset --hard origin/master >/dev/null 2>&1
)
# create branch in utility repo
(
cd ../utility
if ! git checkout -b $TAG > /dev/null; then
die "Error creating utility branch $TAG -- already exists?"
fi
git fetch >/dev/null 2>&1
git reset --hard origin/master >/dev/null 2>&1
# update version strings
sed -i "s/^COREBOOT_SEABIOS_VERSION.*$/COREBOOT_SEABIOS_VERSION=\"${TAG}\"/" coreboot_util.sh
sed -i "s/^COREBOOT_REPO_TAG.*$/COREBOOT_REPO_TAG=\"${TAG}\"/" coreboot_util.sh
)
for board in ${boards[@]}
do
filename="coreboot-${board}-${TAG}.rom"
rm ${filename} 2>/dev/null | true
# build board
./build.sh ${board}
# get SHA for BIOS region
util/ifdtool/ifdtool -x build/coreboot.rom >/dev/null
BIOS_SHA=$(sha256sum flashregion_1_bios.bin | awk '{print $1}')
rm -f flashregion* 2>/dev/null
# compress
gzip -k $filename
# get hash
ZIP_SHA=$(sha256sum $filename.gz | awk '{print $1}')
# update in releases repo
mkdir -p ../releases/${board}/ 2>/dev/null | true
rm ../releases/${board}/coreboot-${board}* 2>/dev/null | true
mv $filename.gz ../releases/${board}/
# update board hashes in coreboot_util.sh
brd=`echo $board | cut -f2-3 -d'_'`
sed -i "s/^COREBOOT_SEABIOS_IMAGE_${brd}_SHA.*$/COREBOOT_SEABIOS_IMAGE_${brd}_SHA=\"${ZIP_SHA}\"/" ../utility/coreboot_util.sh
sed -i "s/^COREBOOT_BIOS_SHA_${brd^^}=.*$/COREBOOT_BIOS_SHA_${brd^^}=\"${BIOS_SHA}\"/" ../utility/coreboot_util.sh
done
# commit new boards in releases
(
cd ../releases
if ! git checkout $TAG >/dev/null 2>&1; then
die "Error checking out release branch $TAG"
fi
# prompt to update changelog
echo -e "\nPlease update the releases changelog, then press enter to continue"
read -rp "" discard
# add files, do commit
git add librem_*/coreboot-* >/dev/null 2>&1
git commit -s -S -a -m "Update coreboot/SeaBIOS images to $TAG"
# get releases hash
REL_SHA=$(git rev-parse --verify HEAD)
# inject into coreboot_util
sed -i "s/^RELEASES_GIT_HASH.*$/RELEASES_GIT_HASH=\"${REL_SHA}\"/" ../utility/coreboot_util.sh
)
# commit updates to coreboot_util
(
cd ../utility
if ! git checkout $TAG >/dev/null 2>&1 ; then
die "Error checking out utility branch $TAG"
fi
### add files, do commit
git add coreboot_util.sh >/dev/null 2>&1
git commit -s -S -m "Update coreboot/SeaBIOS images to $TAG" -m "Update releases repo hash, filenames/hashes."
)
echo -e "\nRelease builds successfully built and branches added\n"
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment