File kiwi_post_run of Package live-kiwi-hook
#!/bin/sh
# This script saves two purposes:
# When a new snapshot gets released, a setrelease request is sent to OBS.
# It does $nbin =~ s/-([^-]+)(-Media(?:\d?)(?:\..*?)?)$/$setrelease$2/;
# which basically replaces -Media* with the Snapshot number.
# The isos written by KIWI (and subsequently renamed by the OBS KIWI
# build recipe) do not follow that name scheme, so we need to rename
# it manually to the expected names.
# Additionally, kiwi in a newer version uses "ix86" instead of the full
# arch, which is not handled/expected by various scripts. So undo that.
# The Rescue CD is intented to be written to CDs, so it must not exceed
# the 680 MiB size limit. For GNOME and KDE Lives there's an arbitrary
# 1 GiB limit for USB drives. If the maximum size is exceeded, this script
# exits with 1 and thus aborts the build.
set -eu
TOPDIR=${TOPDIR:-/usr/src/packages}
cd "${TOPDIR}/KIWI"
if ! [ -f *.iso ]; then
echo "No .iso image in here - nothing do to."
exit 0
fi
# openSUSE-Tumbleweed-GNOME-Live.ix86-2.8.0-noEFI-Build22.1
oldiso="$(echo *.iso | sed 's/\.iso//')"
flavor="$(echo "${oldiso}" | awk -F- '/-Rescue-CD/ { print "Rescue" } /-GNOME-Live/ { print "GNOME" } /-KDE-Live/ { print "KDE" } /-XFCE-Live/ { print "XFCE" }')"
# openSUSE-Tumbleweed-GNOME-Live.i686-2.8.0-noEFI-Build22.1
newiso="$(echo "${oldiso}" | sed -E 's/ix86/i686/')"
# openSUSE-Tumbleweed-GNOME-Live-i686-Build22.1-Media
newiso="$(echo "${newiso}" | sed -E 's/([^.]*)\.([^0-9][^-]+).*(Build.*)/\1-\2-\3-Media/')"
# Use rename to also rename the checksum files
rename -v "${oldiso}" "${newiso}" ./*
# Adjust references in .sha256 files
sed -i"" "s/${oldiso}/${newiso}/g" ./*.sha256
isosize="$(stat -c %s "${newiso}.iso")"
arch="$(uname -m)"
case "${flavor}" in
GNOME|KDE|XFCE)
msize=1500000000
;;
Rescue)
msize=1000000000
;;
*)
echo "Unknown flavor ${flavor}" >&2
exit 1
;;
esac
if [ "${isosize}" -gt "${msize}" ]; then
ls -lRaS ${TOPDIR}/SOURCES/repos/*:* >&2
echo "TOO LARGE - Current size ${isosize} (max ${msize})" >&2
exit 1
fi
# All good!
exit 0