Skip to content

Commit fc3e8b1

Browse files
vic-tsangalinaliBQ
andauthored
Mac Setup ODBC ini Script
* added setup script for mac and platform folders updated read me windows file path updated windows folder related file paths added license Fix Lint issues Add install ODBC script Update install_odbc_ini.sh This script depends on the ODBC install script. Add TODO note and update DSN * Fix typo in README --------- Co-authored-by: Alina (Xi) Li <[email protected]> Co-authored-by: vic-tsang <[email protected]>
1 parent 64894e0 commit fc3e8b1

File tree

8 files changed

+184
-6
lines changed

8 files changed

+184
-6
lines changed

cpp/src/arrow/flight/sql/odbc/CMakeLists.txt

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ if(WIN32)
5858
set(VER_COMPANYNAME_STR ${ODBC_PACKAGE_VENDOR})
5959
set(VER_PRODUCTNAME_STR ${ODBC_PACKAGE_NAME})
6060

61-
configure_file("install/versioninfo.rc.in" "install/versioninfo.rc" @ONLY)
61+
configure_file("install/windows/versioninfo.rc.in" "install/versioninfo.rc" @ONLY)
6262

6363
list(APPEND ARROW_FLIGHT_SQL_ODBC_SRCS odbc.def install/versioninfo.rc)
6464
endif()
@@ -136,11 +136,12 @@ if(ARROW_FLIGHT_SQL_ODBC_INSTALLER)
136136
PATTERN "zlib1.dll")
137137

138138
set(CPACK_WIX_EXTRA_SOURCES
139-
"${CMAKE_CURRENT_SOURCE_DIR}/install/arrow-flight-sql-odbc.wxs")
139+
"${CMAKE_CURRENT_SOURCE_DIR}/install/windows/arrow-flight-sql-odbc.wxs")
140140
set(CPACK_WIX_PATCH_FILE
141-
"${CMAKE_CURRENT_SOURCE_DIR}/install/arrow-flight-sql-odbc-patch.xml")
141+
"${CMAKE_CURRENT_SOURCE_DIR}/install/windows/arrow-flight-sql-odbc-patch.xml")
142142

143-
set(CPACK_WIX_UI_BANNER "${CMAKE_CURRENT_SOURCE_DIR}/install/arrow-wix-banner.bmp")
143+
set(CPACK_WIX_UI_BANNER
144+
"${CMAKE_CURRENT_SOURCE_DIR}/install/windows/arrow-wix-banner.bmp")
144145
endif()
145146

146147
get_cmake_property(CPACK_COMPONENTS_ALL COMPONENTS)

cpp/src/arrow/flight/sql/odbc/README

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,9 @@ After the build succeeds, the ODBC DLL will be located in
3030
i. `cd to repo.`
3131
ii. `cd <path\to\repo>`
3232
iii. Run script to register your ODBC DLL as Apache Arrow Flight SQL ODBC Driver
33-
`.\cpp\src\arrow\flight\sql\odbc\install\install_amd64.cmd <path\to\repo>\cpp\build\< release | debug >\< Release | Debug>\arrow_flight_sql_odbc.dll`
33+
`.\cpp\src\arrow\flight\sql\odbc\tests\install_odbc.cmd <path\to\repo>\cpp\build\< release | debug >\< Release | Debug>\arrow_flight_sql_odbc.dll`
3434
Example command for reference:
35-
`.\cpp\src\arrow\flight\sql\odbc\install\install_amd64.cmd C:\path\to\arrow\cpp\build\release\Release\arrow_flight_sql_odbc.dll`
35+
`.\cpp\src\arrow\flight\sql\odbc\tests\install_odbc.cmd C:\path\to\arrow\cpp\build\release\Release\arrow_flight_sql_odbc.dll`
3636

3737
If the registration is successful, then Apache Arrow Flight SQL ODBC Driver
3838
should show as an available ODBC driver in the x64 ODBC Driver Manager.
@@ -44,6 +44,27 @@ should show as an available ODBC driver in the x64 ODBC Driver Manager.
4444

4545
If the generation is successful, you will find `Apache Arrow Flight SQL ODBC-<version>-win64.msi` generated under the `build` folder.
4646

