Subversion Repositories HomeAutomation

Rev

Rev 2293 | Rev 2303 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | SVN | RSS feed

Rev Author Line No. Line
1672 arune 1
#!/bin/bash
2
 
1965 arune 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
 
1672 arune 11
ATOMDIR=/tmp/atomppa
2015 arune 12
SVNURL=http://svn.auml.se/svn/HomeAutomation/trunk/PcSoftware/Atom1.5
13
SVNURLCNF=http://svn.auml.se/svn/HomeAutomation/trunk/Configuration
1672 arune 14
SVNDIR=AtomSvn
15
SVNDIRCNF=ConfigSvn
16
CNFDIR=Configuration
17
PPA=ppa:arune/auml-atom-daily
1676 arune 18
DEBUILDFLG="-S -sa -k7EA270B4"
19
PKGNAME=atom
2302 arune 20
PKGMAINT="Anders Sandblad <runeson@gmail.com>"
1672 arune 21
 
1965 arune 22
# Dist name from command line argument
23
DIST=$1
1672 arune 24
RUNDIR=`dirname $0`
1676 arune 25
CHLOGDATE=`date -R`
1965 arune 26
REVFILE=$RUNDIR/AtomSvnRev-$DIST
1690 arune 27
TMPFILE=/tmp/atompparunning
1672 arune 28
 
1690 arune 29
CURRREV=`svn info $SVNURL |grep '^Last Changed Rev:' | sed -e 's/^Last Changed Rev: //'`
1965 arune 30
VERSION=1.5.${CURRREV}ppa1~${DIST}
31
# Dir name of atom svn export (no svn folders)
1676 arune 32
NOSVNDIR=atom-$VERSION
1965 arune 33
# File name to use for tarball with original source, NOSVNDIR will be compressed to this file
1676 arune 34
ORIGTAR=atom_$VERSION.orig.tar.gz
1965 arune 35
# File with source changes (?)
1676 arune 36
SRCCHFILE=atom_$VERSION\_source.changes
1965 arune 37
# Dput is called with these flags
1676 arune 38
DPUTFLG="auml-atom-daily $SRCCHFILE"
1672 arune 39
 
1965 arune 40
case $DIST in
41
  oneiric)
2000 arune 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"
1965 arune 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)
2000 arune 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"
1965 arune 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
    ;;
2227 arune 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
    ;;
2293 arune 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
    ;;
2302 arune 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, libmysqlclient18"
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
    ;;
1965 arune 73
esac
74
 
1676 arune 75
# Run script from cron every hour
1672 arune 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
 
1690 arune 79
# Newline and date in log
80
echo ""
81
date
1672 arune 82
 
1690 arune 83
# Run next line to force, even if no new svn revision
84
#rm $REVFILE
1672 arune 85
 
1690 arune 86
# Check if script is already running
2293 arune 87
if [ -e $TMPFILE ]
88
then
1690 arune 89
  echo "Error: Already running?"
90
  exit 1
91
fi
92
 
1682 arune 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
 
1690 arune 105
# Set old revision, in case no file is found
106
OLDREV=$CURRREV
1672 arune 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
 
1690 arune 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
 
1672 arune 122
mkdir $ATOMDIR
123
 
2293 arune 124
echo "******** Exporting SVN ********"
1672 arune 125
# Export atom to get rid of .svn subfolders
1682 arune 126
svn export $SVNURL $ATOMDIR/$NOSVNDIR
127
# Export configuration folder into the exported Atom-folder
128
svn export $SVNURLCNF $ATOMDIR/$NOSVNDIR/$CNFDIR
1672 arune 129
 
2293 arune 130
echo "******** Creating debian dir ********"
1965 arune 131
mkdir -p $ATOMDIR/$NOSVNDIR/debian
132
 
2293 arune 133
echo "******** Adding SVN revision file ********"
1682 arune 134
# Add a svn revision file, atom need the svn revision when building
135
echo -n $CURRREV > $ATOMDIR/$NOSVNDIR/AtomSvnRev
1672 arune 136
 
1682 arune 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
 
2293 arune 140
echo "******** Copying debian files ********"
1965 arune 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
 
2293 arune 147
echo "******** Set the correct depends and build depends ********"
1965 arune 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
 
2293 arune 152
echo "******** Create debian changelog from SVN log ********"
1690 arune 153
# Create the debian changelog file from svn log
1676 arune 154
echo "$PKGNAME ($VERSION) $DIST; urgency=low" > $ATOMDIR/$NOSVNDIR/debian/changelog
155
echo "" >> $ATOMDIR/$NOSVNDIR/debian/changelog
1682 arune 156
OLDIFS="$IFS"
157
IFS=$'\n'
1690 arune 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
1682 arune 169
done
170
IFS="$OLDIFS"
1676 arune 171
echo "" >> $ATOMDIR/$NOSVNDIR/debian/changelog
172
echo " -- $PKGMAINT  $CHLOGDATE" >> $ATOMDIR/$NOSVNDIR/debian/changelog
1672 arune 173
 
2293 arune 174
echo "******** Create orig tar.gz ********"
1672 arune 175
# Create orig tar gz
1682 arune 176
cd $ATOMDIR
177
tar -zcf $ORIGTAR $NOSVNDIR
1672 arune 178
 
2293 arune 179
echo "******** Create source package with debuild ********"
1672 arune 180
# Create source package with debuild
1690 arune 181
cd $ATOMDIR/$NOSVNDIR
182
debuild $DEBUILDFLG
1672 arune 183
 
2293 arune 184
echo "******** Upload to launchpad with dput ********"
1676 arune 185
# Upload to launchpad with dput
1690 arune 186
cd $ATOMDIR
187
dput $DPUTFLG
1676 arune 188
# Requires ubuntu 9.10 or newer
1672 arune 189
#dput $PPA $SRCCHFILE
190
 
1676 arune 191
# Remove all temporary files
1672 arune 192
#rm -rf $ATOMDIR
193
 
2293 arune 194
echo "******** Write current SVN rev to file ********"
1672 arune 195
# Write the current svn revision to file
1682 arune 196
echo -n $CURRREV > $REVFILE
1676 arune 197
 
198
cd $RUNDIR
1690 arune 199
 
200
# Remove temprary running-file
201
rm $TMPFILE