Skip to content

Commit 1b8f118

Browse files
committed
macOS .PKG installer for Intel and ARM
Co-authored-by: vic-tsang <victor.tsang@improving.com> cpp/src/arrow/flight/sql/odbc/install/unix/install_odbc_ini.sh is originally authored by vic-tsang <victor.tsang@improving.com> --------------------------------------- * Initial draft for macOS .pkg installer * in-progress for `install_odbc` * Remove `$HOME` from registration script * Generate .pkg installer and attempts to fix installer * Attempt to fix doc not seen * Attempt to fix ODBC registration script * Fix installer script and doc * Rename `install_odbc_ini.sh` to `postinstall` * Reuse `install_odbc.sh` script inside `postinstall` * Fix to generate macOS installer - Check $(pwd)/build/cpp * Clean up PR and todos * Update format to re-use code * Use `install_odbc_ini.sh` script to install DSN Keep a lightweight `postinstall` file for macOS * Update install_odbc_ini.sh execution access * Address Justin's comment
1 parent 0ce017b commit 1b8f118

10 files changed

Lines changed: 226 additions & 5 deletions

File tree

.github/workflows/cpp_extra.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -429,6 +429,7 @@ jobs:
429429
ARROW_DEPENDENCY_SOURCE: BUNDLED
430430
ARROW_DEPENDENCY_USE_SHARED: OFF
431431
ARROW_FLIGHT_SQL_ODBC: ON
432+
ARROW_FLIGHT_SQL_ODBC_INSTALLER: ON
432433
ARROW_HOME: /tmp/local
433434
ARROW_MIMALLOC: OFF
434435
steps:
@@ -504,6 +505,19 @@ jobs:
504505
--allow libresolv \
505506
--allow libz \
506507
"$(pwd)/build/cpp/${{ matrix.build-type }}/libarrow_flight_sql_odbc.dylib"
508+
- name: Generate macOS Installer
509+
if: matrix.build-type == 'release'
510+
shell: bash
511+
run: |
512+
cd $(pwd)/build/cpp
513+
cpack
514+
- name: Upload ODBC PKG to the job
515+
if: matrix.build-type == 'release'
516+
uses: actions/upload-artifact@v7
517+
with:
518+
name: flight-sql-odbc-pkg-installer-${{ matrix.architecture }}
519+
path: build/cpp/ArrowFlightSqlOdbcODBC-*.pkg
520+
if-no-files-found: error
507521
- name: Register Flight SQL ODBC Driver
508522
run: |
509523
sudo cpp/src/arrow/flight/sql/odbc/install/unix/install_odbc.sh $(pwd)/build/cpp/${{ matrix.build-type }}/libarrow_flight_sql_odbc.dylib

.pre-commit-config.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -347,7 +347,9 @@ repos:
347347
?^cpp/build-support/update-thrift\.sh$|
348348
?^cpp/examples/minimal_build/run\.sh$|
349349
?^cpp/examples/tutorial_examples/run\.sh$|
350+
?^cpp/src/arrow/flight/sql/odbc/install/mac/postinstall$|
350351
?^cpp/src/arrow/flight/sql/odbc/install/unix/install_odbc\.sh$|
352+
?^cpp/src/arrow/flight/sql/odbc/install/unix/install_odbc_ini\.sh$|
351353
?^dev/release/05-binary-upload\.sh$|
352354
?^dev/release/08-binary-verify\.sh$|
353355
?^dev/release/binary-recover\.sh$|

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

Lines changed: 73 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,6 @@ if(ARROW_FLIGHT_SQL_ODBC_INSTALLER)
132132
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Apache Arrow Flight SQL ODBC Driver")
133133
set(CPACK_PACKAGE_CONTACT "dev@arrow.apache.org")
134134

135-
# GH-47876 TODO: set up `arrow_flight_sql_odbc` component for macOS Installer
136135
# GH-47877 TODO: set up `arrow_flight_sql_odbc` component for Linux Installer
137136
if(WIN32)
138137
# Install ODBC and its Arrow dependencies
@@ -159,6 +158,66 @@ if(ARROW_FLIGHT_SQL_ODBC_INSTALLER)
159158

