myodbc-5.2.7-r2.ebuild 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. # Copyright 1999-2015 Gentoo Foundation
  2. # Distributed under the terms of the GNU General Public License v2
  3. EAPI=5
  4. inherit cmake-multilib eutils flag-o-matic versionator
  5. MAJOR="$(get_version_component_range 1-2 $PV)"
  6. MY_PN="mysql-connector-odbc"
  7. MY_P="${MY_PN}-${PV/_p/r}-src"
  8. DESCRIPTION="ODBC driver for MySQL"
  9. HOMEPAGE="http://www.mysql.com/products/myodbc/"
  10. SRC_URI="mirror://mysql/Downloads/Connector-ODBC/${MAJOR}/${MY_P}.tar.gz"
  11. RESTRICT="primaryuri"
  12. LICENSE="GPL-2"
  13. SLOT="${MAJOR}"
  14. KEYWORDS="~amd64 ~ppc ~x86"
  15. IUSE=""
  16. # Does not build with mysql-connector-c
  17. RDEPEND="
  18. dev-db/unixODBC[${MULTILIB_USEDEP}]
  19. ~virtual/libmysqlclient-18[${MULTILIB_USEDEP}]
  20. abi_x86_32? (
  21. !app-emulation/emul-linux-x86-db[-abi_x86_32(-)]
  22. )
  23. !dev-db/mysql-connector-c
  24. "
  25. DEPEND="${RDEPEND}"
  26. S=${WORKDIR}/${MY_P}
  27. # Careful!
  28. DRIVER_NAME="${PN}-${SLOT}"
  29. src_prepare() {
  30. # Remove Tests
  31. sed -i -e "s/ADD_SUBDIRECTORY(test)//" \
  32. "${S}/CMakeLists.txt"
  33. # Fix as-needed on the installer binary
  34. echo "TARGET_LINK_LIBRARIES(myodbc-installer odbc)" >> "${S}/installer/CMakeLists.txt"
  35. # Patch document path so it doesn't install files to /usr
  36. epatch "${FILESDIR}/cmake-doc-path.patch" \
  37. "${FILESDIR}/${PV}-r1-cxxlinkage.patch" \
  38. "${FILESDIR}/${PV}-mariadb-dynamic-array.patch" \
  39. "${FILESDIR}/${PV}-my_malloc.patch"
  40. }
  41. multilib_src_configure() {
  42. # The RPM_BUILD flag does nothing except install to /usr/lib64 when "x86_64"
  43. # MYSQL_CXX_LINKAGE expects "mysql_config --cxxflags" which doesn't exist on MariaDB
  44. mycmakeargs+=(
  45. -DMYSQL_CXX_LINKAGE=0
  46. -DWITH_UNIXODBC=1
  47. -DMYSQLCLIENT_LIB_NAME="libmysqlclient_r.so"
  48. -DWITH_DOCUMENTATION_INSTALL_PATH=/usr/share/doc/${PF}
  49. -DMYSQL_LIB_DIR="${ROOT}/usr/$(get_libdir)"
  50. -DLIB_SUBDIR="$(get_libdir)"
  51. )
  52. cmake-utils_src_configure
  53. }
  54. multilib_src_install_all() {
  55. debug-print-function ${FUNCNAME} "$@"
  56. dodir /usr/share/${PN}-${SLOT}
  57. for i in odbc.ini odbcinst.ini; do
  58. einfo "Building $i"
  59. sed \
  60. -e "s,__PN__,${DRIVER_NAME},g" \
  61. -e "s,__PF__,${MAJOR},g" \
  62. -e "s,libmyodbc3.so,libmyodbc${SLOT:0:1}a.so,g" \
  63. >"${D}"/usr/share/${PN}-${SLOT}/${i} \
  64. <"${FILESDIR}"/${i}.m4 \
  65. || die "Failed to build $i"
  66. done;
  67. mv "${D}/usr/bin/myodbc-installer" \
  68. "${D}/usr/bin/myodbc-installer-${MAJOR}" || die "failed to move slotted binary"
  69. }
  70. pkg_config() {
  71. [ "${ROOT}" != "/" ] && \
  72. die 'Sorry, non-standard ROOT setting is not supported :-('
  73. local msg='MySQL ODBC driver'
  74. local drivers=$(/usr/bin/odbcinst -q -d)
  75. if echo $drivers | grep -vq "^\[${DRIVER_NAME}\]$" ; then
  76. ebegin "Installing ${msg}"
  77. /usr/bin/odbcinst -i -d -f /usr/share/${PN}-${SLOT}/odbcinst.ini
  78. rc=$?
  79. eend $rc
  80. [ $rc -ne 0 ] && die
  81. else
  82. einfo "Skipping already installed ${msg}"
  83. fi
  84. local sources=$(/usr/bin/odbcinst -q -s)
  85. msg='sample MySQL ODBC DSN'
  86. if echo $sources | grep -vq "^\[${DRIVER_NAME}-test\]$"; then
  87. ebegin "Installing ${msg}"
  88. /usr/bin/odbcinst -i -s -l -f /usr/share/${PN}-${SLOT}/odbc.ini
  89. rc=$?
  90. eend $rc
  91. [ $rc -ne 0 ] && die
  92. else
  93. einfo "Skipping already installed ${msg}"
  94. fi
  95. }
  96. pkg_postinst() {
  97. elog "If this is a new install, please run the following command"
  98. elog "to configure the MySQL ODBC drivers and sources:"
  99. elog "emerge --config =${CATEGORY}/${PF}"
  100. elog "Please note that the driver name used to form the DSN now includes the SLOT."
  101. elog "The myodbc-install utility is installed as myodbc-install-${MAJOR}"
  102. }