#!/bin/bash # Usage ./build-yunohost [ARCH [DIST [DEB_DIST]]] # ARCH amd64|i386 # DIST stable|testing # DEB_DIST jessie|stretch readonly DEFAULT_DEB_DIST="jessie" readonly REPO_URL="http://repo.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 jessie stable#$REPO_URL $DEB_DIST stable testing#" profiles/*.preseed sed -i "s#$REPO_URL stretch stable#$REPO_URL $DEB_DIST stable testing#" profiles/*.preseed else sed -i "s#$REPO_URL jessie stable testing#$REPO_URL $DEB_DIST stable#" profiles/*.preseed sed -i "s#$REPO_URL stretch stable testing#$REPO_URL $DEB_DIST stable#" profiles/*.preseed fi # Build a simple/regular debian CD image ? 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 :|" } # Sign the new iso # Usage: sign ARCH function sign { local ARCH="$1" local NAME="images/yunohost-$DEB_DIST-$YNH_VERSION-$ARCH-$DIST.iso" info "Signing image $NAME ..." gpg --output $NAME.sig --detach-sig $NAME sha256sum $NAME > $NAME.sum } function build_and_sign { local ARCH="$1" rm -rf $(pwd)/tmp rm -rf $(pwd)/images/debian* build $ARCH sign $ARCH } function main { if [ -z "$ARCH_CHOICE" ] then info "No arch chosen, will build both i396 and amd64" build_and_sign i386 build_and_sign amd64 else build_and_sign $ARCH_CHOICE fi } main