160159
set(CPACK_WIX_UI_BANNER
161160
"${CMAKE_CURRENT_SOURCE_DIR}/install/windows/arrow-wix-banner.bmp")
161+
else()
162+
if(APPLE)
163+
set(CPACK_PACKAGE_FILE_NAME
164+
"ArrowFlightSqlOdbcODBC-${CPACK_PACKAGE_VERSION_MAJOR}.${ODBC_PACKAGE_VERSION_MINOR}.${ODBC_PACKAGE_VERSION_PATCH}"
165+
)
166+
set(CPACK_PACKAGE_INSTALL_DIRECTORY "${CPACK_PACKAGE_NAME}")
167+
168+
set(CPACK_SET_DESTDIR ON)
169+
set(CPACK_INSTALL_PREFIX "/Library/ODBC")
170+
# Register ODBC after install
171+
set(CPACK_POSTFLIGHT_ARROW_FLIGHT_SQL_ODBC_SCRIPT
172+
"${CMAKE_CURRENT_SOURCE_DIR}/install/mac/postinstall")
173+
set(CPACK_RESOURCE_FILE_README "${CMAKE_CURRENT_SOURCE_DIR}/install/mac/README.txt")
174+
set(CPACK_RESOURCE_FILE_WELCOME
175+
"${CMAKE_CURRENT_SOURCE_DIR}/install/mac/Welcome.txt")
176+
177+
set(ODBC_INSTALL_DIR "arrow-odbc/lib")
178+
set(DOC_INSTALL_DIR "arrow-odbc/doc")
179+
else()
180+
# Linux
181+
# GH-49595: TODO implement DEB installer
182+
# GH-47977: TODO implement RPM installer
183+
message(STATUS "ODBC_PACKAGE_FORMAT DEB not implemented, see GH-49595")
184+
message(STATUS "ODBC_PACKAGE_FORMAT RPM not implemented, see GH-47977")
185+
endif()
186+
187+
# Install ODBC
188+
install(TARGETS arrow_flight_sql_odbc_shared
189+
DESTINATION "${ODBC_INSTALL_DIR}"
190+
COMPONENT arrow_flight_sql_odbc)
191+
192+
# Install temporary driver registration scripts, they will be removed after driver registration is complete
193+
install(FILES "${CMAKE_CURRENT_SOURCE_DIR}/install/unix/install_odbc.sh"
194+
DESTINATION "${ODBC_INSTALL_DIR}"
195+
COMPONENT arrow_flight_sql_odbc
196+
PERMISSIONS OWNER_EXECUTE
197+
OWNER_WRITE
198+
OWNER_READ
199+
GROUP_EXECUTE
200+
GROUP_READ
201+
WORLD_EXECUTE
202+
WORLD_READ)
203+
install(FILES "${CMAKE_CURRENT_SOURCE_DIR}/install/unix/install_odbc_ini.sh"
204+
DESTINATION "${ODBC_INSTALL_DIR}"
205+
COMPONENT arrow_flight_sql_odbc
206+
PERMISSIONS OWNER_EXECUTE
207+
OWNER_WRITE
208+
OWNER_READ
209+
GROUP_EXECUTE
210+
GROUP_READ
211+
WORLD_EXECUTE
212+
WORLD_READ)
213+
214+
# Install documentation files
215+
install(FILES "${CMAKE_CURRENT_SOURCE_DIR}/../../../../../../LICENSE.txt"
216+
DESTINATION "${DOC_INSTALL_DIR}"
217+
COMPONENT Docs)
218+
install(FILES "${CMAKE_CURRENT_SOURCE_DIR}/Connection-Options.md"
219+
DESTINATION "${DOC_INSTALL_DIR}"
220+
COMPONENT Docs)
162221
endif()
163222

