unixodbc: auto-generate odbcinst.ini 4532/head
authorDaniel Golle <daniel@makrotopia.org>
Sun, 2 Jul 2017 12:06:34 +0000 (14:06 +0200)
committerDaniel Golle <daniel@makrotopia.org>
Sun, 2 Jul 2017 18:47:26 +0000 (20:47 +0200)
This allows ODBC drivers to create odbcinst.ini-snippets in
/etc/odbcinst.ini.d/ which will be assembled into
/tmp/etc/odbcinst.ini. /etc/odbcinst.ini is provided as a symlink
pointing to /tmp/etc/odbcinst.ini
Hence the unixODBC-provided PostgreSQL driver was also given an
odbcinst.ini.d snippet.

Signed-off-by: Daniel Golle <daniel@makrotopia.org>
libs/unixodbc/Makefile
libs/unixodbc/files/odbc.init [new file with mode: 0644]

index d962371baa3470f8bfc1d6453bc5beac8e6d9241..b13636ad5a70728a191c433d641928b5cfff33e5 100644 (file)
@@ -9,7 +9,7 @@ include $(TOPDIR)/rules.mk
 
 PKG_NAME:=unixodbc
 PKG_VERSION:=2.3.4
-PKG_RELEASE:=2
+PKG_RELEASE:=3
 
 PKG_SOURCE_URL:=ftp://ftp.unixodbc.org/pub/unixODBC/
 PKG_SOURCE:=unixODBC-$(PKG_VERSION).tar.gz
@@ -98,8 +98,9 @@ define Package/unixodbc/install
        $(CP) $(PKG_INSTALL_DIR)/usr/lib/libodbc[ci]*so* $(1)/usr/lib/
        $(CP) $(PKG_INSTALL_DIR)/usr/lib/libodbc.*so* $(1)/usr/lib/
        $(CP) $(PKG_INSTALL_DIR)/usr/lib/libnn*so* $(1)/usr/lib/
-       $(INSTALL_DIR) $(1)/etc
-       $(CP) $(PKG_INSTALL_DIR)/etc/odbc* $(1)/etc/
+       $(INSTALL_DIR) $(1)/etc/init.d
+       $(INSTALL_BIN) ./files/odbc.init $(1)/etc/init.d/odbc
+       $(LN) /tmp/etc/odbcinst.ini $(1)/etc/odbcinst.ini
 endef
 
 define Package/unixodbc-tools/install
@@ -110,6 +111,10 @@ endef
 define Package/pgsqlodbc/install
        $(INSTALL_DIR) $(1)/usr/lib
        $(CP) $(PKG_INSTALL_DIR)/usr/lib/libodbcpsql*so* $(1)/usr/lib/
+       $(INSTALL_DIR) $(1)/etc/odbcinst.ini.d/
+       echo "[PostgreSQL]" > $(1)/etc/odbcinst.ini.d/pgsqlodbc.ini
+       echo "Description = unixODBC PostgreSQL driver" >> $(1)/etc/odbcinst.ini.d/pgsqlodbc.ini
+       echo "Driver = /usr/lib/libodbcpsql.so" >> $(1)/etc/odbcinst.ini.d/pgsqlodbc.ini
 endef
 
 $(eval $(call BuildPackage,unixodbc))
diff --git a/libs/unixodbc/files/odbc.init b/libs/unixodbc/files/odbc.init
new file mode 100644 (file)
index 0000000..32ae7f8
--- /dev/null
@@ -0,0 +1,26 @@
+#!/bin/sh /etc/rc.common
+
+START=50
+
+gen_odbcinst() {
+       local inifile
+
+       echo "[ODBC]"
+       echo "Trace = off"
+       echo "TraceFile ="
+
+       for inifile in /etc/odbcinst.ini.d/*.ini; do
+               cat "$inifile"
+       done
+}
+
+start() {
+       [ ! -d /tmp/etc ] && mkdir /tmp/etc
+
+       gen_odbcinst > /tmp/etc/odbcinst.ini.new
+       chmod 0644 /tmp/etc/odbcinst.ini.new
+
+       [ -e /tmp/etc/odbcinst.ini ] && ( rm /tmp/etc/odbcinst.ini || return 1 )
+
+       mv /tmp/etc/odbcinst.ini.new /tmp/etc/odbcinst.ini
+}