Skip to content

Commit 3c0ace5

Browse files
committed
CDRIVER-2682 add an uninstall target
1 parent d91c87d commit 3c0ace5

File tree

10 files changed

+712
-0
lines changed

10 files changed

+712
-0
lines changed

.evergreen/config.yml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1591,6 +1591,36 @@ tasks:
15911591
bucket: mciuploads
15921592
permissions: public-read
15931593
content_type: ${content_type|application/x-gzip}
1594+
1595+
- name: install-uninstall-check-mingw
1596+
depends_on:
1597+
- name: "make-release-archive"
1598+
variant: releng
1599+
commands:
1600+
- command: shell.exec
1601+
type: test
1602+
params:
1603+
working_dir: "mongoc"
1604+
script: |
1605+
set -o xtrace
1606+
set -o errexit
1607+
BSON_ONLY=1 cmd.exe /c .\\.evergreen\\install-uninstall-check-mingw.cmd
1608+
cmd.exe /c .\\.evergreen\\install-uninstall-check-mingw.cmd
1609+
1610+
- name: install-uninstall-check
1611+
depends_on:
1612+
- name: "make-release-archive"
1613+
variant: releng
1614+
commands:
1615+
- command: shell.exec
1616+
type: test
1617+
params:
1618+
working_dir: "mongoc"
1619+
script: |
1620+
set -o xtrace
1621+
set -o errexit
1622+
BSON_ONLY=1 sh ./.evergreen/install-uninstall-check.sh
1623+
sh ./.evergreen/install-uninstall-check.sh
15941624
# }}}
15951625

15961626
# Test Matrix {{{
@@ -8934,6 +8964,10 @@ buildvariants:
89348964
distros:
89358965
- windows-64-vs2013-compile
89368966
- "check-public-headers"
8967+
- name: "install-uninstall-check"
8968+
- name: "install-uninstall-check-mingw"
8969+
distros:
8970+
- windows-64-vs2015-compile
89378971

