%global libglib2_version 2.45.8
%global libappstream_version 0.5.10
%global libgusb_version 0.2.9
%global libsoup_version 2.51.92

%define alphatag                #ALPHATAG#

%ifarch x86_64 %{ix86}
%global have_smbios 1
%endif

# FIXME: should also be aarch64, but efivar not present there yet
%ifarch x86_64 %{ix86}
%global have_uefi 1
%endif

Summary:   Firmware update daemon
Name:      fwupd
Version:   #VERSION#
Release:   0.#BUILD#%{?alphatag}%{?dist}
License:   GPLv2+
URL:       https://github.com/hughsie/fwupd
Source0:   http://people.freedesktop.org/~hughsient/releases/%{name}-%{version}.tar.xz

BuildRequires: docbook-utils
BuildRequires: gettext
BuildRequires: glib2-devel >= %{glib2_version}
BuildRequires: intltool
BuildRequires: libappstream-glib-devel >= %{libappstream_version}
BuildRequires: libgudev1-devel
BuildRequires: libgusb-devel >= %{libgusb_version}
BuildRequires: libsoup-devel >= %{libsoup_version}
BuildRequires: colord-devel >= 1.0.0
BuildRequires: polkit-devel >= 0.103
BuildRequires: libgcab1-devel
BuildRequires: sqlite-devel
BuildRequires: gpgme-devel
BuildRequires: systemd
BuildRequires: libarchive-devel
BuildRequires: gobject-introspection-devel
BuildRequires: gcab
BuildRequires: valgrind
BuildRequires: valgrind-devel
BuildRequires: elfutils-libelf-devel
BuildRequires: gtk-doc

%if 0%{?have_smbios}
BuildRequires: libsmbios-devel >= 2.3.0
%endif

%if 0%{?have_uefi}
BuildRequires: fwupdate-devel >= 7
%endif

Requires(post): systemd
Requires(preun): systemd
Requires(postun): systemd

Requires: libdfu%{?_isa} = %{version}-%{release}
Requires: glib2%{?_isa} >= %{glib2_version}
Requires: libappstream-glib%{?_isa} >= %{libappstream_version}
Requires: libgusb%{?_isa} >= %{libgusb_version}
Requires: libsoup%{?_isa} >= %{libsoup_version}

Obsoletes: fwupd-sign < 0.1.6
Obsoletes: libebitdo < 0.7.5-3

%description
fwupd is a daemon to allow session software to update device firmware.

%package devel
Summary: Development package for %{name}
Requires: %{name}%{?_isa} = %{version}-%{release}
Obsoletes: libebitdo-devel < 0.7.5-3

%description devel
Files for development with %{name}.

%package -n libdfu
Summary: A library for DFU

%description -n libdfu
A library for updating USB devices using DFU.

%package -n libdfu-devel
Summary: Development package for libdfu
Requires: libdfu%{?_isa} = %{version}-%{release}

%description -n libdfu-devel
Files for development with libdfu.

%prep
%setup -q

%build
%configure \
        --disable-static        \
        --disable-thunderbolt   \
        --enable-gtk-doc        \
        --enable-colorhug       \
%if 0%{?have_uefi}
        --enable-uefi           \
%else
        --disable-uefi          \
%endif
%if 0%{?have_smbios}
        --enable-dell           \
        --enable-synaptics      \
%else
        --disable-dell          \
        --disable-synaptics     \
%endif
        --disable-rpath         \
        --disable-silent-rules  \
        --disable-dependency-tracking

make %{?_smp_mflags}

%install
make install DESTDIR=$RPM_BUILD_ROOT
find %{buildroot} -name '*.la' -exec rm -f {} ';'
mkdir --mode=0700 $RPM_BUILD_ROOT%{_localstatedir}/lib/fwupd/gnupg

%find_lang %{name}

%check
make check VERBOSE=1

%post
/sbin/ldconfig
%systemd_post fwupd.service

%preun
%systemd_preun fwupd.service

