197 lines
5.3 KiB
Bash
197 lines
5.3 KiB
Bash
#!/bin/bash
|
|
#
|
|
# Copyright (C) 2009,2010,2011 Ruben Rodriguez <ruben@trisquel.info>
|
|
#
|
|
# This program is free software; you can redistribute it and/or modify
|
|
# it under the terms of the GNU General Public License as published by
|
|
# the Free Software Foundation; either version 2 of the License, or
|
|
# (at your option) any later version.
|
|
#
|
|
# This program is distributed in the hope that it will be useful,
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
# GNU General Public License for more details.
|
|
#
|
|
# You should have received a copy of the GNU General Public License
|
|
# along with this program; if not, write to the Free Software
|
|
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|
#
|
|
#
|
|
#
|
|
# This script compares two Sources.gz files, and reports available updates
|
|
|
|
[ 1$1 = 1"test" ] && TEST=echo
|
|
|
|
WD=$PWD
|
|
LOGS=$PWD/logs
|
|
[ -d $LOGS ] || mkdir $LOGS
|
|
export LANG=C
|
|
FILE=$(mktemp)
|
|
TMP=$(mktemp -d)
|
|
cd $TMP
|
|
|
|
echo "List of packages with available updates:
|
|
" > $FILE
|
|
|
|
listmirror (){
|
|
DIST=$1
|
|
COMPONENT=$2
|
|
echo -n Downloading Sources.gz from $MIRROR/dists/$DIST/$COMPONENT/source/Sources.gz >&2
|
|
wget $MIRROR/dists/$DIST/$COMPONENT/source/Sources.gz -q -O - | zcat | egrep dsc$ | cut -d" " -f 4|sed 's/\.dsc//'
|
|
echo " Done" >&2
|
|
}
|
|
|
|
listsweets (){
|
|
DIST=$1
|
|
echo -n Downloading Sources.gz from $MIRROR >&2
|
|
wget $MIRROR/Sources.gz -q -O - | zcat | egrep dsc$ | cut -d" " -f 4|sed 's/\.dsc//'
|
|
echo " Done" >&2
|
|
}
|
|
|
|
|
|
update(){
|
|
|
|
MIRROR="http://archive.ubuntu.com/ubuntu"
|
|
|
|
for i in hardy lucid maverick natty oneiric
|
|
do
|
|
listmirror $i main >> $i
|
|
listmirror $i-updates main >> $i
|
|
listmirror $i-security main >> $i
|
|
listmirror $i universe >> $i
|
|
listmirror $i-updates universe >> $i
|
|
listmirror $i-security universe >> $i
|
|
done
|
|
|
|
#MIRROR="http://download.sugarlabs.org/packages/SweetsDistribution:/0.94/Ubuntu-11.04/"
|
|
|
|
#listsweets >> sweets-natty
|
|
|
|
MIRROR="ftp://archive.trisquel.info/trisquel"
|
|
|
|
for i in main extras
|
|
do
|
|
listmirror robur $i >> robur
|
|
listmirror robur-updates $i >> robur
|
|
listmirror robur-security $i >> robur
|
|
done
|
|
|
|
for i in taranis slaine dagda brigantia
|
|
do
|
|
listmirror $i main >> $i
|
|
listmirror $i-updates main >> $i
|
|
listmirror $i-security main >> $i
|
|
done
|
|
|
|
MIRROR="http://devel.trisquel.info/trisquel/hardy"
|
|
listmirror hardy main >> robur
|
|
#MIRROR="http://devel.trisquel.info/trisquel/jaunty"
|
|
#listmirror jaunty main >> dwyn
|
|
#MIRROR="http://devel.trisquel.info/trisquel/karmic"
|
|
#listmirror karmic main >> awen
|
|
MIRROR="http://devel.trisquel.info/trisquel/lucid"
|
|
listmirror lucid main >> taranis
|
|
MIRROR="http://devel.trisquel.info/trisquel/maverick"
|
|
listmirror maverick main >> slaine
|
|
MIRROR="http://devel.trisquel.info/trisquel/natty"
|
|
listmirror natty main >> dagda
|
|
MIRROR="http://devel.trisquel.info/trisquel/oneiric"
|
|
listmirror oneiric main >> brigantia
|
|
|
|
}
|
|
|
|
higher(){
|
|
LIST="$(echo $* |sed 's/:/./g; s/+/./g') EOL"
|
|
|
|
HI=$(echo $LIST | cut -d" " -f1)
|
|
LIST=$(echo $LIST | cut -d" " -f2-)
|
|
|
|
while [ "$LIST" != "EOL" ]
|
|
do
|
|
TEST=$(echo $LIST | cut -d" " -f1)
|
|
dpkg --compare-versions $HI lt $TEST && HI=$TEST
|
|
LIST=$(echo $LIST | cut -d" " -f2-)
|
|
done
|
|
echo $HI
|
|
}
|
|
|
|
check(){
|
|
for package in $PACKAGES
|
|
do
|
|
LIST=$(egrep ^${package}_ $DISTRO)
|
|
current=$( higher $LIST)
|
|
LIST=$(egrep ^${package}_ $UPSTREAM)
|
|
upstream=$( higher $LIST)
|
|
|
|
if dpkg --compare-versions $current lt $upstream
|
|
then
|
|
|
|
# echo Current version in $DISTRO: $current 1>&2
|
|
# echo Upstream version in $UPSTREAM: $upstream 1>&2
|
|
[ $package = "grub2" -a $UPSTREAM = natty ] && continue
|
|
[ $package = "grub2" -a $UPSTREAM = oneiric ] && continue
|
|
[ $package = "yelp" -a $UPSTREAM = natty ] && continue
|
|
|
|
echo Current version in $DISTRO: $current
|
|
echo Upstream version in $UPSTREAM: $upstream
|
|
[ $current = "EOL" ] && continue
|
|
if echo $package |grep -q linux-ubuntu-modules
|
|
then
|
|
echo WARNING! linux-ubuntu-modules packages need to be manually compiled!
|
|
echo
|
|
continue
|
|
fi
|
|
|
|
echo Running makepackage $package $UPSTREAM at $(date)
|
|
echo Running makepackage $package $UPSTREAM at $(date) $LOGS/$package-$UPSTREAM-$(date +%Y%m%d).log 1>&2
|
|
$TEST sh $WD/makepackage $package $UPSTREAM > $LOGS/$package-$UPSTREAM-$(date +%Y%m%d).log && echo -n Done! || echo -n FAILED!
|
|
echo " ($(date))"
|
|
echo
|
|
fi
|
|
done
|
|
}
|
|
|
|
update
|
|
|
|
DISTRO="robur"
|
|
UPSTREAM="hardy"
|
|
PACKAGES=$(ls -1 $WD/helpers/$UPSTREAM/make-* | sed 's:^.*/::; s:make-::')
|
|
check >> $FILE
|
|
|
|
DISTRO="taranis"
|
|
UPSTREAM="lucid"
|
|
PACKAGES=$(ls -1 $WD/helpers/$UPSTREAM/make-* | sed 's:^.*/::; s:make-::')
|
|
check >> $FILE
|
|
|
|
DISTRO="slaine"
|
|
UPSTREAM="maverick"
|
|
PACKAGES=$(ls -1 $WD/helpers/$UPSTREAM/make-* | sed 's:^.*/::; s:make-::')
|
|
check >> $FILE
|
|
|
|
DISTRO="dagda"
|
|
UPSTREAM="natty"
|
|
PACKAGES=$(ls -1 $WD/helpers/$UPSTREAM/make-* | sed 's:^.*/::; s:make-::')
|
|
check >> $FILE
|
|
|
|
DISTRO="brigantia"
|
|
UPSTREAM="oneiric"
|
|
PACKAGES=$(ls -1 $WD/helpers/$UPSTREAM/make-* | sed 's:^.*/::; s:make-::')
|
|
check >> $FILE
|
|
|
|
#DISTRO="dagda"
|
|
#UPSTREAM="sweets-natty"
|
|
#PACKAGES=$(ls -1 $WD/helpers/$UPSTREAM/make-* | sed 's:^.*/::; s:make-::')
|
|
#check >> $FILE
|
|
|
|
report () {
|
|
#address=trisquel-devel@listas.trisquel.info
|
|
address=ruben@trisquel.info
|
|
|
|
echo "Subject: Compiling updates
|
|
To: $address
|
|
|
|
$(cat $FILE)" | $TEST /usr/sbin/sendmail -f watchdog@devel.trisquel.info -h correo.sognus.com
|
|
}
|
|
|
|
grep -q makepackage $FILE && $TEST report
|
|
rm $FILE $TMP -rf
|