%bcond_with systemd

#%define git_snapshot .git20130607
%define git_snapshot %{nil}
#define ppp_version 2.4.7
%define glib2_version 2.40

Name: ModemManager
Summary: Mobile broadband modem management service
Summary(ja): モバイルブロードバンドモデム運用サービス
Version: 1.20.6
Release: 1%{git_snapshot}%{?_dist_release}%{?with_systemd:.systemd}
Group: network,system
Vendor: Project Vine
Distribution: Vine Linux

License: GPLv2+
URL: https://www.freedesktop.org/wiki/Software/ModemManager/
Source: https://gitlab.freedesktop.org/mobile-broadband/ModemManager/-/archive/%{version}/ModemManager-%{version}.tar.bz2
#https://www.freedesktop.org/software/%{name}/%{name}-%{version}.tar.xz

BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root
BuildRequires: glib2-devel >= %{glib2_version}
BuildRequires: meson
BuildRequires: gobject-introspection-devel
BuildRequires: vala
BuildRequires: vala-libs
BuildRequires: polkit-devel
BuildRequires: dbus-devel
# for xsltproc
BuildRequires: libxslt
%if %{with systemd}
BuildRequires: systemd-devel 
%{?systemd_requires}
%endif
BuildRequires: libgudev-devel
Requires: dbus-glib

%description
The ModemManager service manages WWAN modems and provides a consistent API for
interacting with these devices to client applications.


%package        devel
Summary:        Development tools for %{name}
Summary(ja):    %{name} の開発環境
Group:          programming
Requires:       %{name} = %{version}-%{release}
Requires:       pkgconfig

%description	devel
Header files and libraries for building a extension library for the %{name}.


%package	glib
Summary:	Libraries for adding ModemManager support to applications that use glib.
Summary(ja):    Glib を使用するアプリケーションに ModemManager サポートを追加するためのライブラリ
Group: 		system
Requires:	glib2 >= %{glib2_version}

%description	glib
This package contains the libraries that make it easier to use some ModemManager
functionality from applications that use glib.


%package        glib-devel
Summary:        Development tools for %{name}-glib
Summary(ja):    %{name}-glib の開発環境
Group:          programming
Requires:       %{name}-glib = %{version}-%{release}
Requires:       %{name}-devel = %{version}-%{release}
Requires:       glib2-devel
Requires:       pkgconfig

%description	glib-devel
Header files and libraries for building a extension library for the %{name}-glib.


%debug_package


%prep
%setup -q


%build
%meson \
	-Ddist_version='"%{version}-%{release}"' \
	-Dvapi=true \
	-Dudevdir=/lib/udev \
	-Dpolkit=permissive \
	-Dbash_completion=false \
	-Dgtk_doc=false \
	-Dmbim=false \
	-Dqmi=false \
	-Dqrtr=false \
	-Dplugin_fibocom=disabled \
	-Dplugin_foxconn=disabled \
	-Dplugin_qcom_soc=disabled \
%if %{with systemd}
	-Dsystemd_journal=true \
	-Dsystemd_suspend_resume=true \
	-Dsystemdsystemunitdir=%{_unitdir} \
%else
	-Dsystemd_journal=false \
	-Dsystemd_suspend_resume=false \
	-Dsystemdsystemunitdir="no" \
%endif
	%{nil}

%meson_build


%install
%meson_install
%find_lang %{name}
mkdir -p %{buildroot}%{_datadir}/bash-completion/completions/
cp -a cli/mmcli-completion %{buildroot}%{_datadir}/bash-completion/completions/mmcli


%check


%if %{with systemd}
%post
%systemd_post ModemManager.service
%endif

%if %{with systemd}
%preun
%systemd_preun ModemManager.service
%endif

%if %{with systemd}
%postun
%systemd_postun ModemManager.service
%endif