47+
## Steps to Register the 64-bit Apache Arrow ODBC driver on macOS
48+
49+
After the build succeeds, the ODBC DYLIB will be located in
50+
`build\debug` for a debug build and `build\release` for a release build.
51+
52+
1. Open terminal shell.
53+
54+
2. Register your ODBC DYLIB:
55+
Need to replace <path\to\repo> with actual path to repository in the commands.
56+
57+
i. `cd to repo.`
58+
ii. `cd <path\to\repo>`
59+
iii. Give script permission to execute
60+
`chmod +x cpp/src/arrow/flight/sql/odbc/install/mac/install_odbc.sh`
61+
iv. Run script with `sudo` to register your ODBC DYLIB as Apache Arrow Flight SQL ODBC Driver
62+
`sudo cpp/src/arrow/flight/sql/odbc/install/mac/install_odbc.sh <path\to\repo>/cpp/build/< release | debug >/libarrow_flight_sql_odbc.dylib`
63+
Example command for reference:
64+
`sudo cpp/src/arrow/flight/sql/odbc/install/mac/install_odbc.sh /path/to/arrow/cpp/build/release/libarrow_flight_sql_odbc.dylib`
65+
66+
If the registration is successful, then Apache Arrow Flight SQL ODBC Driver
67+
should be shown at `~/Library/ODBC/odbcinst.ini`
4768

