Fix inversion between Tinos and Cousine in the comment
[platform/upstream/fontconfig.git] / new-version.sh
1 #!/bin/sh
2
3 if [ "x`git status -s -uno`" != "x" ]; then
4         echo 'Uncommited changes in repository' 1>&2
5         exit 1
6 fi
7
8 version="$1"
9 case "$version" in
10 2.[0-9.]*)
11         ;;
12 *)
13         echo 'Invalid version number:' "$version" 1>&2
14         exit 1
15         ;;
16 esac
17
18 eval `echo $version | 
19         awk -F. '{ printf ("major=%d\nminor=%d\nrevision=%d\n",
20                            $1, $2, $3); }'`
21                            
22 # Update the version numbers
23
24 sed -i configure.ac -e "/^AC_INIT(/s/2\.[0-9.]*/$version/"
25
26 sed -i fontconfig/fontconfig.h \
27         -e "/^#define FC_MAJOR/s/[0-9][0-9]*/$major/" \
28         -e "/^#define FC_MINOR/s/[0-9][0-9]*/$minor/" \
29         -e "/^#define FC_REVISION/s/[0-9][0-9]*/$revision/"
30
31 #
32 # Compute pretty form of new version number
33 #
34 version_note=`echo $version | awk -F. '{ 
35         if ($3 > 90) 
36                 printf ("%d.%d.%d (%d.%d RC%d)\n",
37                         $1, $2, $3, $1, $2 + 1, $3 - 90);
38         else if ($3 == 0)
39                 printf ("%d.%d\n", $1, $2);
40         else
41                 printf ("%d.%d.%d\n", $1, $2, $3); }'`
42                 
43 #
44 # Find previous version in README
45 #
46 last_note=`grep '^2\.[0-9.]*' README |
47         head -1 |
48         sed 's/ (2\.[0-9]* RC[0-9]*)//'`
49 case $last_note in
50 2.*.*)
51         last=$last_note
52         ;;
53 2.*)
54         last="$last_note.0"
55         ;;
56 *)
57         echo 'cannot find previous changelog' 1>&2
58         exit 1
59 esac
60
61 #
62 # Format the current date for the README header
63 #
64 date=`date '+%Y-%m-%d'`
65
66 #
67 # Update the readme file
68
69 if [ $version != $last ]; then
70         #
71         # header
72         #
73         (sed '/^2\.[0-9.]*/,$d' README | 
74                 sed -r -e "s/Version.*/Version $version_note/" \
75                     -e "s/[0-9]{4}\-[0-9]{2}\-[0-9]{2}$/$date/" | awk '
76                     /^[ \t]/ {
77                                 gsub ("^[ \t]*", "");
78                                 gsub ("[ \t]*$", "");
79                                 space=(70 - length) / 2;
80                                 for (i = 0; i < space; i++)
81                                         printf (" ");
82                                 print 
83                                 next
84                               } 
85                               { 
86                                 print 
87                               }'
88         
89         #
90         # changelog
91         #
92         
93         echo $version_note
94         echo
95         git log --pretty=short $last.. | git shortlog | cat
96         
97         #
98         # previous changelogs
99         #
100         
101         sed -n '/^2\.[0-9.]*/,$p' README) > README.tmp ||
102                 (echo "README update failed"; exit 1)
103         
104         mv README.tmp README
105 fi
106
107 $test git commit -m"Bump version to $version" \
108         configure.ac \
109         fontconfig/fontconfig.h \
110         README
111
112 # tag the tree
113 $test git tag -s -m "Version $version" $version
114
115 # Make distributed change log
116
117 git log --stat $last.. > ChangeLog-$version
118