%files -f %{name}.lang
%defattr(-,root, root,-)
%license COPYING
%doc README
%{_sysconfdir}/dbus-1/system.d/org.freedesktop.ModemManager1.conf
%{_libdir}/girepository-1.0/ModemManager-1.0.typelib
%{_datadir}/dbus-1/system-services/org.freedesktop.ModemManager1.service
%attr(0755,root,root) %{_sbindir}/ModemManager
%attr(0755,root,root) %{_bindir}/mmcli
%dir %{_libdir}/%{name}
%attr(0755,root,root) %{_libdir}/%{name}/*.so*
%dir %{_datadir}/%{name}
%{_datadir}/%{name}/*
/lib/udev/rules.d/*
%{_datadir}/dbus-1/interfaces/*.xml
%{_datadir}/icons/hicolor/22x22/apps/*.png
%{_datadir}/polkit-1/actions/org.freedesktop.ModemManager1.policy
%{_mandir}/man1/*
%{_mandir}/man8/*
%dir %{_datadir}/bash-completion
%dir %{_datadir}/bash-completion/completions
%{_datadir}/bash-completion/completions/*
%if %{with systemd}
%{_unitdir}/*.service
%endif

%files devel
%defattr(-,root,root,-)
%{_includedir}/ModemManager/*.h
%{_datadir}/gir-1.0/ModemManager-1.0.gir
%{_libdir}/pkgconfig/%{name}.pc

%files glib
%defattr(-,root,root,-)
%{_libdir}/libmm-glib.so.*

%files glib-devel
%defattr(-,root,root,-)
%{_libdir}/libmm-glib.so
%dir %{_includedir}/libmm-glib
%{_includedir}/libmm-glib/*.h
%{_libdir}/pkgconfig/mm-glib.pc
%dir %{_datadir}/vala
%dir %{_datadir}/vala/vapi
%{_datadir}/vala/vapi/libmm-glib.*


%changelog
* Fri Apr 21 2023 Tomohiro "Tomo-p" KATO <tomop@teamgedoh.net> 1.20.6-1
- new upstream release.

* Mon Feb 15 2021 Tomohiro "Tomo-p" KATO <tomop@teamgedoh.net> 1.14.10-1
- new upstream release.

* Mon Aug  3 2020 Tomohiro "Tomo-p" KATO <tomop@teamgedoh.net> 1.14.0-1
- new upstream release.

* Sun Sep 01 2019 Tomohiro "Tomo-p" KATO <tomop@teamgedoh.net> 1.10.4-1
- new upstream release.

* Mon Dec 17 2018 Tomohiro "Tomo-p" KATO <tomop@teamgedoh.net> 1.8.2-1
- new upstream release.
- added elogind support.

* Sat Mar 03 2018 Tomohiro "Tomo-p" KATO <tomop@teamgedoh.net> 1.6.12-1
- new upstream release.

* Sun Apr 24 2016 Yoji TOYODA <bsyamato@sea.plala.or.jp> 1.4.14-1
- new upstream release
- change BuildRequires: libgudev-devel instead of eudev-libgudev1-devel

* Sun Feb 14 2016 Yoji TOYODA <bsyamato@sea.plala.or.jp> 1.4.12-3
- fix spec file

* Thu Nov 12 2015 Yoji TOYODA <bsyamato@sea.plala.or.jp> 1.4.12-2
- fix spec file

* Fri Oct 09 2015 Yoji TOYODA <bsyamato@sea.plala.or.jp> 1.4.12-1
- new upstream release
- add BuildRequires: gobject-introspection-devel, polkit-devel

* Sun Jul 26 2015 Yoji TOYODA <bsyamato@sea.plala.or.jp> 1.4.10-1
- new upstream release

* Sat May 16 2015 Yoji TOYODA <bsyamato@sea.plala.or.jp> 1.4.8-1
- new upstream release

* Mon Apr 13 2015 Yoji TOYODA <bsyamato@sea.plala.or.jp> 1.4.6-1
- new upstream release

* Wed Jan 28 2015 Yoji TOYODA <bsyamato@sea.plala.or.jp> 1.4.2-1
- new upstream release

* Sun Oct 26 2014 Yoji TOYODA <bsyamato@sea.plala.or.jp> 1.4.0-1
- new upstream release

* Tue Oct  7 2014 Ryoichi INAGAKI <ryo1@toki.waseda.jp> 1.2.0-2
- moved ModemManager-glib to System Environment/Libraries Group
- removed BR: ppp, ppp-devel and dbus-glib-devel

* Sat Mar 29 2014 Yoji TOYODA <bsyamato@sea.plala.or.jp> 1.2.0-1
- new upstream release
- remove Patch1 (ModemManager-1.0.0-git20130911.patch)

* Sun Dec 29 2013 Yoji TOYODA <bsyamato@sea.plala.or.jp> 1.0.0-2
- add Patch1 (ModemManager-1.0.0-git20130911.patch)

* Tue Aug 27 2013 Yoji TOYODA <bsyamato@sea.plala.or.jp> 1.0.0-1
- new upstream release
- update Patch0

* Sun Jun 09 2013 Yoji TOYODA <bsyamato@sea.plala.or.jp> 0.7.991-1.git20130607
- update to 0.7.991 snapshot
- fix spec file based on FC package
  * Fri Jun  7 2013 Dan Williams <dcbw@redhat.com> - 0.7.991-1.git20130607
  - Update to 0.7.991 snapshot
  - Fix SMS validity parsing
  - Allow registration changes to 'searching' without disconnecting
  - Fix reading SMS messages from some QMI-based devices
  - Increase connection timeout for Novatel E362
  - Fix PIN retries checking when unlocking Ericsson devices
  - Better handling of supported and preferred modes (eg 2G, 3G, 4G preference)
- add configure option (--enable-gtk-doc=yes, --without-qmi)

* Sun Apr 15 2012 Yoji TOYODA <bsyamato@sea.plala.or.jp> 0.5.2.0-1
- new upstream release

* Tue Aug 23 2011 Yoji TOYODA <bsyamato@sea.plala.or.jp> 0.5-1
- new upstream release

* Tue Aug 16 2011 Yoji TOYODA <bsyamato@sea.plala.or.jp> 0.4.998-1
- delete Patch20

* Wed May 04 2011 Yoji TOYODA <bsyamato@sea.plala.or.jp> 0.4-2
- update Patch20 (ModemManager-0.4-git20110428.patch)
- delete Patch21,22

* Sat Jan 01 2011 Yoji TOYODA <bsyamato@sea.plala.or.jp> 0.4-1
- update to 0.4
- add Patch20 (ModemManager-0.4-git20100720.patch)
- add Patch21 (ModemManager-0.4-glib2-2.25.12.patch)
- add Patch22 (ModemManager-0.4-dbus-glib-property-access-bug.patch)

* Fri May 07 2010 Daisuke SUZUKI <daisuke@linux.or.jp> 0.3-1.git20100502
- initial build for Vine Linux

* Sun May  2 2010 Dan Williams <dcbw@redhat.com> - 0.3-11.git20100502
- core: ignore some failures on disconnect (rh #578280)
- core: add support for platform serial devices
- gsm: better Blackberry DUN support
- gsm: periodically poll access technology
- cdma: prevent crash on modem removal (rh #571921)
- mbm: add support for Sony Ericsson MD400, Dell 5541, and Dell 5542 modems
- novatel: better signal strength reporting on CDMA cards
- novatel: add access technology and mode preference support on GSM cards
- zte: fix mode preference retrieval
- longcheer: add support for Zoom modems (4595, 4596, etc)
- longcheer: add access technology and mode preference support

* Fri Apr 30 2010 Matthias Clasen <mclasen@redhat.com> - 0.3-10.git20100409
- Silence %%post
- Update scripts

* Fri Apr  9 2010 Dan Williams <dcbw@redhat.com> - 0.3-9.git20100409
- gsm: fix parsing Blackberry supported character sets response

* Thu Apr  8 2010 Dan Williams <dcbw@redhat.com> - 0.3-8.git20100408
- mbm: fix retrieval of current allowed mode
- gsm: fix initialization issues with some devices (like Blackberries)

* Mon Apr  5 2010 Dan Williams <dcbw@redhat.com> - 0.3-7.git20100405
- core: fix detection of some generic devices (rh #579247)
- core: fix detection regression of some Huawei devices in 0.3-5
- cdma: periodically poll registration state and signal quality
- cdma: really fix registration detection on various devices (rh #569067)

* Wed Mar 31 2010 Dan Williams <dcbw@redhat.com> - 0.3-6.git20100331
- core: fix PPC/SPARC/etc builds

* Wed Mar 31 2010 Dan Williams <dcbw@redhat.com> - 0.3-5.git20100331
- core: only export a modem when all its ports are handled (rh #540438, rh #569067, rh #552121)
- cdma: handle signal quality requests while connected for more devices
- cdma: handle serving system requests while connected for more devices
- gsm: determine current access technology earlier
- huawei: work around automatic registration issues on some devices

* Tue Mar 23 2010 Dan Williams <dcbw@redhat.com> - 0.3-4.git20100323
- core: ensure enabled modems are disabled when MM stops
- core: better capability detection for Blackberry devices (rh #573510)
- cdma: better checking of registration states (rh #540438, rh #569067, rh #552121)
- gsm: don't block modem when it requires PIN2
- option: fix access technology updates

* Wed Mar 17 2010 Dan Williams <dcbw@redhat.com> - 0.3-3.git20100317
- mbm: add device IDs for C3607w
- mbm: fail earlier during connection failures
- mbm: fix username/password authentication when checked by the network
- hso: implement asynchronous signal quality updates
- option: implement asynchronous signal quality updates
- novatel: correctly handle CDMA signal quality
- core: basic PolicyKit support
- core: fix direct GSM registration information requests
- core: general GSM PIN/PUK unlock fixes
- core: poll GSM registration state internally for quicker status updates
- core: implement GSM 2G/3G preference
- core: implement GSM roaming allowed/disallowed preference
- core: emit signals on access technology changes
- core: better handling of disconnections
- core: fix simple CDMA status requests

* Thu Feb 11 2010 Dan Williams <dcbw@redhat.com> - 0.3-2.git20100211
- core: startup speed improvements
- core: GSM PIN checking improvements
- huawei: fix EVDO-only connections on various devices (rh #553199)
- longcheer: add support for more devices

* Tue Jan 19 2010 Dan Williams <dcbw@redhat.com> - 0.3-1.git20100119
- anydata: new plugin for AnyData CDMA modems (rh #547294)
- core: fix crashes when devices are unplugged during operation (rh #553953)
- cdma: prefer primary port for status/registration queries
- core: fix probing/detection of some PIN-locked devices (rh #551376)
- longcheer: add plugin for Alcatel (X020, X030, etc) and other devices
- gsm: fix Nokia N80 network scan parsing

* Fri Jan  1 2010 Dan Williams <dcbw@redhat.com> - 0.2.997-5.git20100101
- core: fix apparent hangs by limiting retried serial writes
- gsm: ensure modem state is reset when disabled

* Fri Dec 18 2009 Dan Williams <dcbw@redhat.com> - 0.2.997-4.git20091218
- sierra: fix CDMA registration detection in some cases (rh #547513)

* Wed Dec 16 2009 Dan Williams <dcbw@redhat.com> - 0.2.997-3.git20091216
- sierra: ensure CDMA device is powered up when trying to use it
- cdma: better signal quality parsing (fixes ex Huawei EC168C)
- zte: handle unsolicited messages better during probing

* Mon Dec 14 2009 Dan Williams <dcbw@redhat.com> - 0.2.997-2.git20091214
- cdma: fix signal strength reporting on some devices
- cdma: better registration state detection when dialing (ex Sierra 5275)
- option: always use the correct tty for dialing commands

* Mon Dec  7 2009 Dan Williams <dcbw@redhat.com> - 0.2.997-1
- core: fix reconnect after manual disconnect (rh #541314)
- core: fix various segfaults during registration
- core: fix probing of various modems on big-endian architectures (ie PPC)
- core: implement modem states to avoid duplicate operations
- hso: fix authentication for Icera-based devices like iCON 505
- zte: use correct port for new devices
- nozomi: fix detection

* Thu Nov  5 2009 Dan Williams <dcbw@redhat.com> - 0.2-4.20091105
- Update to latest git
- core: fix pppd 2.4.5 errors about 'baudrate 0'
- cdma: wait for network registration before trying to connect
- gsm: add cell access technology reporting
- gsm: allow longer-running network scans
- mbm: various fixes for Ericsson F3507g/F3607gw/Dell 5530
- nokia: don't power down phones on disconnect
- hso: fix disconnection/disable

* Wed Aug 26 2009 Dan Williams <dcbw@redhat.com> - 0.2-3.20090826
- Fixes for Motorola and Ericsson devices
- Fixes for CDMA "serving-system" command parsing

* Fri Jul 31 2009 Matthias Clasen <mclasen@redhat.com>
- Fix a typo in one of the udev rules files

* Fri Jul 24 2009 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 0.2-2.20090707
- Rebuilt for https://fedoraproject.org/wiki/Fedora_12_Mass_Rebuild

* Tue Jul 7 2009 Dan Williams <dcbw@redhat.com> - 0.2-1.20090707
- Fix source repo location
- Fix directory ownership

* Tue Jul 7 2009 Dan Williams <dcbw@redhat.com> - 0.2-0.20090707
- Initial version

