20-makedist-autobuild: some hardcoded entries parametrized from /etc/sysconfig/makedist

This commit is contained in:
Silvan Calarco 2022-07-09 21:05:11 +02:00
parent 8397319980
commit 235ba99548
2 changed files with 67 additions and 59 deletions

View File

@ -1,24 +1,23 @@
#!/bin/bash
#
# Makedist automatic build script
# Copyright (c) 2007-2015 by Silvan Calarco <silvan.calarco@mambasoft.it>
# Makedist automatic media build script
# Copyright (c) 2007-2022 by Silvan Calarco <silvan.calarco@mambasoft.it>
#
# Usage:
#
# To overwrite already existing images
# FORCE_OVERWRITE=1 ./20-openmamba-makedist
# FORCE_OVERWRITE=1 ./20-makedist-autobuild
#
# To commit a new release (relies on snapshot images):
# RELEASE=1.0pre3 ./20-openmamba-makedist
# RELEASE=1.0pre3 ./20-makedist-autobuild
#
. /etc/sysconfig/makedist
. /usr/share/makedist/functions.inc.sh
# DO_RECORDVM=1
DESTIMGFILEPREFIX="openmamba"
ALLMEDIASLAST=`expr ${#MEDIA_NAME[*]} - 1`
[ "$MAKEDIST_CRON_ENABLE" = "1" ] || exit 0
[ "$MAKEDIST_CRON_ENABLE" = "1" -o "$FORCE" ] || exit 0
ME=`basename $0`
[ "$$" == "`pidof -x $ME`" ] || {
@ -28,10 +27,6 @@ ME=`basename $0`
[ "`uname -m`" = "x86_64" ] && HOST_IS_X86_64=1
TORRENTURL=http://torrent.mambasoft.it:8080/announce
DISTRONAME=openmamba
MAKEDIST_TARGET=openmamba
arch=i586
SOURCEDIR=/var/makedist
[ "$MAKEDIST_FORCE" ] || MAKEDIST_FORCE=1
@ -58,7 +53,7 @@ SOURCEDIR=/var/makedist
# $7: architecture
function do_makedist() {
local DIST_CREATED=0 SOURCEIMG DESTFILENAME DESTNAME DESTLANGUAGE DESTPLATFORM DESTSUBPLATFORM DESTARCH \
DESTVARIANT DESTPRODUCTNAME DESTDIR DESTIMG DESTMD5 DESTTORRENT DESTMILESTONE
DESTVARIANT DESTPRODUCTNAME DESTDIR DESTIMG DESTMD5 DESTTORRENT DESTMILESTONE DESTTARGET
DESTFILENAME=$1
DESTNAME=$2
DESTLANGUAGE=$3
@ -68,6 +63,7 @@ function do_makedist() {
DESTPRODUCTNAME=$7
DESTARCH=$8
DESTMILESTONE=$9
DESTTARGET=${10}
SOURCEIMG=$SOURCEDIR/${DESTFILENAME}
DESTDIR=$DESTBASEDIR/${DESTPRODUCTNAME}/${DESTLANGUAGE}
DESTIMG=$DESTDIR/$DESTNAME
@ -92,17 +88,17 @@ function do_makedist() {
else
CMD_PREFIX=
fi
if [ "${DESTMILESTONE}" = "devel" ]; then
MAKEDIST_TARGET=openmamba
if [ "${DESTMILESTONE}" = "devel" -o "${DESTMILESTONE}" = "main" ]; then
MAKEDIST_TARGET=${DESTTARGET}
else
MAKEDIST_TARGET=openmamba-${DESTMILESTONE}
MAKEDIST_TARGET=${DESTTARGET}-${DESTMILESTONE}
fi
[ "$CRON_DEBUG" = "1" ] && \
echo "-> makedist $MAKEDIST_TARGET PLATFORM=${DESTPLATFORM} SUBPLATFORM=${DESTSUBPLATFORM} \
VARIANT=${DESTVARIANT} LANGUAGE=${DESTLANGUAGE} ARCH=${DESTARCH} FORCE=${MAKEDIST_FORCE}"
makedist $MAKEDIST_TARGET PLATFORM=${DESTPLATFORM} SUBPLATFORM=${DESTSUBPLATFORM} \
VARIANT=${DESTVARIANT} LANGUAGE=${DESTLANGUAGE} ARCH=${DESTARCH} FORCE=${MAKEDIST_FORCE} || {
echo "Error building openmamba ${DESTPRODUCTNAME} medium; skipping."
echo "Error building ${DESTPRODUCTNAME} medium; skipping."
return 255
}
DIST_CREATED=1
@ -110,7 +106,7 @@ VARIANT=${DESTVARIANT} LANGUAGE=${DESTLANGUAGE} ARCH=${DESTARCH} FORCE=${MAKEDIS
if [ "$RELEASE" ]; then
[ -e $DESTDIR ] || mkdir -p $DESTDIR
cp $SOURCEIMG $DESTIMG
cp $SOURCEDIR/.${DESTFILENAME}.inc.html $DESTDIR/buildinfo-$RELEASE.inc.html
cp ${SOURCEDIR}/.${DESTFILENAME}.inc.html $DESTDIR/buildinfo-$RELEASE.inc.html
[ "$RELEASE/pre" != "$RELEASE" ] && ln -sf buildinfo-$RELEASE.inc.html $DESTDIR/buildinfo-pre.inc.html
cd $DESTDIR
md5sum $DESTNAME > $DESTMD5
@ -123,7 +119,7 @@ VARIANT=${DESTVARIANT} LANGUAGE=${DESTLANGUAGE} ARCH=${DESTARCH} FORCE=${MAKEDIS
else
[ -e $DESTDIR ] || mkdir -p $DESTDIR
cp $SOURCEIMG $DESTIMG
cp $SOURCEDIR/.${DESTFILENAME}.inc.html $DESTDIR/buildinfo.inc.html
cp ${SOURCEDIR}/.${DESTFILENAME}.inc.html $DESTDIR/buildinfo.inc.html
cd $DESTDIR
md5sum $DESTNAME > $DESTMD5
rm -f $DESTDIR/latest-is-*.txt
@ -134,27 +130,29 @@ VARIANT=${DESTVARIANT} LANGUAGE=${DESTLANGUAGE} ARCH=${DESTARCH} FORCE=${MAKEDIS
fi
fi
fi
if [ "${TORRENTURL}" ]; then
if [ "$DIST_CREATED" = "1" -o $DESTIMG -nt $DESTTORRENT -o \
"$FORCE_OVERWRITE" = "1" -o "$FORCE_OVERWRITE_TORRENT" = "1" ]; then
# Generate TORRENT
if [ "$RELEASE" ]; then
cd $DESTDIR
maketorrent-console \
--comment "openmamba $RELEASE ${DESTPRODUCTNAME} ${DESTLANGUAGE}-${DESTARCH} from http://openmamba.org" \
--tracker_name "mambaSoft BitTorrent tracker" \
--comment "${DESTTARGET} $RELEASE ${DESTPRODUCTNAME} ${DESTLANGUAGE}-${DESTARCH} from ${PROJECT_URL}" \
--tracker_name "${DESTTARGET} BitTorrent tracker" \
--language ${DESTLANGUAGE} \
$TORRENTURL \
$DESTNAME --target $DESTTORRENT >/dev/null
else
cd $DESTDIR
maketorrent-console \
--comment "openmamba snapshot $SNAPDATE ${DESTPRODUCTNAME} ${DESTLANGUAGE}-${DESTARCH} from http://openmamba.org" \
--tracker_name "mambaSoft BitTorrent tracker" \
--comment "${DESTTARGET} snapshot $SNAPDATE ${DESTPRODUCTNAME} ${DESTLANGUAGE}-${DESTARCH} from ${PROJECT_URL}" \
--tracker_name "${DESTTARGET} BitTorrent tracker" \
--language ${DESTLANGUAGE} \
$TORRENTURL \
$DESTNAME --target $DESTTORRENT >/dev/null
fi
fi
fi
return $DIST_CREATED
}
@ -174,9 +172,9 @@ function do_makedist_and_html() {
local DIST_LINE DIST_CREATED DIST_DWD HTMLLANG MEDIA_ARCH PRODNAME \
MEDIUMFILENAME MEDIUMNAME MEDIUMPLATFORM MEDIUMSUBPLATFORM MEDIUMVARIANT \
m l MEDIUMMILESTONE
m l MEDIUMMILESTONE MEDIUMTARGET
local tempfile2=`tempfile 2>/dev/null` || tempfile2=/tmp/makedist_tmpfile2
local tempfile2=`mktemp 2>/dev/null` || tempfile2=/tmp/makedist_tmpfile2
MEDIUMSUFFIX=$1
MEDIUMTAG=$2
@ -187,16 +185,18 @@ function do_makedist_and_html() {
PRODNAME=$7
m=$8
MEDIUMMILESTONE=${MEDIA_MILESTONE[$m]}
MEDIUMTARGET=${MEDIA_TARGET[$m]}
[ "${MEDIUMMILESTONE}" ] || {
echo "Error: do_makedist_and_html: invalid number of parameters; aborting."
exit 1
}
if [ "${MEDIUMMILESTONE}" != "devel" ]; then
SOURCEIMGFILEPREFIX="openmamba-${MEDIUMMILESTONE}"
DESTIMGFILEPREFIX="openmamba-${MEDIUMMILESTONE}"
if [ "${MEDIUMMILESTONE}" != "devel" -a "${MEDIUMMILESTONE}" != "main" ]; then
SOURCEIMGFILEPREFIX="${MEDIUMTARGET}-${MEDIUMMILESTONE}"
DESTIMGFILEPREFIX="${MEDIUMTARGET}-${MEDIUMMILESTONE}"
else
SOURCEIMGFILEPREFIX="openmamba"
DESTIMGFILEPREFIX="openmamba"
SOURCEIMGFILEPREFIX="${MEDIUMTARGET}"
DESTIMGFILEPREFIX="${MEDIUMTARGET}"
fi
cat > $tempfile2 << _EOF
@ -209,16 +209,17 @@ _EOF
*) echo -n "Language: " >> $tempfile2; selecttext="Download..."; fortext="for" ;;
esac
for l in ${MEDIA_LANGUAGES[$m]}; do
[ "$l" = "${HTMLLANG}" ] && {
checked=""
if [ "${l}" = "${HTMLLANG}" ]; then
checked="checked"
} || checked=""
fi
case $l in
it) langname="italiano" ;;
es) langname="espa&ntilde;ol" ;;
en) langname="english" ;;
*) langname="unknown" ;;
esac
echo "<input type=radio id=\"language\" name=\"language\" value=\"$l\" onclick=\"javascript:selectlang('$PRODNAME-${RELEASETAG}');\" $checked />$langname" >> $tempfile2
echo "<input type=radio id=\"language\" name=\"language\" value=\"${l}\" onclick=\"javascript:selectlang('$PRODNAME-${RELEASETAG}');\" $checked />$langname" >> $tempfile2
done
case ${HTMLLANG} in
@ -242,7 +243,7 @@ _EOF
for l in ${MEDIA_LANGUAGES[$m]}; do
if [ "$RELEASE" ]; then
latest=`ls $DESTBASEDIR/$PRODNAME/$l/latest-is-${MEDIA_MILESTONE[i]}-*.txt 2>/dev/null| sed "s/.*latest-is-${MEDIA_MILESTONE[i]}-\(.*\)\.txt/\1/"`
latest=`ls $DESTBASEDIR/$PRODNAME/$l/latest-is-${MEDIA_MILESTONE[$m]}-*.txt 2>/dev/null| sed "s/.*latest-is-${MEDIA_MILESTONE[$m]}-\(.*\)\.txt/\1/"`
DESTLATESTFILENAME=latest-$latest.inc.js
else
DESTLATESTFILENAME=latest.inc.js
@ -265,8 +266,8 @@ _EOF
if [ "$DIST_CREATED" != "255" ]; then
# in case of previous build error (255) skipping building target for other langs and archs
[ "$CRON_DEBUG" = "1" ] && \
echo "do_makedist_and_html: calling do_makedist \"$SOURCEIMGFILEPREFIX-$PRODNAME-$l.${a}.${MEDIUMSUFFIX}\" \"$DESTNAME\" \"${l}\" \"${MEDIUMPLATFORM}\" \"${MEDIUMSUBPLATFORM}\" \"$PRODNAME\" \"${a}\"" ${MEDIUMMILESTONE}
do_makedist "$SOURCEIMGFILEPREFIX-$PRODNAME-$l.${a}.${MEDIUMSUFFIX}" "$DESTNAME" "${l}" "${MEDIUMPLATFORM}" "${MEDIUMSUBPLATFORM}" "${MEDIUMVARIANT}" "$PRODNAME" "${a}" ${MEDIUMMILESTONE}
echo "do_makedist_and_html: calling do_makedist \"$SOURCEIMGFILEPREFIX-$PRODNAME-$l.${a}.${MEDIUMSUFFIX}\" \"$DESTNAME\" \"${l}\" \"${MEDIUMPLATFORM}\" \"${MEDIUMSUBPLATFORM}\" \"$PRODNAME\" \"${a}\"" \"${MEDIUMMILESTONE}\" \"${MEDIUMTARGET}\"
do_makedist "$SOURCEIMGFILEPREFIX-$PRODNAME-$l.${a}.${MEDIUMSUFFIX}" "$DESTNAME" "${l}" "${MEDIUMPLATFORM}" "${MEDIUMSUBPLATFORM}" "${MEDIUMVARIANT}" "$PRODNAME" "${a}" "${MEDIUMMILESTONE}" "${MEDIUMTARGET}"
DIST_CREATED=$?
[ "$DIST_CREATED" = "255" ] && return 255
@ -329,7 +330,7 @@ _EOF
chmod +r $DESTHTML
if [ "$DIST_CREATED" = "1" ]; then
# snapshots
if [ "$MEDIUMMILESTONE" != "devel" ]; then
if [ "$MEDIUMMILESTONE" != "devel" -a "$MEDIUMMILESTONE" != "main" ]; then
#temporary
makedist-announcement --rebuild-announcement --send-test-email -y ${MEDIUMMILESTONE} $PRODNAME
else
@ -354,14 +355,14 @@ for i in `seq 0 $ALLMEDIASLAST`; do
PLATFORM=${MEDIA_PLATFORM[i]}
SUBPLATFORM=${MEDIA_SUBPLATFORM[i]}
VARIANT=${MEDIA_VARIANT[i]}
DESTBASEDIR=/var/ftp/pub/openmamba/${MEDIA_MILESTONE[i]}/media
DESTBASEURL=/pub/openmamba/${MEDIA_MILESTONE[i]}/media
DESTBASEDIR=${REPODIR_LOCAL}/${MEDIA_MILESTONE[i]}/media
DESTBASEURL=${REPODIR_URL}/${MEDIA_MILESTONE[i]}/media
unset PRODUCT_NAME
unset PRODUCT_NAME_OVERRIDE
[ $SUBPLATFORM ] && . /var/makedist/targets/$MAKEDIST_TARGET/platforms/$SUBPLATFORM/settings.inc
. /var/makedist/targets/$MAKEDIST_TARGET/platforms/$PLATFORM/settings.inc
[ $SUBPLATFORM ] && . ${SOURCEDIR}/targets/${MEDIA_TARGET[i]}/platforms/$SUBPLATFORM/settings.inc
. ${SOURCEDIR}/targets/${MEDIA_TARGET[i]}/platforms/$PLATFORM/settings.inc
[ "$SUBPLATFORM" ] && \
medium_name=`arch=_SPLIT_ VARIANT=$VARIANT PLATFORM=$SUBPLATFORM media_name` ||
medium_name=`arch=_SPLIT_ VARIANT=$VARIANT media_name`
@ -371,7 +372,7 @@ for i in `seq 0 $ALLMEDIASLAST`; do
unset latest
#echo "PLATFORM=$PLATFORM SUBPLATFORM=$SUBPLATFORM MEDIA_SUFFIX=$media_suffix"
[ "${CRON_DEBUG}" ] && echo "PLATFORM=$PLATFORM SUBPLATFORM=$SUBPLATFORM MEDIA_SUFFIX=$media_suffix MEDIA_WEEKDAY=${MEDIA_WEEKDAY[i]}"
if [ "$RELEASE" ]; then
echo "Releasing $PRODUCT_NAME media (${PLATFORM}/${SUBPLATFORM} $RELEASETAG)"
SIMULATE=1

View File

@ -1,6 +1,13 @@
#
# makedist automatic build global configuration
#
REPODIR_LOCAL="/var/ftp/pub/openmamba"
REPODIR_URL="/pub/openmamba"
PROJECTURL=https://openmamba.org
#TORRENTURL=http://torrent.mambasoft.it:8080/announce
# list of supported languages
#
HTML_LANGS="it en"
@ -9,7 +16,7 @@ HTML_LANGS="it en"
MAKEDIST_CRON_ENABLE=0
# announcements configuration
#ANNOUNCEMENTS_SIGNER="Silvan Calarco"
#ANNOUNCEMENTS_SIGNER="Distribution Maintainer"
#ANNOUNCEMENTS_EMAILS_TEST="test@example.org"
#ANNOUNCEMENTS_EMAILS_STABLE_EN="ml@example.org"
#ANNOUNCEMENTS_EMAILS_STABLE_IT="ml-it@example.org"