-
Notifications
You must be signed in to change notification settings - Fork 8
/
changeversion
executable file
·119 lines (103 loc) · 4.43 KB
/
changeversion
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
#!/bin/bash
# Change the version of the source code to the supplied value
# Check that a version information was correctly supplied
if [ "$#" -eq "0" ]
then
echo "Checking current version numbers only..."
TEST="true"
elif [ "$1" = "bump" ]
then
echo "Bumping version number..."
MAJOR=`grep 'set(VERSION_MAJOR' ./CMakeLists.txt | sed -e 's/set(VERSION_MAJOR \"\([0-9a-z\.]\+\)\")/\1/g'`
MINOR=`grep 'set(VERSION_MINOR' ./CMakeLists.txt | sed -e 's/set(VERSION_MINOR \"\([0-9a-z\.]\+\)\")/\1/g'`
PATCH=`grep 'set(VERSION_PATCH' ./CMakeLists.txt | sed -e 's/set(VERSION_PATCH \"\([0-9a-z\.]\+\)\")/\1/g'`
echo "Current version is $MAJOR.$MINOR.$PATCH"
PATCH=$(($PATCH+1))
echo "New version will be $MAJOR.$MINOR.$PATCH"
TEST="false"
elif [ "$#" -ne "3" ]
then
echo "Improper version number supplied (use 'changeversion MAJOR MINOR PATCH', 'bump' to increase patch number, or no args to check existing files)"
exit 1
else
MAJOR=$1
MINOR=$2
PATCH=$3
TEST="false"
echo "Changing version numbers in files (to ${MAJOR}.${MINOR}.{$PATCH}..."
fi
# Create git tag
if [ "$TEST" = "false" ]
then
git tag -a $MAJOR.$MINOR.$PATCH -m "change version to $MAJOR.$MINOR.$PATCH"
fi
# Program (version.h)
if [ "$TEST" = "false" ]
then
#cp src/main/version.h src/main/version.h.orig
sed -i -e "s/#define ATENVERSION \"[0-9\.]\+\(.*\)\"/#define ATENVERSION \"$MAJOR.$MINOR.$PATCH\"\1/g" src/main/version.h
fi
echo -n " version.h (Program Version) : "
grep '#define ATENVERSION' src/main/version.h | sed -e 's/#define ATENVERSION "\([0-9a-z\.]\+\).*"/\1/g'
# ./CMakeLists.txt
if [ "$TEST" = "false" ]
then
sed -i -e "s/set(VERSION_MAJOR \"\([0-9\.]\+\)\")/set(VERSION_MAJOR \"$MAJOR\")/g" -e "s/set(VERSION_MINOR \"\([0-9a-z\.]\+\)\")/set(VERSION_MINOR \"$MINOR\")/g" -e "s/set(VERSION_PATCH \"\([0-9a-z\.]\+\)\")/set(VERSION_PATCH \"$PATCH\")/g" CMakeLists.txt
fi
echo -n " ./CMakeLists.txt (Major Version) : "
grep 'set(VERSION_MAJOR' ./CMakeLists.txt | sed -e 's/set(VERSION_MAJOR \"\([0-9a-z\.]\+\)\")/\1/g'
echo -n " (Minor Version) : "
grep 'set(VERSION_MINOR' ./CMakeLists.txt | sed -e 's/set(VERSION_MINOR \"\([0-9a-z\.]\+\)\")/\1/g'
echo -n " (Patch Version) : "
grep 'set(VERSION_PATCH' ./CMakeLists.txt | sed -e 's/set(VERSION_PATCH \"\([0-9a-z\.]\+\)\")/\1/g'
# ./configure.ac
echo -n " ./configure.ac (Package Version) : "
if [ "$TEST" = "false" ]
then
sed -i -e "s/m4_define(\[ATEN_VERSION\],\[\([0-9a-z\.]\+\)\])/m4_define([ATEN_VERSION],[$MAJOR.$MINOR.$PATCH])/g" configure.ac
fi
grep 'm4_define(\[ATEN_VERSION\]' ./configure.ac | sed -e 's/m4_define(\[ATEN_VERSION\],\[\([0-9a-z\.]\+\)\])/\1/g'
# Change specfile names and contents
if [ "$TEST" = "false" ]
then
sed -i -e "s/Version: [0-9a-z\.]\+/Version: $MAJOR.$MINOR.$PATCH/g" extra/*/aten.spec
fi
for a in extra/*/aten.spec
do
ver=`grep "Version:" $a | sed -e 's/Version: \([0-9a-z\.]\+\)/\1/g'`
printf '%34s : %s\n' $a $ver
done
# Debian build files
if [ "$TEST" = "false" ]
then
sed -i -e "s/aten (\([0-9\.]\+\))/aten ($MAJOR.$MINOR.$PATCH)/g" -e "s/^ v \([0-9\.]*\)-1/ * \1-1/g" extra/*/changelog
fi
for a in extra/*/changelog
do
ver=`grep 'aten (' $a | sed -e 's/aten (\([0-9\.]\+\).*/\1/g'`
printf '%34s : %s\n' $a $ver
done
# OSX build files
echo -n " aten.dmginfo (Program Version) : "
if [ "$TEST" = "false" ]
then
sed -i -e "s/APP_VERSION=\"\([0-9a-z\.]\+\)\"/APP_VERSION=\"$MAJOR.$MINOR.$PATCH\"/g" ./extra/OSX/aten.dmginfo
fi
grep 'APP_VERSION=' ./extra/OSX/aten.dmginfo | sed -e 's/APP_VERSION=\"\([0-9a-z\.]\+\)\"/\1/g'
# Windows build files
if [ "$TEST" = "false" ]
then
sed -i -e "s/#define MyAppVersion \"[0-9\.]*\"/#define MyAppVersion \"$MAJOR.$MINOR.$PATCH\"/g" -e "s/OutputBaseFilename=Aten-[0-9\.]*/OutputBaseFilename=Aten-$MAJOR.$MINOR.$PATCH/g" extra/Win32/aten.iss
fi
echo -n " aten.iss (Program Version) : "
grep 'define MyAppVersion' extra/Win32/aten.iss | sed -e 's/#define MyAppVersion \"\([0-9\.]*\)\"/\1/g'
echo -n " aten.iss (Output Filename) : "
grep 'OutputBaseFilename' extra/Win32/aten.iss | sed -e 's/OutputBaseFilename=Aten-\([0-9\.]*\)/\1/g'
# AppImage build files
#if [ "$TEST" = "false" ]
#then
# sed -i -e "s/Version=[0-9\.]*/Version=$MAJOR.$MINOR.$PATCH/g" extra/appimage/usr/share/applications/com.projectaten.Aten.desktop
#fi
#echo -n "appimage.desktop (Program Version) : "
#grep 'Version=' extra/appimage/usr/share/applications/com.projectaten.Aten.desktop | sed -e 's/Version=\([0-9\.]*\)/\1/g'
exit 0