%global gtk3_version          %(pkg-config --modversion gtk+-3.0 2>/dev/null || echo bad)
%global glib2_version         %(pkg-config --modversion glib-2.0 2>/dev/null || echo bad)
%global nm_version            1:1.8.0
%global mbp_version           0.20090602
%global old_libnma_version    1.8.30
%global rpm_version 1.8.32
%global real_version 1.8.32
%global release_version 2
%global real_version_major %(printf '%s' '%{real_version}' | sed -n 's/^\\([1-9][0-9]*\\.[1-9][0-9]*\\)\\.[1-9][0-9]*$/\\1/p')

Name:           libnma
Summary:        NetworkManager GUI library
Version:        %{rpm_version}
Release:        %{release_version}
License:        GPLv2+ and LGPLv2+
URL:            https://gitlab.gnome.org/GNOME/libnma/
Source0:        https://download.gnome.org/sources/libnma/%{real_version_major}/%{name}-%{real_version}.tar.xz
Patch1:         0001-nm-applet-no-notifications.patch

Obsoletes:      libnma < %{old_libnma_version}

BuildRequires:  gcc gettext-devel pkgconfig meson gtk-doc  iso-codes-devel gcr-devel
BuildRequires:  NetworkManager-libnm-devel >= %{nm_version}  gtk3-devel >= 3.10
BuildRequires:  ModemManager-glib-devel >= 1.0  glib2-devel >= 2.32
BuildRequires:  gobject-introspection-devel >= 0.10.3 pkgconfig
BuildRequires:  mobile-broadband-provider-info-devel >= %{mbp_version}

%description
This package contains the library used for integrating GUI tools with
NetworkManager.

%package devel
Summary:        Header files for NetworkManager GUI library
Requires:       NetworkManager-libnm-devel >= %{nm_version}
Obsoletes:      NetworkManager-gtk-devel < 1:0.9.7
Requires:       libnma = %{version}-%{release} pkgconfig  gtk3-devel
Obsoletes:      libnma < %{old_libnma_version}

%description devel
This package contains header and pkg-config files to be used for integrating
GUI tools with NetworkManager.

%prep
%autosetup -p1 -n "%{name}-%{real_version}"

%build
%configure --disable-mobile-broadband-provider-info
%meson \
        -Dgcr=true \
        -Ddisable-static=true \
        -Dvapi=false \
        -Dlibnma_gtk4=false \
        -Dmobile_broadband_provider_info=false
%meson_build

%install
%meson_install
%find_lang %{name}

%check
%meson_test

%files -f %{name}.lang
%defattr(-,root,root)
%doc NEWS CONTRIBUTING
%license COPYING
%{_libdir}/libnma.so.*
%{_libdir}/girepository-1.0/NMA-1.0.typelib
%{_datadir}/glib-2.0/schemas/org.gnome.nm-applet.gschema.xml

%files devel
%defattr(-,root,root)
%{_includedir}/libnma
%{_libdir}/pkgconfig/libnma.pc
%{_libdir}/libnma.so
%{_datadir}/gir-1.0/NMA-1.0.gir
%{_datadir}/gtk-doc

%changelog
* Tue Oct 25 2022 wangkerong <wangkerong@h-partners.com> - 1.8.32-2
- rebuild for next release

* Thu Dec 30 2021 yanan <yanan@huawei.com> - 1.8.32-1
- upgrade to libnma-1.8.32
- remove the installation dependency on mobile-broadband-provider-info

* Fri May 28 2021 weijin deng <weijin.deng@turbolinux.com.cn> - 1.8.30-1
- Upgrade to 1.8.30
- Update old_libnma_version, rpm_version, real_version, release_version, BuildRequires
- Add patch

* Wed Sep 2 2020 jinzhimin <jinzhimin2@huawei.com> - 1.8.28-2
- Fix nm-connection-editor command core dump issue

* Fri Jul  31 2020 wuchaochao <wuchaochao4@huawei.com> - 1.8.28-1
- Update to 1.8.28 release
