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