From dcd3b3055fa47263c307d74aa6369eedc1658f28 Mon Sep 17 00:00:00 2001 From: "Alina (Xi) Li" <96995091+alinaliBQ@users.noreply.github.com> Date: Thu, 8 Oct 2026 13:54:48 -0700 Subject: [PATCH 1/4] Upload macOS package to GitHub release In-progress fix CI logic Revert "Increase nugettimeout to 30 mins" This reverts commit 62b8d41964d7873db3058e1925fb42af67fce3c3. Increase nugettimeout to 30 mins Upload gRPC can take long for vcpkg Clean up IN-PROGRESS add check Address Raul and Bryce comments - removed `Check runner architecture` - remove `odbc-release-check` Fix sudo issue Empty commit to retrigger CI to fix https://github.com/apache/arrow/actions/runs/41538385140/job/125596157426 ODBC debug AMD64 macOS 26-intel error Re-use macOS ODBC workflow .github/actions/odbc-mac/action.yml mirrors .github/actions/odbc-windows/action.yml Address Bryce's comments Co-Authored-By: Bryce Mecum --- .github/actions/odbc-mac/action.yml | 94 +++++++++++ .github/workflows/cpp_extra.yml | 56 +------ .github/workflows/package_odbc.yml | 249 +++++++++++++++++++++++++++- 3 files changed, 345 insertions(+), 54 deletions(-) create mode 100644 .github/actions/odbc-mac/action.yml diff --git a/.github/actions/odbc-mac/action.yml b/.github/actions/odbc-mac/action.yml new file mode 100644 index 000000000000..42bf95656924 --- /dev/null +++ b/.github/actions/odbc-mac/action.yml @@ -0,0 +1,94 @@ +# 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. + +name: ODBC macOS Reusable +description: Install dependencies and build the Flight SQL ODBC driver on macOS +inputs: + architecture: + description: 'Architecture to build for (AMD64 or ARM64)' + required: true + generate-installer: + description: 'Whether to run cpack to generate the .pkg installer after the build' + required: false + default: 'false' +runs: + using: "composite" + steps: + - name: Install Dependencies + shell: bash + run: | + brew bundle --file=cpp/Brewfile + + # We want to use bundled RE2 for static linking. If + # Homebrew's RE2 is installed, its header file may be used. + # We uninstall Homebrew's RE2 to ensure using bundled RE2. + brew uninstall grpc || : # gRPC depends on RE2 + brew uninstall grpc@1.54 || : # gRPC 1.54 may be installed too + brew uninstall re2 + + # We want to use bundled Protobuf for static linking. If + # Homebrew's Protobuf is installed, its library file may be + # used on test. We uninstall Homebrew's Protobuf to ensure using + # bundled Protobuf. + brew uninstall protobuf + + # We want to use bundled Boost for static linking. + brew uninstall boost + - name: Setup ccache + shell: bash + run: | + ci/scripts/ccache_setup.sh + - name: ccache info + id: ccache-info + shell: bash + run: | + echo "cache-dir=$(ccache --get-config cache_dir)" >> $GITHUB_OUTPUT + - name: Restore ccache + uses: apache/infrastructure-actions/stash/restore@762a01f36a09ab9e0e4c8af8f4b0f2ed12683df5 + with: + path: ${{ steps.ccache-info.outputs.cache-dir }} + key: cpp-odbc-ccache-macos-${{ inputs.architecture }}-${{ env.ARROW_BUILD_TYPE }} + - name: Build + shell: bash + run: | + # Homebrew uses /usr/local as prefix. So packages + # installed by Homebrew also use /usr/local/include. We + # want to include headers for packages installed by + # Homebrew as system headers to ignore warnings in them. + # But "-isystem /usr/local/include" isn't used by CMake + # because /usr/local/include is marked as the default + # include path. So we disable -Werror to avoid build error + # by warnings from packages installed by Homebrew. + export BUILD_WARNING_LEVEL=PRODUCTION + LIBIODBC_DIR="$(brew --cellar libiodbc)/$(brew list --versions libiodbc | awk '{print $2}')" + ODBC_INCLUDE_DIR=$LIBIODBC_DIR/include + export ARROW_CMAKE_ARGS="-DODBC_INCLUDE_DIR=$ODBC_INCLUDE_DIR" + export CXXFLAGS="$CXXFLAGS -I$ODBC_INCLUDE_DIR" + ci/scripts/cpp_build.sh $(pwd) $(pwd)/build + - name: Save ccache + if: ${{ !cancelled() }} + continue-on-error: true + uses: apache/infrastructure-actions/stash/save@762a01f36a09ab9e0e4c8af8f4b0f2ed12683df5 + with: + path: ${{ steps.ccache-info.outputs.cache-dir }} + key: cpp-odbc-ccache-macos-${{ inputs.architecture }}-${{ env.ARROW_BUILD_TYPE }} + - name: Generate macOS Installer + if: inputs.generate-installer == 'true' + shell: bash + run: | + cd build/cpp + cpack diff --git a/.github/workflows/cpp_extra.yml b/.github/workflows/cpp_extra.yml index 40ad84643231..4a823bea2024 100644 --- a/.github/workflows/cpp_extra.yml +++ b/.github/workflows/cpp_extra.yml @@ -576,60 +576,10 @@ jobs: persist-credentials: false fetch-depth: 0 submodules: recursive - - name: Install Dependencies - run: | - brew bundle --file=cpp/Brewfile - - # We want to use bundled RE2 for static linking. If - # Homebrew's RE2 is installed, its header file may be used. - # We uninstall Homebrew's RE2 to ensure using bundled RE2. - brew uninstall grpc || : # gRPC depends on RE2 - brew uninstall grpc@1.54 || : # gRPC 1.54 may be installed too - brew uninstall re2 - - # We want to use bundled Protobuf for static linking. If - # Homebrew's Protobuf is installed, its library file may be - # used on test We uninstall Homebrew's Protobuf to ensure using - # bundled Protobuf. - brew uninstall protobuf - - # We want to use bundled Boost for static linking. - brew uninstall boost - - name: Setup ccache - run: | - ci/scripts/ccache_setup.sh - - name: ccache info - id: ccache-info - run: | - echo "cache-dir=$(ccache --get-config cache_dir)" >> $GITHUB_OUTPUT - - name: Restore ccache - uses: apache/infrastructure-actions/stash/restore@762a01f36a09ab9e0e4c8af8f4b0f2ed12683df5 + - name: Build ODBC macOS + uses: ./.github/actions/odbc-mac with: - path: ${{ steps.ccache-info.outputs.cache-dir }} - key: cpp-odbc-ccache-macos-${{ matrix.macos-version }}-${{ matrix.build-type }} - - name: Build - run: | - # Homebrew uses /usr/local as prefix. So packages - # installed by Homebrew also use /usr/local/include. We - # want to include headers for packages installed by - # Homebrew as system headers to ignore warnings in them. - # But "-isystem /usr/local/include" isn't used by CMake - # because /usr/local/include is marked as the default - # include path. So we disable -Werror to avoid build error - # by warnings from packages installed by Homebrew. - export BUILD_WARNING_LEVEL=PRODUCTION - LIBIODBC_DIR="$(brew --cellar libiodbc)/$(brew list --versions libiodbc | awk '{print $2}')" - ODBC_INCLUDE_DIR=$LIBIODBC_DIR/include - export ARROW_CMAKE_ARGS="-DODBC_INCLUDE_DIR=$ODBC_INCLUDE_DIR" - export CXXFLAGS="$CXXFLAGS -I$ODBC_INCLUDE_DIR" - ci/scripts/cpp_build.sh $(pwd) $(pwd)/build - - name: Save ccache - if: ${{ !cancelled() }} - continue-on-error: true - uses: apache/infrastructure-actions/stash/save@762a01f36a09ab9e0e4c8af8f4b0f2ed12683df5 - with: - path: ${{ steps.ccache-info.outputs.cache-dir }} - key: cpp-odbc-ccache-macos-${{ matrix.macos-version }}-${{ matrix.build-type }} + architecture: ${{ matrix.architecture }} - name: Setup Python uses: actions/setup-python@v7 with: diff --git a/.github/workflows/package_odbc.yml b/.github/workflows/package_odbc.yml index 975ad05ce007..241bf632351d 100644 --- a/.github/workflows/package_odbc.yml +++ b/.github/workflows/package_odbc.yml @@ -24,7 +24,7 @@ on: workflow_dispatch: inputs: odbc_release_step: - description: 'ODBC MSI release step' + description: 'ODBC MSI and macOS PKG release step' required: false default: false type: boolean @@ -179,3 +179,250 @@ jobs: gh release upload $env:GITHUB_REF_NAME ` --clobber ` Apache-Arrow-Flight-SQL-ODBC-*-win64.msi + + # Upload unsigned non-universal DYLIBs and the ARM64 base PKG + odbc-macos-upload-dylib: + name: ODBC macOS Upload Unsigned ${{ matrix.architecture }} DYLIB and ARM64 PKG + runs-on: macos-${{ matrix.macos-version }} + if: github.event_name == 'push' + timeout-minutes: 120 + strategy: + fail-fast: false + matrix: + include: + - { architecture: AMD64, macos-version: "26-intel" } + - { architecture: ARM64, macos-version: "26" } + env: + ARROW_BUILD_TESTS: OFF + ARROW_BUILD_TYPE: release + ARROW_DEPENDENCY_SOURCE: BUNDLED + ARROW_DEPENDENCY_USE_SHARED: OFF + ARROW_FLIGHT_SQL_ODBC: ON + ARROW_FLIGHT_SQL_ODBC_INSTALLER: ON + ARROW_HOME: /tmp/local + ARROW_MIMALLOC: OFF + MACOSX_DEPLOYMENT_TARGET: "14.0" + steps: + - name: Checkout Arrow + uses: actions/checkout@v7 + with: + persist-credentials: false + fetch-depth: 0 + submodules: recursive + - name: Build ODBC macOS + uses: ./.github/actions/odbc-mac + with: + architecture: ${{ matrix.architecture }} + generate-installer: ${{ matrix.architecture == 'ARM64' }} + - name: Copy Unsigned ODBC DYLIB + run: | + # The unversioned name libarrow_flight_sql_odbc.dylib is a symlink to + # libarrow_flight_sql_odbc..dylib. Copy the real file, keeping + # its versioned name, so the upload doesn't hit a dangling symlink. + mkdir ${{ matrix.architecture }}-dylib + cp "$(realpath build/cpp/${{ env.ARROW_BUILD_TYPE }}/libarrow_flight_sql_odbc.dylib)" \ + ${{ matrix.architecture }}-dylib/ + - name: Rename ARM64 base ODBC PKG + if: matrix.architecture == 'ARM64' + run: | + pkg_path="$(ls build/cpp/ArrowFlightSQLODBC-*.pkg)" + mv "${pkg_path}" "$(basename "${pkg_path}" .pkg)_ARM64_base.pkg" + - name: Upload ODBC DYLIB to the job + uses: actions/upload-artifact@v7 + with: + name: flight-sql-odbc-dylib-${{ matrix.architecture }} + path: ${{ matrix.architecture }}-dylib/libarrow_flight_sql_odbc.*.dylib + if-no-files-found: error + - name: Upload ARM64 base ODBC PKG to the job + if: matrix.architecture == 'ARM64' + uses: actions/upload-artifact@v7 + with: + name: flight-sql-odbc-pkg-base-ARM64 + path: ArrowFlightSQLODBC-*_ARM64_base.pkg + if-no-files-found: error + + # Upload unsigned universal DYLIB from ARM and AMD DYLIBs + odbc-macos-upload-universal-dylib: + needs: odbc-macos-upload-dylib + name: ODBC macOS Create Unsigned Universal DYLIB + runs-on: macos-26 + timeout-minutes: 30 + steps: + - name: Download ARM64 DYLIB + uses: actions/download-artifact@v8 + with: + name: flight-sql-odbc-dylib-ARM64 + path: arm64-dylib + - name: Download AMD64 DYLIB + uses: actions/download-artifact@v8 + with: + name: flight-sql-odbc-dylib-AMD64 + path: amd64-dylib + - name: Create universal DYLIB + run: | + set -euo pipefail + + arm64_dylib="$(ls arm64-dylib/libarrow_flight_sql_odbc.*.dylib)" + amd64_dylib="$(ls amd64-dylib/libarrow_flight_sql_odbc.*.dylib)" + dylib_name="$(basename "${arm64_dylib}")" + if [ "$(basename "${amd64_dylib}")" != "${dylib_name}" ]; then + echo "ARM64 and AMD64 DYLIB names differ: ${arm64_dylib} vs ${amd64_dylib}" + exit 1 + fi + + # Rename unsigned DYLIB + mkdir universal-dylib + unsigned_path="universal-dylib/libarrow_flight_sql_odbc_unsigned.${dylib_name#libarrow_flight_sql_odbc.}" + lipo -create "${arm64_dylib}" "${amd64_dylib}" -output "${unsigned_path}" + unsigned_archs="$(lipo -archs "${unsigned_path}")" + echo "${unsigned_path}: ${unsigned_archs}" + - name: Upload universal DYLIB to the job + uses: actions/upload-artifact@v7 + with: + name: flight-sql-odbc-dylib-universal + path: universal-dylib/libarrow_flight_sql_odbc_unsigned.*.dylib + if-no-files-found: error + + odbc-dylib-base-pkg-release: + needs: + - odbc-macos-upload-dylib + - odbc-macos-upload-universal-dylib + name: Upload Unsigned ODBC DYLIB and Base PKG to Release + runs-on: ubuntu-latest + permissions: + # Upload to GitHub Release + contents: write + steps: + - name: Checkout Arrow + uses: actions/checkout@v7 + with: + persist-credentials: false + fetch-depth: 0 + submodules: recursive + - name: Download the universal DYLIB + uses: actions/download-artifact@v8 + with: + name: flight-sql-odbc-dylib-universal + - name: Download the ARM64 base PKG + uses: actions/download-artifact@v8 + with: + name: flight-sql-odbc-pkg-base-ARM64 + - name: Wait for creating GitHub Release + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + dev/release/utils-watch-gh-workflow.sh \ + ${GITHUB_REF_NAME} \ + release_candidate.yml + - name: Upload the artifacts to GitHub Release + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + gh release upload ${GITHUB_REF_NAME} \ + --clobber \ + libarrow_flight_sql_odbc_unsigned.*.dylib \ + ArrowFlightSQLODBC-*_ARM64_base.pkg + + # Download and repackage the ARM64 base PKG and + # the signed universal dylib + odbc-macos-upload-pkg: + name: ODBC macOS Repackage & Upload Unsigned Universal PKG + runs-on: macos-26 + if: inputs.odbc_release_step + timeout-minutes: 30 + permissions: + # Upload to GitHub Release + contents: write + steps: + - name: Download ARM64 base PKG and signed universal ODBC DYLIB + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + gh release download ${GITHUB_REF_NAME} \ + --repo ${{ github.repository }} \ + --pattern 'ArrowFlightSQLODBC-*_ARM64_base.pkg' \ + --pattern 'libarrow_flight_sql_odbc.*.dylib' \ + --clobber + - name: Build universal macOS installer + run: | + set -euo pipefail + + pkg_path="$(ls ArrowFlightSQLODBC-*_ARM64_base.pkg)" + pkg_name="$(basename "${pkg_path}" _ARM64_base.pkg)" + + # Use the ARM64 .pkg and swap in the signed universal ODBC dylib. + # Use sudo for every step that touches the expanded payload so the + # root-owned files in the PKG keep their ownership instead of being + # re-stamped with the runner user's uid/gid. + sudo pkgutil --expand-full "${pkg_path}" expanded + + # The unversioned name libarrow_flight_sql_odbc.dylib is a symlink + # to the versioned dylib that the install name + # (@rpath/libarrow_flight_sql_odbc..dylib) resolves to. + # Replace the real file so the symlinks stay intact. + symlink_path="$(find expanded -name libarrow_flight_sql_odbc.dylib)" + lib_dir="$(dirname "${symlink_path}")" + dylib_path="$(realpath "${symlink_path}")" + signed_dylib="$(ls libarrow_flight_sql_odbc.*.dylib)" + if [ "${signed_dylib}" != "$(basename "${dylib_path}")" ]; then + echo "Signed DYLIB ${signed_dylib} doesn't match PKG DYLIB $(basename "${dylib_path}")" + exit 1 + fi + echo "Replacing ${dylib_path} (via ${symlink_path}) with ${signed_dylib}" + # cp onto an existing file keeps its owner and mode. + sudo cp "${signed_dylib}" "${dylib_path}" + + # Verify every dylib (including the symlinks) is universal before re-packaging. + for lib in "${lib_dir}"/libarrow_flight_sql_odbc*.dylib; do + dylib_archs="$(lipo -archs "${lib}")" + echo "${lib}: ${dylib_archs}" + for arch in arm64 x86_64; do + if ! grep -qw "${arch}" <<< "${dylib_archs}"; then + echo "${lib} is missing '${arch}' (got: ${dylib_archs})" + exit 1 + fi + done + done + + # --flatten-full regenerates each component's Bom and PackageInfo + # installKBytes, but leaves Distribution with the ARM64 base PKG's + # sizes. Copy the regenerated sizes into Distribution, then + # re-flatten without -full so the payloads are reused as-is. + sudo pkgutil --flatten-full expanded flattened.pkg + sudo pkgutil --expand flattened.pkg shallow + for component in shallow/*.pkg; do + component_name="$(basename "${component}")" + kbytes="$(sudo sed -n 's/.*installKBytes="\([0-9]*\)".*/\1/p' "${component}/PackageInfo")" + sudo sed -i '' \ + "/>#${component_name}<\/pkg-ref>/ s/installKBytes=\"[0-9]*\"/installKBytes=\"${kbytes}\"/" \ + shallow/Distribution + done + mkdir universal + sudo pkgutil --flatten shallow "universal/${pkg_name}.pkg" + sudo chown "$(id -u):$(id -g)" "universal/${pkg_name}.pkg" + - name: Verify universal macOS installer + run: | + set -euo pipefail + + pkg_path="$(ls universal/ArrowFlightSQLODBC-*.pkg)" + pkgutil --check-signature "${pkg_path}" || true + pkgutil --expand "${pkg_path}" verify + # Installed files must not be owned by the runner user. + runner_uid="$(id -u)" + for bom in verify/*.pkg/Bom; do + echo "${bom}:" + lsbom -p MugF "${bom}" + if lsbom -p u "${bom}" | grep -qx "${runner_uid}"; then + echo "${bom} contains files owned by the runner user (uid ${runner_uid})" + exit 1 + fi + done + grep installKBytes verify/Distribution + - name: Upload the artifacts to GitHub Release + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + gh release upload ${GITHUB_REF_NAME} \ + --repo ${{ github.repository }} \ + --clobber \ + universal/ArrowFlightSQLODBC-*.pkg From b199c250960e3decce3908f5ef135bfe243aabd7 Mon Sep 17 00:00:00 2001 From: "Alina (Xi) Li" <96995091+alinaliBQ@users.noreply.github.com> Date: Thu, 19 Nov 2026 14:15:55 -0700 Subject: [PATCH 2/4] Work on kou's comments - update dependabot --- .github/dependabot.yml | 4 +++- .github/workflows/package_odbc.yml | 2 -- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 1acdf1e9cad8..d4f702e8c049 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -18,7 +18,9 @@ version: 2 updates: - package-ecosystem: "github-actions" - directory: "/" + directories: + - "/" + - "/.github/actions/*" schedule: interval: "weekly" commit-message: diff --git a/.github/workflows/package_odbc.yml b/.github/workflows/package_odbc.yml index 241bf632351d..faf780b73438 100644 --- a/.github/workflows/package_odbc.yml +++ b/.github/workflows/package_odbc.yml @@ -297,8 +297,6 @@ jobs: uses: actions/checkout@v7 with: persist-credentials: false - fetch-depth: 0 - submodules: recursive - name: Download the universal DYLIB uses: actions/download-artifact@v8 with: From d36796baebf3dfcda8fc1c8a083a2fff06a44906 Mon Sep 17 00:00:00 2001 From: "Alina (Xi) Li" <96995091+alinaliBQ@users.noreply.github.com> Date: Fri, 20 Nov 2026 14:01:49 -0700 Subject: [PATCH 3/4] Extract common code for universal pkg --- .github/workflows/cpp_extra.yml | 22 ++---- .github/workflows/package_odbc.yml | 34 ++------- .../odbc_macos_flatten_universal_pkg.sh | 74 +++++++++++++++++++ 3 files changed, 85 insertions(+), 45 deletions(-) create mode 100755 ci/scripts/odbc_macos_flatten_universal_pkg.sh diff --git a/.github/workflows/cpp_extra.yml b/.github/workflows/cpp_extra.yml index 4a823bea2024..938c8fcc7e68 100644 --- a/.github/workflows/cpp_extra.yml +++ b/.github/workflows/cpp_extra.yml @@ -36,6 +36,7 @@ on: - 'ci/scripts/install_gcs_testbench.sh' - 'ci/scripts/install_minio.sh' - 'ci/scripts/msys2_*' + - 'ci/scripts/odbc_macos_flatten_universal_pkg.sh' - 'ci/scripts/util_*' - 'cpp/**' - 'compose.yaml' @@ -638,6 +639,10 @@ jobs: runs-on: macos-26 timeout-minutes: 30 steps: + - name: Checkout Arrow + uses: actions/checkout@v7 + with: + persist-credentials: false - name: Download ARM64 PKG uses: actions/download-artifact@v8 with: @@ -664,27 +669,12 @@ jobs: # install name (@rpath/libarrow_flight_sql_odbc..dylib) # resolves to. Run lipo on the real file so the symlinks stay intact. symlink_path="$(find expanded -name libarrow_flight_sql_odbc.dylib)" - lib_dir="$(dirname "${symlink_path}")" dylib_path="$(realpath "${symlink_path}")" echo "Merging into ${dylib_path} (via ${symlink_path})" lipo -create "${dylib_path}" amd64-dylib/libarrow_flight_sql_odbc.dylib \ -output "${dylib_path}" - # Verify every dylib (including the symlinks) is universal before re-packaging. - # Check one architecture at a time with `lipo -archs`, - # as macOS 27 support only one architecture search at a time. - for lib in "${lib_dir}"/libarrow_flight_sql_odbc*.dylib; do - dylib_archs="$(lipo -archs "${lib}")" - echo "${lib}: ${dylib_archs}" - for arch in arm64 x86_64; do - if ! grep -qw "${arch}" <<< "${dylib_archs}"; then - echo "${lib} is missing '${arch}' (got: ${dylib_archs})" - exit 1 - fi - done - done - - pkgutil --flatten-full expanded "${pkg_name}.pkg" + ci/scripts/odbc_macos_flatten_universal_pkg.sh expanded "${pkg_name}.pkg" - name: Upload universal ODBC PKG uses: actions/upload-artifact@v7 with: diff --git a/.github/workflows/package_odbc.yml b/.github/workflows/package_odbc.yml index faf780b73438..af2d701a5f8f 100644 --- a/.github/workflows/package_odbc.yml +++ b/.github/workflows/package_odbc.yml @@ -332,6 +332,10 @@ jobs: # Upload to GitHub Release contents: write steps: + - name: Checkout Arrow + uses: actions/checkout@v7 + with: + persist-credentials: false - name: Download ARM64 base PKG and signed universal ODBC DYLIB env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} @@ -359,7 +363,6 @@ jobs: # (@rpath/libarrow_flight_sql_odbc..dylib) resolves to. # Replace the real file so the symlinks stay intact. symlink_path="$(find expanded -name libarrow_flight_sql_odbc.dylib)" - lib_dir="$(dirname "${symlink_path}")" dylib_path="$(realpath "${symlink_path}")" signed_dylib="$(ls libarrow_flight_sql_odbc.*.dylib)" if [ "${signed_dylib}" != "$(basename "${dylib_path}")" ]; then @@ -370,34 +373,7 @@ jobs: # cp onto an existing file keeps its owner and mode. sudo cp "${signed_dylib}" "${dylib_path}" - # Verify every dylib (including the symlinks) is universal before re-packaging. - for lib in "${lib_dir}"/libarrow_flight_sql_odbc*.dylib; do - dylib_archs="$(lipo -archs "${lib}")" - echo "${lib}: ${dylib_archs}" - for arch in arm64 x86_64; do - if ! grep -qw "${arch}" <<< "${dylib_archs}"; then - echo "${lib} is missing '${arch}' (got: ${dylib_archs})" - exit 1 - fi - done - done - - # --flatten-full regenerates each component's Bom and PackageInfo - # installKBytes, but leaves Distribution with the ARM64 base PKG's - # sizes. Copy the regenerated sizes into Distribution, then - # re-flatten without -full so the payloads are reused as-is. - sudo pkgutil --flatten-full expanded flattened.pkg - sudo pkgutil --expand flattened.pkg shallow - for component in shallow/*.pkg; do - component_name="$(basename "${component}")" - kbytes="$(sudo sed -n 's/.*installKBytes="\([0-9]*\)".*/\1/p' "${component}/PackageInfo")" - sudo sed -i '' \ - "/>#${component_name}<\/pkg-ref>/ s/installKBytes=\"[0-9]*\"/installKBytes=\"${kbytes}\"/" \ - shallow/Distribution - done - mkdir universal - sudo pkgutil --flatten shallow "universal/${pkg_name}.pkg" - sudo chown "$(id -u):$(id -g)" "universal/${pkg_name}.pkg" + ci/scripts/odbc_macos_flatten_universal_pkg.sh expanded "universal/${pkg_name}.pkg" - name: Verify universal macOS installer run: | set -euo pipefail diff --git a/ci/scripts/odbc_macos_flatten_universal_pkg.sh b/ci/scripts/odbc_macos_flatten_universal_pkg.sh new file mode 100755 index 000000000000..ff6bc3908376 --- /dev/null +++ b/ci/scripts/odbc_macos_flatten_universal_pkg.sh @@ -0,0 +1,74 @@ +#!/usr/bin/env 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. + +# Verify that every ODBC dylib in an expanded ODBC macOS installer PKG is +# universal (ARM64 and AMD64), then flatten it back to a PKG. +# +# Usage: odbc_macos_flatten_universal_pkg.sh EXPANDED_DIR OUTPUT_PKG +# +# EXPANDED_DIR: Directory created by `pkgutil --expand-full` +# OUTPUT_PKG: Path of the flat PKG to create + +set -euo pipefail + +if [ $# -ne 2 ]; then + echo "Usage: $0 EXPANDED_DIR OUTPUT_PKG" >&2 + exit 1 +fi + +expanded_dir="${1}" +output_pkg="${2}" +work_dir="$(mktemp -d)" + +symlink_path="$(find "${expanded_dir}" -name libarrow_flight_sql_odbc.dylib)" +lib_dir="$(dirname "${symlink_path}")" + +# Verify every dylib (including the symlinks) is universal before re-packaging. +# Check architecture with `grep` on `lipo -archs` to be compatible on macOS 27. +for lib in "${lib_dir}"/libarrow_flight_sql_odbc*.dylib; do + dylib_archs="$(lipo -archs "${lib}")" + echo "${lib}: ${dylib_archs}" + for arch in arm64 x86_64; do + if ! grep -qw "${arch}" <<< "${dylib_archs}"; then + echo "${lib} is missing '${arch}' (got: ${dylib_archs})" + exit 1 + fi + done +done + +# --flatten-full regenerates each component's Bom and PackageInfo +# installKBytes, but leaves Distribution with outdated PKG's sizes. +# Workaround is to copy regenerated sizes into Distribution, +# then re-flatten without -full so the correct sizes stay in Distribution. +# +# Use sudo for every step that touches the expanded payload so the root-owned +# files in the PKG keep their ownership instead of being re-stamped with the +# runner user's uid/gid. +sudo pkgutil --flatten-full "${expanded_dir}" "${work_dir}/flattened.pkg" +sudo pkgutil --expand "${work_dir}/flattened.pkg" "${work_dir}/shallow" +for component in "${work_dir}"/shallow/*.pkg; do + component_name="$(basename "${component}")" + kbytes="$(sudo sed -n 's/.*installKBytes="\([0-9]*\)".*/\1/p' "${component}/PackageInfo")" + sudo sed -i '' \ + "/>#${component_name}<\/pkg-ref>/ s/installKBytes=\"[0-9]*\"/installKBytes=\"${kbytes}\"/" \ + "${work_dir}/shallow/Distribution" +done +mkdir -p "$(dirname "${output_pkg}")" +sudo pkgutil --flatten "${work_dir}/shallow" "${output_pkg}" +sudo chown "$(id -u):$(id -g)" "${output_pkg}" From 1bc7e29a7cb8105c1acb25d68ab2d7ec5d45404d Mon Sep 17 00:00:00 2001 From: "Alina (Xi) Li" <96995091+alinaliBQ@users.noreply.github.com> Date: Tue, 24 Nov 2026 10:57:42 -0700 Subject: [PATCH 4/4] Work on kou's comments - remove `--check-signature` - update common script to use universal dylib to create a pkg - remove static directory upon exit --- .github/workflows/cpp_extra.yml | 44 ++++++++++++------- .github/workflows/package_odbc.yml | 24 ++-------- ...sal_pkg.sh => odbc_macos_universal_pkg.sh} | 42 ++++++++++++++---- 3 files changed, 63 insertions(+), 47 deletions(-) rename ci/scripts/{odbc_macos_flatten_universal_pkg.sh => odbc_macos_universal_pkg.sh} (62%) diff --git a/.github/workflows/cpp_extra.yml b/.github/workflows/cpp_extra.yml index 938c8fcc7e68..2645932f469f 100644 --- a/.github/workflows/cpp_extra.yml +++ b/.github/workflows/cpp_extra.yml @@ -36,7 +36,7 @@ on: - 'ci/scripts/install_gcs_testbench.sh' - 'ci/scripts/install_minio.sh' - 'ci/scripts/msys2_*' - - 'ci/scripts/odbc_macos_flatten_universal_pkg.sh' + - 'ci/scripts/odbc_macos_universal_pkg.sh' - 'ci/scripts/util_*' - 'cpp/**' - 'compose.yaml' @@ -612,12 +612,18 @@ jobs: name: flight-sql-odbc-pkg-installer-${{ matrix.architecture }} path: build/cpp/ArrowFlightSQLODBC-*.pkg if-no-files-found: error - - name: Upload AMD64 ODBC dylib to the job - if: matrix.build-type == 'release' && matrix.architecture == 'AMD64' + - name: Copy ODBC dylib + if: matrix.build-type == 'release' + run: | + mkdir ${{ matrix.architecture }}-dylib + cp "$(realpath build/cpp/${{ matrix.build-type }}/libarrow_flight_sql_odbc.dylib)" \ + ${{ matrix.architecture }}-dylib/ + - name: Upload ODBC dylib to the job + if: matrix.build-type == 'release' uses: actions/upload-artifact@v7 with: name: flight-sql-odbc-dylib-${{ matrix.architecture }} - path: build/cpp/${{ matrix.build-type }}/libarrow_flight_sql_odbc.dylib + path: ${{ matrix.architecture }}-dylib/libarrow_flight_sql_odbc.*.dylib if-no-files-found: error - name: Register Flight SQL ODBC Driver run: | @@ -648,33 +654,37 @@ jobs: with: name: flight-sql-odbc-pkg-installer-ARM64 path: arm64-pkg + - name: Download ARM64 dylib + uses: actions/download-artifact@v8 + with: + name: flight-sql-odbc-dylib-ARM64 + path: arm64-dylib - name: Download AMD64 dylib uses: actions/download-artifact@v8 with: name: flight-sql-odbc-dylib-AMD64 path: amd64-dylib + - name: Create universal dylib + run: | + set -euo pipefail + + arm64_dylib="$(ls arm64-dylib/libarrow_flight_sql_odbc.*.dylib)" + amd64_dylib="$(ls amd64-dylib/libarrow_flight_sql_odbc.*.dylib)" + mkdir universal-dylib + lipo -create "${arm64_dylib}" "${amd64_dylib}" \ + -output "universal-dylib/$(basename "${arm64_dylib}")" - name: Build universal macOS installer run: | set -euo pipefail pkg_path="$(ls arm64-pkg/ArrowFlightSQLODBC-*.pkg)" pkg_name="$(basename "${pkg_path}" .pkg)" + universal_dylib="$(ls universal-dylib/libarrow_flight_sql_odbc.*.dylib)" # Use the ARM64 .pkg and swap in a universal ODBC dylib # that works on ARM64 and AMD64. - pkgutil --expand-full "${pkg_path}" expanded - - # The unversioned name libarrow_flight_sql_odbc.dylib is a symlink - # to the versioned dylib that the - # install name (@rpath/libarrow_flight_sql_odbc..dylib) - # resolves to. Run lipo on the real file so the symlinks stay intact. - symlink_path="$(find expanded -name libarrow_flight_sql_odbc.dylib)" - dylib_path="$(realpath "${symlink_path}")" - echo "Merging into ${dylib_path} (via ${symlink_path})" - lipo -create "${dylib_path}" amd64-dylib/libarrow_flight_sql_odbc.dylib \ - -output "${dylib_path}" - - ci/scripts/odbc_macos_flatten_universal_pkg.sh expanded "${pkg_name}.pkg" + ci/scripts/odbc_macos_universal_pkg.sh \ + "${pkg_path}" "${universal_dylib}" "${pkg_name}.pkg" - name: Upload universal ODBC PKG uses: actions/upload-artifact@v7 with: diff --git a/.github/workflows/package_odbc.yml b/.github/workflows/package_odbc.yml index af2d701a5f8f..3a98da46c9d9 100644 --- a/.github/workflows/package_odbc.yml +++ b/.github/workflows/package_odbc.yml @@ -352,34 +352,16 @@ jobs: pkg_path="$(ls ArrowFlightSQLODBC-*_ARM64_base.pkg)" pkg_name="$(basename "${pkg_path}" _ARM64_base.pkg)" - # Use the ARM64 .pkg and swap in the signed universal ODBC dylib. - # Use sudo for every step that touches the expanded payload so the - # root-owned files in the PKG keep their ownership instead of being - # re-stamped with the runner user's uid/gid. - sudo pkgutil --expand-full "${pkg_path}" expanded - - # The unversioned name libarrow_flight_sql_odbc.dylib is a symlink - # to the versioned dylib that the install name - # (@rpath/libarrow_flight_sql_odbc..dylib) resolves to. - # Replace the real file so the symlinks stay intact. - symlink_path="$(find expanded -name libarrow_flight_sql_odbc.dylib)" - dylib_path="$(realpath "${symlink_path}")" signed_dylib="$(ls libarrow_flight_sql_odbc.*.dylib)" - if [ "${signed_dylib}" != "$(basename "${dylib_path}")" ]; then - echo "Signed DYLIB ${signed_dylib} doesn't match PKG DYLIB $(basename "${dylib_path}")" - exit 1 - fi - echo "Replacing ${dylib_path} (via ${symlink_path}) with ${signed_dylib}" - # cp onto an existing file keeps its owner and mode. - sudo cp "${signed_dylib}" "${dylib_path}" - ci/scripts/odbc_macos_flatten_universal_pkg.sh expanded "universal/${pkg_name}.pkg" + # Use the ARM64 .pkg and swap in the signed universal ODBC dylib. + ci/scripts/odbc_macos_universal_pkg.sh \ + "${pkg_path}" "${signed_dylib}" "universal/${pkg_name}.pkg" - name: Verify universal macOS installer run: | set -euo pipefail pkg_path="$(ls universal/ArrowFlightSQLODBC-*.pkg)" - pkgutil --check-signature "${pkg_path}" || true pkgutil --expand "${pkg_path}" verify # Installed files must not be owned by the runner user. runner_uid="$(id -u)" diff --git a/ci/scripts/odbc_macos_flatten_universal_pkg.sh b/ci/scripts/odbc_macos_universal_pkg.sh similarity index 62% rename from ci/scripts/odbc_macos_flatten_universal_pkg.sh rename to ci/scripts/odbc_macos_universal_pkg.sh index ff6bc3908376..829ac3e4e81b 100755 --- a/ci/scripts/odbc_macos_flatten_universal_pkg.sh +++ b/ci/scripts/odbc_macos_universal_pkg.sh @@ -17,27 +17,51 @@ # specific language governing permissions and limitations # under the License. -# Verify that every ODBC dylib in an expanded ODBC macOS installer PKG is -# universal (ARM64 and AMD64), then flatten it back to a PKG. +# Build a universal (ARM64 and AMD64) ODBC macOS installer PKG from an +# ARM64 base PKG by replacing its dylib with a universal dylib. # -# Usage: odbc_macos_flatten_universal_pkg.sh EXPANDED_DIR OUTPUT_PKG +# Usage: odbc_macos_universal_pkg.sh BASE_PKG UNIVERSAL_DYLIB OUTPUT_PKG # -# EXPANDED_DIR: Directory created by `pkgutil --expand-full` +# BASE_PKG: ARM64 installer PKG built by CPack +# UNIVERSAL_DYLIB: Universal libarrow_flight_sql_odbc..dylib. Its +# name must match the dylib in BASE_PKG. # OUTPUT_PKG: Path of the flat PKG to create set -euo pipefail -if [ $# -ne 2 ]; then - echo "Usage: $0 EXPANDED_DIR OUTPUT_PKG" >&2 +if [ $# -ne 3 ]; then + echo "Usage: $0 BASE_PKG UNIVERSAL_DYLIB OUTPUT_PKG" >&2 exit 1 fi -expanded_dir="${1}" -output_pkg="${2}" -work_dir="$(mktemp -d)" +base_pkg="${1}" +universal_dylib="${2}" +output_pkg="${3}" +work_dir="odbc_pkg_build_dir" +expanded_dir="${work_dir}/expanded" +mkdir "${work_dir}" +trap 'sudo rm -rf "${work_dir}"' EXIT + +# Use sudo for every step that touches the expanded payload so the root-owned +# files in the PKG keep their ownership instead of being re-stamped with the +# runner user's uid/gid. +sudo pkgutil --expand-full "${base_pkg}" "${expanded_dir}" + +# The unversioned name libarrow_flight_sql_odbc.dylib is a symlink to the +# versioned dylib that the install name +# (@rpath/libarrow_flight_sql_odbc..dylib) resolves to. +# Replace the real file so the symlinks stay intact. symlink_path="$(find "${expanded_dir}" -name libarrow_flight_sql_odbc.dylib)" lib_dir="$(dirname "${symlink_path}")" +dylib_path="$(realpath "${symlink_path}")" +if [ "$(basename "${universal_dylib}")" != "$(basename "${dylib_path}")" ]; then + echo "DYLIB $(basename "${universal_dylib}") doesn't match PKG DYLIB $(basename "${dylib_path}")" + exit 1 +fi +echo "Replacing ${dylib_path} (via ${symlink_path}) with ${universal_dylib}" +# cp onto an existing file keeps its owner and mode. +sudo cp "${universal_dylib}" "${dylib_path}" # Verify every dylib (including the symlinks) is universal before re-packaging. # Check architecture with `grep` on `lipo -archs` to be compatible on macOS 27.