autodist/etc/cron.hourly/65-openmamba-autobuild-autoport

99 lines
3.8 KiB
Plaintext
Raw Normal View History

2011-05-04 02:31:45 +02:00
#!/bin/bash
#
# 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`" ] || {
[[ "`/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`
[ "`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
}
}
pid_check
2011-05-04 02:31:45 +02:00
for i in `seq 0 ${#AUTOPORT_ARCH[*]}`; do
[ "${AUTOPORT_ARCH[$i]}" ] || continue
if [ "$HOST_IS_X86_64" -a "${AUTOPORT_ARCH[$i]}" != "x86_64" ]; then
CMD_PREFIX=linux32
else
CMD_PREFIX=
fi
echo "ARCH=${AUTOPORT_ARCH[$i]} CHROOT=${AUTOPORT_CHROOT[$i]} \
CROSS=${AUTOPORT_CROSS[$i]} NATIVE=${AUTOPORT_NATIVE[$i]} \
REPOSITORIES=${AUTOPORT_REPOSITORIES[$i]} CMD_PREFIX=$CMD_PREFIX"
2011-05-04 02:31:45 +02:00
for r in ${AUTOPORT_REPOSITORIES[$i]}; do
echo "Autoport start at `date`" > /var/autodist/log/autoport-$r.log
echo "========================" >> /var/autodist/log/autoport-$r.log
2011-05-04 02:31:45 +02:00
done
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"
echo "Updating packages in $a chroot environment..." >> /var/autodist/log/autoport-chroot-$a.log
LANG=C /usr/sbin/chroot /var/autoport/$a smart update --quiet > /dev/null
LANG=C /usr/sbin/chroot /var/autoport/$a smart upgrade -y >> /var/autodist/log/autoport-chroot-$a.log
for r in ${AUTOPORT_REPOSITORIES[$i]}; do
echo "Working on $r($a) in chroot mode..." >> /var/autodist/log/autoport-$r.log
[[ "`/usr/bin/tty`" != "not a tty" ]] && echo "Working on $r($a) in chroot mode" > $local_ftp/$r/autoport-$a.log
$CMD_PREFIX /usr/sbin/chroot /var/autoport/$a su -l sdk -c "autoport -b -r $r" >> $local_ftp/$r/autoport-$a.log
cat /var/autoport/$a/home/sdk/.autoport/${AUTOPORT_ARCH[$i]}/log >> $local_ftp/$r/autoport-$a.log
echo >> $local_ftp/$r/autoport-$a.log
done
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..." >> /var/autodist/log/autoport-native-$a.log
LANG=C smart update > /dev/null
LANG=C smart upgrade -y >> /var/log/autoupgrade
for r in ${AUTOPORT_REPOSITORIES[$i]}; do
echo "Working on $r($a) in native mode" >> /var/autodist/log/autoport-$r.log
su -l autodist -c "autoport -b -r $r" >> /var/autodist/log/autoport-$r.log
cat /var/autodist/.autoport/$a/log >> /var/autodist/log/autoport-$r.log
echo >> /var/autodist/log/autoport-$r.log
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"
echo "Working on $r($a) in cross-platform mode" >> /var/autodist/log/autoport-$r.log
su -l autodist -c "autoport -b -x $a -r $r" > $local_ftp/$r/autoport-$a.log
cat /var/autodist/.autoport/$a/log >> $local_ftp/$r/autoport-$a.log
echo >> $local_ftp/$r/autoport-$a.log
done
fi
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
2011-05-04 02:31:45 +02:00
done
done