89388972
- name: clang34ubuntu
89398973
display_name: "clang 3.4 (Ubuntu 14.04)"
Lines changed: 160 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,160 @@
1+
rem Ensure Cygwin executables like sh.exe are not in PATH
2+
rem set PATH=C:\Windows\system32;C:\Windows
3+
4+
echo on
5+
echo
6+
7+
set TAR=C:\cygwin\bin\tar
8+
set CMAKE=C:\cmake\bin\cmake
9+
set CMAKE_MAKE_PROGRAM=C:\mingw-w64\x86_64-4.9.1-posix-seh-rt_v3-rev1\mingw64\bin\mingw32-make.exe
10+
set CC=C:\mingw-w64\x86_64-4.9.1-posix-seh-rt_v3-rev1\mingw64\bin\gcc.exe
11+
rem Ensure Cygwin executables like sh.exe are not in PATH
12+
set PATH=C:\cygwin\bin;C:\Windows\system32;C:\Windows;C:\mingw-w64\x86_64-4.9.1-posix-seh-rt_v3-rev1\mingw64\bin;C:\mongoc;src\libbson;src\libmongoc
13+
14+
if "%BSON_ONLY%"=="1" (
15+
set BUILD_DIR=%CD%\build-dir-bson
16+
set INSTALL_DIR=%CD%\install-dir-bson
17+
) else (
18+
set BUILD_DIR=%CD%\build-dir-mongoc
19+
set INSTALL_DIR=%CD%\install-dir-mongoc
20+
)
21+
rmdir /S /Q %BUILD_DIR%
22+
mkdir %BUILD_DIR%
23+
24+
rmdir /S /Q %INSTALL_DIR%
25+
mkdir %INSTALL_DIR%
26+
27+
set PATH=%PATH%;"c:\Program Files (x86)\MSBuild\14.0\Bin"
28+
set PATH=%PATH%;"c:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin"
29+
set PATH=%PATH%;%INSTALL_DIR%\bin
30+
31+
cd %BUILD_DIR%
32+
%TAR% xf ..\..\mongoc.tar.gz -C . --strip-components=1
33+
34+
if "%BSON_ONLY%"=="1" (
35+
set BSON_ONLY_OPTION=-DENABLE_MONGOC=OFF
36+
) else (
37+
set BSON_ONLY_OPTION=-DENABLE_MONGOC=ON
38+
)
39+
40+
rem Build libmongoc, with flags that the downstream R driver mongolite uses
41+
%CMAKE% -G "MinGW Makefiles" -DCMAKE_MAKE_PROGRAM=%CMAKE_MAKE_PROGRAM% -DCMAKE_INSTALL_PREFIX=%INSTALL_DIR% -DCMAKE_CFLAGS="-std=c99 -pedantic" -DCMAKE_PREFIX_PATH=%INSTALL_DIR%\lib\cmake %BSON_ONLY_OPTION% .
42+
%CMAKE_MAKE_PROGRAM%
43+
if errorlevel 1 (
44+
exit /B 1
45+
)
46+
47+
%CMAKE_MAKE_PROGRAM% install
48+
if errorlevel 1 (
49+
exit /B 1
50+
)
51+
52+
echo > %INSTALL_DIR%\lib\canary.txt
53+
54+
dir %INSTALL_DIR%\share\mongo-c-driver
55+
56+
call %INSTALL_DIR%\share\mongo-c-driver\uninstall.cmd
57+
if errorlevel 1 (
58+
exit /B 1
59+
)
60+
61+
if exist %INSTALL_DIR%\lib\pkgconfig\libbson-1.0.pc (
62+
echo libbson-1.0.pc found!
63+
exit /B 1
64+
) else (
65+
echo libbson-1.0.pc check ok
66+
)
67+
if exist %INSTALL_DIR%\lib\cmake\libbson-1.0\libbson-1.0-config.cmake (
68+
echo libbson-1.0-config.cmake found!
69+
exit /B 1
70+
) else (
71+
echo libbson-1.0-config.cmake check ok
72+
)
73+
if exist %INSTALL_DIR%\lib\cmake\libbson-1.0\libbson-1.0-config-version.cmake (
74+
echo libbson-1.0-config-version.cmake found!
75+
exit /B 1
76+
) else (
77+
echo libbson-1.0-config-version.cmake check ok
78+
)
79+
if not exist %INSTALL_DIR%\lib\canary.txt (
80+
echo canary.txt not found!
81+
exit /B 1
82+
) else (
83+
echo canary.txt check ok
84+
)
85+
if not exist %INSTALL_DIR%\lib (
86+
echo %INSTALL_DIR%\lib not found!
87+
exit /B 1
88+
) else (
89+
echo %INSTALL_DIR%\lib check ok
90+
)
91+
if "%BSON_ONLY%" NEQ "1" (
92+
if exist %INSTALL_DIR%\lib\pkgconfig\libmongoc-1.0.pc (
93+
echo libmongoc-1.0.pc found!
94+
exit /B 1
95+
) else (
96+
echo libmongoc-1.0.pc check ok
97+
)
98+
if exist %INSTALL_DIR%\lib\cmake\libmongoc-1.0\libmongoc-1.0-config.cmake (
99+
echo libmongoc-1.0-config.cmake found!
100+
exit /B 1
101+
) else (
102+
echo libmongoc-1.0-config.cmake check ok
103+
)
104+
if exist %INSTALL_DIR%\lib\cmake\libmongoc-1.0\libmongoc-1.0-config-version.cmake (
105+
echo libmongoc-1.0-config-version.cmake found!
106+
exit /B 1
107+
) else (
108+
echo libmongoc-1.0-config-version.cmake check ok
109+
)
110+
)
111+
if exist %INSTALL_DIR%\include\libbson-1.0\bson\bson.h (
112+
echo bson\bson.h found!
113+
exit /B 1
114+
) else (
115+
echo bson\bson.h check ok
116+
)
117+
if exist %INSTALL_DIR%\include\libbson-1.0\bson.h (
118+
echo bson.h found!
119+
exit /B 1
120+
) else (
121+
echo bson.h check ok
122+
)
123+
if exist %INSTALL_DIR%\include\libbson-1.0 (
124+
echo $INSTALL_DIR\include\libbson-1.0 found!
125+
exit /B 1
126+
) else (
127+
echo $INSTALL_DIR\include\libbson-1.0 check ok
128+
)
129+
if "%BSON_ONLY%" NEQ "1" (
130+
if exist %INSTALL_DIR%\include\libmongoc-1.0\mongoc\mongoc.h (
131+
echo mongoc\mongoc.h found!
132+
exit /B 1
133+
) else (
134+
echo mongoc\mongoc.h check ok
135+
)
136+
if exist %INSTALL_DIR%\include\libmongoc-1.0\mongoc.h (
137+
echo mongoc.h found!
138+
exit /B 1
139+
) else (
140+
echo mongoc.h check ok
141+
)
142+
if exist %INSTALL_DIR%\include\libmongoc-1.0 (
143+
echo $INSTALL_DIR\include\libmongoc-1.0 found!
144+
exit /B 1
145+
) else (
146+
echo $INSTALL_DIR\include\libmongoc-1.0 check ok
147+
)
148+
)
149+
if exist %INSTALL_DIR%\share\mongo-c-driver\uninstall.sh (
150+
echo uninstall.sh found!
151+
exit /B 1
152+
) else (
153+
echo uninstall.sh check ok
154+
)
155+
if exist %INSTALL_DIR%\share\mongo-c-driver (
156+
echo $INSTALL_DIR\share\mongo-c-driver found!
157+
exit /B 1
158+
) else (
159+
echo $INSTALL_DIR\share\mongo-c-driver check ok
160+
)

