Subversion Repositories HomeAutomation

Rev

Rev 1760 | Rev 1965 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | SVN | RSS feed

  1. #!/bin/bash
  2.  
  3. ATOMDIR=/tmp/atomppa
  4. SVNURL=http://svn.arune.se/svn/HomeAutomation/trunk/PcSoftware/Atom1.5
  5. SVNURLCNF=http://svn.arune.se/svn/HomeAutomation/trunk/Configuration
  6. SVNDIR=AtomSvn
  7. SVNDIRCNF=ConfigSvn
  8. CNFDIR=Configuration
  9. PPA=ppa:arune/auml-atom-daily
  10. DEBUILDFLG="-S -sa -k7EA270B4"
  11. PKGNAME=atom
  12. DIST=natty
  13. PKGMAINT="Anders Runeson <runeson@gmail.com>"
  14.  
  15. RUNDIR=`dirname $0`
  16. CHLOGDATE=`date -R`
  17. REVFILE=$RUNDIR/AtomSvnRev
  18. TMPFILE=/tmp/atompparunning
  19.  
  20. CURRREV=`svn info $SVNURL |grep '^Last Changed Rev:' | sed -e 's/^Last Changed Rev: //'`
  21. VERSION=1.5.$CURRREV
  22. NOSVNDIR=atom-$VERSION
  23. ORIGTAR=atom_$VERSION.orig.tar.gz
  24. SRCCHFILE=atom_$VERSION\_source.changes
  25. DPUTFLG="auml-atom-daily $SRCCHFILE"
  26.  
  27. # Run script from cron every hour
  28. # script will check revision of Atom in SVN and if there is a new version the script will
  29. # download it and create a complete debian source package and upload to launchpad as a ppa
  30.  
  31. # Newline and date in log
  32. echo ""
  33. date
  34.  
  35. # Run next line to force, even if no new svn revision
  36. #rm $REVFILE
  37.  
  38. # Check if script is already running
  39. if [ -e $TMPFILE ]; then
  40.   echo "Error: Already running?"
  41.   exit 1
  42. fi
  43.  
  44. # Check that revision variable is set
  45. if [ -z $CURRREV ]; then
  46.   echo "Error: Could not find SVN revision"
  47.   exit 1
  48. fi
  49.  
  50. # Check that revision is sane
  51. if [ ! $CURRREV -gt 0 ]; then
  52.   echo "Error: SVN revision is not greater than 0"
  53.   exit 1
  54. fi
  55.  
  56. # Set old revision, in case no file is found
  57. OLDREV=$CURRREV
  58. if [ -e $REVFILE ]; then
  59.   # If revision file exists, check current revision
  60.   OLDREV=`cat $REVFILE`
  61.   if [ "$CURRREV" -le "$OLDREV" ]; then
  62.     echo "Error: No new svn revision."
  63.     exit 1
  64.   fi
  65. fi
  66.  
  67. # Temporary during development of script, this is needed if tmp dir is kept at the end of the script
  68. rm -rf $ATOMDIR
  69.  
  70. # Now running script
  71. touch $TMPFILE
  72.  
  73. mkdir $ATOMDIR
  74.  
  75. # Export atom to get rid of .svn subfolders
  76. svn export $SVNURL $ATOMDIR/$NOSVNDIR
  77. # Export configuration folder into the exported Atom-folder
  78. svn export $SVNURLCNF $ATOMDIR/$NOSVNDIR/$CNFDIR
  79.  
  80. # Add a svn revision file, atom need the svn revision when building
  81. echo -n $CURRREV > $ATOMDIR/$NOSVNDIR/AtomSvnRev
  82.  
  83. # Change install-target for data.xml file in CMakeList.txt, not needed, done in CMakeList.txt
  84. #cat $ATOMDIR/$NOSVNDIR/CMakeLists.txt | sed -e 's/\/..\/..\/Configuration\/data.xml/\/Configuration\/data.xml/' > $ATOMDIR/$NOSVNDIR/CMakeLists.txt
  85.  
  86. # Create the debian changelog file from svn log
  87. echo "$PKGNAME ($VERSION) $DIST; urgency=low" > $ATOMDIR/$NOSVNDIR/debian/changelog
  88. echo "" >> $ATOMDIR/$NOSVNDIR/debian/changelog
  89. OLDIFS="$IFS"
  90. IFS=$'\n'
  91. REVCNT=$CURRREV
  92. # Loop through the revisions
  93. while [ $REVCNT -gt $OLDREV ]; do
  94.   # Add change entries by reading log from svn
  95.   SVNLOG=`svn log -r $REVCNT $SVNURL`
  96.   for LOGENTRY in $SVNLOG; do
  97.     if [[ ! $LOGENTRY == *--------------* ]]; then
  98.       echo "  * $LOGENTRY" >> $ATOMDIR/$NOSVNDIR/debian/changelog
  99.     fi
  100.   done
  101.   let REVCNT=REVCNT-1
  102. done
  103. IFS="$OLDIFS"
  104. echo "" >> $ATOMDIR/$NOSVNDIR/debian/changelog
  105. echo " -- $PKGMAINT  $CHLOGDATE" >> $ATOMDIR/$NOSVNDIR/debian/changelog
  106.  
  107. # Create orig tar gz
  108. cd $ATOMDIR
  109. tar -zcf $ORIGTAR $NOSVNDIR
  110.  
  111. # Create source package with debuild
  112. cd $ATOMDIR/$NOSVNDIR
  113. debuild $DEBUILDFLG
  114.  
  115. # Upload to launchpad with dput
  116. cd $ATOMDIR
  117. dput $DPUTFLG
  118. # Requires ubuntu 9.10 or newer
  119. #dput $PPA $SRCCHFILE
  120.  
  121. # Remove all temporary files
  122. #rm -rf $ATOMDIR
  123.  
  124. # Write the current svn revision to file
  125. echo -n $CURRREV > $REVFILE
  126.  
  127. cd $RUNDIR
  128.  
  129. # Remove temprary running-file
  130. rm $TMPFILE
  131.