File: update_version.sh

package info (click to toggle)
primesieve 7.3%2Bds-1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 1,080 kB
  • sloc: cpp: 7,270; ansic: 455; sh: 199; makefile: 86
file content (83 lines) | stat: -rwxr-xr-x 2,072 bytes parent folder | download
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
#!/bin/sh

if [ $# -ne 1 ]
then
    echo "Usage example:"
    echo "$ ./update_version.sh 1.2"
    echo ""
    echo "Updates the primesieve version to 1.2 in all files"

    exit 1
fi

# Run from primesieve root directory
test -e ../src && cd ..

new_version=$1
old_version=$(grep "PRIMESIEVE_VERSION " include/primesieve.hpp | cut -f2 -d'"')

new_major=$(echo $new_version | cut -f1 -d'.')
new_minor=$(echo $new_version | cut -f2 -d'.')

old_major=$(echo $old_version | cut -f1 -d'.')
old_minor=$(echo $old_version | cut -f2 -d'.')

new_year=$(date +'%Y')
old_year=$(grep "Copyright (C)" src/gui/src/PrimeSieveGUI.hpp | cut -f5 -d' ')

echo "New version: $new_version"
echo "Old version: $old_version"
echo ""
echo "New year: $new_year"
echo "Old year: $old_year"
echo ""

# Update version
for i in $(echo README.md \
                CMakeLists.txt \
                include/primesieve.hpp \
                include/primesieve.h)
do
    echo "Update version in $i"
    sed "s/$old_major\.$old_minor/$new_version/g" $i > $i.tmp
    mv -f $i.tmp $i
done

# Update shared libprimesieve version
for i in $(echo CMakeLists.txt)
do
    echo "Update shared libprimesieve version in $i"
    old_so_major=$(($old_major + 2))
    new_so_major=$(($new_major + 2))
    new_so_version="$new_so_major.$new_minor.0"
    sed "s/$old_so_major\.$old_minor\.0/$new_so_version/g" $i > $i.tmp
    mv -f $i.tmp $i
done

# Update version
for i in $(echo include/primesieve.hpp \
                include/primesieve.h)
do
    sed "s/PRIMESIEVE_VERSION_MAJOR $old_major/PRIMESIEVE_VERSION_MAJOR $new_major/g" $i > $i.tmp
    mv -f $i.tmp $i
    sed "s/PRIMESIEVE_VERSION_MINOR $old_minor/PRIMESIEVE_VERSION_MINOR $new_minor/g" $i > $i.tmp
    mv -f $i.tmp $i
done

# Update year
for i in $(echo COPYING \
                src/console/help.cpp \
                src/gui/src/PrimeSieveGUI.hpp)
do
    echo "Update year in $i"
    sed "s/$old_year/$new_year/g" $i > $i.tmp
    mv -f $i.tmp $i
done

# Update version number in man page
echo ""
cmake .
make -j
echo ""

echo "Version has been updated!"