Subversion Repositories HomeAutomation

Rev

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

  1. #!/bin/bash
  2.  
  3. if [ $# -lt 1 ]
  4. then
  5.   echo "Error: need to run script with ubuntu releasename as argument"
  6.   exit 1
  7. fi
  8.  
  9. #exit 1
  10.  
  11. ATOMDIR=/tmp/atomppa
  12. SVNURL=http://svn.auml.se/svn/HomeAutomation/trunk/PcSoftware/Atom1.5
  13. SVNURLCNF=http://svn.auml.se/svn/HomeAutomation/trunk/Configuration
  14. SVNDIR=AtomSvn
  15. SVNDIRCNF=ConfigSvn
  16. CNFDIR=Configuration
  17. PPA=ppa:arune/auml-atom-daily
  18. DEBUILDFLG="-S -sa -k7EA270B4"
  19. PKGNAME=atom
  20. PKGMAINT="Anders Runeson <runeson@gmail.com>"
  21.  
  22. # Dist name from command line argument
  23. DIST=$1
  24. RUNDIR=`dirname $0`
  25. CHLOGDATE=`date -R`
  26. REVFILE=$RUNDIR/AtomSvnRev-$DIST
  27. TMPFILE=/tmp/atompparunning
  28.  
  29. CURRREV=`svn info $SVNURL |grep '^Last Changed Rev:' | sed -e 's/^Last Changed Rev: //'`
  30. VERSION=1.5.${CURRREV}ppa1~${DIST}
  31. # Dir name of atom svn export (no svn folders)
  32. NOSVNDIR=atom-$VERSION
  33. # File name to use for tarball with original source, NOSVNDIR will be compressed to this file
  34. ORIGTAR=atom_$VERSION.orig.tar.gz
  35. # File with source changes (?)
  36. SRCCHFILE=atom_$VERSION\_source.changes
  37. # Dput is called with these flags
  38. DPUTFLG="auml-atom-daily $SRCCHFILE"
  39.  
  40. case $DIST in
  41.   oneiric)
  42.     DEPS="libc6 (>= 2.3.6), libgcc1 (>= 1:4.1), libboost-thread1.46.1, libboost-system1.46.1, libboost-signals1.46.1, libboost-filesystem1.46.1, libboost-date-time1.46.1, libboost-program-options1.46.1, libv8-3.1.8.22, libmysqlclient16"
  43.     BDEPS="debhelper (>= 7.0.50~), cmake, libc6 (>= 2.3.6), libgcc1 (>= 1:4.1), libv8-dev (>= 2.2.18), libboost-date-time1.46-dev, libboost-filesystem1.46-dev, libboost-program-options1.46-dev, libboost-signals1.46-dev, libboost-thread1.46-dev, libreadline-dev, libx11-dev (>= 2:1.3), libmysqlclient-dev"
  44.     ;;
  45.   precise)
  46.     DEPS="libc6 (>= 2.3.6), libgcc1 (>= 1:4.1), libboost-thread1.48.0, libboost-system1.48.0, libboost-signals1.48.0, libboost-filesystem1.48.0, libboost-date-time1.48.0, libboost-program-options1.48.0, libv8-3.7.12.22, libmysqlclient18"
  47.     BDEPS="debhelper (>= 7.0.50~), cmake, libc6 (>= 2.3.6), libgcc1 (>= 1:4.1), libv8-dev (>= 2.2.18), libboost-date-time1.48-dev, libboost-filesystem1.48-dev, libboost-program-options1.48-dev, libboost-signals1.48-dev, libboost-thread1.48-dev, libreadline-dev, libx11-dev (>= 2:1.3), libmysqlclient-dev"
  48.     ;;
  49.   quantal)
  50.     DEPS="libc6 (>= 2.3.6), libgcc1 (>= 1:4.1), libboost-thread1.49.0, libboost-system1.49.0, libboost-signals1.49.0, libboost-filesystem1.49.0, libboost-date-time1.49.0, libboost-program-options1.49.0, libv8-3.8.9.20, libmysqlclient18"
  51.     BDEPS="debhelper (>= 7.0.50~), cmake, libc6 (>= 2.3.6), libgcc1 (>= 1:4.1), libv8-dev (>= 2.2.18), libboost-date-time1.49-dev, libboost-filesystem1.49-dev, libboost-program-options1.49-dev, libboost-signals1.49-dev, libboost-thread1.49-dev, libreadline-dev, libx11-dev (>= 2:1.3), libmysqlclient-dev"
  52.     ;;
  53.   raring)
  54.     DEPS="libc6 (>= 2.3.6), libgcc1 (>= 1:4.1), libboost-thread1.53.0, libboost-system1.53.0, libboost-signals1.53.0, libboost-filesystem1.53.0, libboost-date-time1.53.0, libboost-program-options1.53.0, libv8-3.8.9.20, libmysqlclient18"
  55.     BDEPS="debhelper (>= 7.0.50~), cmake, libc6 (>= 2.3.6), libgcc1 (>= 1:4.1), libv8-dev (>= 2.2.18), libboost-date-time1.53-dev, libboost-filesystem1.53-dev, libboost-program-options1.53-dev, libboost-signals1.53-dev, libboost-thread1.53-dev, libreadline-dev, libx11-dev (>= 2:1.3), libmysqlclient-dev"
  56.     ;;
  57.   saucy)
  58.     DEPS="libc6 (>= 2.3.6), libgcc1 (>= 1:4.1), libboost-thread1.54.0, libboost-system1.54.0, libboost-signals1.54.0, libboost-filesystem1.54.0, libboost-date-time1.54.0, libboost-program-options1.54.0, libv8-3.14.5, libmysqlclient18"
  59.     BDEPS="debhelper (>= 7.0.50~), cmake, libc6 (>= 2.3.6), libgcc1 (>= 1:4.1), libv8-dev (>= 2.2.18), libboost-date-time1.54-dev, libboost-filesystem1.54-dev, libboost-program-options1.54-dev, libboost-signals1.54-dev, libboost-thread1.54-dev, libreadline-dev, libx11-dev (>= 2:1.3), libmysqlclient-dev"
  60.     ;;
  61.   trusty)
  62.     DEPS="libc6 (>= 2.3.6), libgcc1 (>= 1:4.1), libboost-thread1.54.0, libboost-system1.54.0, libboost-signals1.54.0, libboost-filesystem1.54.0, libboost-date-time1.54.0, libboost-program-options1.54.0, libv8-3.14.5, libmysqlclient18"
  63.     BDEPS="debhelper (>= 7.0.50~), cmake, libc6 (>= 2.3.6), libgcc1 (>= 1:4.1), libv8-dev (>= 2.2.18), libboost-date-time1.54-dev, libboost-filesystem1.54-dev, libboost-program-options1.54-dev, libboost-signals1.54-dev, libboost-thread1.54-dev, libreadline-dev, libx11-dev (>= 2:1.3), libmysqlclient-dev"
  64.     ;;
  65. esac
  66.  
  67. # Run script from cron every hour
  68. # script will check revision of Atom in SVN and if there is a new version the script will
  69. # download it and create a complete debian source package and upload to launchpad as a ppa
  70.  
  71. # Newline and date in log
  72. echo ""
  73. date
  74.  
  75. # Run next line to force, even if no new svn revision
  76. #rm $REVFILE
  77.  
  78. # Check if script is already running
  79. if [ -e $TMPFILE ]
  80. then
  81.   echo "Error: Already running?"
  82.   exit 1
  83. fi
  84.  
  85. # Check that revision variable is set
  86. if [ -z $CURRREV ]; then
  87.   echo "Error: Could not find SVN revision"
  88.   exit 1
  89. fi
  90.  
  91. # Check that revision is sane
  92. if [ ! $CURRREV -gt 0 ]; then
  93.   echo "Error: SVN revision is not greater than 0"
  94.   exit 1
  95. fi
  96.  
  97. # Set old revision, in case no file is found
  98. OLDREV=$CURRREV
  99. if [ -e $REVFILE ]; then
  100.   # If revision file exists, check current revision
  101.   OLDREV=`cat $REVFILE`
  102.   if [ "$CURRREV" -le "$OLDREV" ]; then
  103.     echo "Error: No new svn revision."
  104.     exit 1
  105.   fi
  106. fi
  107.  
  108. # Temporary during development of script, this is needed if tmp dir is kept at the end of the script
  109. rm -rf $ATOMDIR
  110.  
  111. # Now running script
  112. touch $TMPFILE
  113.  
  114. mkdir $ATOMDIR
  115.  
  116. echo "******** Exporting SVN ********"
  117. # Export atom to get rid of .svn subfolders
  118. svn export $SVNURL $ATOMDIR/$NOSVNDIR
  119. # Export configuration folder into the exported Atom-folder
  120. svn export $SVNURLCNF $ATOMDIR/$NOSVNDIR/$CNFDIR
  121.  
  122. echo "******** Creating debian dir ********"
  123. mkdir -p $ATOMDIR/$NOSVNDIR/debian
  124.  
  125. echo "******** Adding SVN revision file ********"
  126. # Add a svn revision file, atom need the svn revision when building
  127. echo -n $CURRREV > $ATOMDIR/$NOSVNDIR/AtomSvnRev
  128.  
  129. # Change install-target for data.xml file in CMakeList.txt, not needed, done in CMakeList.txt
  130. #cat $ATOMDIR/$NOSVNDIR/CMakeLists.txt | sed -e 's/\/..\/..\/Configuration\/data.xml/\/Configuration\/data.xml/' > $ATOMDIR/$NOSVNDIR/CMakeLists.txt
  131.  
  132. echo "******** Copying debian files ********"
  133. cp $RUNDIR/files/atom.conf $ATOMDIR/$NOSVNDIR/debian/
  134. cp $RUNDIR/files/compat $ATOMDIR/$NOSVNDIR/debian/
  135. cp $RUNDIR/files/copyright $ATOMDIR/$NOSVNDIR/debian/
  136. cp $RUNDIR/files/rules $ATOMDIR/$NOSVNDIR/debian/
  137. cp $RUNDIR/files/control $ATOMDIR/$NOSVNDIR/debian/
  138.  
  139. echo "******** Set the correct depends and build depends ********"
  140. # Set the correct depends and build depends, different for different distributions
  141. sed -i "s/^Build-Depends/Build-Depends: ${BDEPS}/g" $ATOMDIR/$NOSVNDIR/debian/control
  142. sed -i "s/^Depends/Depends: ${DEPS}/g" $ATOMDIR/$NOSVNDIR/debian/control
  143.  
  144. echo "******** Create debian changelog from SVN log ********"
  145. # Create the debian changelog file from svn log
  146. echo "$PKGNAME ($VERSION) $DIST; urgency=low" > $ATOMDIR/$NOSVNDIR/debian/changelog
  147. echo "" >> $ATOMDIR/$NOSVNDIR/debian/changelog
  148. OLDIFS="$IFS"
  149. IFS=$'\n'
  150. REVCNT=$CURRREV
  151. # Loop through the revisions
  152. while [ $REVCNT -gt $OLDREV ]; do
  153.   # Add change entries by reading log from svn
  154.   SVNLOG=`svn log -r $REVCNT $SVNURL`
  155.   for LOGENTRY in $SVNLOG; do
  156.     if [[ ! $LOGENTRY == *--------------* ]]; then
  157.       echo "  * $LOGENTRY" >> $ATOMDIR/$NOSVNDIR/debian/changelog
  158.     fi
  159.   done
  160.   let REVCNT=REVCNT-1
  161. done
  162. IFS="$OLDIFS"
  163. echo "" >> $ATOMDIR/$NOSVNDIR/debian/changelog
  164. echo " -- $PKGMAINT  $CHLOGDATE" >> $ATOMDIR/$NOSVNDIR/debian/changelog
  165.  
  166. echo "******** Create orig tar.gz ********"
  167. # Create orig tar gz
  168. cd $ATOMDIR
  169. tar -zcf $ORIGTAR $NOSVNDIR
  170.  
  171. echo "******** Create source package with debuild ********"
  172. # Create source package with debuild
  173. cd $ATOMDIR/$NOSVNDIR
  174. debuild $DEBUILDFLG
  175.  
  176. echo "******** Upload to launchpad with dput ********"
  177. # Upload to launchpad with dput
  178. cd $ATOMDIR
  179. dput $DPUTFLG
  180. # Requires ubuntu 9.10 or newer
  181. #dput $PPA $SRCCHFILE
  182.  
  183. # Remove all temporary files
  184. #rm -rf $ATOMDIR
  185.  
  186. echo "******** Write current SVN rev to file ********"
  187. # Write the current svn revision to file
  188. echo -n $CURRREV > $REVFILE
  189.  
  190. cd $RUNDIR
  191.  
  192. # Remove temprary running-file
  193. rm $TMPFILE
  194.