alinaliBQ commented on code in PR #55321:
URL: https://github.com/apache/arrow/pull/55321#discussion_r4684770557


##########
.github/workflows/package_odbc.yml:
##########
@@ -179,3 +179,224 @@ 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.<version>.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
+      - 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: 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 }}
+        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.<SOVERSION>.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}"

Review Comment:
   Done. To do this, I changed `cpp_extra.yml` to use the same approach as 
`package_odbc.yml` where an universal dylib file is used with an ARM64 pkg to 
create an universal pkg. 



##########
.github/workflows/package_odbc.yml:
##########
@@ -179,3 +179,224 @@ 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.<version>.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
+      - 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: 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 }}
+        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.<SOVERSION>.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"
+      - name: Verify universal macOS installer
+        run: |
+          set -euo pipefail
+
+          pkg_path="$(ls universal/ArrowFlightSQLODBC-*.pkg)"
+          pkgutil --check-signature "${pkg_path}" || true

Review Comment:
   I have removed it as this line isn't required. I added it for printing out 
the status of package signature and forgot to remove it



##########
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)"

Review Comment:
   Sure, added `trap 'sudo rm -rf "${work_dir}"' EXIT` to clean up static 
directory



-- 
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