Skip to content

Commit

Permalink
Adding dirver UnixODBC template ini file to installation(RPM/DEB/TGZ)
Browse files Browse the repository at this point in the history
Adding (post)installation script to RPM and DEB to register the driver
with DM
Adding source rpm build
  • Loading branch information
lawrinn committed Aug 23, 2023
1 parent 9209023 commit 2c09a87
Show file tree
Hide file tree
Showing 3 changed files with 65 additions and 4 deletions.
45 changes: 41 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ IF(NOT USE_SYSTEM_INSTALLED_LIB)
ELSE()
INSTALL(FILES
$<TARGET_FILE:libmariadb>
DESTINATION ${INSTALL_LIBDIR}
DESTINATION "${INSTALL_LIBDIR}"
COMPONENT ConCLib)
MESSAGE(STATUS "Configuring to install libmariadb to ${INSTALL_LIBDIR}")
IF(NOT ALL_PLUGINS_STATIC)
Expand Down Expand Up @@ -474,8 +474,44 @@ ELSE()
INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/libmaodbc.pc
DESTINATION "${INSTALL_PCDIR}"
COMPONENT Development)
IF(RPM)
SET(CPACK_RPM_Development_USER_FILELIST "%ignore ${CMAKE_INSTALL_PREFIX}/${INSTALL_PCDIR}")
# Not doing this with MacOS(iOdbc). So far, at least
CONFIGURE_FILE(${CMAKE_SOURCE_DIR}/packaging/linux/maodbc.ini.in
${CMAKE_BINARY_DIR}/packaging/linux/maodbc.ini @ONLY)
INSTALL(FILES
${CMAKE_BINARY_DIR}/packaging/linux/maodbc.ini
DESTINATION
"${INSTALL_DOCDIR}"
COMPONENT Documentation)
IF(RPM OR DEB)
CONFIGURE_FILE(${CMAKE_SOURCE_DIR}/packaging/linux/postinstall.in
${CMAKE_BINARY_DIR}/packaging/linux/postinstall @ONLY)

IF(RPM)
SET(CPACK_RPM_Development_USER_FILELIST "%ignore ${CMAKE_INSTALL_PREFIX}/${INSTALL_PCDIR}")
SET(CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST_ADDITION ${CMAKE_INSTALL_PREFIX}/${INSTALL_PCDIR})
MESSAGE(STATUS "Excluding ${CMAKE_INSTALL_PREFIX}/${INSTALL_PCDIR} from RPM filelist")
SET(CPACK_RPM_POST_INSTALL_SCRIPT_FILE ${CMAKE_BINARY_DIR}/packaging/linux/postinstall)

IF(CMAKE_VERSION VERSION_GREATER "3.9.99")

SET(CPACK_SOURCE_GENERATOR "RPM")
SETA(CPACK_RPM_SOURCE_PKG_BUILD_PARAMS "-DRPM=${RPM}")

MACRO(ADDIF var)
IF(DEFINED ${var})
SETA(CPACK_RPM_SOURCE_PKG_BUILD_PARAMS "-D${var}=${${var}}")
ENDIF()
ENDMACRO()

ADDIF(CMAKE_BUILD_TYPE)
ADDIF(BUILD_CONFIG)
#ADDIF(WITH_SSL)

ENDIF()
ELSE()
SET(CPACK_DEBIAN_PACKAGE_CONTROL_EXTRA "${CMAKE_BINARY_DIR}/packaging/linux/postinstall")
ENDIF()

ENDIF()
ENDIF()
INSTALL(TARGETS
Expand All @@ -488,6 +524,7 @@ ELSE()
DESTINATION
"${INSTALL_DOCDIR}"
COMPONENT Documentation)

INSTALL(FILES
${CMAKE_SOURCE_DIR}/COPYING
DESTINATION
Expand Down Expand Up @@ -573,7 +610,7 @@ SET(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/COPYING")
SET(CPACK_PACKAGE_DESCRIPTION_FILE "${CMAKE_CURRENT_SOURCE_DIR}/README")
SET(CPACK_SOURCE_PACKAGE_FILE_NAME "mariadb-connector-odbc-${CPACK_PACKAGE_VERSION}${QUALITY_SUFFIX}-src")
SET(CPACK_PACKAGE_CONTACT "[email protected]")
SET(CPACK_PACKAGE_VENDOR "MariaDB Corporation AB")
SET(CPACK_PACKAGE_VENDOR "MariaDB plc")
SET(CPACK_SOURCE_IGNORE_FILES
/test/
/.git/
Expand Down
9 changes: 9 additions & 0 deletions packaging/linux/maodbc.ini.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[MariaDB]
Driver = @CMAKE_INSTALL_PREFIX@/@INSTALL_LIBDIR@/libmaodbc.so
DESCRIPTION = MariaDB ODBC Connector
Threading = 0

[@CMAKE_INSTALL_PREFIX@/@INSTALL_LIBDIR@/libmaodbc.so]
Driver = @CMAKE_INSTALL_PREFIX@/@INSTALL_LIBDIR@/libmaodbc.so
DESCRIPTION = MariaDB ODBC Connector
Threading = 0
15 changes: 15 additions & 0 deletions packaging/linux/postinstall.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/bin/sh

if ! odbcinst -i -d -n "MariaDB ODBC Connector" -f @CMAKE_INSTALL_PREFIX@/@INSTALL_DOCDIR@/maodbc.ini ; then
if [-z ${ODBCINSTINI+x}]; then
if [-z ${ODBCSYSINI+x}]; then
ODBCINIFILE="/etc/odbcinst.ini";
else
ODBCINIFILE="$ODBCSYSINI/odbcinst.ini";
fi
else
ODBCINIFILE="$ODBCINSTINI";
fi

cat @CMAKE_INSTALL_PREFIX@/@INSTALL_DOCDIR@/maodbc.ini >> $ODBCINIFILE
fi

0 comments on commit 2c09a87

Please sign in to comment.