.evergreen/install-uninstall-check.sh

Lines changed: 155 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,155 @@
1+
#!/bin/sh
2+
set -o xtrace # Write all commands first to stderr
3+
set -o errexit # Exit the script with error if any of the commands fail
4+
5+
# Supported/used environment variables:
6+
# CMAKE Path to cmake executable.
7+
# BSON_ONLY Whether to build only the BSON library.
8+
9+
10+
DIR=$(dirname $0)
11+
. $DIR/find-cmake.sh
12+
. $DIR/check-symlink.sh
13+
14+
if command -v gtar 2>/dev/null; then
15+
TAR=gtar
16+
else
17+
TAR=tar
18+
fi
19+
20+
if [ "$BSON_ONLY" ]; then
21+
BUILD_DIR=$(pwd)/build-dir-bson
22+
INSTALL_DIR=$(pwd)/install-dir-bson
23+
else
24+
BUILD_DIR=$(pwd)/build-dir-mongoc
25+
INSTALL_DIR=$(pwd)/install-dir-mongoc
26+
fi
27+
28+
rm -rf $BUILD_DIR
29+
mkdir $BUILD_DIR
30+
31+
rm -rf $INSTALL_DIR
32+
mkdir -p $INSTALL_DIR
33+
34+
cd $BUILD_DIR
35+
$TAR xf ../../mongoc.tar.gz -C . --strip-components=1
36+
37+
if [ "$BSON_ONLY" ]; then
38+
BSON_ONLY_OPTION="-DENABLE_MONGOC=OFF"
39+
else
40+
BSON_ONLY_OPTION="-DENABLE_MONGOC=ON"
41+
fi
42+
43+
44+
$CMAKE -DCMAKE_INSTALL_PREFIX=$INSTALL_DIR -DCMAKE_PREFIX_PATH=$INSTALL_DIR/lib/cmake $BSON_ONLY_OPTION .
45+
make
46+
make install
47+
touch $INSTALL_DIR/lib/canary.txt
48+
49+
ls -l $INSTALL_DIR/share/mongo-c-driver
50+
51+
$INSTALL_DIR/share/mongo-c-driver/uninstall.sh
52+
53+
set +o xtrace
54+
55+
if test -f $INSTALL_DIR/lib/pkgconfig/libbson-1.0.pc; then
56+
echo "libbson-1.0.pc found!"
57+
exit 1
58+
else
59+
echo "libbson-1.0.pc check ok"
60+
fi
61+
if test -f $INSTALL_DIR/lib/cmake/libbson-1.0/libbson-1.0-config.cmake; then
62+
echo "libbson-1.0-config.cmake found!"
63+
exit 1
64+
else
65+
echo "libbson-1.0-config.cmake check ok"
66+
fi
67+
if test -f $INSTALL_DIR/lib/cmake/libbson-1.0/libbson-1.0-config-version.cmake; then
68+
echo "libbson-1.0-config-version.cmake found!"
69+
exit 1
70+
else
71+
echo "libbson-1.0-config-version.cmake check ok"
72+
fi
73+
if test ! -f $INSTALL_DIR/lib/canary.txt; then
74+
echo "canary.txt not found!"
75+
exit 1
76+
else
77+
echo "canary.txt check ok"
78+
fi
79+
if test ! -d $INSTALL_DIR/lib; then
80+
echo "$INSTALL_DIR/lib not found!"
81+
exit 1
82+
else
83+
echo "$INSTALL_DIR/lib check ok"
84+
fi
85+
if [ -z "$BSON_ONLY" ]; then
86+
if test -f $INSTALL_DIR/lib/pkgconfig/libmongoc-1.0.pc; then
87+
echo "libmongoc-1.0.pc found!"
88+
exit 1
89+
else
90+
echo "libmongoc-1.0.pc check ok"
91+
fi
92+
if test -f $INSTALL_DIR/lib/cmake/libmongoc-1.0/libmongoc-1.0-config.cmake; then
93+
echo "libmongoc-1.0-config.cmake found!"
94+
exit 1
95+
else
96+
echo "libmongoc-1.0-config.cmake check ok"
97+
fi
98+
if test -f $INSTALL_DIR/lib/cmake/libmongoc-1.0/libmongoc-1.0-config-version.cmake; then
99+
echo "libmongoc-1.0-config-version.cmake found!"
100+
exit 1
101+
else
102+
echo "libmongoc-1.0-config-version.cmake check ok"
103+
fi
104+
fi
105+
if test -f $INSTALL_DIR/include/libbson-1.0/bson/bson.h; then
106+
echo "bson/bson.h found!"
107+
exit 1
108+
else
109+
echo "bson/bson.h check ok"
110+
fi
111+
if test -f $INSTALL_DIR/include/libbson-1.0/bson.h; then
112+
echo "bson.h found!"
113+
exit 1
114+
else
115+
echo "bson.h check ok"
116+
fi
117+
if test -d $INSTALL_DIR/include/libbson-1.0; then
118+
echo "$INSTALL_DIR/include/libbson-1.0 found!"
119+
exit 1
120+
else
121+
echo "$INSTALL_DIR/include/libbson-1.0 check ok"
122+
fi
123+
if [ -z "$BSON_ONLY" ]; then
124+
if test -f $INSTALL_DIR/include/libmongoc-1.0/mongoc/mongoc.h; then
125+
echo "mongoc/mongoc.h found!"
126+
exit 1
127+
else
128+
echo "mongoc/mongoc.h check ok"
129+
fi
130+
if test -f $INSTALL_DIR/include/libmongoc-1.0/mongoc.h; then
131+
echo "mongoc.h found!"
132+
exit 1
133+
else
134+
echo "mongoc.h check ok"
135+
fi
136+
if test -d $INSTALL_DIR/include/libmongoc-1.0; then
137+
echo "$INSTALL_DIR/include/libmongoc-1.0 found!"
138+
exit 1
139+
else
140+
echo "$INSTALL_DIR/include/libmongoc-1.0 check ok"
141+
fi
142+
fi
143+
if test -f $INSTALL_DIR/share/mongo-c-driver/uninstall.sh; then
144+
echo "uninstall.sh found!"
145+
exit 1
146+
else
147+
echo "uninstall.sh check ok"
148+
fi
149+
if test -d $INSTALL_DIR/share/mongo-c-driver; then
150+
echo "$INSTALL_DIR/share/mongo-c-driver found!"
151+
exit 1
152+
else
153+
echo "$INSTALL_DIR/share/mongo-c-driver check ok"
154+
fi
155+

