2011-05-04 02:31:45 +02:00
|
|
|
#!/bin/bash
|
|
|
|
#
|
2012-04-26 15:21:34 +02:00
|
|
|
# openmamba-autobuild-autoport daily cron script
|
2014-06-07 19:30:39 +02:00
|
|
|
# (c) 2008-2014 by Silvan Calarco <silvan.calarco@mambasoft.it>
|
2011-05-04 02:31:45 +02:00
|
|
|
#
|
|
|
|
#. /etc/sysconfig/openmamba-central
|
|
|
|
. /etc/sysconfig/autoport
|
|
|
|
|
|
|
|
[ "$AUTOPORT_ENABLE" = "1" -o "$AUTOPORT_ENABLE" = "true" ] || exit 0
|
|
|
|
|
|
|
|
ME=`basename $0`
|
|
|
|
[ "$$" == "`pidof -x $ME`" ] || {
|
2012-04-26 15:21:34 +02:00
|
|
|
[[ "`/usr/bin/tty`" != "not a tty" ]] && echo "Warning: $ME script already running; exiting."
|
2011-05-04 02:31:45 +02:00
|
|
|
exit 0
|
|
|
|
}
|
|
|
|
|
2012-07-29 10:58:07 +02:00
|
|
|
PIDFILE=/var/run/autodist/autoport.pid
|
2011-05-04 02:31:45 +02:00
|
|
|
HOUR=`date +%H`
|
2012-05-09 17:29:23 +02:00
|
|
|
[ "`uname -m`" = "x86_64" ] && HOST_IS_X86_64=1
|
2011-05-04 02:31:45 +02:00
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-05-09 17:29:23 +02:00
|
|
|
pid_check
|
2011-05-04 02:31:45 +02:00
|
|
|
|
2012-05-09 17:29:23 +02:00
|
|
|
for i in `seq 0 ${#AUTOPORT_ARCH[*]}`; do
|
2013-04-22 12:24:34 +02:00
|
|
|
[ "${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]} smart update --quiet > /dev/null
|
|
|
|
LANG=C /usr/sbin/chroot /var/autoport/${AUTOPORT_CHROOT[$i]} smart upgrade -y > /dev/null
|
2014-06-07 19:30:39 +02:00
|
|
|
[ "${AUTOPORT_CHROOT_ICECREAM[$i]}" ] && LANG=C /usr/sbin/chroot /var/autoport/${AUTOPORT_CHROOT[$i]} /etc/init.d/icecream start
|
2013-04-22 12:24:34 +02:00
|
|
|
fi
|
|
|
|
|
2012-09-04 13:04:11 +02:00
|
|
|
for r in ${AUTOPORT_REPOSITORIES[$i]}; do
|
2012-05-09 17:29:23 +02:00
|
|
|
|
|
|
|
if [ "$HOST_IS_X86_64" -a "${AUTOPORT_ARCH[$i]}" != "x86_64" ]; then
|
|
|
|
CMD_PREFIX=linux32
|
|
|
|
else
|
|
|
|
CMD_PREFIX=
|
|
|
|
fi
|
|
|
|
|
2012-05-12 13:43:19 +02:00
|
|
|
if [ "${AUTOPORT_CHROOT[$i]}" ]; then
|
2012-09-10 17:51:11 +02:00
|
|
|
LOGFILE="/var/autodist/log/autoport-chroot-$r-${AUTOPORT_CHROOT[$i]}.log"
|
|
|
|
LASTLOGFILE="/var/autodist/log/autoport-chroot-$r-${AUTOPORT_CHROOT[$i]}-last.log"
|
2012-05-12 13:43:19 +02:00
|
|
|
elif [ "${AUTOPORT_CROSS[$i]}" ]; then
|
2012-09-10 17:51:11 +02:00
|
|
|
LOGFILE="/var/autodist/log/autoport-cross-$r-${AUTOPORT_CROSS[$i]}.log"
|
|
|
|
LASTLOGFILE="/var/autodist/log/autoport-cross-$r-${AUTOPORT_CROSS[$i]}-last.log"
|
2012-05-12 13:43:19 +02:00
|
|
|
else
|
|
|
|
continue
|
|
|
|
fi
|
|
|
|
[ -e $LOGFILE ] && mv $LOGFILE $LASTLOGFILE
|
|
|
|
|
2012-09-04 13:04:11 +02:00
|
|
|
echo "+ Autoport start at `date`" > $LOGFILE
|
|
|
|
echo "============================================" >> $LOGFILE
|
2011-05-04 02:31:45 +02:00
|
|
|
|
2012-05-09 17:29:23 +02:00
|
|
|
if [ "${AUTOPORT_CHROOT[$i]}" ]; then
|
2013-04-22 12:24:34 +02:00
|
|
|
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
|
2014-06-10 01:44:26 +02:00
|
|
|
if [ "${AUTOPORT_CHROOT[$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
|
2012-05-09 17:29:23 +02:00
|
|
|
fi
|
|
|
|
|
2012-09-21 12:53:08 +02:00
|
|
|
# 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 smart update > /dev/null
|
|
|
|
# LANG=C smart upgrade -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
|
2012-05-09 17:29:23 +02:00
|
|
|
|
|
|
|
if [ "${AUTOPORT_CROSS[$i]}" ]; then
|
2013-04-22 12:24:34 +02:00
|
|
|
[[ "`/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
|
2012-05-09 17:29:23 +02:00
|
|
|
fi
|
|
|
|
|
2012-05-24 16:35:34 +02:00
|
|
|
echo "- Autoport end at `date`" >> $LOGFILE
|
|
|
|
echo "============================================" >> $LOGFILE
|
2012-05-12 13:43:19 +02:00
|
|
|
|
2012-09-04 13:04:11 +02:00
|
|
|
done
|
2013-04-22 12:24:34 +02:00
|
|
|
|
|
|
|
if [ "${AUTOPORT_CHROOT[$i]}" ]; then
|
2013-12-14 11:51:37 +01:00
|
|
|
mv /var/autoport/${AUTOPORT_CHROOT[$i]}/sbin/service.autoport /var/autoport/${AUTOPORT_CHROOT[$i]}/sbin/service
|
2014-06-07 19:30:39 +02:00
|
|
|
[ "${AUTOPORT_CHROOT_ICECREAM[$i]}" ] && LANG=C /usr/sbin/chroot /var/autoport/${AUTOPORT_CHROOT[$i]} /etc/init.d/icecream stop
|
2013-04-22 12:24:34 +02:00
|
|
|
fi
|
|
|
|
|
2011-05-04 02:31:45 +02:00
|
|
|
done
|