/
upgrade-boost.sh
executable file
·126 lines (97 loc) · 3.83 KB
/
upgrade-boost.sh
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
119
120
121
122
123
124
125
126
#!/bin/bash
#===============================================================================
#
# This script is for the Math library maintainers to use upgrade Boost.
# To update to a new Boost version, download the boost_<version>.tar.gz to
# the lib/ directory.
# https://www.boost.org/users/download/
# This script will also manage the git process so the different steps are in
# separate git commits.
#
# This script will take these steps and add a git commit after each:
# 1. Remove the old version of Boost.
# 2. Modify makefiles and README with new version numbers
# 3. Unpack the new Boost version.
# 4. Prune Boost
#
# This script should be run from the lib/ folder and the argument should be the
# name of the boost_*.tar.gz file.
#===============================================================================
set -e
err_report() {
echo "Error on line $1"
}
trap 'err_report $LINENO' ERR
usage() {
cat <<HELP_USAGE
Usage:
$0 boost_<version>.tar.gz
Download the new Boost version to boost_<version>.tar.gz in this
directory. Provide that filename as the only parameter to this script.
This script will upgrade the Boost library to the one provide,
making modifications to the library as necessary. The modifications
will be separate git commits for verification.
If there are any unstaged modifications or staged modifications that
haven't been git committed, this script will quit prior to adding any
git commits.
HELP_USAGE
exit 0
}
[ -z "$1" ] && { usage; }
boost_filename=$1
## extract version number from argument
## ex: boost_1_69_0.tar.gz -> version=1.69.0
boost_version=`expr "$boost_filename" : '^boost_\(.*\)\.tar\.gz'`
boost_version_underscore=$boost_version
#replace underscores with dots
boost_version=${boost_version//_/.}
if [[ -z "$boost_version" ]] ; then
cat <<BOOST_VERSION_ERROR
Can not parse the Boost version from the filename.
Expecting: boost_<version>.tar.gz
Is the filename correct? "$boost_filename"
BOOST_VERSION_ERROR
exit 1
fi
## check git tree for modifications
if ! git diff-index --quiet HEAD --
then
cat <<GIT_ERROR
Please commit or stash any git changes prior to
running this script. Quitting.
GIT_ERROR
exit 1
fi
boost_old_version=`expr "$(ls -d boost_*/)" : '^boost_\(.*\)/'`
boost_old_version=${boost_old_version//_/.}
echo "Old version: $boost_old_version"
echo "New version: $boost_version"
# 1. Remove the old version of Boost.
git rm -r boost_${boost_old_version}/
rm -rf boost_${boost_old_version}/
git commit -m "upgrading to boost v${boost_version}; removing old boost library"
# 2. Modify makefiles and README with new version number
# if the versions are the same we are only trimming files
if [ "$boost_version" != "$boost_old_version" ]; then
sed -i -e "s|lib/boost_${boost_old_version}|lib/boost_${boost_version}|g" ../README.md ../make/*
sed -i -e "s|Boost (version ${boost_old_version})|Boost (version ${boost_version})|g" ../README.md
rm -f ../README.md*-e ../make/*-e
git add -u ../README.md ../make/*
git commit -m "upgrading to boost v${boost_version}; modifying with new version number"
fi
# 3. Unpack the new Boost version.
tar xvzf $boost_filename
mv boost_${boost_version_underscore} boost_${boost_version}
git add boost_${boost_version}
git commit -m "upgrading to boost v${boost_version}; adding unmodified boost library"
# 4. Prune Boost
cd boost_${boost_version}
git rm -rf boost.css boost.png index.htm index.html INSTALL rst.css
git rm -rf doc/ libs/*/test/ libs/*/example/ libs/*/doc/
git commit -m "upgrading to boost v${boost_version}; pruning files"
cat <<EOF
Done upgrading Boost from v${boost_old_version} to v${boost_version}.
Please check the upgrade worked by running a test that uses Boost
Example (from Math home directory):
./runTests.py test/unit/math/prim/mat/prob/multi_normal_test.cpp
EOF