%define glib2_version           2.40.0
%define dbus_version            1.6.14
%define dbus_glib_version       0.98
%define polkit_version          0.104
%define parted_version          2.3
%define mdadm_version           2.6.7
%define device_mapper_version   1.02
%define libatasmart_version     0.17
%define sg3_utils_version       1.27
%define smp_utils_version       0.94
%define lvm2_version            2.02.78
%global libblockdev_version     2.19

Summary: Storage Management Service
Name: udisks2
Version: 2.8.1
Release: 2%{?_dist_release}
License: GPLv2+
Group: System Environment/Libraries
URL: http://www.freedesktop.org/wiki/Software/udisks

Source0: http://udisks.freedesktop.org/releases/udisks-%{version}.tar.bz2

BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root

BuildRequires: glib2-devel >= %{glib2_version}
BuildRequires: gobject-introspection-devel
BuildRequires: eudev-libgudev1-devel
BuildRequires: eudev-libudev-devel
BuildRequires: dbus-devel  >= %{dbus_version}
BuildRequires: dbus-glib-devel >= %{dbus_glib_version}
BuildRequires: polkit-devel >= %{polkit_version}
BuildRequires: parted-devel >= %{parted_version}
BuildRequires: device-mapper-devel >= %{device_mapper_version}
BuildRequires: libacl-devel
BuildRequires: intltool
BuildRequires: libatasmart-devel >= %{libatasmart_version}
BuildRequires: sg3_utils-devel >= %{sg3_utils_version}
BuildRequires: lvm2-devel >= %{lvm2_version}
BuildRequires: elogind-devel
BuildRequires: gnome-common
BuildRequires: libmount-devel
BuildRequires: chrpath
BuildRequires: libblockdev-devel        >= %{libblockdev_version}
BuildRequires: libblockdev-crypto-devel >= %{libblockdev_version}
BuildRequires: libblockdev-dm-devel     >= %{libblockdev_version}
BuildRequires: libblockdev-fs-devel     >= %{libblockdev_version}
BuildRequires: libblockdev-kbd-devel    >= %{libblockdev_version}
BuildRequires: libblockdev-loop-devel   >= %{libblockdev_version}
BuildRequires: libblockdev-lvm-devel    >= %{libblockdev_version}
BuildRequires: libblockdev-mdraid-devel >= %{libblockdev_version}
BuildRequires: libblockdev-part-devel   >= %{libblockdev_version}
BuildRequires: libblockdev-swap-devel   >= %{libblockdev_version}
%if 0
BuildRequires: libblockdev-vdo-devel    >= %{libblockdev_version}
%endif

# needed to pull in the system bus daemon
Requires: dbus >= %{dbus_version}
# needed to pull in the udev daemon
Requires: eudev
# we need at least this version for bugfixes / features etc.
Requires: libatasmart >= %{libatasmart_version}
Requires: mdadm >= %{mdadm_version}
# for smp_rep_manufacturer
Requires: smp_utils >= %{smp_utils_version}
# for mount, umount, mkswap
Requires: util-linux-ng
# for mkfs.ext3, mkfs.ext3, e2label
Requires: e2fsprogs
# for mkfs.xfs, xfs_admin
Requires: xfsprogs
# for mkfs.vfat
Requires: dosfstools
# for mlabel
Requires: mtools
# for mkntfs - no ntfsprogs on ppc, though
%ifnarch ppc ppc64
Requires: ntfsprogs
%endif
Requires: gdisk

Requires: libblockdev        >= %{libblockdev_version}
Requires: libblockdev-part   >= %{libblockdev_version}
Requires: libblockdev-loop   >= %{libblockdev_version}
Requires: libblockdev-swap   >= %{libblockdev_version}
Requires: libblockdev-mdraid >= %{libblockdev_version}
Requires: libblockdev-fs     >= %{libblockdev_version}
Requires: libblockdev-crypto >= %{libblockdev_version}

# for /proc/self/mountinfo, only available in 2.6.26 or higher
Conflicts: kernel < 2.6.26

