e8d49b1d6b921fd0da4140ce6973f2e970b70e4e
[yaffs-website] / vendor / lsolesen / pel / make-release.sh
1 #!/bin/sh
2 #
3 #  PEL: PHP Exif Library.  A library with support for reading and
4 #  writing all Exif headers in JPEG and TIFF images using PHP.
5 #
6 #  Copyright (C) 2004, 2005, 2006  Martin Geisler.
7 #
8 #  This program is free software; you can redistribute it and/or modify
9 #  it under the terms of the GNU General Public License as published by
10 #  the Free Software Foundation; either version 2 of the License, or
11 #  (at your option) any later version.
12 #
13 #  This program is distributed in the hope that it will be useful,
14 #  but WITHOUT ANY WARRANTY; without even the implied warranty of
15 #  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16 #  GNU General Public License for more details.
17 #
18 #  You should have received a copy of the GNU General Public License
19 #  along with this program in the file COPYING; if not, write to the
20 #  Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
21 #  Boston, MA 02110-1301 USA
22
23 # $Id$
24
25
26 # This small script retrieves the latest version of PEL, packs it up
27 # into two tarballs (gz and bz2) and a zip file, and then asks for
28 # permission to upload these files to SourceForge.  The generated
29 # files are placed in the current directory.
30
31
32 # Fix the locale to C, e.g. untranslated.
33 export LC_ALL=C
34
35
36 # Paths used below
37 BUILD_BASE="build-base.$$"
38 PHPDOC_PATH='phpdoc'
39
40
41
42 # Create the base directory for the build or bail out if it already
43 # exists
44 if [[ -d $BUILD_BASE ]]; then
45     echo "The build directory $BUILD_BASE already exists!"
46     exit
47 else
48     echo "Building the release in $BUILD_BASE"
49     mkdir $BUILD_BASE
50 fi
51
52 cd $BUILD_BASE
53
54
55 echo -n "Exporting trunk from SourceForge... "
56 svn export https://pel.svn.sourceforge.net/svnroot/pel/trunk pel || exit
57 echo "done."
58
59 # Grab version number from ChangeLog...
60 PREFIX='PEL Version'
61 MIDDLE='[0-9]+\.[0-9]+(\.[0-9]+(-[0-9a-z]+)?)?'
62 DATE=$(date -u '+%B %-d.. %Y')
63 REGEXP="$PREFIX $MIDDLE  $DATE"
64
65 OFFSET=$(grep -n -E -m 1 "$REGEXP" pel/NEWS | cut -d ':' -f 1)
66 if [[ -z $OFFSET ]]; then
67     echo "Found no version from today in NEWS, creating SVN version."
68     VERSION='svn' #$(date -u '+svn-%Y-%m-%d')
69 else
70     echo "Offset: $OFFSET"
71     VERSION=$(head -n $OFFSET pel/NEWS | tail -n 1 | cut -d ' ' -f 3)
72     echo "Found match for today in NEWS: $VERSION."
73
74     LINE=$(head -n $OFFSET pel/NEWS | tail -n 1)
75     STARS=$(head -n $((OFFSET+1)) pel/NEWS | tail -n 1)
76     if [[ ${#LINE} != ${#STARS} ]]; then
77         echo "Aborting because of bad underlining:"
78         echo
79         echo "$LINE"
80         echo "$STARS"
81         exit
82     fi
83 fi
84
85 mv pel pel-$VERSION
86
87 if [[ $VERSION == "svn" ]]; then
88     echo "Skipping tagging since this is a SVN snapshot."
89 else
90     read -p "Create SVN tag? [y/N] " -n 1
91     echo
92
93     if [[ $REPLY == "y" ]]; then
94         echo -n "Creating SVN tag 'pel-$VERSION'... "
95         svn copy \
96             https://pel.svn.sourceforge.net/svnroot/pel/trunk \
97             https://pel.svn.sourceforge.net/svnroot/pel/tags/pel-$VERSION \
98             -m "Tagging PEL version $VERSION."
99         echo "done."
100     else
101         echo "Skipping tagging by user request."
102     fi
103 fi
104
105 cd pel-$VERSION
106
107 # Generate the ChangeLog, prefixed with a standard header
108 echo -n "Generating SVN ChangeLog... "
109 echo "ChangeLog file for PEL: PHP Exif Library.  A library with support for
110 reading and writing Exif headers in JPEG and TIFF images using PHP.
111
112 Copyright (C) 2004, 2005, 2006  Martin Geisler.
113 Licensed under the GNU GPL, see COPYING for details.
114
115 " > ChangeLog
116 svn2cl --include-rev --group-by-day --separate-daylogs  \
117     --reparagraph --authors=authors.xml --stdout        \
118     https://pel.svn.sourceforge.net/svnroot/pel/trunk/ >> ChangeLog || exit
119 echo "done."
120
121
122 #echo -n "Marking releases in ChangeLog... "
123 #sed -re '/./{H;$!d;};x;/tags/s|tags/pel-([0-9]+\.[0-9]+).*|PEL Version \1|'
124 #echo "done."
125
126
127 # Generate the binary MO files
128 ./update-locales.sh
129
130
131 # Generate the API documentation
132 ./run-phpdoc.sh $VERSION $PHPDOC_PATH
133
134
135 # Cleanup files that aren't needed in the released package
136 rm make-release.sh authors.xml
137 rm -r tutorials
138
139
140 # Add anchors and headers to the HTML ChangeLog so that each release
141 # notices can link back to it
142
143 #sed -i -re 's|^[0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}  tag release-([0-9])_([0-9])$|</pre>\n\n<div align="center"><h2 id="v\1.\2">PEL Version \1.\2</h2></div>\n\n<pre>\n|g' doc/ric_ChangeLog.html
144
145 # Leave the pel-$VERSION directory
146 cd ..
147
148 mv pel-$VERSION/test/image-tests image-tests
149
150 echo -n "Creating pel-image-tests-$VERSION.tar.gz... "
151 tar -cz image-tests -f pel-image-tests-$VERSION.tar.gz
152 echo "done."
153
154 echo -n "Creating pel-image-tests-$VERSION.tar.bz2... "
155 tar -cj image-tests -f pel-image-tests-$VERSION.tar.bz2
156 echo "done."
157
158 echo -n "Creating pel-images-$VERSION.zip... "
159 zip -qr pel-image-tests-$VERSION.zip image-tests
160 echo "done."
161
162 echo -n "Creating pel-$VERSION.tar.gz... "
163 tar -cz pel-$VERSION -f pel-$VERSION.tar.gz
164 echo "done."
165
166 echo -n "Creating pel-$VERSION.tar.bz2... "
167 tar -cj pel-$VERSION -f pel-$VERSION.tar.bz2
168 echo "done."
169
170 echo -n "Creating pel-$VERSION.zip... "
171 zip -qr pel-$VERSION.zip pel-$VERSION
172 echo "done."
173
174
175 # Upload the compressed files and API documentation, if allowed
176 if [[ $VERSION != "svn" && ( $REPLY == "y" || $REPLY == "Y" ) ]]; then
177     echo -n "Uploading files to SourceForge for release... "
178     ncftpput upload.sourceforge.net /incoming \
179         pel-$VERSION.tar.gz                   \
180         pel-$VERSION.tar.bz2                  \
181         pel-$VERSION.zip                      \
182         pel-image-tests-$VERSION.tar.gz       \
183         pel-image-tests-$VERSION.tar.bz2      \
184         pel-image-tests-$VERSION.zip
185     echo "done."
186
187     echo -n "Uploading API documentation to SourceForge... "
188     scp -C -q -r pel-$VERSION/doc \
189         shell.sourceforge.net:/home/groups/p/pe/pel/htdocs
190     echo "done."
191 else
192     echo "Skipping upload."
193 fi
194
195 echo "All done. The $BUILD_BASE directory can be removed at any time."
196
197 # The End --- PEL has now been packaged (and maybe even released)!