Subversion Repositories HomeAutomation

Rev

Rev 2304 | 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=https://svn.auml.se/svn/HomeAutomation/trunk/PcSoftware/Atom1.5
  13. SVNURLCNF=https://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 Sandblad <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, libx11-6"
  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.   utopic)
  66.     DEPS="libc6 (>= 2.3.6), libgcc1 (>= 1:4.1), libboost-thread1.55.0, libboost-system1.55.0, libboost-signals1.55.0, libboost-filesystem1.55.0, libboost-date-time1.55.0, libboost-program-options1.55.0, libv8-3.14.5, libmysqlclient18"
  67.     BDEPS="debhelper (>= 7.0.50~), cmake, libc6 (>= 2.3.6), libgcc1 (>= 1:4.1), libv8-dev (>= 2.2.18), libboost-date-time1.55-dev, libboost-filesystem1.55-dev, libboost-program-options1.55-dev, libboost-signals1.55-dev, libboost-thread1.55-dev, libreadline-dev, libx11-dev (>= 2:1.3), libmysqlclient-dev"
  68.     ;;
  69.   xenial)
  70.     DEPS="libc6 (>= 2.3.6), libgcc1 (>= 1:4.1), libboost-thread1.58.0, libboost-system1.58.0, libboost-signals1.58.0, libboost-filesystem1.58.0, libboost-date-time1.58.0, libboost-program-options1.58.0, libv8-3.14.5, libmysqlclient20, libx11-6"
  71.     BDEPS="debhelper (>= 7.0.50~), cmake, libc6 (>= 2.3.6), libgcc1 (>= 1:4.1), libv8-dev (>= 2.2.18), libboost-date-time1.58-dev, libboost-filesystem1.58-dev, libboost-program-options1.58-dev, libboost-signals1.58-dev, libboost-thread1.58-dev, libreadline-dev, libx11-dev (>= 2:1.3), libmysqlclient-dev"
  72.     ;;
  73. esac
  74.  
  75. # Run script from cron every hour
  76. # script will check revision of Atom in SVN and if there is a new version the script will
  77. # download it and create a complete debian source package and upload to launchpad as a ppa
  78.  
  79. # Newline and date in log
  80. echo ""
  81. date
  82.  
  83. # Run next line to force, even if no new svn revision
  84. #rm $REVFILE
  85.  
  86. # Check if script is already running
  87. if [ -e $TMPFILE ]
  88. then
  89.   echo "Error: Already running?"
  90.   exit 1
  91. fi
  92.  
  93. # Check that revision variable is set
  94. if [ -z $CURRREV ]; then
  95.   echo "Error: Could not find SVN revision"
  96.   exit 1
  97. fi
  98.  
  99. # Check that revision is sane
  100. if [ ! $CURRREV -gt 0 ]; then
  101.   echo "Error: SVN revision is not greater than 0"
  102.   exit 1
  103. fi
  104.  
  105. # Set old revision, in case no file is found
  106. OLDREV=$CURRREV
  107. if [ -e $REVFILE ]; then
  108.   # If revision file exists, check current revision
  109.   OLDREV=`cat $REVFILE`
  110.   if [ "$CURRREV" -le "$OLDREV" ]; then
  111.     echo "Error: No new svn revision."
  112.     exit 1
  113.   fi
  114. fi
  115.  
  116. # Temporary during development of script, this is needed if tmp dir is kept at the end of the script
  117. rm -rf $ATOMDIR
  118.  
  119. # Now running script
  120. touch $TMPFILE
  121.  
  122. mkdir $ATOMDIR
  123.  
  124. echo "******** Exporting SVN ********"
  125. # Export atom to get rid of .svn subfolders
  126. svn export $SVNURL $ATOMDIR/$NOSVNDIR
  127. # Export configuration folder into the exported Atom-folder
  128. svn export $SVNURLCNF $ATOMDIR/$NOSVNDIR/$CNFDIR
  129.  
  130. echo "******** Creating debian dir ********"
  131. mkdir -p $ATOMDIR/$NOSVNDIR/debian
  132.  
  133. echo "******** Adding SVN revision file ********"
  134. # Add a svn revision file, atom need the svn revision when building
  135. echo -n $CURRREV > $ATOMDIR/$NOSVNDIR/AtomSvnRev
  136.  
  137. # Change install-target for data.xml file in CMakeList.txt, not needed, done in CMakeList.txt
  138. #cat $ATOMDIR/$NOSVNDIR/CMakeLists.txt | sed -e 's/\/..\/..\/Configuration\/data.xml/\/Configuration\/data.xml/' > $ATOMDIR/$NOSVNDIR/CMakeLists.txt
  139.  
  140. echo "******** Copying debian files ********"
  141. cp $RUNDIR/files/atom.conf $ATOMDIR/$NOSVNDIR/debian/
  142. cp $RUNDIR/files/compat $ATOMDIR/$NOSVNDIR/debian/
  143. cp $RUNDIR/files/copyright $ATOMDIR/$NOSVNDIR/debian/
  144. cp $RUNDIR/files/rules $ATOMDIR/$NOSVNDIR/debian/
  145. cp $RUNDIR/files/control $ATOMDIR/$NOSVNDIR/debian/
  146.  
  147. echo "******** Set the correct depends and build depends ********"
  148. # Set the correct depends and build depends, different for different distributions
  149. sed -i "s/^Build-Depends/Build-Depends: ${BDEPS}/g" $ATOMDIR/$NOSVNDIR/debian/control
  150. sed -i "s/^Depends/Depends: ${DEPS}/g" $ATOMDIR/$NOSVNDIR/debian/control
  151.  
  152. echo "******** Create debian changelog from SVN log ********"
  153. # Create the debian changelog file from svn log
  154. echo "$PKGNAME ($VERSION) $DIST; urgency=low" > $ATOMDIR/$NOSVNDIR/debian/changelog
  155. echo "" >> $ATOMDIR/$NOSVNDIR/debian/changelog
  156. OLDIFS="$IFS"
  157. IFS=$'\n'
  158. REVCNT=$CURRREV
  159. # Loop through the revisions
  160. while [ $REVCNT -gt $OLDREV ]; do
  161.   # Add change entries by reading log from svn
  162.   SVNLOG=`svn log -r $REVCNT $SVNURL`
  163.   for LOGENTRY in $SVNLOG; do
  164.     if [[ ! $LOGENTRY == *--------------* ]]; then
  165.       echo "  * $LOGENTRY" >> $ATOMDIR/$NOSVNDIR/debian/changelog
  166.     fi
  167.   done
  168.   let REVCNT=REVCNT-1
  169. done
  170. IFS="$OLDIFS"
  171. echo "" >> $ATOMDIR/$NOSVNDIR/debian/changelog
  172. echo " -- $PKGMAINT  $CHLOGDATE" >> $ATOMDIR/$NOSVNDIR/debian/changelog
  173.  
  174. echo "******** Create orig tar.gz ********"
  175. # Create orig tar gz
  176. cd $ATOMDIR
  177. tar -zcf $ORIGTAR $NOSVNDIR
  178.  
  179. echo "******** Create source package with debuild ********"
  180. # Create source package with debuild
  181. cd $ATOMDIR/$NOSVNDIR
  182. debuild $DEBUILDFLG
  183.  
  184. echo "******** Upload to launchpad with dput ********"
  185. # Upload to launchpad with dput
  186. cd $ATOMDIR
  187. dput $DPUTFLG
  188. # Requires ubuntu 9.10 or newer
  189. #dput $PPA $SRCCHFILE
  190.  
  191. # Remove all temporary files
  192. #rm -rf $ATOMDIR
  193.  
  194. echo "******** Write current SVN rev to file ********"
  195. # Write the current svn revision to file
  196. echo -n $CURRREV > $REVFILE
  197.  
  198. cd $RUNDIR
  199.  
  200. # Remove temprary running-file
  201. rm $TMPFILE
  202.