forked from mongodb/mongo-c-driver
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall-uninstall-check.sh
executable file
·202 lines (181 loc) · 5.04 KB
/
install-uninstall-check.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
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
#!/usr/bin/env bash
set -o errexit # Exit the script with error if any of the commands fail
# Supported/used environment variables:
# CMAKE Path to cmake executable.
# BSON_ONLY Whether to build only the BSON library.
DIR=$(dirname $0)
. $DIR/find-cmake-latest.sh
CMAKE=$(find_cmake_latest)
. $DIR/check-symlink.sh
SRCROOT=$(pwd)
# The major version of the project. Appears in certain install filenames.
_full_version=$(cat "$DIR/../../VERSION_CURRENT")
version="${_full_version%-*}" # 1.2.3-dev → 1.2.3
major="${version%%.*}" # 1.2.3 → 1
echo "major version: $major"
echo " full version: $version"
# Use ccache if able.
. $DIR/find-ccache.sh
find_ccache_and_export_vars "$(pwd)" || true
SCRATCH_DIR=$(pwd)/.scratch
rm -rf "$SCRATCH_DIR"
mkdir -p "$SCRATCH_DIR"
cp -r -- "$SRCROOT"/* "$SCRATCH_DIR"
if [ "$BSON_ONLY" ]; then
BUILD_DIR=$SCRATCH_DIR/build-dir-bson
INSTALL_PREFIX=$SCRATCH_DIR/install-dir-bson
else
BUILD_DIR=$SCRATCH_DIR/build-dir-mongoc
INSTALL_PREFIX=$SCRATCH_DIR/install-dir-mongoc
fi
if [ "$DESTDIR" ]; then
INSTALL_DIR="${DESTDIR}/${INSTALL_PREFIX}"
else
INSTALL_DIR=$INSTALL_PREFIX
fi
rm -rf $BUILD_DIR
mkdir $BUILD_DIR
rm -rf $INSTALL_DIR
mkdir -p $INSTALL_DIR
cd $BUILD_DIR
cp -r -- "$SRCROOT"/* "$SCRATCH_DIR"
if [ "$BSON_ONLY" ]; then
BSON_ONLY_OPTION="-DENABLE_MONGOC=OFF"
else
BSON_ONLY_OPTION="-DENABLE_MONGOC=ON"
fi
# Use ccache if able.
if [[ -f $DIR/find-ccache.sh ]]; then
. $DIR/find-ccache.sh
find_ccache_and_export_vars "$SCRATCH_DIR" || true
fi
$CMAKE -DCMAKE_INSTALL_PREFIX=$INSTALL_PREFIX -DBUILD_TESTING=OFF -DCMAKE_PREFIX_PATH=$INSTALL_DIR/lib/cmake $BSON_ONLY_OPTION "$SCRATCH_DIR"
$CMAKE --build . --parallel
if [ "$DESTDIR" ]; then
DESTDIR=$DESTDIR $CMAKE --build . --target install
else
$CMAKE --build . --target install
fi
touch $INSTALL_DIR/lib/canary.txt
# no kms-message components should be installed
if test -f $INSTALL_DIR/include/kms_message/kms_message.h; then
echo "kms_message.h found!"
exit 1
else
echo "kms_message.h check ok"
fi
if test -f $INSTALL_DIR/lib/libkms_message-static.a; then
echo "libkms_message-static.a found!"
exit 1
else
echo "libkms_message-static.a check ok"
fi
if test -f $INSTALL_DIR/lib/cmake/kms_message/kms_message-config.cmake; then
echo "kms_message-config.cmake found!"
exit 1
else
echo "kms_message-config.cmake check ok"
fi
ls -l $INSTALL_DIR/share/mongo-c-driver
$CMAKE --build . --target uninstall
set +o xtrace
if test -f $INSTALL_DIR/lib/pkgconfig/bson$major.pc; then
echo "bson$major.pc found!"
exit 1
else
echo "bson$major.pc check ok"
fi
if test -f $INSTALL_DIR/lib/cmake/bson-$version/bsonConfig.cmake; then
echo "bsonConfig.cmake found!"
exit 1
else
echo "bsonConfig.cmake check ok"
fi
if test -f $INSTALL_DIR/lib/cmake/bson-$version/bsonConfigVersion.cmake; then
echo "bsonConfigVersion.cmake found!"
exit 1
else
echo "bsonConfigVersion.cmake check ok"
fi
if test ! -f $INSTALL_DIR/lib/canary.txt; then
echo "canary.txt not found!"
exit 1
else
echo "canary.txt check ok"
fi
if test ! -d $INSTALL_DIR/lib; then
echo "$INSTALL_DIR/lib not found!"
exit 1
else
echo "$INSTALL_DIR/lib check ok"
fi
if [ -z "$BSON_ONLY" ]; then
if test -f $INSTALL_DIR/lib/pkgconfig/mongoc$major.pc; then
echo "mongoc$major.pc found!"
exit 1
else
echo "mongoc$major.pc check ok"
fi
if test -f $INSTALL_DIR/lib/cmake/mongoc-1.0/mongoc-1.0-config.cmake; then
echo "mongoc-1.0-config.cmake found!"
exit 1
else
echo "mongoc-1.0-config.cmake check ok"
fi
if test -f $INSTALL_DIR/lib/cmake/mongoc-1.0/mongoc-1.0-config-version.cmake; then
echo "mongoc-1.0-config-version.cmake found!"
exit 1
else
echo "mongoc-1.0-config-version.cmake check ok"
fi
if test -f $INSTALL_DIR/lib/cmake/mongoc-1.0/mongoc-targets.cmake; then
echo "mongoc-targets.cmake found!"
exit 1
else
echo "mongoc-targets.cmake check ok"
fi
fi
if test -f $INSTALL_DIR/include/bson-$version/bson/bson.h; then
echo "bson/bson.h found!"
exit 1
else
echo "bson/bson.h check ok"
fi
if test -d $INSTALL_DIR/include/bson-$version; then
echo "$INSTALL_DIR/include/bson-$version found!"
exit 1
else
echo "$INSTALL_DIR/include/bson-$version check ok"
fi
if [ -z "$BSON_ONLY" ]; then
if test -f $INSTALL_DIR/include/libmongoc-1.0/mongoc/mongoc.h; then
echo "mongoc/mongoc.h found!"
exit 1
else
echo "mongoc/mongoc.h check ok"
fi
if test -d $INSTALL_DIR/include/libmongoc-1.0; then
echo "$INSTALL_DIR/include/libmongoc-1.0 found!"
exit 1
else
echo "$INSTALL_DIR/include/libmongoc-1.0 check ok"
fi
fi
if test -f $INSTALL_DIR/share/mongo-c-driver/uninstall-bson.sh; then
echo "uninstall-bson.sh found!"
exit 1
else
echo "uninstall-bson.sh check ok"
fi
if test -f $INSTALL_DIR/share/mongo-c-driver/uninstall.sh; then
echo "uninstall.sh found!"
exit 1
else
echo "uninstall.sh check ok"
fi
if test -d $INSTALL_DIR/share/mongo-c-driver; then
echo "$INSTALL_DIR/share/mongo-c-driver found!"
exit 1
else
echo "$INSTALL_DIR/share/mongo-c-driver check ok"
fi