164223
get_cmake_property(CPACK_COMPONENTS_ALL COMPONENTS)
@@ -173,8 +232,13 @@ if(ARROW_FLIGHT_SQL_ODBC_INSTALLER)
173232
# Upgrade GUID is required to be unchanged for ODBC installer to upgrade
174233
set(CPACK_WIX_UPGRADE_GUID "DBF27A18-F8BF-423F-9E3A-957414D52C4B")
175234
set(CPACK_WIX_PRODUCT_GUID "279D087B-93B5-4DC3-BA69-BCF485022A26")
235+
else()
236+
# macOS and Linux
237+
list(APPEND CPACK_COMPONENTS_ALL Docs)
238+
if(APPLE)
239+
set(CPACK_GENERATOR "productbuild")
240+
endif()
176241
endif()
177-
# GH-47876 TODO: create macOS Installer using cpack
178242
# GH-47877 TODO: create Linux Installer using cpack
179243

180244
# Load CPack after all CPACK* variables are set
@@ -183,4 +247,11 @@ if(ARROW_FLIGHT_SQL_ODBC_INSTALLER)
183247
DISPLAY_NAME "ODBC library"
184248
DESCRIPTION "Apache Arrow Flight SQL ODBC library bin, required to install"
185249
REQUIRED)
250+
if(UNIX)
251+
# On macOS and Linux, provide connection string documentation since users need to manually enter DSN keys.
252+
cpack_add_component(Docs
253+
DISPLAY_NAME "Documentation"
254+
DESCRIPTION "Documentation for Apache Arrow Flight SQL ODBC Driver"
255+
)
256+
endif()
186257
endif()
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<!---
2+
Licensed to the Apache Software Foundation (ASF) under one
3+
or more contributor license agreements. See the NOTICE file
4+
distributed with this work for additional information
5+
regarding copyright ownership. The ASF licenses this file
6+
to you under the Apache License, Version 2.0 (the
7+
"License"); you may not use this file except in compliance
8+
with the License. You may obtain a copy of the License at
9+
10+
http://www.apache.org/licenses/LICENSE-2.0
11+
12+
Unless required by applicable law or agreed to in writing,
13+
software distributed under the License is distributed on an
14+
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
KIND, either express or implied. See the License for the
16+
specific language governing permissions and limitations
17+
under the License.
18+
-->
19+
20+
GH-49723 TODO: enter ODBC connection options for unix DSN
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
Files are available in '/Library/ODBC/arrow-odbc' after installation.
2+
3+
To setup a connection, you can use DSN to store your data source connection information.
4+
1. Open 'iODBC Data Source Administrator'.
5+
2. To create a user DSN, go to 'User DSN' tab and click 'Add'.
6+
3. Select 'Apache Arrow Flight SQL ODBC Driver' and click 'Finish'.
7+
4. Enter DSN name and connection string values.
8+
For the list of all supported options, check '/Library/ODBC/arrow-odbc/doc/Connection-Options.md'.
9+
5. Click 'Ok' to save the DSN.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Apache Arrow Flight SQL ODBC Driver is a read-only ODBC driver for connecting to data sources that support Arrow Flight SQL.
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#!/bin/bash
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+
# Use temporary driver registration script to register ODBC driver in system DSN
21+
odbc_install_script="/Library/ODBC/arrow-odbc/lib/install_odbc.sh"
22+
"$odbc_install_script" /Library/ODBC/arrow-odbc/lib/libarrow_flight_sql_odbc.dylib
23+
24+
# Use temporary DSN registration script to register sample system DSN
25+
dsn_install_script="/Library/ODBC/arrow-odbc/lib/install_odbc_ini.sh"
26+
"$dsn_install_script" /Library/ODBC/odbc.ini
27+
28+
# clean temporary script
29+
rm -f "$odbc_install_script"
30+
rm -f "$dsn_install_script"

cpp/src/arrow/flight/sql/odbc/install/unix/install_odbc.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
# specific language governing permissions and limitations
1818
# under the License.
1919

20-
# Used by macOS ODBC installer script `install_odbc_ini.sh` and macOS ODBC testing
20+
# Used by arrow/cpp/src/arrow/flight/sql/odbc/install/mac/postinstall
2121

2222
set -euo pipefail
2323

@@ -46,8 +46,8 @@ case "$(uname)" in
4646
;;
4747
*)
4848
# macOS
49-
USER_ODBCINST_FILE="$HOME/Library/ODBC/odbcinst.ini"
50-
mkdir -p "$HOME"/Library/ODBC
49+
USER_ODBCINST_FILE="/Library/ODBC/odbcinst.ini"
50+
mkdir -p /Library/ODBC
5151
;;
5252
esac
5353

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
#!/bin/bash
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+
SYSTEM_ODBC_FILE="$1"
21+
22+
if [[ -z "$SYSTEM_ODBC_FILE" ]]; then
23+
echo "error: path to system ODBC DSN is not specified. Call format: install_odbc_ini abs_path_to_odbc_dsn_ini"
24+
exit 1
25+
fi
26+
27+
DRIVER_NAME="Apache Arrow Flight SQL ODBC Driver"
28+
DSN_NAME="Apache Arrow Flight SQL ODBC DSN"
29+
30+
touch "$SYSTEM_ODBC_FILE"
31+
32+
if grep -q "^\[$DSN_NAME\]" "$SYSTEM_ODBC_FILE"; then
33+
echo "DSN [$DSN_NAME] already exists in $SYSTEM_ODBC_FILE"
34+
else
35+
echo "Adding [$DSN_NAME] to $SYSTEM_ODBC_FILE..."
36+
cat >> "$SYSTEM_ODBC_FILE" <<EOF
37+
38+
[$DSN_NAME]
39+
Description = An ODBC Driver DSN for Apache Arrow Flight SQL
40+
Driver = Apache Arrow Flight SQL ODBC Driver
41+
Host =
42+
Port =
43+
UID =
44+
PWD =
45+
EOF
46+
fi
47+
48+
# Check if [ODBC Data Sources] section exists
49+
if grep -q '^\[ODBC Data Sources\]' "$SYSTEM_ODBC_FILE"; then
50+
# Section exists: check if DSN entry exists
51+
if ! grep -q "^${DSN_NAME}=" "$SYSTEM_ODBC_FILE"; then
52+
# Add DSN entry under [ODBC Data Sources] section
53+
54+
# Use awk to insert the line immediately after [ODBC Data Sources]
55+
awk -v dsn="$DSN_NAME" -v driver="$DRIVER_NAME" '
56+
$0 ~ /^\[ODBC Data Sources\]/ && !inserted {
57+
print
58+
print dsn "=" driver
59+
inserted=1
60+
next
61+
}
62+
{ print }
63+
' "$SYSTEM_ODBC_FILE" > "${SYSTEM_ODBC_FILE}.tmp" && mv "${SYSTEM_ODBC_FILE}.tmp" "$SYSTEM_ODBC_FILE"
64+
fi
65+
else
66+
# Section doesn't exist, append section and DSN entry at end
67+
{
68+
echo ""
69+
echo "[ODBC Data Sources]"
70+
echo "${DSN_NAME}=${DRIVER_NAME}"
71+
} >> "$SYSTEM_ODBC_FILE"
72+
fi

dev/release/rat_exclude_files.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ ci/vcpkg/*.patch
1313
CHANGELOG.md
1414
cpp/CHANGELOG_PARQUET.md
1515
cpp/src/arrow/c/dlpack_abi.h
16+
cpp/src/arrow/flight/sql/odbc/install/mac/README.txt
17+
cpp/src/arrow/flight/sql/odbc/install/mac/Welcome.txt
1618
cpp/src/arrow/io/mman.h
1719
cpp/src/arrow/util/random.h
1820
cpp/src/arrow/status.cc

0 commit comments

Comments
 (0)