diff --git a/Makefile b/Makefile index 4faaeb7..c1a7457 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,5 @@ # Makefile for autodist -# Copyright (C) 2006-2014 by Silvan Calarco +# Copyright (C) 2006-2021 by Silvan Calarco # PACKAGE = autodist @@ -71,8 +71,9 @@ install-programs: @$(INSTALL_SCRIPT) autodist $(DESTDIR)$(bindir)/autodist @$(INSTALL_SCRIPT) autodist-tool $(DESTDIR)$(bindir)/autodist-tool @$(INSTALL_SCRIPT) autoport $(DESTDIR)$(bindir)/autoport - @$(INSTALL_SCRIPT) automaint $(DESTDIR)$(sbindir)/automaint + @$(INSTALL_SCRIPT) autoport-launcher $(DESTDIR)$(bindir)/autoport-launcher @$(INSTALL_SCRIPT) autoport-chroot $(DESTDIR)$(sbindir)/autoport-chroot + @$(INSTALL_SCRIPT) automaint $(DESTDIR)$(sbindir)/automaint @$(INSTALL_SCRIPT) autodist-repository $(DESTDIR)$(sbindir)/autodist-repository @$(INSTALL_SCRIPT) autodist-upstream-updates $(DESTDIR)$(sbindir)/autodist-upstream-updates @$(INSTALL_SCRIPT) autoport-fix-environment $(DESTDIR)$(bindir)/autoport-fix-environment @@ -96,8 +97,7 @@ install-data: @$(INSTALL_DATA) webbuild/webbuild-admin $(DESTDIR)$(localstatedir)/webbuild/users/admin.conf @$(INSTALL_SCRIPT) etc/sysconfig/autoport $(DESTDIR)$(sysconfdir)/sysconfig/autoport @$(INSTALL_SCRIPT) etc/cron.hourly/60-autodist-update $(DESTDIR)$(sysconfdir)/cron.hourly/ - @$(INSTALL_SCRIPT) etc/cron.hourly/65-autoport-native $(DESTDIR)$(sysconfdir)/cron.hourly/ - @$(INSTALL_SCRIPT) etc/cron.hourly/66-autoport-chroot $(DESTDIR)$(sysconfdir)/cron.hourly/ + @$(INSTALL_SCRIPT) etc/cron.hourly/65-autoport $(DESTDIR)$(sysconfdir)/cron.hourly/ @$(INSTALL_SCRIPT) etc/cron.daily/40-autodist-cleanold $(DESTDIR)$(sysconfdir)/cron.daily/ @$(INSTALL_SCRIPT) etc/cron.daily/40-autodist-upstream-updates $(DESTDIR)$(sysconfdir)/cron.daily/ @$(INSTALL_SCRIPT) etc/logrotate.d/webbuild $(DESTDIR)$(sysconfdir)/logrotate.d/webbuild diff --git a/autoport b/autoport index 55b1ae6..0408f20 100755 --- a/autoport +++ b/autoport @@ -1,6 +1,6 @@ #!/bin/bash # autoport -- batch cross-build tool based on autodist -# Copyright (C) 2011-2020 by Silvan Calarco +# Copyright (C) 2011-2021 by Silvan Calarco # # Released under the terms of the GNU GPL release 3 license # @@ -329,6 +329,19 @@ done [ "$DEST_REPOSITORY" ] || DEST_REPOSITORY=$PORT_REPOSITORY +if [ "$BATCH_MODE" ]; then + PIDFILE="/run/autodist/autoport-${BUILD_ARCH}-${PORT_REPOSITORY}.pid" + [ -e $PIDFILE ] && { + PIDCHECK=`cat $PIDFILE` + [ "$PIDCHECK" -a -e /proc/$PIDCHECK -a ! "$DISABLE_PID_CHECK" ] && { + echo "Error: autoport -b already running with PID=$PIDCHECK.Aborting." + exit 1 + } + } + echo $$ > $PIDFILE + trap "rm -f $PIDFILE; exit 1" SIGQUIT SIGINT SIGKILL SIGTERM +fi + for TARGET_ARCH in ${TARGET_ARCHS}; do JOBS_SKIPPED=() @@ -411,6 +424,7 @@ for TARGET_ARCH in ${TARGET_ARCHS}; do [ "$FIX_MODE" -o "$BATCH_MODE" -o "${JOB[*]}" ] || { echo "Nothing to do."; exit 0; } if [ "$BATCH_MODE" ]; then + [ "${JOB[*]}" ] && { echo "Error: no jobs allowed in batch mode; aborting." exit 1 @@ -557,8 +571,8 @@ for TARGET_ARCH in ${TARGET_ARCHS}; do autoport_log ${JOB_CURRENT} prepare failed $tmpfile continue } || { - spec_version=`grep "^Version:" ${SPECDIR}/${JOB_CURRENT}.spec | awk '{ print $2}'` - spec_release=`grep "^Release:" ${SPECDIR}/${JOB_CURRENT}.spec | awk '{ print $2}'` + spec_version=`grep -m1 "^Version:" ${SPECDIR}/${JOB_CURRENT}.spec | awk '{ print $2}'` + spec_release=`grep -m1 "^Release:" ${SPECDIR}/${JOB_CURRENT}.spec | awk '{ print $2}'` if [ "${spec_version}-${spec_release}" != "$src_version-$src_release" ]; then echo "< (FAILED) [wrong version ${src_version}-${src_release} != ${spec_version}-${spec_release}]" JOB_CANTPREPARE=(${JOB_CANTPREPARE[*]} $JOB_CURRENT) @@ -789,4 +803,5 @@ MESSAGE=`cgi_encodevar \"ported $JOB_CURRENT to $TARGET_ARCH and s rm -f $tmpfile $tmpfile1 done echo "* All jobs completed. See $logfile for details." +[ "$BATCH_MODE" ] && rm -f $PIDFILE exit ${#JOB_FAILED[*]} diff --git a/autoport-launcher b/autoport-launcher new file mode 100755 index 0000000..1c62621 --- /dev/null +++ b/autoport-launcher @@ -0,0 +1,111 @@ +#!/bin/bash +# +# autoport launcher +# (c) 2021 by Silvan Calarco +# +#. /etc/sysconfig/openmamba-central +. /etc/sysconfig/autoport + +[ "$AUTOPORT_ENABLE" = "1" -o "$AUTOPORT_ENABLE" = "true" ] || exit 0 + +i=$1 + +[ "$i" ] || { + echo "Usage: autoport-launcher autoport_conf" + exit 1 +} + +[ "`uname -m`" = "x86_64" ] && HOST_IS_X86_64=1 + +[ "${AUTOPORT_DISABLE[$i]}" -a "${AUTOPORT_DISABLE[$i]}" != "0" ] && exit 0 + +PIDFILE=/run/autodist/autoport-launcher-${i}.pid +[ -e $PIDFILE ] && { + PIDCHECK=`cat $PIDFILE` + [ "$PIDCHECK" -a -e /proc/$PIDCHECK ] && { + echo "autoport-launcher for configuration $i already running; exiting." + exit 0 + } +} +echo $$ > $PIDFILE +trap "rm -f $PIDFILE; exit 1" SIGQUIT SIGINT SIGKILL SIGTERM + +if [ "$HOST_IS_X86_64" -a "${AUTOPORT_ARCH[$i]}" != "x86_64" ]; then + CMD_PREFIX=linux32 +else + CMD_PREFIX= +fi + +UPDATE_DONE= + +for r in ${AUTOPORT_REPOSITORIES[$i]}; do + + if [ "${AUTOPORT_NATIVE[$i]}" ]; then + AUTOPORT_PIDFILE="/run/autodist/autoport-${AUTOPORT_ARCH[$i]}-$r.pid" + LOGFILE="/var/autodist/log/autoport-native-$r-${AUTOPORT_ARCH[$i]}.log" + LASTLOGFILE="/var/autodist/log/autoport-native-$r-${AUTOPORT_ARCH[$i]}-last.log" + elif [ "${AUTOPORT_CHROOT[$i]}" ]; then + AUTOPORT_PIDFILE="/var/autoport/${AUTOPORT_CHROOT[$i]}/run/autodist/autoport-${AUTOPORT_ARCH[$i]}-$r.pid" + LOGFILE="/var/autodist/log/autoport-chroot-$r-${AUTOPORT_CHROOT[$i]}.log" + LASTLOGFILE="/var/autodist/log/autoport-chroot-$r-${AUTOPORT_CHROOT[$i]}-last.log" + elif [ "${AUTOPORT_CROSS[$i]}" ]; then + AUTOPORT_PIDFILE="/run/autoport/autoport-${AUTOPORT_ARCH[$i]}-$r.pid" + LOGFILE="/var/autodist/log/autoport-cross-$r-${AUTOPORT_CROSS[$i]}.log" + LASTLOGFILE="/var/autodist/log/autoport-cross-$r-${AUTOPORT_CROSS[$i]}-last.log" + else + continue + fi + + if [ "$UPDATE_DONE" == "" ]; then + if [ "${AUTOPORT_NATIVE[$i]}" ]; then + [[ "`/usr/bin/tty`" != "not a tty" ]] && echo "Updating packages in ${AUTOPORT_ARCH[$i]} native environment" + echo "= Updating packages in ${AUTOPORT_ARCH[$i]} native environment..." >> $LOGFILE + LANG=C dnf update -y >> $LOGFILE + UPDATE_DONE=1 + elif [ "${AUTOPORT_CHROOT[$i]}" ]; then + [[ "`/usr/bin/tty`" != "not a tty" ]] && echo "Updating packages in ${AUTOPORT_CHROOT[$i]} chroot environment" + #echo "= Updating packages in ${AUTOPORT_CHROOT[$i]} chroot environment..." >> $LOGFILE + LANG=C /usr/sbin/chroot /var/autoport/${AUTOPORT_CHROOT[$i]} dnf update -y > /dev/null + #[ "${AUTOPORT_CHROOT_ICECREAM[$i]}" ] && LANG=C /usr/sbin/chroot /var/autoport/${AUTOPORT_CHROOT[$i]} /etc/init.d/icecream start + UPDATE_DONE=1 + fi + fi + + if [ -e $AUTOPORT_PIDFILE ]; then + PIDCHECK=`cat $AUTOPORT_PIDFILE` + if [ "$PIDCHECK" -a -e /proc/$PIDCHECK ]; then + echo "autoport for configuration $i already running; continuing." + continue + fi + fi + + [ -e $LOGFILE ] && mv $LOGFILE $LASTLOGFILE + + echo "+ Autoport start at `date`" > $LOGFILE + echo "============================================" >> $LOGFILE + + if [ "${AUTOPORT_NATIVE[$i]}" ]; then + echo "= Working on $r(${AUTOPORT_ARCH[$i]}) in native mode" >> $LOGFILE + su -l ${AUTOPORT_CHROOT_USER[$i]} -c "$CMD_PREFIX autoport -b -r $r" >> $LOGFILE + AUTODIST_HOME=`getent passwd ${AUTOPORT_CHROOT_USER[$i]} | cut -d: -f6` + cat $AUTODIST_HOME/.autoport/${AUTOPORT_ARCH[$i]}/$r-current.log >> $LOGFILE + elif [ "${AUTOPORT_CHROOT[$i]}" ]; then + echo "= Working on $r(${AUTOPORT_CHROOT[$i]}) in chroot mode..." >> $LOGFILE + $CMD_PREFIX /usr/sbin/chroot /var/autoport/${AUTOPORT_CHROOT[$i]} su -l ${AUTOPORT_CHROOT_USER[$i]} -c "autoport -b -r $r" >> $LOGFILE + if [ "${AUTOPORT_CHROOT_USER[$i]}" = "autodist" ]; then + cat /var/autoport/${AUTOPORT_CHROOT[$i]}/var/autodist/.autoport/${AUTOPORT_ARCH[$i]}/$r-current.log >> $LOGFILE + else + cat /var/autoport/${AUTOPORT_CHROOT[$i]}/home/${AUTOPORT_CHROOT_USER[$i]}/.autoport/${AUTOPORT_ARCH[$i]}/$r-current.log >> $LOGFILE + fi + elif [ "${AUTOPORT_CROSS[$i]}" ]; then + [[ "`/usr/bin/tty`" != "not a tty" ]] && echo "Working on $r(${AUTOPORT_CROSS[$i]}) in cross-platform mode" + echo "= Working on $r(${AUTOPORT_CROSS[$i]}) in cross-platform mode" >> $LOGFILE + su -l autodist -c "autoport -b -x ${AUTOPORT_CROSS[$i]} -r $r" >> $LOGFILE + cat /var/autodist/.autoport/${AUTOPORT_CROSS[$i]}/$r-current.log >> $LOGFILE + fi + + echo "- Autoport end at `date`" >> $LOGFILE + echo "============================================" >> $LOGFILE + +done +rm -f ${PIDFILE} diff --git a/etc/cron.hourly/65-autoport b/etc/cron.hourly/65-autoport new file mode 100755 index 0000000..d2e1a25 --- /dev/null +++ b/etc/cron.hourly/65-autoport @@ -0,0 +1,14 @@ +#!/bin/bash +# +# openmamba-autobuild-autoport daily cron script +# (c) 2008-2021 by Silvan Calarco +# +#. /etc/sysconfig/openmamba-central +. /etc/sysconfig/autoport + +[ "$AUTOPORT_ENABLE" = "1" -o "$AUTOPORT_ENABLE" = "true" ] || exit 0 + +for i in `seq 0 ${#AUTOPORT_ARCH[*]}`; do + echo "Running autoport-launcher ${i} `date`" + systemd-run /usr/bin/autoport-launcher ${i} +done diff --git a/etc/cron.hourly/65-autoport-native b/etc/cron.hourly/65-autoport-native deleted file mode 100755 index 93f1ef2..0000000 --- a/etc/cron.hourly/65-autoport-native +++ /dev/null @@ -1,84 +0,0 @@ -#!/bin/bash -# -# openmamba-autobuild-autoport daily cron script -# (c) 2008-2020 by Silvan Calarco -# -#. /etc/sysconfig/openmamba-central -. /etc/sysconfig/autoport - -[ "$AUTOPORT_ENABLE" = "1" -o "$AUTOPORT_ENABLE" = "true" ] || exit 0 - -ME=`basename $0` -[ "$$" == "`pidof -x $ME`" ] || { - [[ "`/usr/bin/tty`" != "not a tty" ]] && echo "Warning: $ME script already running; exiting." - exit 0 -} - -PIDFILE=/run/autodist/autoport.pid -HOUR=`date +%H` -[ "`uname -m`" = "x86_64" ] && HOST_IS_X86_64=1 - -function pid_check() { - - [ -e $PIDFILE ] && PIDCHECK=`cat $PIDFILE` - - [ "$PIDCHECK" -a -e /proc/$PIDCHECK ] && { - echo "Error: an autodist process is already running; exiting for safety." - exit 0 - - } -} - -pid_check - -NATIVE_UPGRADED= - -for i in `seq 0 ${#AUTOPORT_ARCH[*]}`; do - for r in ${AUTOPORT_REPOSITORIES[$i]}; do - [ "${AUTOPORT_ARCH[$i]}" ] || continue - [ "${AUTOPORT_DISABLE[$i]}" -a "${AUTOPORT_DISABLE[$i]}" != "0" ] && continue - - if [ "$HOST_IS_X86_64" -a "${AUTOPORT_ARCH[$i]}" != "x86_64" ]; then - CMD_PREFIX=linux32 - else - CMD_PREFIX= - fi - - if [ "${AUTOPORT_NATIVE[$i]}" ]; then - LOGFILE="/var/autodist/log/autoport-native-$r-${AUTOPORT_ARCH[$i]}.log" - LASTLOGFILE="/var/autodist/log/autoport-native-$r-${AUTOPORT_ARCH[$i]}-last.log" - else - continue - fi - [ -e $LOGFILE ] && mv $LOGFILE $LASTLOGFILE - - echo "+ Autoport start at `date`" > $LOGFILE - echo "============================================" >> $LOGFILE - - if [ "${AUTOPORT_NATIVE[$i]}" ]; then - a=${AUTOPORT_ARCH[$i]} - if [ ! "$NATIVE_UPGRADED" ]; then - [[ "`/usr/bin/tty`" != "not a tty" ]] && echo "Updating packages in $a native environment" - echo "= Updating packages in $a native environment..." >> $LOGFILE - LANG=C dnf update -y >> $LOGFILE - NATIVE_UPGRADED=1 - fi - echo "= Working on $r($a) in native mode" >> $LOGFILE - su -l ${AUTOPORT_CHROOT_USER[$i]} -c "$CMD_PREFIX autoport -b -r $r" >> $LOGFILE - AUTODIST_HOME=`getent passwd ${AUTOPORT_CHROOT_USER[$i]} | cut -d: -f6` - cat $AUTODIST_HOME/.autoport/$a/$r-current.log >> $LOGFILE - fi - -# if [ "${AUTOPORT_CROSS[$i]}" ]; then -# a=${AUTOPORT_CROSS[$i]} -# [[ "`/usr/bin/tty`" != "not a tty" ]] && echo "Working on $r($a) in cross-platform mode" -# echo "= Working on $r($a) in cross-platform mode" >> $LOGFILE -# su -l autodist -c "autoport -b -x $a -r $r" >> $LOGFILE -# cat /var/autodist/.autoport/$a/$r-current.log >> $LOGFILE -# fi - - echo "- Autoport end at `date`" >> $LOGFILE - echo "============================================" >> $LOGFILE - - done -done diff --git a/etc/cron.hourly/66-autoport-chroot b/etc/cron.hourly/66-autoport-chroot deleted file mode 100755 index bd55f70..0000000 --- a/etc/cron.hourly/66-autoport-chroot +++ /dev/null @@ -1,109 +0,0 @@ -#!/bin/bash -# -# openmamba-autobuild-autoport daily cron script -# (c) 2008-2020 by Silvan Calarco -# -#. /etc/sysconfig/openmamba-central -. /etc/sysconfig/autoport - -[ "$AUTOPORT_ENABLE" = "1" -o "$AUTOPORT_ENABLE" = "true" ] || exit 0 - -ME=`basename $0` -[ "$$" == "`pidof -x $ME`" ] || { - [[ "`/usr/bin/tty`" != "not a tty" ]] && echo "Warning: $ME script already running; exiting." - exit 0 -} - -PIDFILE=/run/autodist/autoport.pid -HOUR=`date +%H` -[ "`uname -m`" = "x86_64" ] && HOST_IS_X86_64=1 - -function pid_check() { - - [ -e $PIDFILE ] && PIDCHECK=`cat $PIDFILE` - - [ "$PIDCHECK" -a -e /proc/$PIDCHECK ] && { - echo "Error: an autodist process is already running; exiting for safety." - exit 0 - - } -} - -pid_check - -for i in `seq 0 ${#AUTOPORT_ARCH[*]}`; do - [ "${AUTOPORT_ARCH[$i]}" ] || continue - [ "${AUTOPORT_DISABLE[$i]}" -a "${AUTOPORT_DISABLE[$i]}" != "0" ] && continue - - if [ "${AUTOPORT_CHROOT[$i]}" ]; then - # disable service restarts - mv /var/autoport/${AUTOPORT_CHROOT[$i]}/sbin/service /var/autoport/${AUTOPORT_CHROOT[$i]}/sbin/service.autoport - ln -s /bin/true /var/autoport/${AUTOPORT_CHROOT[$i]}/sbin/service - # sudo mount -o bind /proc /var/autoport/${AUTOPORT_CHROOT[$i]}/proc - [[ "`/usr/bin/tty`" != "not a tty" ]] && echo "Updating packages in ${AUTOPORT_CHROOT[$i]} chroot environment" - #echo "= Updating packages in ${AUTOPORT_CHROOT[$i]} chroot environment..." >> $LOGFILE - LANG=C /usr/sbin/chroot /var/autoport/${AUTOPORT_CHROOT[$i]} dnf update -y > /dev/null - [ "${AUTOPORT_CHROOT_ICECREAM[$i]}" ] && LANG=C /usr/sbin/chroot /var/autoport/${AUTOPORT_CHROOT[$i]} /etc/init.d/icecream start - fi - - for r in ${AUTOPORT_REPOSITORIES[$i]}; do - - if [ "$HOST_IS_X86_64" -a "${AUTOPORT_ARCH[$i]}" != "x86_64" ]; then - CMD_PREFIX=linux32 - else - CMD_PREFIX= - fi - - if [ "${AUTOPORT_CHROOT[$i]}" ]; then - LOGFILE="/var/autodist/log/autoport-chroot-$r-${AUTOPORT_CHROOT[$i]}.log" - LASTLOGFILE="/var/autodist/log/autoport-chroot-$r-${AUTOPORT_CHROOT[$i]}-last.log" - elif [ "${AUTOPORT_CROSS[$i]}" ]; then - LOGFILE="/var/autodist/log/autoport-cross-$r-${AUTOPORT_CROSS[$i]}.log" - LASTLOGFILE="/var/autodist/log/autoport-cross-$r-${AUTOPORT_CROSS[$i]}-last.log" - else - continue - fi - [ -e $LOGFILE ] && mv $LOGFILE $LASTLOGFILE - - echo "+ Autoport start at `date`" > $LOGFILE - echo "============================================" >> $LOGFILE - - if [ "${AUTOPORT_CHROOT[$i]}" ]; then - echo "= Working on $r(${AUTOPORT_CHROOT[$i]}) in chroot mode..." >> $LOGFILE - [[ "`/usr/bin/tty`" != "not a tty" ]] && echo "Working on $r(${AUTOPORT_CHROOT[$i]}) in chroot mode" >> $LOGFILE - $CMD_PREFIX /usr/sbin/chroot /var/autoport/${AUTOPORT_CHROOT[$i]} su -l ${AUTOPORT_CHROOT_USER[$i]} -c "autoport -b -r $r" >> $LOGFILE - if [ "${AUTOPORT_CHROOT_USER[$i]}" = "autodist" ]; then - cat /var/autoport/${AUTOPORT_CHROOT[$i]}/var/autodist/.autoport/${AUTOPORT_ARCH[$i]}/$r-current.log >> $LOGFILE - else - cat /var/autoport/${AUTOPORT_CHROOT[$i]}/home/${AUTOPORT_CHROOT_USER[$i]}/.autoport/${AUTOPORT_ARCH[$i]}/$r-current.log >> $LOGFILE - fi - fi - -# if [ "${AUTOPORT_NATIVE[$i]}" ]; then -# a=${AUTOPORT_ARCH[$i]} -# [[ "`/usr/bin/tty`" != "not a tty" ]] && echo "Updating packages in $a native environment" -# echo "= Updating packages in $a native environment..." >> $LOGFILE -# LANG=C dnf update -y >> $LOGFILE -# echo "= Working on $r($a) in native mode" >> $LOGFILE -# su -l autodist -c "autoport -b -r $r" >> $LOGFILE -# cat /var/autodist/.autoport/$a/$r-current.log >> $LOGFILE -# fi - - if [ "${AUTOPORT_CROSS[$i]}" ]; then - [[ "`/usr/bin/tty`" != "not a tty" ]] && echo "Working on $r(${AUTOPORT_CROSS[$i]}) in cross-platform mode" - echo "= Working on $r(${AUTOPORT_CROSS[$i]}) in cross-platform mode" >> $LOGFILE - su -l autodist -c "autoport -b -x ${AUTOPORT_CROSS[$i]} -r $r" >> $LOGFILE - cat /var/autodist/.autoport/${AUTOPORT_CROSS[$i]}/$r-current.log >> $LOGFILE - fi - - echo "- Autoport end at `date`" >> $LOGFILE - echo "============================================" >> $LOGFILE - - done - - if [ "${AUTOPORT_CHROOT[$i]}" ]; then - mv /var/autoport/${AUTOPORT_CHROOT[$i]}/sbin/service.autoport /var/autoport/${AUTOPORT_CHROOT[$i]}/sbin/service - [ "${AUTOPORT_CHROOT_ICECREAM[$i]}" ] && LANG=C /usr/sbin/chroot /var/autoport/${AUTOPORT_CHROOT[$i]} /etc/init.d/icecream stop - fi - -done