public inbox for git-commits@fedoraproject.org
help / color / mirror / Atom feed
From: Yaakov Selkowitz <yselkowi@redhat.com>
To: git-commits@fedoraproject.org
Subject: [rpms/unixODBC] rawhide: Fix odbcinst-generate for flatpaks
Date: Wed, 04 Nov 2026 05:27:25 GMT [thread overview]
Message-ID: <179377004567.1.8168238409359108242.rpms-unixODBC-0a5cad135148@fedoraproject.org> (raw)
A new commit has been pushed.
Repo : rpms/unixODBC
Branch : rawhide
Commit : 0a5cad1351484bf7b60c01b685bf486cbf9c0896
Author : Yaakov Selkowitz <yselkowi@redhat.com>
Date : 2026-11-03T15:54:33-05:00
Stats : +132/-128 in 3 file(s)
URL : https://src.fedoraproject.org/rpms/unixODBC/c/0a5cad1351484bf7b60c01b685bf486cbf9c0896?branch=rawhide
Log:
Fix odbcinst-generate for flatpaks
unixODBC and any ODBC drivers are built in /app for apps which need it.
The input redirection does not work when run from a scriptlet while
installing in the flatpak buildroot.
---
diff --git a/odbcinst-generate b/odbcinst-generate
deleted file mode 100644
index 99f10d7..0000000
--- a/odbcinst-generate
+++ /dev/null
@@ -1,123 +0,0 @@
-#!/bin/bash
-# SPDX-License-Identifier: GPL-2.0-or-later
-# Copyright (C) 2026 Michal Schorm <mschorm@redhat.com>
-#
-# Regenerate /etc/odbcinst.ini from drop-in snippets.
-#
-# Merge order:
-# 1. /usr/lib/odbc/odbcinst.d/*.ini (vendor, low-numbered prefixes)
-# 2. /etc/odbc/odbcinst.d/*.ini (admin, high-numbered prefixes)
-#
-# Override rules:
-# - Files are sorted by full basename (numeric prefix determines order)
-# - When two files share the same name after stripping the numeric prefix
-# (e.g., 10-mariadb.ini and 60-mariadb.ini), the higher-numbered one wins
-# - A symlink to /dev/null disables the corresponding driver entry
-#
-# This script is called from RPM file triggers and %post.
-# It must be safe to run at any time (idempotent).
-
-set -eo pipefail
-
-VENDOR_DIR=/usr/lib/odbc/odbcinst.d
-ADMIN_DIR=/etc/odbc/odbcinst.d
-TARGET=/etc/odbcinst.ini
-
-tmpfile=$(mktemp "${TARGET}.XXXXXX")
-resolved=""
-trap 'rm -f "$tmpfile" "$resolved"' EXIT
-
-cat > "$tmpfile" << 'HEADER'
-# Auto-generated from drop-in snippets. Do not edit this file.
-#
-# Vendor defaults: /usr/lib/odbc/odbcinst.d/*.ini
-# Admin overrides: /etc/odbc/odbcinst.d/*.ini
-#
-# To override a vendor driver, place a file with the same name
-# (or higher numeric prefix) in /etc/odbc/odbcinst.d/.
-# To disable a vendor driver, symlink its snippet to /dev/null:
-# ln -sf /dev/null /etc/odbc/odbcinst.d/10-freetds.ini
-#
-# To apply changes after editing drop-in files, run:
-# odbcinst-generate
-HEADER
-
-# Build an associative array: key → path (last writer wins by sort order)
-declare -A snippets
-
-# Process vendor first (lower priority), then admin (higher priority)
-for dir in "$VENDOR_DIR" "$ADMIN_DIR"; do
- [ -d "$dir" ] || continue
- for f in "$dir"/*.ini; do
- [ -e "$f" ] || continue
- base=$(basename "$f")
- # Strip numeric prefix for override matching: "10-mariadb.ini" → "mariadb.ini"
- key="${base#[0-9][0-9]-}"
- snippets["$key"]="$f"
- done
-done
-
-# Sort keys and emit content
-if [ ${#snippets[@]} -gt 0 ]; then
- while IFS= read -r key; do
- f="${snippets[$key]}"
-
- # Symlink to /dev/null = disabled
- if [ -L "$f" ] && [ "$(readlink -f "$f")" = "/dev/null" ]; then
- continue
- fi
-
- [ -f "$f" ] || continue
- echo "" >> "$tmpfile"
- cat "$f" >> "$tmpfile"
- done < <(printf '%s\n' "${!snippets[@]}" | sort)
-fi
-
-# Resolve bare library names (e.g. "libmaodbc.so") to absolute paths.
-# unixODBC finds bare names via its compiled-in --with-odbc-driver-path,
-# but iODBC requires absolute paths for dlopen(). Absolute paths also
-# make the generated config self-documenting.
-#
-# Multilib: when a driver .so exists in both /usr/lib64/odbc/ and
-# /usr/lib/odbc/ (e.g. both x86_64 and i686 RPMs installed), emit
-# Driver= for the 32-bit path and Driver64= for the 64-bit path.
-# unixODBC selects the matching key based on the calling application's
-# word size. When only one architecture is present, only Driver= is
-# emitted. Same for Setup/Setup64.
-#
-# If a bare name is not found in either directory, it is left unchanged
-# so unixODBC can still find it via its built-in search path.
-resolved=$(mktemp "${TARGET}.XXXXXX")
-
-while IFS= read -r line; do
- if [[ "$line" =~ ^((Driver|Setup)[[:space:]]*=[[:space:]]*)([^/[:space:]][^/[:space:]]*\.so[^/[:space:]]*)[[:space:]]*$ ]]; then
- prefix="${BASH_REMATCH[1]}"
- key="${BASH_REMATCH[2]}"
- bare="${BASH_REMATCH[3]}"
-
- in_lib64=""
- in_lib32=""
- [ -f "/usr/lib64/odbc/$bare" ] && in_lib64="/usr/lib64/odbc/$bare"
- [ -f "/usr/lib/odbc/$bare" ] && in_lib32="/usr/lib/odbc/$bare"
-
- if [ -n "$in_lib64" ] && [ -n "$in_lib32" ]; then
- printf '%s%s\n' "$prefix" "$in_lib32"
- printf '%s64 = %s\n' "$key" "$in_lib64"
- elif [ -n "$in_lib64" ]; then
- printf '%s%s\n' "$prefix" "$in_lib64"
- elif [ -n "$in_lib32" ]; then
- printf '%s%s\n' "$prefix" "$in_lib32"
- else
- printf '%s\n' "$line"
- fi
- else
- printf '%s\n' "$line"
- fi
-done < "$tmpfile" > "$resolved"
-
-mv "$resolved" "$tmpfile"
-
-# Atomic replace
-chmod 644 "$tmpfile"
-mv "$tmpfile" "$TARGET"
-trap - EXIT
diff --git a/odbcinst-generate.in b/odbcinst-generate.in
new file mode 100644
index 0000000..5ef9b26
--- /dev/null
+++ b/odbcinst-generate.in
@@ -0,0 +1,124 @@
+#!/bin/bash
+# SPDX-License-Identifier: GPL-2.0-or-later
+# Copyright (C) 2026 Michal Schorm <mschorm@redhat.com>
+#
+# Regenerate @sysconfdir@/odbcinst.ini from drop-in snippets.
+#
+# Merge order:
+# 1. @prefix@/lib/odbc/odbcinst.d/*.ini (vendor, low-numbered prefixes)
+# 2. @sysconfdir@/odbc/odbcinst.d/*.ini (admin, high-numbered prefixes)
+#
+# Override rules:
+# - Files are sorted by full basename (numeric prefix determines order)
+# - When two files share the same name after stripping the numeric prefix
+# (e.g., 10-mariadb.ini and 60-mariadb.ini), the higher-numbered one wins
+# - A symlink to /dev/null disables the corresponding driver entry
+#
+# This script is called from RPM file triggers and %post.
+# It must be safe to run at any time (idempotent).
+
+set -eo pipefail
+
+VENDOR_DIR=@prefix@/lib/odbc/odbcinst.d
+ADMIN_DIR=@sysconfdir@/odbc/odbcinst.d
+TARGET=@sysconfdir@/odbcinst.ini
+
+tmpfile=$(mktemp "${TARGET}.XXXXXX")
+resolved=""
+trap 'rm -f "$tmpfile" "$resolved"' EXIT
+
+cat > "$tmpfile" << 'HEADER'
+# Auto-generated from drop-in snippets. Do not edit this file.
+#
+# Vendor defaults: @prefix@/lib/odbc/odbcinst.d/*.ini
+# Admin overrides: @sysconfdir@/odbc/odbcinst.d/*.ini
+#
+# To override a vendor driver, place a file with the same name
+# (or higher numeric prefix) in @sysconfdir@/odbc/odbcinst.d/.
+# To disable a vendor driver, symlink its snippet to /dev/null:
+# ln -sf /dev/null @sysconfdir@/odbc/odbcinst.d/10-freetds.ini
+#
+# To apply changes after editing drop-in files, run:
+# odbcinst-generate
+HEADER
+
+# Build an associative array: key → path (last writer wins by sort order)
+declare -A snippets
+
+# Process vendor first (lower priority), then admin (higher priority)
+for dir in "$VENDOR_DIR" "$ADMIN_DIR"; do
+ [ -d "$dir" ] || continue
+ for f in "$dir"/*.ini; do
+ [ -e "$f" ] || continue
+ base=$(basename "$f")
+ # Strip numeric prefix for override matching: "10-mariadb.ini" → "mariadb.ini"
+ key="${base#[0-9][0-9]-}"
+ snippets["$key"]="$f"
+ done
+done
+
+# Sort keys and emit content
+if [ ${#snippets[@]} -gt 0 ]; then
+ printf '%s\n' "${!snippets[@]}" | sort | \
+ while IFS= read -r key; do
+ f="${snippets[$key]}"
+
+ # Symlink to /dev/null = disabled
+ if [ -L "$f" ] && [ "$(readlink -f "$f")" = "/dev/null" ]; then
+ continue
+ fi
+
+ [ -f "$f" ] || continue
+ echo "" >> "$tmpfile"
+ cat "$f" >> "$tmpfile"
+ done
+fi
+
+# Resolve bare library names (e.g. "libmaodbc.so") to absolute paths.
+# unixODBC finds bare names via its compiled-in --with-odbc-driver-path,
+# but iODBC requires absolute paths for dlopen(). Absolute paths also
+# make the generated config self-documenting.
+#
+# Multilib: when a driver .so exists in both @prefix@/lib64/odbc/ and
+# @prefix@/lib/odbc/ (e.g. both x86_64 and i686 RPMs installed), emit
+# Driver= for the 32-bit path and Driver64= for the 64-bit path.
+# unixODBC selects the matching key based on the calling application's
+# word size. When only one architecture is present, only Driver= is
+# emitted. Same for Setup/Setup64.
+#
+# If a bare name is not found in either directory, it is left unchanged
+# so unixODBC can still find it via its built-in search path.
+resolved=$(mktemp "${TARGET}.XXXXXX")
+
+while IFS= read -r line; do
+ if [[ "$line" =~ ^((Driver|Setup)[[:space:]]*=[[:space:]]*)([^/[:space:]][^/[:space:]]*\.so[^/[:space:]]*)[[:space:]]*$ ]]; then
+ prefix="${BASH_REMATCH[1]}"
+ key="${BASH_REMATCH[2]}"
+ bare="${BASH_REMATCH[3]}"
+
+ in_lib64=""
+ in_lib32=""
+ [ -f "@prefix@/lib64/odbc/$bare" ] && in_lib64="@prefix@/lib64/odbc/$bare"
+ [ -f "@prefix@/lib/odbc/$bare" ] && in_lib32="@prefix@/lib/odbc/$bare"
+
+ if [ -n "$in_lib64" ] && [ -n "$in_lib32" ]; then
+ printf '%s%s\n' "$prefix" "$in_lib32"
+ printf '%s64 = %s\n' "$key" "$in_lib64"
+ elif [ -n "$in_lib64" ]; then
+ printf '%s%s\n' "$prefix" "$in_lib64"
+ elif [ -n "$in_lib32" ]; then
+ printf '%s%s\n' "$prefix" "$in_lib32"
+ else
+ printf '%s\n' "$line"
+ fi
+ else
+ printf '%s\n' "$line"
+ fi
+done < "$tmpfile" > "$resolved"
+
+mv "$resolved" "$tmpfile"
+
+# Atomic replace
+chmod 644 "$tmpfile"
+mv "$tmpfile" "$TARGET"
+trap - EXIT
diff --git a/unixODBC.spec b/unixODBC.spec
index 6b49c42..851644d 100644
--- a/unixODBC.spec
+++ b/unixODBC.spec
@@ -13,7 +13,7 @@ Summary: A complete ODBC driver manager for Linux
URL: http://www.unixODBC.org/
Source: http://www.unixODBC.org/%{name}-%{version}.tar.gz
-Source2: odbcinst-generate
+Source2: odbcinst-generate.in
Source3: odbcinst-generate.1
Patch8: so-version-bump.patch
@@ -63,6 +63,9 @@ ODBC, you need to install this package.
%setup -q
%patch -P8 -p1 -b .soname-bump
+sed -e 's|@sysconfdir@|%{_sysconfdir}|g' -e 's|@prefix@|%{_prefix}|g' \
+ %{SOURCE2} > odbcinst-generate.sh
+
autoreconf -vfi
%build
@@ -91,7 +94,7 @@ sed -i 's|^runpath_var=LD_RUN_PATH|runpath_var=DIE_RPATH_DIE|g' libtool
# Drop-in directory infrastructure for ODBC driver registration
mkdir -p $RPM_BUILD_ROOT%{_prefix}/lib/odbc/odbcinst.d
mkdir -p $RPM_BUILD_ROOT%{_sysconfdir}/odbc/odbcinst.d
-install -m755 %{SOURCE2} $RPM_BUILD_ROOT%{_bindir}/odbcinst-generate
+install -m755 odbcinst-generate.sh $RPM_BUILD_ROOT%{_bindir}/odbcinst-generate
install -m644 -D %{SOURCE3} $RPM_BUILD_ROOT%{_mandir}/man1/odbcinst-generate.1
# Create %ghost file so RPM tracks ownership of the generated config
@@ -228,15 +231,15 @@ fi
%dir %{_sysconfdir}/odbc/odbcinst.d
%post -n odbcinst-generate
-odbcinst-generate || :
+%{_bindir}/odbcinst-generate || :
# Regenerate odbcinst.ini when driver packages install drop-in snippets
%transfiletriggerin -n odbcinst-generate -- %{_prefix}/lib/odbc/odbcinst.d %{_sysconfdir}/odbc/odbcinst.d
-odbcinst-generate || :
+%{_bindir}/odbcinst-generate || :
# Regenerate after driver packages are removed
%transfiletriggerpostun -n odbcinst-generate -- %{_prefix}/lib/odbc/odbcinst.d %{_sysconfdir}/odbc/odbcinst.d
-odbcinst-generate || :
+%{_bindir}/odbcinst-generate || :
%files devel -f devel-so-list
reply other threads:[~2026-11-04 5:27 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=179377004567.1.8168238409359108242.rpms-unixODBC-0a5cad135148@fedoraproject.org \
--to=yselkowi@redhat.com \
--cc=git-commits@fedoraproject.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox