Copilot commented on code in PR #49766:
URL: https://github.com/apache/arrow/pull/49766#discussion_r3270490792


##########
cpp/src/arrow/flight/sql/odbc/install/unix/install_odbc_ini.sh:
##########
@@ -0,0 +1,81 @@
+#!/bin/bash
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+set -euo pipefail
+
+SYSTEM_ODBC_FILE="${1:-}"
+
+if [[ -z "$SYSTEM_ODBC_FILE" ]]; then
+  echo "ERROR: path to system ODBC DSN is not specified." >&2
+  echo "Usage: install_odbc_ini.sh <abs_path_to_odbc_dsn_ini>" >&2
+  exit 1
+fi
+
+DRIVER_NAME="Apache Arrow Flight SQL ODBC Driver"
+DSN_NAME="Apache Arrow Flight SQL ODBC DSN"
+
+if ! touch "$SYSTEM_ODBC_FILE"; then
+  echo "ERROR: Cannot access or create $SYSTEM_ODBC_FILE" >&2
+  exit 1
+fi
+
+if grep -q "^\[$DSN_NAME\]" "$SYSTEM_ODBC_FILE"; then
+  echo "DSN [$DSN_NAME] already exists in $SYSTEM_ODBC_FILE"
+else
+  echo "Adding [$DSN_NAME] to $SYSTEM_ODBC_FILE..."
+  cat >> "$SYSTEM_ODBC_FILE" <<EOF
+
+[$DSN_NAME]
+Description = An ODBC Driver DSN for Apache Arrow Flight SQL
+Driver      = $DRIVER_NAME
+Host        =
+Port        =
+UID         =
+PWD         =
+EOF
+fi
+
+# Check if [ODBC Data Sources] section exists
+if grep -q '^\[ODBC Data Sources\]' "$SYSTEM_ODBC_FILE"; then
+  # Section exists: check if DSN entry exists
+  if ! grep -Eq "^${DSN_NAME}[[:space:]]*=" "$SYSTEM_ODBC_FILE"; then
+    # Add DSN entry under [ODBC Data Sources] section
+    tmp_file="$(mktemp "${SYSTEM_ODBC_FILE}.XXXX")"
+
+    # Use awk to insert the line immediately after [ODBC Data Sources]
+    awk -v dsn="$DSN_NAME" -v driver="$DRIVER_NAME" '
+      $0 ~ /^\[ODBC Data Sources\]/ && !inserted {

Review Comment:
   `mktemp` creates the temp file with mode 0600, and the subsequent `mv` 
replaces the target INI file with that restrictive mode. For system DSNs, 
`/Library/ODBC/odbc.ini` generally needs to remain world-readable; this script 
can inadvertently make it unreadable for non-root ODBC clients. Preserve the 
original file's mode/ownership (or explicitly chmod/chown after update) instead 
of replacing it with a mktemp-created file.



##########
cpp/src/arrow/flight/sql/odbc/CMakeLists.txt:
##########
@@ -159,10 +157,69 @@ if(ARROW_FLIGHT_SQL_ODBC_INSTALLER)
 
     set(CPACK_WIX_UI_BANNER
         "${CMAKE_CURRENT_SOURCE_DIR}/install/windows/arrow-wix-banner.bmp")
+  else()
+    if(APPLE)
+      set(CPACK_PACKAGE_FILE_NAME
+          
"ArrowFlightSQLODBC-${CPACK_PACKAGE_VERSION_MAJOR}.${ODBC_PACKAGE_VERSION_MINOR}.${ODBC_PACKAGE_VERSION_PATCH}"
+      )
+      set(CPACK_PACKAGE_INSTALL_DIRECTORY "${CPACK_PACKAGE_NAME}")
+
+      set(CPACK_SET_DESTDIR ON)
+      set(CPACK_INSTALL_PREFIX "/Library/ODBC")
+      # Register ODBC after install
+      set(CPACK_POSTFLIGHT_ARROWFLIGHTSQLODBC_SCRIPT
+          "${CMAKE_CURRENT_SOURCE_DIR}/install/mac/postinstall")
+      set(CPACK_RESOURCE_FILE_README 
"${CMAKE_CURRENT_SOURCE_DIR}/install/mac/README.txt")
+      set(CPACK_RESOURCE_FILE_WELCOME
+          "${CMAKE_CURRENT_SOURCE_DIR}/install/mac/welcome.txt")
+
+      set(ODBC_INSTALL_DIR "arrow-odbc/lib")
+      set(ODBC_DOC_INSTALL_DIR "arrow-odbc/doc")
+    else()
+      # Linux
+      # GH-49595: TODO implement DEB installer
+      # GH-47977: TODO implement RPM installer
+      message(STATUS "ODBC_PACKAGE_FORMAT DEB not implemented, see GH-49595")
+      message(STATUS "ODBC_PACKAGE_FORMAT RPM not implemented, see GH-47977")
+    endif()
+
+    # Install ODBC
+    install(TARGETS arrow_flight_sql_odbc_shared
+            DESTINATION "${ODBC_INSTALL_DIR}"
+            COMPONENT ArrowFlightSQLODBC)

Review Comment:
   In the non-Windows branch, `ODBC_INSTALL_DIR`/`ODBC_DOC_INSTALL_DIR` are 
only set in the `if(APPLE)` block, but the `install(... DESTINATION 
"${ODBC_INSTALL_DIR}")` calls run unconditionally after the `endif()`. If 
`ARROW_FLIGHT_SQL_ODBC_INSTALLER` is enabled on Linux today, this expands to an 
empty destination and will install/package files into an unintended location. 
Consider failing fast with `message(FATAL_ERROR ...)` when not `WIN32`/`APPLE`, 
or define Linux install dirs before these `install()` calls.



##########
cpp/src/arrow/flight/sql/odbc/connection-options.md:
##########
@@ -0,0 +1,20 @@
+<!---
+  Licensed to the Apache Software Foundation (ASF) under one
+  or more contributor license agreements.  See the NOTICE file
+  distributed with this work for additional information
+  regarding copyright ownership.  The ASF licenses this file
+  to you under the Apache License, Version 2.0 (the
+  "License"); you may not use this file except in compliance
+  with the License.  You may obtain a copy of the License at
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing,
+  software distributed under the License is distributed on an
+  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+  KIND, either express or implied.  See the License for the
+  specific language governing permissions and limitations
+  under the License.
+-->
+
+GH-49723 TODO: enter ODBC connection options for unix DSN

Review Comment:
   `connection-options.md` is installed into the packaged documentation, but it 
currently contains only a TODO placeholder. Since this is user-facing content 
shipped in the macOS installer, it should be populated with the actual 
supported connection options (or omitted from the installer until the content 
is ready) to avoid distributing incomplete documentation.
   



##########
cpp/src/arrow/flight/sql/odbc/install/unix/install_odbc.sh:
##########
@@ -17,7 +17,7 @@
 # specific language governing permissions and limitations
 # under the License.
 
-# Used by macOS ODBC installer script `install_odbc_ini.sh` and macOS ODBC 
testing
+# Used by arrow/cpp/src/arrow/flight/sql/odbc/install/mac/postinstall

Review Comment:
   The comment references `arrow/cpp/src/.../postinstall`, but the repository 
path is `cpp/src/.../postinstall` (there is no `arrow/` prefix). Updating the 
path in the comment will avoid confusion when grepping or following the 
instructions.
   



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to