CMakeLists.txt

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,8 @@ if (ENABLE_MONGOC)
259259
THIRD_PARTY_NOTICES
260260
VERSION_CURRENT
261261
VERSION_RELEASED
262+
# This sub-directory is added later, so manually include here
263+
generate_uninstall/CMakeLists.txt
262264
)
263265

264266
set_local_dist (top_DIST ${top_DIST_local})
@@ -322,3 +324,20 @@ if (ENABLE_MONGOC)
322324
endif ()
323325

324326
endif ()
327+
328+
if (WIN32)
329+
set (UNINSTALL_PROG "uninstall.cmd")
330+
else ()
331+
set (UNINSTALL_PROG "uninstall.sh")
332+
endif ()
333+
set (UNINSTALL_PROG_DIR "${CMAKE_INSTALL_FULL_DATADIR}/mongo-c-driver")
334+
335+
# Create uninstall program and associated uninstall target
336+
#
337+
# This needs to be last (after all other add_subdirectory calls) to ensure that
338+
# the generated uninstall program is complete and correct
339+
add_subdirectory (generate_uninstall)
340+
341+
add_custom_target (uninstall
342+
COMMAND "${UNINSTALL_PROG_DIR}/${UNINSTALL_PROG}"
343+
)

0 commit comments

Comments
 (0)