From 5257106fd6bd71993f38ffc736393a5d247747ec Mon Sep 17 00:00:00 2001 From: Alexandre Aubin Date: Thu, 8 Mar 2018 20:51:10 +0100 Subject: [PATCH 1/4] Cosmetics / try to avoid a few unecessary error message (rm without -f) (#5) --- add-firmware-to | 4 ++-- build-yunohost | 53 ++++++++++++++++++++++++++++++++----------------- common.sh | 43 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 80 insertions(+), 20 deletions(-) create mode 100644 common.sh diff --git a/add-firmware-to b/add-firmware-to index eca6303..051c371 100755 --- a/add-firmware-to +++ b/add-firmware-to @@ -123,7 +123,7 @@ if is_iso "$file"; then then cp -f $BUILD_DIR/isolinux/{adgtk.cfg,adtxt.cfg,gtk.cfg,menu.cfg,stdmenu.cfg,txt.cfg} $buildtree/isolinux/ else - rm $buildtree/isolinux/{adgtk.cfg,adtxt.cfg,gtk.cfg,menu.cfg,stdmenu.cfg,txt.cfg} + rm -f $buildtree/isolinux/{adgtk.cfg,adtxt.cfg,gtk.cfg,menu.cfg,stdmenu.cfg,txt.cfg} cp -f $BUILD_DIR/isolinux/{amdadgtk.cfg,amdadtxt.cfg,amdgtk.cfg,menu.cfg,stdmenu.cfg,amdtxt.cfg} $buildtree/isolinux/ fi @@ -144,4 +144,4 @@ fi echo "Output in $outfile" -rm "$fwfile" +rm -f "$fwfile" diff --git a/build-yunohost b/build-yunohost index ae2c725..0b03d0e 100755 --- a/build-yunohost +++ b/build-yunohost @@ -4,14 +4,23 @@ # DIST stable|testing # DEB_DIST jessie|stretch -DEFAULT_DEB_DIST="jessie" +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" - REPO_URL="http://repo.yunohost.org/debian/" + + 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 @@ -22,18 +31,20 @@ function build build-simple-cdd --dist $DEB_DIST --conf ./simple-cdd-$ARCH.conf # Find the release version of debian - DEBNUM="$(grep "Version:" tmp/${DEB_DIST}_Release | awk '{print $2;}')" + local DEBNUM="$(grep "Version:" tmp/${DEB_DIST}_Release | awk '{print $2;}')" # Find the release version of YunoHost wget ${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 Packages + rm -f Packages rm -f images/yunohost-$DEB_DIST-$YNH_VERSION-$ARCH-$DIST.iso $(pwd)/add-firmware-to images/debian-$DEBNUM-$ARCH-CD-1.iso images/yunohost-$DEB_DIST-$YNH_VERSION-$ARCH-$DIST.iso $DEB_DIST - rm images/debian-$DEBNUM-$ARCH-CD-1.iso - rm images/debian-$DEBNUM-$ARCH-CD-1.list.gz + rm -f images/debian-$DEBNUM-$ARCH-CD-1.iso + rm -f images/debian-$DEBNUM-$ARCH-CD-1.list.gz + success "The image should now be available in images/yunohost-$DEB_DIST-$YNH_VERSION-$ARCH-$DIST.iso" + } # Sign the new iso @@ -41,27 +52,33 @@ function build function sign { local ARCH="$1" - NAME="images/yunohost-$DEB_DIST-$YNH_VERSION-$ARCH-$DIST.iso" + 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 { - rm -r $(pwd)/tmp - local ARCH="$1" + + rm -r $(pwd)/tmp build $ARCH sign $ARCH } -DIST="${2:-stable}" -DEB_DIST="${3:-$DEFAULT_DEB_DIST}" +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 +} -if [ -z "$1" ] -then - build_and_sign i386 - build_and_sign amd64 -else - build_and_sign $1 -fi +main diff --git a/common.sh b/common.sh new file mode 100644 index 0000000..39895dd --- /dev/null +++ b/common.sh @@ -0,0 +1,43 @@ +readonly NORMAL=$(printf '\033[0m') +readonly BOLD=$(printf '\033[1m') +readonly faint=$(printf '\033[2m') +readonly UNDERLINE=$(printf '\033[4m') +readonly NEGATIVE=$(printf '\033[7m') +readonly RED=$(printf '\033[31m') +readonly GREEN=$(printf '\033[32m') +readonly ORANGE=$(printf '\033[33m') +readonly BLUE=$(printf '\033[34m') +readonly YELLOW=$(printf '\033[93m') +readonly WHITE=$(printf '\033[39m') + +function success() +{ + local msg=${1} + echo " " + echo "[${BOLD}${GREEN} OK ${NORMAL}] ${msg}" + echo " " +} + +function info() +{ + local msg=${1} + echo " " + echo "[${BOLD}${BLUE}INFO${NORMAL}] ${msg}" + echo " " +} + +function warn() +{ + local msg=${1} + echo " " + echo "[${BOLD}${ORANGE}WARN${NORMAL}] ${msg}" + echo " " +} + +function error() +{ + local msg=${1} + echo " " + echo "[${BOLD}${RED}FAIL${NORMAL}] ${msg}" + echo " " +} From c3f7db27d74c0828faedaacb088fec594bb87a08 Mon Sep 17 00:00:00 2001 From: Alexandre Aubin Date: Thu, 8 Mar 2018 20:51:24 +0100 Subject: [PATCH 2/4] Use isohybrid to add MBR/EFI stuff such that the iso is bootable with dd/Etcher (#6) --- add-firmware-to | 3 +++ 1 file changed, 3 insertions(+) diff --git a/add-firmware-to b/add-firmware-to index 051c371..2ba33be 100755 --- a/add-firmware-to +++ b/add-firmware-to @@ -142,6 +142,9 @@ if is_initrd "$file"; then initrd_append_fw "$file" "$fwfile" "$outfile" fi +# Add MBR/EFI stuff to make iso bootable with dd / Etcher ... +isohybrid $outfile + echo "Output in $outfile" rm -f "$fwfile" From 3b1e42727225c3c1846e5c89025fcfec01157f61 Mon Sep 17 00:00:00 2001 From: Alexandre Aubin Date: Thu, 8 Mar 2018 20:54:13 +0100 Subject: [PATCH 3/4] Building on stretch (#7) * Cosmetics / try to avoid a few unecessary error message (rm without -f) * Use isohybrid to add MBR/EFI stuff such that the iso is bootable with dd/Etcher * Missing dependency cpio when running on stretch * On stretch, build-simple-cdd output is not ISO 9660 * Cosmetics / adjusment / fixes when running on stretch... --- README.md | 2 +- add-firmware-to | 2 +- build-yunohost | 36 ++++++++++++++++++++++++++++-------- common.sh | 21 +++++++++++++++------ 4 files changed, 45 insertions(+), 16 deletions(-) diff --git a/README.md b/README.md index 834bb66..d2b74d9 100644 --- a/README.md +++ b/README.md @@ -13,7 +13,7 @@ Installation ``` git clone git://github.com/YunoHost/cd_build.git cd cd_build -sudo apt-get install -f simple-cdd genisoimage qemu-kvm xorriso syslinux-utils +sudo apt-get install -f simple-cdd genisoimage qemu-kvm xorriso syslinux-utils cpio ``` Build an image diff --git a/add-firmware-to b/add-firmware-to index 2ba33be..a528a83 100755 --- a/add-firmware-to +++ b/add-firmware-to @@ -29,7 +29,7 @@ set -x is_iso() { - file "$1" | grep -q "ISO 9660" + file "$1" | grep -q "ISO 9660\|DOS/MBR boot sector" } is_initrd() { diff --git a/build-yunohost b/build-yunohost index 0b03d0e..703bc0a 100755 --- a/build-yunohost +++ b/build-yunohost @@ -28,23 +28,41 @@ function build 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 - wget ${REPO_URL}dists/${DEB_DIST}/${DIST}/binary-i386/Packages.gz + 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 - rm -f images/yunohost-$DEB_DIST-$YNH_VERSION-$ARCH-$DIST.iso - $(pwd)/add-firmware-to images/debian-$DEBNUM-$ARCH-CD-1.iso images/yunohost-$DEB_DIST-$YNH_VERSION-$ARCH-$DIST.iso $DEB_DIST - rm -f images/debian-$DEBNUM-$ARCH-CD-1.iso - rm -f images/debian-$DEBNUM-$ARCH-CD-1.list.gz - success "The image should now be available in images/yunohost-$DEB_DIST-$YNH_VERSION-$ARCH-$DIST.iso" + 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 @@ -57,14 +75,16 @@ function sign info "Signing image $NAME ..." gpg --output $NAME.sig --detach-sig $NAME + sha256sum $NAME > $NAME.sum } function build_and_sign { local ARCH="$1" - - rm -r $(pwd)/tmp + + rm -rf $(pwd)/tmp + rm -rf $(pwd)/images/debian* build $ARCH sign $ARCH } diff --git a/common.sh b/common.sh index 39895dd..0e40d87 100644 --- a/common.sh +++ b/common.sh @@ -29,15 +29,24 @@ function info() function warn() { local msg=${1} - echo " " - echo "[${BOLD}${ORANGE}WARN${NORMAL}] ${msg}" - echo " " + echo " " 2>&1 + echo "[${BOLD}${ORANGE}WARN${NORMAL}] ${msg}" 2>&1 + echo " " 2>&1 } function error() { local msg=${1} - echo " " - echo "[${BOLD}${RED}FAIL${NORMAL}] ${msg}" - echo " " + echo " " 2>&1 + echo "[${BOLD}${RED}FAIL${NORMAL}] ${msg}" 2>&1 + echo " " 2>&1 +} + +function critical() +{ + local msg=${1} + echo " " 2>&1 + echo "[${BOLD}${RED}CRIT${NORMAL}] ${msg}" 2>&1 + echo " " 2>&1 + exit 1 } From d30337d7b7978f4bb187057e9f233a004d995108 Mon Sep 17 00:00:00 2001 From: Maniack Crudelis Date: Thu, 8 Mar 2018 20:57:03 +0100 Subject: [PATCH 4/4] Remove previous sig (#8) * Cosmetics / try to avoid a few unecessary error message (rm without -f) * Use isohybrid to add MBR/EFI stuff such that the iso is bootable with dd/Etcher * Missing dependency cpio when running on stretch * On stretch, build-simple-cdd output is not ISO 9660 * Cosmetics / adjusment / fixes when running on stretch... * Remove previous sig Built over https://github.com/YunoHost/cd_build/pull/7 --- build-yunohost | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/build-yunohost b/build-yunohost index 703bc0a..f6d2e92 100755 --- a/build-yunohost +++ b/build-yunohost @@ -71,9 +71,12 @@ function sign { local ARCH="$1" local NAME="images/yunohost-$DEB_DIST-$YNH_VERSION-$ARCH-$DIST.iso" - + info "Signing image $NAME ..." - + + # Remove previous signature to prevent gpg to ask about overwriting + rm -f $NAME.sig + gpg --output $NAME.sig --detach-sig $NAME sha256sum $NAME > $NAME.sum