|
1 |
| -@echo off |
2 |
| - |
3 |
| -REM Copyright 2018-present MongoDB, Inc. |
4 |
| -REM |
5 |
| -REM Licensed under the Apache License, Version 2.0 (the "License"); |
6 |
| -REM you may not use this file except in compliance with the License. |
7 |
| -REM You may obtain a copy of the License at |
8 |
| -REM |
9 |
| -REM http://www.apache.org/licenses/LICENSE-2.0 |
10 |
| -REM |
11 |
| -REM Unless required by applicable law or agreed to in writing, software |
12 |
| -REM distributed under the License is distributed on an "AS IS" BASIS, |
13 |
| -REM WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
14 |
| -REM See the License for the specific language governing permissions and |
15 |
| -REM limitations under the License. |
16 |
| - |
17 |
| -setlocal EnableExtensions |
18 |
| -setlocal EnableDelayedExpansion |
19 |
| - |
20 |
| -set manifest=%1 |
21 |
| - |
22 |
| -if not exist "%manifest%" ( |
23 |
| - echo.***** Specify location of installation manifest as first parameter >&2 |
24 |
| - goto :print_usage |
25 |
| -) |
26 |
| - |
27 |
| -set prefix=%2 |
28 |
| - |
29 |
| -if "%prefix%"=="" ( |
30 |
| - echo.***** Specify installation prefix as second parameter >&2 |
31 |
| - goto :print_usage |
32 |
| -) |
33 |
| - |
34 |
| -if "%prefix:~1,1%" NEQ ":" ( |
35 |
| - echo.***** Installation prefix must refer to an absolute path with drive letter >&2 |
36 |
| - goto :print_usage |
37 |
| -) |
38 |
| - |
39 |
| -if "%prefix:~-1%" NEQ "\" ( |
40 |
| - REM Trailing slash was omitted from prefix, so add it here |
41 |
| - set prefix=%prefix%\ |
42 |
| -) |
43 |
| -REM remove surruonding quotes to prevent fouling string substitution |
44 |
| -set prefix=%prefix:"=% |
45 |
| - |
46 |
| -echo.@echo off |
47 |
| -echo. |
48 |
| -echo.REM Mongo C Driver uninstall program, generated on %date% %time% |
49 |
| -echo. |
50 |
| -echo.REM Copyright 2018-present MongoDB, Inc. |
51 |
| -echo.REM |
52 |
| -echo.REM Licensed under the Apache License, Version 2.0 (the "License"); |
53 |
| -echo.REM you may not use this file except in compliance with the License. |
54 |
| -echo.REM You may obtain a copy of the License at |
55 |
| -echo.REM |
56 |
| -echo.REM http://www.apache.org/licenses/LICENSE-2.0 |
57 |
| -echo.REM |
58 |
| -echo.REM Unless required by applicable law or agreed to in writing, software |
59 |
| -echo.REM distributed under the License is distributed on an "AS IS" BASIS, |
60 |
| -echo.REM WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
61 |
| -echo.REM See the License for the specific language governing permissions and |
62 |
| -echo.REM limitations under the License. |
63 |
| -echo. |
64 |
| -echo. |
65 |
| -echo. |
66 |
| -echo.REM Windows does not handle a batch script deleting itself during |
67 |
| -echo.REM execution. Copy the uninstall program into the TEMP directory from |
68 |
| -echo.REM the environment and run from there so everything in the installation |
69 |
| -echo.REM is deleted and the copied program deletes itself at the end. |
70 |
| -echo.if /i "%%~dp0" NEQ "%%TEMP%%\" ^( |
71 |
| -echo. copy "%%~f0" "%%TEMP%%\mongoc-%%~nx0" ^>NUL |
72 |
| -echo. "%%TEMP%%\mongoc-%%~nx0" ^& del "%%TEMP%%\mongoc-%%~nx0" |
73 |
| -echo.^) |
74 |
| -echo. |
75 |
| -echo.pushd %prefix% |
76 |
| -echo. |
77 |
| - |
78 |
| -for /f "usebackq delims=" %%a in ("%manifest%") do ( |
79 |
| - set filepath=%%a |
80 |
| - set suffix=!filepath:%prefix%=! |
81 |
| - set filedir=!suffix:\%%~nxa=! |
82 |
| - call :save_dirs "!filedir!" |
83 |
| - echo.echo Removing file !suffix! |
84 |
| - echo.del !suffix! ^|^| echo ... not removed |
85 |
| -) |
86 |
| - |
87 |
| -echo.echo Removing file share\mongo-c-driver\uninstall.cmd |
88 |
| -echo.del share\mongo-c-driver\uninstall.cmd ^|^| echo ... not removed |
89 |
| -call :save_dirs "share\mongo-c-driver" |
90 |
| - |
91 |
| -for /f "tokens=2 delims=[]" %%a in ('set dirs[') do ( |
92 |
| - set directory=%%a |
93 |
| - echo.echo Removing directory !directory! |
94 |
| - echo.^(rmdir !directory! 2^>NUL^) ^|^| echo ... not removed ^(probably not empty^) |
95 |
| -) |
96 |
| - |
97 |
| -echo.cd .. |
98 |
| -echo.echo Removing top-level installation directory: %prefix% |
99 |
| -echo.^(rmdir %prefix% 2^>NUL^) ^|^| echo ... not removed ^(probably not empty^) |
100 |
| -echo. |
101 |
| -echo.REM Return to the directory from which the program was called |
102 |
| -echo.popd |
103 |
| - |
104 |
| -exit /b 0 |
105 |
| - |
106 |
| -:print_usage |
107 |
| - echo. >&2 |
108 |
| - echo.Usage: >&2 |
109 |
| - echo. >&2 |
110 |
| - echo.%0 install-manifest install-prefix ^> uninstall.cmd >&2 |
111 |
| - echo. >&2 |
112 |
| - echo.Note: program prints to standard out; redirect to desired location. >&2 |
113 |
| - echo. >&2 |
114 |
| - goto :eof |
115 |
| - |
116 |
| -:save_dirs |
117 |
| - set dirlist=%1 |
118 |
| - set dirlist=%dirlist:"=% |
119 |
| - set dirs[%dirlist%]=%dirlist% |
120 |
| - REM if the path still has multiple components, strip the last and recurse |
121 |
| - if "%dirlist:\=%" NEQ "%dirlist%" ( |
122 |
| - for %%e in (%dirlist:\= %) do set last=%%e |
123 |
| - call :save_dirs "%%dirlist:\!last!=%%" |
124 |
| - ) |
125 |
| - goto :end_save_dirs |
126 |
| - :end_save_dirs |
| 1 | +@echo off |
| 2 | + |
| 3 | +REM Copyright 2018-present MongoDB, Inc. |
| 4 | +REM |
| 5 | +REM Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 | +REM you may not use this file except in compliance with the License. |
| 7 | +REM You may obtain a copy of the License at |
| 8 | +REM |
| 9 | +REM http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | +REM |
| 11 | +REM Unless required by applicable law or agreed to in writing, software |
| 12 | +REM distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | +REM WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | +REM See the License for the specific language governing permissions and |
| 15 | +REM limitations under the License. |
| 16 | + |
| 17 | +setlocal EnableExtensions |
| 18 | +setlocal EnableDelayedExpansion |
| 19 | + |
| 20 | +set manifest=%1 |
| 21 | + |
| 22 | +if not exist "%manifest%" ( |
| 23 | + echo.***** Specify location of installation manifest as first parameter >&2 |
| 24 | + goto :print_usage |
| 25 | +) |
| 26 | + |
| 27 | +set prefix=%2 |
| 28 | + |
| 29 | +if "%prefix%"=="" ( |
| 30 | + echo.***** Specify installation prefix as second parameter >&2 |
| 31 | + goto :print_usage |
| 32 | +) |
| 33 | + |
| 34 | +if "%prefix:~1,1%" NEQ ":" ( |
| 35 | + echo.***** Installation prefix must refer to an absolute path with drive letter >&2 |
| 36 | + goto :print_usage |
| 37 | +) |
| 38 | + |
| 39 | +if "%prefix:~-1%" NEQ "\" ( |
| 40 | + REM Trailing slash was omitted from prefix, so add it here |
| 41 | + set prefix=%prefix%\ |
| 42 | +) |
| 43 | +REM remove surruonding quotes to prevent fouling string substitution |
| 44 | +set prefix=%prefix:"=% |
| 45 | + |
| 46 | +echo.@echo off |
| 47 | +echo. |
| 48 | +echo.REM Mongo C Driver uninstall program, generated with CMake |
| 49 | +echo. |
| 50 | +echo.REM Copyright 2018-present MongoDB, Inc. |
| 51 | +echo.REM |
| 52 | +echo.REM Licensed under the Apache License, Version 2.0 (the "License"); |
| 53 | +echo.REM you may not use this file except in compliance with the License. |
| 54 | +echo.REM You may obtain a copy of the License at |
| 55 | +echo.REM |
| 56 | +echo.REM http://www.apache.org/licenses/LICENSE-2.0 |
| 57 | +echo.REM |
| 58 | +echo.REM Unless required by applicable law or agreed to in writing, software |
| 59 | +echo.REM distributed under the License is distributed on an "AS IS" BASIS, |
| 60 | +echo.REM WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 61 | +echo.REM See the License for the specific language governing permissions and |
| 62 | +echo.REM limitations under the License. |
| 63 | +echo. |
| 64 | +echo. |
| 65 | +echo. |
| 66 | +echo.REM Windows does not handle a batch script deleting itself during |
| 67 | +echo.REM execution. Copy the uninstall program into the TEMP directory from |
| 68 | +echo.REM the environment and run from there so everything in the installation |
| 69 | +echo.REM is deleted and the copied program deletes itself at the end. |
| 70 | +echo.if /i "%%~dp0" NEQ "%%TEMP%%\" ^( |
| 71 | +echo. copy "%%~f0" "%%TEMP%%\mongoc-%%~nx0" ^>NUL |
| 72 | +echo. "%%TEMP%%\mongoc-%%~nx0" ^& del "%%TEMP%%\mongoc-%%~nx0" |
| 73 | +echo.^) |
| 74 | +echo. |
| 75 | +echo.pushd %prefix% |
| 76 | +echo. |
| 77 | + |
| 78 | +for /f "usebackq delims=" %%a in ("%manifest%") do ( |
| 79 | + set filepath=%%a |
| 80 | + set suffix=!filepath:%prefix%=! |
| 81 | + set filedir=!suffix:\%%~nxa=! |
| 82 | + call :save_dirs "!filedir!" |
| 83 | + echo.echo Removing file !suffix! |
| 84 | + echo.del !suffix! ^|^| echo ... not removed |
| 85 | +) |
| 86 | + |
| 87 | +echo.echo Removing file share\mongo-c-driver\uninstall.cmd |
| 88 | +echo.del share\mongo-c-driver\uninstall.cmd ^|^| echo ... not removed |
| 89 | +call :save_dirs "share\mongo-c-driver" |
| 90 | + |
| 91 | +for /f "tokens=2 delims=[]" %%a in ('set dirs[') do ( |
| 92 | + set directory=%%a |
| 93 | + echo.echo Removing directory !directory! |
| 94 | + echo.^(rmdir !directory! 2^>NUL^) ^|^| echo ... not removed ^(probably not empty^) |
| 95 | +) |
| 96 | + |
| 97 | +echo.cd .. |
| 98 | +echo.echo Removing top-level installation directory: %prefix% |
| 99 | +echo.^(rmdir %prefix% 2^>NUL^) ^|^| echo ... not removed ^(probably not empty^) |
| 100 | +echo. |
| 101 | +echo.REM Return to the directory from which the program was called |
| 102 | +echo.popd |
| 103 | + |
| 104 | +exit /b 0 |
| 105 | + |
| 106 | +:print_usage |
| 107 | + echo. >&2 |
| 108 | + echo.Usage: >&2 |
| 109 | + echo. >&2 |
| 110 | + echo.%0 install-manifest install-prefix ^> uninstall.cmd >&2 |
| 111 | + echo. >&2 |
| 112 | + echo.Note: program prints to standard out; redirect to desired location. >&2 |
| 113 | + echo. >&2 |
| 114 | + goto :eof |
| 115 | + |
| 116 | +:save_dirs |
| 117 | + set dirlist=%1 |
| 118 | + set dirlist=%dirlist:"=% |
| 119 | + set dirs[%dirlist%]=%dirlist% |
| 120 | + REM if the path still has multiple components, strip the last and recurse |
| 121 | + if "%dirlist:\=%" NEQ "%dirlist%" ( |
| 122 | + for %%e in (%dirlist:\= %) do set last=%%e |
| 123 | + call :save_dirs "%%dirlist:\!last!=%%" |
| 124 | + ) |
| 125 | + goto :end_save_dirs |
| 126 | + :end_save_dirs |
0 commit comments