# we need liblvm2app at least this recent since the ABI changed (sizes
# reported in number of bytes instead of number of sectors) without
# the sonumber changing
#
Requires: lvm2-libs >= %{lvm2_version}

Vendor: Project Vine
Distribution: Vine Linux

%description
udisks provides a daemon, D-Bus API and command line tools
for managing disks and storage devices.


%package lvm2
Summary: udisks2 module for LVM2
Group: System Environment/Libraries
Requires: %{name}%{?_isa} = %{version}-%{release}
License: LGPLv2+
Requires: lvm2
Requires: libblockdev-lvm >= %{libblockdev_version}

%description lvm2
This package contains module for LVM2 configuration.


%package zram
Summary: udisks2 module for ZRAM
Group: System Environment/Libraries
Requires: %{name}%{?_isa} = %{version}-%{release}
License: LGPLv2+
Requires: libblockdev-kbd >= %{libblockdev_version}
Requires: libblockdev-swap >= %{libblockdev_version}

%description zram
This package contains module for ZRAM configuration.


%if 0
%package vdo
Summary: udisks2 module for VDO
Group: System Environment/Libraries
Requires: %{name}%{?_isa} = %{version}-%{release}
License: LGPLv2+
Requires: vdo
Requires: libblockdev-vdo >= %{libblockdev_version}

%description vdo
This package contains module for VDO management.
%endif


%package devel
Summary: D-Bus interface definitions for udisks
Group: Development/Libraries
Requires: %{name} = %{version}-%{release}

# See comment above
#
%description devel
D-Bus interface definitions and documentation for udisks.


%package        docs
Summary:        Documentation for udisks2
Group:          Documentation
Requires:       %{name} = %{version}-%{release}
BuildArch:		noarch
Provides:       %{name}-doc = %{version}-%{release}


%description    docs
This package contains documentation for udisks2.


%prep
%setup -q -n udisks-%{version}

%build
autoreconf -vif
%configure \
	--sbindir=%{_syssbindir} \
	--enable-lvm2 \
	--enable-lvmcache \
	--enable-zram \
	--enable-gtk-doc
make

%install
rm -rf $RPM_BUILD_ROOT

make install DESTDIR=$RPM_BUILD_ROOT

find %{buildroot} -name \*.la -o -name \*.a | xargs rm

chrpath --delete %{buildroot}/%{_syssbindir}/umount.udisks2
chrpath --delete %{buildroot}/%{_bindir}/udisksctl
chrpath --delete %{buildroot}/%{_libexecdir}/udisks2/udisksd

mkdir %{buildroot}/run

mkdir -p %{buildroot}/%{_sysconfdir}/udisks2/modules.conf.d

perl -pi \
	-e 's/modules_load_preference=ondemand/modules_load_preference=onstartup/' \
	%{buildroot}%{_sysconfdir}/udisks2/udisks2.conf

%find_lang %{name}

%clean
rm -rf $RPM_BUILD_ROOT

%post
/sbin/ldconfig
udevadm control --reload
udevadm trigger

%postun -p /sbin/ldconfig

