* update the scripts
[modest] / scripts / build-packages
1 #!/bin/sh
2 #Time-stamp: <2007-05-19 20:12:52 (djcb)>
3
4 # Copyright (c) 2007, Nokia Corporation
5 # All rights reserved.
6 #
7 # Redistribution and use in source and binary forms, with or without
8 # modification, are permitted provided that the following conditions are
9 # met:
10 #
11 # * Redistributions of source code must retain the above copyright
12 #   notice, this list of conditions and the following disclaimer.
13 # * Redistributions in binary form must reproduce the above copyright
14 #   notice, this list of conditions and the following disclaimer in the
15 #   documentation and/or other materials provided with the distribution.
16 # * Neither the name of the Nokia Corporation nor the names of its
17 #   contributors may be used to endorse or promote products derived from
18 #   this software without specific prior written permission.
19 #
20 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
21 # IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
22 # TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
23 # PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
24 # OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
25 # EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
26 # PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
27 # PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
28 # LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
29 # NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
30 # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 #
32
33 #
34 # This is a hackish script to build tinymail/modest packages.
35 #
36 # It must be run *outside* scratchbox. You need to make sure that
37 # the paths below are valid both inside and outside scratchbox.
38 # You can use symlinks to do so.
39 # You must also create the packages/ directory inside the src/ directory.
40 # You will probably also need to correct the SCRATCHBOX variable.
41 #
42
43 #
44 # config
45 #
46
47 # Change these to the actual paths to source code of these packages,
48 # in scratchbox.
49 # Use a symlink to create the same path outside of scratchbox. For instance:
50 #  ln -s /scratchbox/users/murrayc/home/murrayc/src /home/murrayc/src
51 #
52 # You probably don't have your modest and tinymail packages at the same level, 
53 # as required by this script, so you may want to create some symlinks inside 
54 # src/, such as:
55 #  ln -s /scratchbox/users/murrayc/home/murrayc/svn/modest-private/modest-email /home/murrayc/src/modest-email
56 #  ln -s /scratchbox/users/murrayc/home/murrayc/svn/ /home/murrayc/src/tinymail
57 #
58 # On Maemo, you will also need to make some changes to tinymail's debian files:
59 # In tinymail/debian
60 # you should:
61 #  cp control.maemo control
62 #  cp rules.maemo rules
63 # (I think the script should instead just do this on every run. murrayc)
64
65 TINYMAIL_PATH="$HOME/src/tinymail"
66 MODEST_PATH="$HOME/src/modest-email/modest/trunk"
67 MAEMO_PROVIDERS_DATA_PATH="$HOME/src/modest-email/maemo-providers-data/"
68
69 # the packager
70 PACKAGER="Dirk-Jan C. Binnema <dirk-jan.binnema@nokia.com>"
71
72 # path to the scratchbox executable
73 # On most systems this will actually be 
74 # SCRATCHBOX="/usr/bin/scratchbox"
75 SCRATCHBOX="/chroot/usr/bin/scratchbox"
76
77 # path where the package files end up
78 PACKAGE_PATH="$HOME/src/packages"
79 ###################################################
80
81 NOW=`date -R`
82
83 echo "*** Building Tinymail/Modest packages"
84 echo "*** Packager: $PACKAGER"
85 echo "*** Time    : ${NOW}"
86 echo
87
88 # where is scratchbox
89 if test -x $SCRATCHBOX; then
90     echo "+ found scratchbox ($SCRATCHBOX)"
91 else
92     echo "- cannot find find scratchbox"
93     exit 1
94 fi
95
96 # checking paths
97 echo 
98 echo "*** checking paths"
99 for p in "$TINYMAIL_PATH" "$MODEST_PATH" "$MAEMO_PROVIDERS_DATA_PATH" "$PACKAGE_PATH"; do
100     if test -d $p; then
101         echo "+ found '$p'"
102     else
103         echo "- cannot find '$p'"
104         exit 1
105     fi
106     
107     if $SCRATCHBOX "test -d $p"; then
108         echo "+ found $p inside scratchbox environment"
109     else
110         echo "- cannot find $p inside scratchbox"
111         exit 1
112     fi
113 done
114 echo
115
116 # check svn version; this needs to happen outside scratchbox, because
117 # the scratcbox svn is too old
118 cd $TINYMAIL_PATH
119 TINYMAIL_REVISION="`svn info | grep '^Revision:' | sed 's/Revision: //'`"
120 echo "* tinymail revision: $TINYMAIL_REVISION"
121
122 cd $MAEMO_PROVIDERS_DATA_PATH
123 MAEMO_PROVIDERS_DATA_REVISION="`svn info | grep '^Revision:' | sed 's/Revision: //'`"
124 echo "* maemo-providers-data revision: $MAEMO_PROVIDERS_DATA_REVISION"
125
126 cd $MODEST_PATH
127 MODEST_REVISION="`svn info | grep '^Revision:' | sed 's/Revision: //'`"
128 echo "* modest revision: $MODEST_REVISION"
129
130 echo 
131
132 # build tinymail
133 if test -n "`ls $PACKAGE_PATH/*tinymail*${TINYMAIL_REVISION}*.deb`"; then
134     echo "* tinymail seems already built, skipping (but still installing pkgs)"
135     $SCRATCHBOX "fakeroot dpkg -i ${PACKAGE_PATH}/*${TINYMAIL_REVISION}*.deb"
136 else
137     cd $TINYMAIL_PATH
138     test -e debian/rules   || cp debian/rules.maemo debian/rules
139     test -e debian/control || cp debian/control.maemo debian/control
140     mv -f debian/changelog debian/changelog.bak
141     cat > debian/changelog <<EOF
142 tinymail (1.0-svn${TINYMAIL_REVISION}) unstable; urgency=low
143
144   * Package subversion revision svn${TINYMAIL_REVISION}
145
146  -- ${PACKAGER}  ${NOW}
147 EOF
148     echo "*** building tinymail"
149     $SCRATCHBOX -d "$TINYMAIL_PATH" "dpkg-buildpackage -rfakeroot -uc -us -sa -D" || {
150         echo "error building tinymail"
151         exit 1
152     }
153     mv -f debian/changelog.bak debian/changelog
154     cd ..
155     $SCRATCHBOX "mv ${TINYMAIL_PATH}/../*${TINYMAIL_REVISION}* $PACKAGE_PATH"
156     $SCRATCHBOX "fakeroot dpkg -i ${PACKAGE_PATH}/*${TINYMAIL_REVISION}*.deb"
157 fi
158
159
160
161
162 # build maemo-providers-data
163 if test -n "`ls $PACKAGE_PATH/*providers*${MAEMO_PROVIDERS_DATA_REVISION}*.deb`"; then
164     echo "* maemo-providers-data seems already built, skipping (but still installing pkgs)"
165     $SCRATCHBOX "fakeroot dpkg -i ${PACKAGE_PATH}/*${MAEMO_PROVIDERS_DATA_REVISION}*.deb"
166 else
167     cd $MAEMO_PROVIDERS_DATA_PATH
168     mv -f debian/changelog debian/changelog.bak
169     cat > debian/changelog <<EOF
170 maemo-providers-data (1.0-svn${MAEMO_PROVIDERS_DATA_REVISION}) unstable; urgency=low
171
172   * Package subversion revision svn${MAEMO_PROVIDERS_DATA_REVISION}
173
174  -- ${PACKAGER}  ${NOW}
175 EOF
176     echo "*** building maemo-providers-data"
177     $SCRATCHBOX -d "$MAEMO_PROVIDERS_DATA_PATH" "dpkg-buildpackage -rfakeroot -uc -us -sa -D" || {
178         echo "failed to build maemo-providers-data"
179         exit 1
180     }
181     mv -f debian/changelog.bak debian/changelog
182     $SCRATCHBOX "mv ${MAEMO_PROVIDERS_DATA_PATH}/../*${MAEMO_PROVIDERS_DATA_REVISION}* $PACKAGE_PATH"
183     $SCRATCHBOX "fakeroot dpkg -i ${PACKAGE_PATH}/*${MAEMO_PROVIDERS_DATA_REVISION}*.deb"
184 fi
185  
186
187
188    
189 # build modest
190 if test -n "`ls $PACKAGE_PATH/*modest_*${MODEST_REVISION}*.deb`"; then
191     echo "* modest seems already built, skipping (but still installing pkgs)"
192     $SCRATCHBOX "fakeroot dpkg -i ${PACKAGE_PATH}/*${MODEST_REVISION}*.deb"
193 else
194     cd $MODEST_PATH
195     test -e debian/control || ( cd debian; cp control-maemo0 control; cd .. )
196     mv -f debian/changelog debian/changelog.bak
197     cat > debian/changelog <<EOF
198 modest (1.0-svn${MODEST_REVISION}) unstable; urgency=low
199
200   * Package subversion revision svn${MODEST_REVISION}
201
202  -- ${PACKAGER}  ${NOW}
203 EOF
204     echo "*** building modest"
205     $SCRATCHBOX -d "$MODEST_PATH" "dpkg-buildpackage -rfakeroot -uc -us -sa -D" || {
206         echo "failed to build modest"
207         exit 1
208     }
209     mv -f debian/changelog.bak debian/changelog
210     cd ..
211     $SCRATCHBOX "mv ${MODEST_PATH}/../*${MODEST_REVISION}* $PACKAGE_PATH"
212     $SCRATCHBOX "fakeroot dpkg -i ${PACKAGE_PATH}/*${MODEST_REVISION}*.deb"
213 fi    
214
215 echo "*** built packages, now building Packages.gz"
216 $SCRATCHBOX -d "${PACKAGE_PATH}" "dpkg-scanpackages . /dev/null | gzip -9c > ${PACKAGE_PATH}/Packages.gz"
217
218
219 #
220 # echo... and ftp them...
221 #
222
223 echo "*** done! now, check $PACKAGE_PATH to find your packages"
224 cd $PACKAGE_PATH