*/*: Replace virtual/libgudev with dev-libs/libgudev
[gentoo.git] / net-misc / modemmanager / modemmanager-1.10.0.ebuild
1 # Copyright 1999-2019 Gentoo Authors
2 # Distributed under the terms of the GNU General Public License v2
3
4 EAPI=6
5 GNOME2_LA_PUNT="yes"
6 VALA_USE_DEPEND="vapigen"
7
8 inherit gnome2 readme.gentoo-r1 systemd udev vala
9
10 DESCRIPTION="Modem and mobile broadband management libraries"
11 HOMEPAGE="https://www.freedesktop.org/wiki/Software/ModemManager/"
12 SRC_URI="https://www.freedesktop.org/software/ModemManager/ModemManager-${PV}.tar.xz"
13
14 LICENSE="GPL-2+"
15 SLOT="0/1" # subslot = dbus interface version, i.e. N in org.freedesktop.ModemManager${N}
16 KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~ia64 ~mips ~ppc ~ppc64 ~sparc ~x86"
17
18 IUSE="elogind +introspection mbim policykit +qmi systemd +udev vala"
19 REQUIRED_USE="
20         ?? ( elogind systemd )
21         vala? ( introspection )
22 "
23
24 RDEPEND="
25         >=dev-libs/glib-2.36.0:2
26         udev? ( >=dev-libs/libgudev-230:= )
27         introspection? ( >=dev-libs/gobject-introspection-0.9.6:= )
28         mbim? ( >=net-libs/libmbim-1.18.0 )
29         policykit? ( >=sys-auth/polkit-0.106[introspection] )
30         qmi? ( >=net-libs/libqmi-1.22.0:= )
31         elogind? ( sys-auth/elogind )
32         systemd? ( >=sys-apps/systemd-209 )
33 "
34 DEPEND="${RDEPEND}
35         dev-util/gdbus-codegen
36         dev-util/glib-utils
37         >=dev-util/gtk-doc-am-1
38         >=sys-devel/gettext-0.19.8
39         virtual/pkgconfig
40         vala? ( $(vala_depend) )
41 "
42 RDEPEND="${RDEPEND}
43         policykit? ( acct-group/plugdev )"
44
45 S="${WORKDIR}/ModemManager-${PV}"
46
47 src_prepare() {
48         DOC_CONTENTS="
49                 If your USB modem shows up only as a storage device when you plug it in,
50                 then you should install sys-apps/usb_modeswitch, which will automatically
51                 switch it over to USB modem mode whenever you plug it in.\n"
52
53         if use policykit; then
54                 DOC_CONTENTS+="\nTo control your modem without needing to enter the root password,
55                         add your user account to the 'plugdev' group."
56         fi
57
58         use vala && vala_src_prepare
59         gnome2_src_prepare
60 }
61
62 src_configure() {
63         local myconf=(
64                 --disable-more-warnings
65                 --disable-static
66                 --with-dist-version=${PVR}
67                 --with-udev-base-dir="$(get_udevdir)"
68                 $(use_with udev)
69                 $(use_enable introspection)
70                 $(use_with mbim)
71                 $(use_with policykit polkit)
72                 $(use_with systemd systemd-suspend-resume)
73                 $(use_with systemd systemd-journal)
74                 $(use_with qmi)
75                 $(use_enable vala)
76         )
77         if use elogind; then
78                 myconf+=(
79                         --with-systemd-suspend-resume
80                         LIBSYSTEMD_LOGIN_CFLAGS=`pkg-config --cflags "libelogind" 2>/dev/null`
81                         LIBSYSTEMD_LOGIN_LIBS=`pkg-config --libs "libelogind" 2>/dev/null`
82                 )
83         fi
84         gnome2_src_configure "${myconf[@]}"
85 }
86
87 src_install() {
88         gnome2_src_install
89
90         # Allow users in plugdev group full control over their modem
91         if use policykit; then
92                 insinto /usr/share/polkit-1/rules.d/
93                 doins "${FILESDIR}"/01-org.freedesktop.ModemManager1.rules
94         fi
95
96         readme.gentoo_create_doc
97 }
98
99 pkg_postinst() {
100         gnome2_pkg_postinst
101
102         # The polkit rules file moved to /usr/share
103         old_rules="${EROOT}etc/polkit-1/rules.d/01-org.freedesktop.ModemManager.rules"
104         if [[ -f "${old_rules}" ]]; then
105                 case "$(md5sum ${old_rules})" in
106                   c5ff02532cb1da2c7545c3069e5d0992* | 5c50f0dc603c0a56e2851a5ce9389335* )
107                         # Automatically delete the old rules.d file if the user did not change it
108                         elog
109                         elog "Removing old ${old_rules} ..."
110                         rm -f "${old_rules}" || eerror "Failed, please remove ${old_rules} manually"
111                         ;;
112                   * )
113                         elog "The ${old_rules}"
114                         elog "file moved to /usr/share/polkit-1/rules.d/ in >=modemmanager-0.5.2.0-r2"
115                         elog "If you edited ${old_rules}"
116                         elog "without changing its behavior, you may want to remove it."
117                         ;;
118                 esac
119         fi
120
121         if ! use udev; then
122                 ewarn "You have built ModemManager without udev support. You may have to teach it"
123                 ewarn "about your modem port manually."
124         fi
125
126         systemd_reenable ModemManager.service
127
128         readme.gentoo_print_elog
129 }