%files -f %{name}.lang
%defattr(-,root,root,-)
%license COPYING
%doc README* AUTHORS NEWS HACKING NEWS
%config(noreplace) %{_sysconfdir}/udisks2/udisks2.conf
%{_sysconfdir}/dbus-1/system.d/org.freedesktop.UDisks2.conf
/lib/udev/rules.d/80-udisks2.rules
%{_bindir}/udisksctl
%{_syssbindir}/umount.udisks2
%{_libexecdir}/udisks2/udisksd
%{_libdir}/libudisks2.so.*
%{_libdir}/girepository-1.0/UDisks-2.0.typelib
%dir %{_libdir}/udisks2
%dir %{_libdir}/udisks2/modules
%dir %{_datadir}/bash-completion
%dir %{_datadir}/bash-completion/completions
%{_datadir}/bash-completion/completions/udisksctl
%{_datadir}/dbus-1/system-services/org.freedesktop.UDisks2.service
%{_datadir}/polkit-1/actions/org.freedesktop.UDisks2.policy
%{_mandir}/man1/*
%{_mandir}/man5/*
%{_mandir}/man8/*
%attr(0700,root,root) %dir %{_localstatedir}/lib/udisks2
%attr(0755,root,root) %dir /run

%files lvm2
%{_libdir}/udisks2/modules/libudisks2_lvm2.so
%{_datadir}/polkit-1/actions/org.freedesktop.UDisks2.lvm2.policy

%files zram
%dir %{_sysconfdir}/udisks2/modules.conf.d
%{_libdir}/udisks2/modules/libudisks2_zram.so
%{_datadir}/polkit-1/actions/org.freedesktop.UDisks2.zram.policy

%if 0
%files vdo
%{_libdir}/udisks2/modules/libudisks2_vdo.so
%{_datadir}/polkit-1/actions/org.freedesktop.UDisks2.vdo.policy
%endif

%files devel
%defattr(-,root,root,-)
%{_includedir}/udisks2
%{_libdir}/libudisks2.so
%{_libdir}/pkgconfig/udisks2.pc
%{_datadir}/gir-1.0/UDisks-2.0.gir

%files docs
%defattr(-,root,root,-)
%{_datadir}/gtk-doc/html/%{name}

#
%changelog
* Mon Jan 07 2019 Tomohiro "Tomo-p" KATO <tomop@teamgedoh.net> 2.8.1-2
- enabled lvm2, lvmcache and zram.

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

* Sun Apr 24 2016 Yoji TOYODA <bsyamato@sea.plala.or.jp> 2.1.7-1
- new upstream release

* Sun Jan 03 2016 Yoji TOYODA <bsyamato@sea.plala.or.jp> 2.1.6-2
- add Requires: gdisk

* Sun Aug 16 2015 Yoji TOYODA <bsyamato@sea.plala.or.jp> 2.1.6-1
- new upstream release

* Sun May 24 2015 Yoji TOYODA <bsyamato@sea.plala.or.jp> 2.1.5-2
- remove unused files
- change path of umount.udisks2

* Sun Apr 12 2015 Yoji TOYODA <bsyamato@sea.plala.or.jp> 2.1.5-1
- new upstream release

* Thu Dec 25 2014 Yoji TOYODA <bsyamato@sea.plala.or.jp> 2.1.4-1
- new upstream release

* Thu Jul 03 2014 Yoji TOYODA <bsyamato@sea.plala.or.jp> 2.1.3-3
- change BuildRequires: eudev-libgudev1-devel instead of libgudev1-devel
- change BuildRequires: eudev-libudev-devel instead of libudev-devel

* Sun Mar 30 2014 Yoji TOYODA <bsyamato@sea.plala.or.jp> 2.1.3-1
- new upstream release

* Sat Jan 04 2014 Yoji TOYODA <bsyamato@sea.plala.or.jp> 2.1.1-2
- rebuild with VineSeed environment

* Sat Oct 26 2013 Yoji TOYODA <bsyamato@sea.plala.or.jp> 2.1.1-1
- new upstream release

* Thu Mar 21 2013 Yoji TOYODA <bsyamato@sea.plala.or.jp> 2.1.0-1
- new upstream release

* Thu Jan 03 2013 Yoji TOYODA <bsyamato@sea.plala.or.jp> 2.0.1-1
- new upstream release

* Tue Oct 16 2012 Yoji TOYODA <bsyamato@sea.plala.or.jp> 2.0.0-1
- new upstream release

* Sat Sep 29 2012 Yoji TOYODA <bsyamato@sea.plala.or.jp> 1.99.0-1
- new upstream release

* Sun Jun 10 2012 Yoji TOYODA <bsyamato@sea.plala.or.jp> 1.98.0-1
- new upstream release
- add BuildRequires: libacl-devel

* Sun Apr 15 2012 Yoji TOYODA <bsyamato@sea.plala.or.jp> 1.94.0-1
- Initial build for Vine Linux

