Run apt-get update before upgrading grml-live
[release-tools.git] / jenkins-link_latest.sh
1 #!/bin/bash
2
3 MIRROR_DIRECTORY=$1
4 if [ -z "$MIRROR_DIRECTORY" ] ; then
5   echo "Usage: jenkins-link_latest.sh path_to_public_directory flavour1 ... flavourN" >&2
6   exit 1
7 fi
8 shift
9
10 FLAVOURS=$*
11
12 JOBS=/var/lib/jenkins/jobs
13
14 cd $MIRROR_DIRECTORY || exit 1
15 for f in $FLAVOURS; do
16   [ -d $JOBS/$f/builds ] || continue
17   [ -d ./$f ] && rm -r ./$f
18   mkdir $f
19   for buildpath in $JOBS/$f/builds/*_*; do
20     build=$(basename $buildpath)
21     mkdir $f/$build
22     for isofile in $buildpath/archive/grml_isos/*; do
23       [ -e $isofile ] && ln -s $isofile $f/$build/
24     done
25     [ -d $buildpath/archive/grml_logs ] && ln -s $buildpath/archive/grml_logs $f/$build/logs
26   done
27   latest=$(basename $(readlink $JOBS/$f/lastSuccessful))
28   mkdir ${f}/latest
29   if [ -e $f/$latest/*.iso ]; then
30     latestname=$(basename ${f}/$latest/*.iso)
31     ln -s ../$latest/${latestname} ${f}/latest/${f}_latest.iso
32     ln -s ../$latest/${latestname}.md5 ${f}/latest/${f}_latest.iso.md5
33     ln -s ../$latest/${latestname}.sha1 ${f}/latest/${f}_latest.iso.sha1
34   fi
35 done