%postun
/sbin/ldconfig
%systemd_postun_with_restart fwupd.service

%post -n libdfu -p /sbin/ldconfig
%postun -n libdfu -p /sbin/ldconfig

%files -f %{name}.lang
%doc README.md AUTHORS NEWS
%license COPYING
%config(noreplace)%{_sysconfdir}/fwupd.conf
%dir %{_libexecdir}/fwupd
%{_libexecdir}/fwupd/fwupd
%{_bindir}/fwupdmgr
%{_sysconfdir}/pki/fwupd
%{_sysconfdir}/pki/fwupd-metadata
%{_sysconfdir}/dbus-1/system.d/org.freedesktop.fwupd.conf
%{_datadir}/app-info/xmls/org.freedesktop.fwupd.xml
%{_datadir}/dbus-1/interfaces/org.freedesktop.fwupd.xml
%{_datadir}/polkit-1/actions/org.freedesktop.fwupd.policy
%{_datadir}/polkit-1/rules.d/org.freedesktop.fwupd.rules
%{_datadir}/dbus-1/system-services/org.freedesktop.fwupd.service
%{_datadir}/man/man1/fwupdmgr.1.gz
%{_unitdir}/fwupd-offline-update.service
%{_unitdir}/fwupd.service
%{_unitdir}/system-update.target.wants/
%dir %{_localstatedir}/lib/fwupd
%{_libdir}/libfwupd*.so.*
%{_libdir}/girepository-1.0/Fwupd-1.0.typelib
/usr/lib/udev/rules.d/*.rules
%dir %{_libdir}/fwupd-plugins-2
%{_libdir}/fwupd-plugins-2/libfu_plugin_altos.so
%{_libdir}/fwupd-plugins-2/libfu_plugin_colorhug.so
%if 0%{?have_smbios}
%{_libdir}/fwupd-plugins-2/libfu_plugin_dell.so
%endif
%{_libdir}/fwupd-plugins-2/libfu_plugin_dfu.so
%{_libdir}/fwupd-plugins-2/libfu_plugin_ebitdo.so
%{_libdir}/fwupd-plugins-2/libfu_plugin_raspberrypi.so
%{_libdir}/fwupd-plugins-2/libfu_plugin_steelseries.so
%if 0%{?have_smbios}
%{_libdir}/fwupd-plugins-2/libfu_plugin_synapticsmst.so
%endif
%{_libdir}/fwupd-plugins-2/libfu_plugin_test.so
%{_libdir}/fwupd-plugins-2/libfu_plugin_udev.so
%if 0%{?have_uefi}
%{_libdir}/fwupd-plugins-2/libfu_plugin_uefi.so
%endif
%{_libdir}/fwupd-plugins-2/libfu_plugin_unifying.so
%{_libdir}/fwupd-plugins-2/libfu_plugin_upower.so
%{_libdir}/fwupd-plugins-2/libfu_plugin_usb.so
%ghost %{_localstatedir}/lib/fwupd/gnupg

%files devel
%{_datadir}/gir-1.0/Fwupd-1.0.gir
%{_datadir}/gtk-doc/html/libfwupd
%{_includedir}/fwupd-1
%{_libdir}/libfwupd*.so
%{_libdir}/pkgconfig/fwupd.pc

%files -n libdfu
%{_bindir}/dfu-tool
%{_datadir}/man/man1/dfu-tool.1.gz
%{_libdir}/girepository-1.0/Dfu-1.0.typelib
%{_libdir}/libdfu*.so.*

%files -n libdfu-devel
%{_datadir}/gir-1.0/Dfu-1.0.gir
%{_datadir}/gtk-doc/html/libdfu
%dir %{_includedir}/libdfu
%{_includedir}/dfu.h
%{_includedir}/libdfu/*.h
%{_libdir}/libdfu*.so
%{_libdir}/pkgconfig/dfu.pc

%changelog
* #LONGDATE# Richard Hughes <richard@hughsie.com> #VERSION#-0.#BUILD##ALPHATAG#
- Update from git