4869
## Steps to Enable Logging
4970
Arrow Flight SQL ODBC driver uses Arrow's internal logging framework. By default, the log messages are printed to the terminal.
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
#!/bin/sh
2+
#
3+
# Licensed to the Apache Software Foundation (ASF) under one
4+
# or more contributor license agreements. See the NOTICE file
5+
# distributed with this work for additional information
6+
# regarding copyright ownership. The ASF licenses this file
7+
# to you under the Apache License, Version 2.0 (the
8+
# "License"); you may not use this file except in compliance
9+
# with the License. You may obtain a copy of the License at
10+
#
11+
# http://www.apache.org/licenses/LICENSE-2.0
12+
#
13+
# Unless required by applicable law or agreed to in writing,
14+
# software distributed under the License is distributed on an
15+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16+
# KIND, either express or implied. See the License for the
17+
# specific language governing permissions and limitations
18+
# under the License.
19+
20+
# Used by macOS ODBC installer script and macOS ODBC testing
21+
22+
ODBC_64BIT="$1"
23+
24+
if [[ -z "$ODBC_64BIT" ]]; then
25+
echo "error: 64-bit driver is not specified. Call format: install_odbc abs_path_to_64_bit_driver"
26+
exit 1
27+
fi
28+
29+
if [ ! -f $ODBC_64BIT ]; then
30+
echo "64-bit driver can not be found: $ODBC_64BIT"
31+
echo "Call format: install_odbc abs_path_to_64_bit_driver"
32+
exit 1
33+
fi
34+
35+
USER_ODBCINST_FILE="$HOME/Library/ODBC/odbcinst.ini"
36+
DRIVER_NAME="Apache Arrow Flight SQL ODBC Driver"
37+
DSN_NAME="Apache Arrow Flight SQL ODBC DSN"
38+
39+
touch "$USER_ODBCINST_FILE"
40+
41+
# Admin privilege is needed to add ODBC driver registration
42+
if [ $EUID -ne 0 ]; then
43+
echo "Please run this script with sudo"
44+
exit 1
45+
fi
46+
47+
if grep -q "^\[$DRIVER_NAME\]" "$USER_ODBCINST_FILE"; then
48+
echo "Driver [$DRIVER_NAME] already exists in odbcinst.ini"
49+
else
50+
echo "Adding [$DRIVER_NAME] to odbcinst.ini..."
51+
echo "
52+
[$DRIVER_NAME]
53+
Description=An ODBC Driver for Apache Arrow Flight SQL
54+
Driver=$ODBC_64BIT
55+
" >> "$USER_ODBCINST_FILE"
56+
fi
57+
58+
# Check if [ODBC Drivers] section exists
59+
if grep -q '^\[ODBC Drivers\]' "$USER_ODBCINST_FILE"; then
60+
# Section exists: check if driver entry exists
61+
if ! grep -q "^${DRIVER_NAME}=" "$USER_ODBCINST_FILE"; then
62+
# Driver entry does not exist, add under [ODBC Drivers]
63+
sed -i '' "/^\[ODBC Drivers\]/a\\
64+
${DRIVER_NAME}=Installed
65+
" "$USER_ODBCINST_FILE"
66+
fi
67+
else
68+
# Section doesn't exist, append both section and driver entry at end
69+
{
70+
echo ""
71+
echo "[ODBC Drivers]"
72+
echo "${DRIVER_NAME}=Installed"
73+
} >> "$USER_ODBCINST_FILE"
74+
fi
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
#!/bin/sh
2+
#
3+
# Licensed to the Apache Software Foundation (ASF) under one
4+
# or more contributor license agreements. See the NOTICE file
5+
# distributed with this work for additional information
6+
# regarding copyright ownership. The ASF licenses this file
7+
# to you under the Apache License, Version 2.0 (the
8+
# "License"); you may not use this file except in compliance
9+
# with the License. You may obtain a copy of the License at
10+
#
11+
# http://www.apache.org/licenses/LICENSE-2.0
12+
#
13+
# Unless required by applicable law or agreed to in writing,
14+
# software distributed under the License is distributed on an
15+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16+
# KIND, either express or implied. See the License for the
17+
# specific language governing permissions and limitations
18+
# under the License.
19+
20+
# GH-47876 TODO: create macOS ODBC Installer.
21+
# Script for installing macOS ODBC driver, to be used for macOS installer.
22+
23+
source_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
24+
25+
odbc_install_script="${source_dir}/install_odbc.sh"
26+
27+
chmod +x "$odbc_install_script"
28+
. "$odbc_install_script" /Library/Apache/ArrowFlightSQLODBC/lib/libarrow_flight_sql_odbc.dylib
29+
30+
USER_ODBC_FILE="$HOME/Library/ODBC/odbc.ini"
31+
DRIVER_NAME="Apache Arrow Flight SQL ODBC Driver"
32+
DSN_NAME="Apache Arrow Flight SQL ODBC DSN"
33+
34+
touch "$USER_ODBC_FILE"
35+
36+
if [ $EUID -ne 0 ]; then
37+
echo "Please run this script with sudo"
38+
exit 1
39+
fi
40+
41+
if grep -q "^\[$DSN_NAME\]" "$USER_ODBC_FILE"; then
42+
echo "DSN [$DSN_NAME] already exists in $USER_ODBC_FILE"
43+
else
44+
echo "Adding [$DSN_NAME] to $USER_ODBC_FILE..."
45+
cat >> "$USER_ODBC_FILE" <<EOF
46+
47+
[$DSN_NAME]
48+
Description = An ODBC Driver DSN for Apache Arrow Flight SQL
49+
Driver = Apache Arrow Flight SQL ODBC Driver
50+
Host =
51+
Port =
52+
UID =
53+
PWD =
54+
EOF
55+
fi
56+
57+
# Check if [ODBC Data Sources] section exists
58+
if grep -q '^\[ODBC Data Sources\]' "$USER_ODBC_FILE"; then
59+
# Section exists: check if DSN entry exists
60+
if ! grep -q "^${DSN_NAME}=" "$USER_ODBC_FILE"; then
61+
# Add DSN entry under [ODBC Data Sources] section
62+
63+
# Use awk to insert the line immediately after [ODBC Data Sources]
64+
awk -v dsn="$DSN_NAME" -v driver="$DRIVER_NAME" '
65+
$0 ~ /^\[ODBC Data Sources\]/ && !inserted {
66+
print
67+
print dsn "=" driver
68+
inserted=1
69+
next
70+
}
71+
{ print }
72+
' "$USER_ODBC_FILE" > "${USER_ODBC_FILE}.tmp" && mv "${USER_ODBC_FILE}.tmp" "$USER_ODBC_FILE"
73+
fi
74+
else
75+
# Section doesn't exist, append section and DSN entry at end
76+
{
77+
echo ""
78+
echo "[ODBC Data Sources]"
79+
echo "${DSN_NAME}=${DRIVER_NAME}"
80+
} >> "$USER_ODBC_FILE"
81+
fi
82+

cpp/src/arrow/flight/sql/odbc/install/arrow-flight-sql-odbc-patch.xml renamed to cpp/src/arrow/flight/sql/odbc/install/windows/arrow-flight-sql-odbc-patch.xml

File renamed without changes.

cpp/src/arrow/flight/sql/odbc/install/arrow-flight-sql-odbc.wxs renamed to cpp/src/arrow/flight/sql/odbc/install/windows/arrow-flight-sql-odbc.wxs

File renamed without changes.

cpp/src/arrow/flight/sql/odbc/install/arrow-wix-banner.bmp renamed to cpp/src/arrow/flight/sql/odbc/install/windows/arrow-wix-banner.bmp

File renamed without changes.

cpp/src/arrow/flight/sql/odbc/install/versioninfo.rc.in renamed to cpp/src/arrow/flight/sql/odbc/install/windows/versioninfo.rc.in

File renamed without changes.

0 commit comments

Comments
 (0)