%bcond_with mozjs

%define _unpackaged_files_terminate_build 1

Summary:        A library handling all the details of proxy configuration
Name:           libproxy
Version:        0.4.17
Release:        1%{?_dist_release}
Group:          system
Vendor:         Project Vine
Distribution:   Vine Linux

License:        LGPLv2+
URL:            http://libproxy.github.io/libproxy
Source0:        https://github.com/libproxy/libproxy/releases/download/%{version}/libproxy-%{version}.tar.xz

BuildRoot:      %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)

Requires: libproxy-bin = %{version}-%{release}

Obsoletes: %{name}-mozjs < 1.4.15
Obsoletes: %{name}-webkitgtk3 < 1.4.15

BuildRequires:  cmake
# gnome
BuildRequires:  pkgconfig(gio-2.0) >= 2.26
# NetworkManager
BuildRequires:  NetworkManager-libnm-devel
BuildRequires:  dbus-devel
BuildRequires:  glib2
# webkit (gtk3)
BuildRequires:  pkgconfig(javascriptcoregtk-4.0)
# python3
BuildRequires:  python3-devel
BuildRequires:  python3-rpm-macros

Obsoletes: %{name}-python < 0.4.17

%description
libproxy offers the following features:

    * extremely small core footprint (< 35K)
    * no external dependencies within libproxy core
      (libproxy plugins may have dependencies)
    * only 3 functions in the stable external API
    * dynamic adjustment to changing network topology
    * a standard way of dealing with proxy settings across all scenarios
    * a sublime sense of joy and accomplishment 

Non-default rpmbuild options:
--with webkit:           Enable WebKit-gtk support


%package        bin
Summary:        Binary to test %{name}
Group:          network
Requires:       %{name} = %{version}-%{release}

%description    bin
The %{name}-bin package contains the proxy binary for %{name}


%package -n     python3-%{name}
Summary:        Binding for %{name} and python
Group:          programming
BuildArch:      noarch
%{?python_provide:%python_provide python3-%{name}}
Obsoletes:      %{name}-python3 < 1.4.17
Provides:       %{name}-python3 = %{version}-%{release}
Requires:       %{name} = %{version}-%{release}

%description -n python3-%{name}
The python3-%{name} package contains the python3 binding for %{name}


%package        gnome
Summary:        Plugin for %{name} and gnome
Group:          system
Requires:       %{name} = %{version}-%{release}

%description    gnome
The %{name}-gnome package contains the %{name} plugin for gnome.


%package        networkmanager
Summary:        Plugin for %{name} and networkmanager
Group:          system
Requires:       %{name}%{?_isa} = %{version}-%{release}

%description    networkmanager
The %{name}-networkmanager package contains the %{name} plugin
for networkmanager.


%package        webkitgtk4
Summary:        Plugin for %{name} and webkitgtk4
Group:          system
Requires:       %{name} = %{version}
Provides:       %{name}-pac = %{version}-%{release}

%description    webkitgtk4
The %{name}-webkitgtk4 package contains the %{name} plugin for
webkitgtk4.


%package        pacrunner
Summary:        Plugin for %{name} and PacRunner
Group:          system
Requires:       %{name}%{?_isa} = %{version}-%{release}
Provides:       %{name}-pac = %{version}-%{release}
Requires:       pacrunner

%description    pacrunner
The %{name}-pacrunner package contains the %{name} plugin for
PacRunner.


%package        devel
Summary:        Development files for %{name}
Group:          programming
Requires:       %{name} = %{version}-%{release}
Requires:       pkgconfig

%description    devel
The %{name}-devel package contains libraries and header files for
developing applications that use %{name}.


%debug_package


%prep
%autosetup -p1


%build
export CXXFLAGS="-std=c++14 $RPM_OPT_FLAGS"
%cmake \
	-DLIBEXEC_INSTALL_DIR=%{_libexecdir} \
	-DMODULE_INSTALL_DIR=%{_libdir}/%{name}/%{version}/modules \
	-DWITH_PERL=OFF \
	-DWITH_PYTHON2=OFF \
	-DWITH_PYTHON3=ON \
	-DBIPR=OFF \
	-DWITH_WEBKIT3=ON \
	-DWITH_GNOME3=ON \
	-DWITH_KDE=OFF \
	%{nil}
%cmake_build

%install
rm -rf $RPM_BUILD_ROOT
%cmake_install


%clean
rm -rf $RPM_BUILD_ROOT


