Add a font path for download fonts
[platform/upstream/fontconfig.git] / new-version.sh
1 #!/bin/sh
2 # fontconfig/new-version.sh
3 #
4 # Copyright © 2000 Keith Packard
5 #
6 # Permission to use, copy, modify, distribute, and sell this software and its
7 # documentation for any purpose is hereby granted without fee, provided that
8 # the above copyright notice appear in all copies and that both that
9 # copyright notice and this permission notice appear in supporting
10 # documentation, and that the name of the author(s) not be used in
11 # advertising or publicity pertaining to distribution of the software without
12 # specific, written prior permission.  The authors make no
13 # representations about the suitability of this software for any purpose.  It
14 # is provided "as is" without express or implied warranty.
15 #
16 # THE AUTHOR(S) DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
17 # INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
18 # EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY SPECIAL, INDIRECT OR
19 # CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
20 # DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
21 # TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
22 # PERFORMANCE OF THIS SOFTWARE.
23
24 if [ "x`git status -s -uno`" != "x" ]; then
25         echo 'Uncommited changes in repository' 1>&2
26         exit 1
27 fi
28
29 version="$1"
30 case "$version" in
31 2.[0-9.]*)
32         ;;
33 *)
34         echo 'Invalid version number:' "$version" 1>&2
35         exit 1
36         ;;
37 esac
38
39 eval `echo $version | 
40         awk -F. '{ printf ("major=%d\nminor=%d\nrevision=%d\n",
41                            $1, $2, $3); }'`
42                            
43 # Update the version numbers
44
45 sed -i configure.ac -e "/^AC_INIT(/s/2\.[0-9.]*/$version/"
46
47 sed -i fontconfig/fontconfig.h \
48         -e "/^#define FC_MAJOR/s/[0-9][0-9]*/$major/" \
49         -e "/^#define FC_MINOR/s/[0-9][0-9]*/$minor/" \
50         -e "/^#define FC_REVISION/s/[0-9][0-9]*/$revision/"
51
52 #
53 # Compute pretty form of new version number
54 #
55 version_note=`echo $version | awk -F. '{ 
56         if ($3 > 90) 
57                 printf ("%d.%d.%d (%d.%d RC%d)\n",
58                         $1, $2, $3, $1, $2 + 1, $3 - 90);
59         else if ($3 == 0)
60                 printf ("%d.%d\n", $1, $2);
61         else
62                 printf ("%d.%d.%d\n", $1, $2, $3); }'`
63                 
64 #
65 # Find previous version in README
66 #
67 last_note=`grep '^2\.[0-9.]*' README |
68         head -1 |
69         sed 's/ (2\.[0-9]* RC[0-9]*)//'`
70 case $last_note in
71 2.*.*)
72         last=$last_note
73         ;;
74 2.*)
75         last="$last_note.0"
76         ;;
77 *)
78         echo 'cannot find previous changelog' 1>&2
79         exit 1
80 esac
81
82 #
83 # Format the current date for the README header
84 #
85 date=`date '+%Y-%m-%d'`
86
87 #
88 # Update the readme file
89
90 if [ $version != $last ]; then
91         #
92         # header
93         #
94         (sed '/^2\.[0-9.]*/,$d' README | 
95                 sed -r -e "s/Version.*/Version $version_note/" \
96                     -e "s/[0-9]{4}\-[0-9]{2}\-[0-9]{2}$/$date/" | awk '
97                     /^[ \t]/ {
98                                 gsub ("^[ \t]*", "");
99                                 gsub ("[ \t]*$", "");
100                                 space=(70 - length) / 2;
101                                 for (i = 0; i < space; i++)
102                                         printf (" ");
103                                 print 
104                                 next
105                               } 
106                               { 
107                                 print 
108                               }'
109         
110         #
111         # changelog
112         #
113         
114         echo $version_note
115         echo
116         git log --pretty=short $last.. | git shortlog | cat
117         
118         #
119         # previous changelogs
120         #
121         
122         sed -n '/^2\.[0-9.]*/,$p' README) > README.tmp ||
123                 (echo "README update failed"; exit 1)
124         
125         mv README.tmp README
126 fi
127
128 $test git commit -m"Bump version to $version" \
129         configure.ac \
130         fontconfig/fontconfig.h \
131         README
132
133 # tag the tree
134 $test git tag -s -m "Version $version" $version
135
136 # Make distributed change log
137
138 git log --stat $last.. > ChangeLog-$version
139