2011-05-04 02:31:45 +02:00
|
|
|
#!/bin/bash
|
|
|
|
#
|
2012-04-26 15:21:34 +02:00
|
|
|
# openmamba-autobuild-autoport daily cron script
|
|
|
|
# (c) 2008-2012 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
|
|
|
|
}
|
|
|
|
|
|
|
|
PIDFILE=/var/run/autodist/autodist.pid
|
|
|
|
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
|
|
|
|
[ "${AUTOPORT_ARCH[$i]}" ] || continue
|
2012-05-10 10:35:14 +02:00
|
|
|
[ "${AUTOPORT_DISABLE[$i]}" -a "${AUTOPORT_DISABLE[$i]}" != "0" ] && continue
|
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
|
|
|
|
LOGFILE="/var/autodist/log/autoport-chroot-${AUTOPORT_CHROOT[$i]}.log"
|
|
|
|
LASTLOGFILE="/var/autodist/log/autoport-chroot-${AUTOPORT_CHROOT[$i]}-last.log"
|
|
|
|
elif [ "${AUTOPORT_NATIVE[$i]}" ]; then
|
|
|
|
LOGFILE="/var/autodist/log/autoport-native-${AUTOPORT_ARCH[$i]}.log"
|
|
|
|
LASTLOGFILE="/var/autodist/log/autoport-native-${AUTOPORT_ARCH[$i]}-last.log"
|
|
|
|
elif [ "${AUTOPORT_CROSS[$i]}" ]; then
|
|
|
|
LOGFILE="/var/autodist/log/autoport-cross-${AUTOPORT_CROSS[$i]}.log"
|
|
|
|
LASTLOGFILE="/var/autodist/log/autoport-cross-${AUTOPORT_CROSS[$i]}-last.log"
|
|
|
|
else
|
|
|
|
continue
|
|
|
|
fi
|
|
|
|
[ -e $LOGFILE ] && mv $LOGFILE $LASTLOGFILE
|
|
|
|
|
|
|
|
# for r in ${AUTOPORT_REPOSITORIES[$i]}; do
|
2012-05-24 16:35:34 +02:00
|
|
|
echo "+ Autoport start at `date`" > $LOGFILE
|
|
|
|
echo "============================================" >> $LOGFILE
|
2012-05-12 13:43:19 +02:00
|
|
|
# done
|
2011-05-04 02:31:45 +02:00
|
|
|
|
2012-05-09 17:29:23 +02:00
|
|
|
if [ "${AUTOPORT_CHROOT[$i]}" ]; then
|
|
|
|
a=${AUTOPORT_CHROOT[$i]}
|
|
|
|
# sudo mount -o bind /proc /var/autoport/$a/proc
|
|
|
|
[[ "`/usr/bin/tty`" != "not a tty" ]] && echo "Updating packages in $a chroot environment"
|
2012-05-24 16:35:34 +02:00
|
|
|
echo "= Updating packages in $a chroot environment..." >> $LOGFILE
|
2012-05-09 17:29:23 +02:00
|
|
|
LANG=C /usr/sbin/chroot /var/autoport/$a smart update --quiet > /dev/null
|
2012-05-12 13:43:19 +02:00
|
|
|
LANG=C /usr/sbin/chroot /var/autoport/$a smart upgrade -y >> $LOGFILE
|
2012-05-09 17:29:23 +02:00
|
|
|
for r in ${AUTOPORT_REPOSITORIES[$i]}; do
|
2012-05-24 16:35:34 +02:00
|
|
|
echo "= Working on $r($a) in chroot mode..." >> $LOGFILE
|
2012-05-12 13:43:19 +02:00
|
|
|
[[ "`/usr/bin/tty`" != "not a tty" ]] && echo "Working on $r($a) in chroot mode" >> $LOGFILE
|
|
|
|
# disable service restarts
|
|
|
|
mv /var/autoport/$a/sbin/service /var/autoport/$a/sbin/service.autoport
|
|
|
|
ln -s /bin/true /var/autoport/$a/sbin/service
|
|
|
|
$CMD_PREFIX /usr/sbin/chroot /var/autoport/$a su -l ${AUTOPORT_CHROOT_USER[$i]} -c "autoport -b -r $r" >> $LOGFILE
|
|
|
|
mv /var/autoport/$a/sbin/service.autoport /var/autoport/$a/sbin/service
|
|
|
|
cat /var/autoport/$a/home/${AUTOPORT_CHROOT_USER[$i]}/.autoport/${AUTOPORT_ARCH[$i]}/log >> $LOGFILE
|
2012-05-09 17:29:23 +02:00
|
|
|
done
|
2012-05-12 13:43:19 +02:00
|
|
|
#$local_ftp/$r/autoport-$a.log
|
2012-05-09 17:29:23 +02:00
|
|
|
fi
|
|
|
|
|
|
|
|
if [ "${AUTOPORT_NATIVE[$i]}" ]; then
|
|
|
|
a=${AUTOPORT_ARCH[$i]}
|
|
|
|
[[ "`/usr/bin/tty`" != "not a tty" ]] && echo "Updating packages in $a native environment"
|
2012-05-24 16:35:34 +02:00
|
|
|
echo "= Updating packages in $a native environment..." >> $LOGFILE
|
2012-05-09 17:29:23 +02:00
|
|
|
LANG=C smart update > /dev/null
|
2012-05-12 13:43:19 +02:00
|
|
|
LANG=C smart upgrade -y >> $LOGFILE
|
2012-05-09 17:29:23 +02:00
|
|
|
for r in ${AUTOPORT_REPOSITORIES[$i]}; do
|
2012-05-24 16:35:34 +02:00
|
|
|
echo "= Working on $r($a) in native mode" >> $LOGFILE
|
2012-05-12 13:43:19 +02:00
|
|
|
su -l autodist -c "autoport -b -r $r" >> $LOGFILE
|
|
|
|
cat /var/autodist/.autoport/$a/log >> $LOGFILE
|
2012-05-09 17:29:23 +02:00
|
|
|
done
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ "${AUTOPORT_CROSS[$i]}" ]; then
|
|
|
|
a=${AUTOPORT_CROSS[$i]}
|
|
|
|
for r in ${AUTOPORT_REPOSITORIES[$i]}; do
|
|
|
|
[[ "`/usr/bin/tty`" != "not a tty" ]] && echo "Working on $r($a) in cross-platform mode"
|
2012-05-24 16:35:34 +02:00
|
|
|
echo "= Working on $r($a) in cross-platform mode" >> $LOGFILE
|
2012-05-12 13:43:19 +02:00
|
|
|
su -l autodist -c "autoport -b -x $a -r $r" >> $LOGFILE
|
|
|
|
cat /var/autodist/.autoport/$a/log >> $LOGFILE
|
|
|
|
# $local_ftp/$r/autoport-$a.log
|
2012-05-09 17:29:23 +02:00
|
|
|
done
|
|
|
|
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
|
|
|
|
|
|
|
# for r in ${AUTOPORT_REPOSITORIES[$i]}; do
|
|
|
|
# [ -e /var/autodist/log/autoport-$r.log ] && \
|
|
|
|
# cp /var/autodist/log/autoport-$r.log /var/autodist/log/autoport-$r-last.log
|
|
|
|
# done
|
2011-05-04 02:31:45 +02:00
|
|
|
|
|
|
|
done
|