%files 
%license COPYING
%doc AUTHORS README
%{_libdir}/*.so.*
%dir %{_libdir}/%{name}
%dir %{_libdir}/%{name}/%{version}
%dir %{_libdir}/%{name}/%{version}/modules
%{_libdir}/%{name}/%{version}/modules/network_networkmanager.so

%files bin
%{_bindir}/proxy

%files -n python3-%{name}
%{python3_sitelib}/libproxy.py

%files gnome
%{_libdir}/%{name}/%{version}/modules/config_gnome3.so
%{_libexecdir}/pxgsettings

%files networkmanager
%{_libdir}/%{name}/%{version}/modules/network_networkmanager.so

%files webkitgtk4
%{_libdir}/%{name}/%{version}/modules/pacrunner_webkit.so

%files pacrunner
%{_libdir}/%{name}/%{version}/modules/config_pacrunner.so

%files devel
%defattr(-,root,root,-)
%{_includedir}/proxy.h
%{_libdir}/*.so
%{_libdir}/pkgconfig/libproxy-1.0.pc
%{_datadir}/cmake/Modules/Findlibproxy.cmake


%changelog
* Fri Apr 02 2021 Tomohiro "Tomo-p" KATO <tomop@teamgedoh.net> 0.4.17-1
- dropped ldconfig scriptlets.
- dropped subpackages: kde, python2.
- dropped Patch0, 1000 and 1001: fixed in upstream.

* Sat Oct 10 2020 Tomohiro "Tomo-p" KATO <tomop@teamgedoh.net> 0.4.15-4
- imported Patch1001 to fix CVE-2020-26154 from rawhide.

* Tue Sep 15 2020 Tomohiro "Tomo-p" KATO <tomop@teamgedoh.net> 0.4.15-3
- imported Patch1000 to fix CVE-2020-25219 from debian.
- imported Patch0 to support python-3.8 from upstream.

* Sun Apr 12 2020 Tomohiro "Tomo-p" KATO <tomop@teamgedoh.net> 0.4.15-2
- rebuilt with current environment.

* Mon Jan 08 2018 Tomohiro "Tomo-p" KATO <tomop@teamgedoh.net> 0.4.15-1
- updated to 0.4.15.
- enabled python3 support.
- disabled mozjs as default.
- switched to webkitgtk4.

* Thu Jul 07 2016 Yoji TOYODA <bsyamato@sea.plala.or.jp> 0.4.11-2
- rebuild with gcc-5.4.0

* Tue Dec 31 2013 Yoji TOYODA <bsyamato@sea.plala.or.jp> 0.4.11-1
- update to 0.4.11
- remove Patch0 (libproxy-0.4.7-cmake-modules.patch)

* Thu Feb 16 2012 Yoji TOYODA <bsyamato@sea.plala.or.jp> 0.4.7-2
- rebuild with python-2.7.2

* Sun Aug 14 2011 Yoji TOYODA <bsyamato@sea.plala.or.jp> 0.4.7-1
- new upstream release
- change BuildRequires: WebKit3-gtk-devel instead of WebKit-gtk-devel
- change BuildRequires: js-devel instead of gecko-devel
- replace Patch0 (libproxy-0.4.7-cmake-modules.patch)
- detele -webkit sub package
- create -webkitgtk3 sub package

* Sun Oct 03 2010 Yoji TOYODA <bsyamato@sea.plala.or.jp> 0.4.6-1
- new upstream release
- drop Patch0
- add BuildRequires: cmake, kdelibs-devel
- fix %files (from %{_libdir}/%{name}/%{version}/plugins to %{_libdir}/%{name}/%{version}/modules)

* Sun Sep 26 2010 Yoji TOYODA <bsyamato@sea.plala.or.jp> 0.2.3-5
- rebuild with rpm-4.8.1 for pkg-config file

* Tue Feb 02 2010 Shu KONNO <owa@bg.wakwak.com> 0.2.3-4
- rebuild with python-2.6

* Tue Jun 30 2009 Daisuke SUZUKI <daisuke@linux.or.jp> 0.2.3-3
- rebuild with gecko-1.9.1

* Thu Mar 26 2009 Daisuke SUZUKI <daisuke@linux.or.jp> 0.2.3-2
- rebuild with WebKit-gtk-1.0.0-8.svn41944

* Sat Mar 21 2009 Daisuke SUZUKI <daisuke@linux.or.jp> 0.2.3-1
- initial build for Vine Linux

* Mon Mar  9 2009 kwizart < kwizart at gmail.com > - 0.2.3-10
- Rebuild for webkit
- Raise requirement for xulrunner to 1.9.1

* Wed Feb 25 2009 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 0.2.3-9
- Rebuilt for https://fedoraproject.org/wiki/Fedora_11_Mass_Rebuild

* Thu Jan 22 2009 kwizart < kwizart at gmail.com > - 0.2.3-8
- Merge NetworkManager module into the main libproxy package
- Main Requires the -python and -bin subpackage 
 (splitted for multilibs compliance).

* Fri Oct 24 2008 kwizart < kwizart at gmail.com > - 0.2.3-7
- Disable Gnome/KDE default support via builtin modules.
 (it needs to be integrated via Gconf2/neon instead).

* Tue Oct 21 2008 kwizart < kwizart at gmail.com > - 0.2.3-6
- Disable Obsoletes.
- Requires ev instead of evr for optionnals sub-packages.

* Tue Oct 21 2008 kwizart < kwizart at gmail.com > - 0.2.3-5
- Use conditionals build.

* Mon Sep 15 2008 kwizart < kwizart at gmail.com > - 0.2.3-4
- Remove plugin- in the name of the packages

* Mon Aug  4 2008 kwizart < kwizart at gmail.com > - 0.2.3-3
- Move proxy.h to libproxy/proxy.h
  This will prevent it to be included in the default include path
- Split main to libs and util and use libproxy to install all

* Mon Aug  4 2008 kwizart < kwizart at gmail.com > - 0.2.3-2
- Rename binding-python to python
- Add Requires: gecko-libs >= %%{gecko_version}
- Fix some descriptions
- Add plugin-webkit package
 
* Fri Jul 11 2008 kwizart < kwizart at gmail.com > - 0.2.3-1
- Convert to Fedora spec

* Fri Jun 6 2008 - dominique-rpm@leuenberger.net
- Updated to version 0.2.3
* Wed Jun 4 2008 - dominique-rpm@leuenberger.net
- Extended spec file to build all available plugins
* Tue Jun 3 2008 - dominique-rpm@leuenberger.net
- Initial spec file for Version 0.2.2

