cd_build/build-yunohost

82 lines
2.3 KiB
Bash
Executable file

#!/bin/bash
# Usage ./build-yunohost [ARCH [DIST [DEB_DIST]]]
# ARCH amd64|i386
# DIST stable|testing
# DEB_DIST stretch
readonly DEFAULT_DEB_DIST="stretch"
readonly REPO_URL="http://forge.yunohost.org/debian/"
readonly ARCH_CHOICE=$1
readonly DIST="${2:-stable}"
readonly DEB_DIST="${3:-$DEFAULT_DEB_DIST}"
source ./common.sh
# Build Yunohost iso for amd64 or i386 arch
# Usage: build ARCH
function build
{
local ARCH="$1"
info "Starting build for arch $ARCH ..."
if [ "$DIST" = "testing" ] ; then
sed -i "s#$REPO_URL stretch stable#$REPO_URL $DEB_DIST stable testing#" profiles/*.preseed
else
sed -i "s#$REPO_URL stretch stable testing#$REPO_URL $DEB_DIST stable#" profiles/*.preseed
fi
rm -rf $(pwd)/tmp
rm -rf $(pwd)/images/debian*
# Build a simple/regular debian CD image ?
sudo -u yunohost build-simple-cdd --dist $DEB_DIST --conf ./simple-cdd-$ARCH.conf
# Find the release version of debian
local DEBNUM="$(grep "Version:" tmp/${DEB_DIST}_Release | awk '{print $2;}')"
# Find the release version of YunoHost
info "Finding out current YunoHost's stable vesion number"
wget -q ${REPO_URL}dists/${DEB_DIST}/${DIST}/binary-i386/Packages.gz
gunzip Packages.gz
YNH_VERSION=$(grep "^Package: yunohost$" --after-context=1 Packages | grep "Version" | awk '{print $2;}')
rm -f Packages
local CD_STUFF="images/debian-$DEBNUM-$ARCH-CD"
# build-simple-cdd is stupid and doesn't name its output correctly -.- ...
mv images/debian-*-$ARCH-CD-1.iso $CD_STUFF.iso
mv images/debian-*-$ARCH-CD-1.list.gz $CD_STUFF.list.gz
local OUTPUT="images/yunohost-$DEB_DIST-$YNH_VERSION-$ARCH-$DIST.iso"
[ -e "$CD_STUFF.iso" ] \
|| critical "Expected to find $CD_STUFF.iso but it's not here ?"
rm -f $OUTPUT
$(pwd)/add-firmware-to $CD_STUFF.iso $OUTPUT $DEB_DIST
rm -f $CD_STUFF.iso
rm -f $CD_STUFF.list.gz
[ -e $OUTPUT ] \
&& success "The image should now be available in $OUTPUT" \
|| critical "Something wrong happened when build the image :|"
}
function main
{
if [ -z "$ARCH_CHOICE" ]
then
info "No arch chosen, will build both i396 and amd64"
build i386
build amd64
else
build $ARCH_CHOICE
fi
}
main