sys-process/glances: 3.1.4.1-r1 amd64 stable, bug #720368
[gentoo.git] / dev-db / myodbc / myodbc-8.0.19.ebuild
1 # Copyright 1999-2020 Gentoo Authors
2 # Distributed under the terms of the GNU General Public License v2
3
4 EAPI=7
5
6 inherit cmake-multilib
7
8 MAJOR="$(ver_cut 1-2)"
9 MY_PN="mysql-connector-odbc"
10 MY_P="${MY_PN}-${PV/_p/r}-src"
11
12 DESCRIPTION="ODBC driver for MySQL"
13 HOMEPAGE="https://dev.mysql.com/downloads/connector/odbc/"
14 SRC_URI="https://dev.mysql.com/get/Downloads/Connector-ODBC/${MAJOR}/${MY_P}.tar.gz"
15
16 LICENSE="GPL-2"
17 SLOT="${MAJOR}"
18 KEYWORDS="amd64 ppc x86"
19 IUSE=""
20
21 # Broken when built dynamically against libmysqlclient.so
22 RDEPEND="
23         dev-db/unixODBC[${MULTILIB_USEDEP}]
24         >=dev-db/mysql-connector-c-8.0:0=[static-libs,${MULTILIB_USEDEP}]
25 "
26 DEPEND="${RDEPEND}"
27 S=${WORKDIR}/${MY_P}
28
29 # Careful!
30 DRIVER_NAME="${PN}-${SLOT}"
31
32 # Patch document path so it doesn't install files to /usr
33 PATCHES=(
34         "${FILESDIR}/${MAJOR}-cmake-doc-path.patch"
35         "${FILESDIR}/${PN}-8.0.19-cxxlinkage.patch"
36 )
37
38 src_prepare() {
39         # Remove Tests
40         sed -i -e "s/ADD_SUBDIRECTORY(test)//" \
41                 "${S}/CMakeLists.txt"
42
43         cmake-utils_src_prepare
44 }
45
46 multilib_src_configure() {
47         mycmakeargs+=(
48                 -DMYSQLCLIENT_STATIC_LINKING=1
49                 -DMYSQL_CXX_LINKAGE=1
50                 -DWITH_UNIXODBC=1
51                 -DWITH_DOCUMENTATION_INSTALL_PATH=/usr/share/doc/${PF}
52                 -DLIB_SUBDIR="$(get_libdir)/${PN}-${MAJOR}"
53                 -DMYSQLCLIENT_NO_THREADS=ON
54                 -DDISABLE_GUI=ON
55                 # The NUMA and LIBWRAP options are not really used.
56                 # They are just copied from the server code
57                 -DWITH_NUMA=OFF
58                 -DWITH_LIBWRAP=OFF
59         )
60         cmake-utils_src_configure
61 }
62
63 multilib_src_install_all() {
64         debug-print-function ${FUNCNAME} "$@"
65
66         dodir /usr/share/${PN}-${SLOT}
67         for i in odbc.ini odbcinst.ini; do
68                 einfo "Building $i"
69                         sed \
70                         -e "s,__PN__,${DRIVER_NAME},g" \
71                         -e "s,__PF__,${MAJOR},g" \
72                         -e "s,lib/libmyodbc3.so,$(get_libdir)/${PN}-${MAJOR}/libmyodbc${SLOT:0:1}a.so,g" \
73                         >"${D}"/usr/share/${PN}-${SLOT}/${i} \
74                         <"${FILESDIR}"/${i}.m4 \
75                         || die "Failed to build $i"
76         done;
77         mv "${D}/usr/bin/myodbc-installer" \
78                 "${D}/usr/bin/myodbc-installer-${MAJOR}" || die "failed to move slotted binary"
79 }
80
81 pkg_config() {
82
83         [ "${ROOT}" != "/" ] && \
84                 die 'Sorry, non-standard ROOT setting is not supported :-('
85
86         local msg='MySQL ODBC driver'
87         local drivers=$(/usr/bin/odbcinst -q -d)
88
89         if echo $drivers | grep -vq "^\[${DRIVER_NAME}\]$" ; then
90                 ebegin "Installing ${msg}"
91                 /usr/bin/odbcinst -i -d -f /usr/share/${PN}-${SLOT}/odbcinst.ini
92                 rc=$?
93                 eend $rc
94                 [ $rc -ne 0 ] && die
95         else
96                 einfo "Skipping already installed ${msg}"
97         fi
98
99         local sources=$(/usr/bin/odbcinst -q -s)
100         msg='sample MySQL ODBC DSN'
101         if echo $sources | grep -vq "^\[${DRIVER_NAME}-test\]$"; then
102                 ebegin "Installing ${msg}"
103                 /usr/bin/odbcinst -i -s -l -f /usr/share/${PN}-${SLOT}/odbc.ini
104                 rc=$?
105                 eend $rc
106                 [ $rc -ne 0 ] && die
107         else
108                 einfo "Skipping already installed ${msg}"
109         fi
110 }
111
112 pkg_postinst() {
113         elog "If this is a new install, please run the following command"
114         elog "to configure the MySQL ODBC drivers and sources:"
115         elog "emerge --config =${CATEGORY}/${PF}"
116         elog "Please note that the driver name used to form the DSN now includes the SLOT."
117         elog "The myodbc-install utility is installed as myodbc-install-${MAJOR}"
118 }