#
# Conditonal build:
-%bcond_without initrd # don't build initrd version
+%bcond_without initrd # don't build initrd version
+%bcond_without dietlibc # build initrd version with static glibc instead of dietlibc
#
%define realname cryptsetup
Summary: LUKS for dm-crypt implemented in cryptsetup
Summary(pl.UTF-8): LUKS dla dm-crypta zaimplementowany w cryptsetup
Name: cryptsetup-luks
Version: 1.0.6
-Release: 4
+Release: 9
License: GPL v2
Group: Base
Source0: http://luks.endorphin.org/source/%{realname}-%{version}.tar.bz2
# Source0-md5: 00d452eb7a76e39f5749545d48934a10
+Source1: %{name}-initramfs-root-conf
+Source2: %{name}-initramfs-root-hook
+Source3: %{name}-initramfs-root-local-top
+Source4: %{name}-initramfs-passdev-hook
+Source5: %{name}-initramfs-README
Patch1: %{name}-nostatic.patch
+Patch2: %{name}-udev.patch
+Patch3: %{name}-diet.patch
URL: http://luks.endorphin.org/
BuildRequires: autoconf
BuildRequires: automake
BuildRequires: libuuid-devel
BuildRequires: popt-devel
%if %{with initrd}
+BuildRequires: libgpg-error-static
+ %if %{with dietlibc}
+BuildRequires: device-mapper-dietlibc
+BuildRequires: libgcrypt-dietlibc
+BuildRequires: libuuid-dietlibc
+BuildRequires: popt-dietlibc
+ %else
BuildRequires: device-mapper-static >= 1.02.07
BuildRequires: libgcrypt-static >= 1.1.42
-BuildRequires: libgpg-error-static
BuildRequires: libselinux-static
BuildRequires: libsepol-static
BuildRequires: libuuid-static
BuildRequires: popt-static
+ %endif
%endif
Provides: cryptsetup = %{version}
Obsoletes: cryptsetup
+Conflicts: udev < 1:118-1
+Conflicts: udev-core < 1:115
BuildRoot: %{tmpdir}/%{name}-%{version}-root-%(id -u -n)
%define _sbindir /sbin
%package initrd
Summary: LUKS for dm-crypt implemented in cryptsetup - initrd version
Group: Base
+Requires: udev-initrd >= 1:115
+Conflicts: geninitrd <= 10000.3
%description initrd
This package contains implementation of LUKS for dm-crypt implemented
in cryptsetup - staticaly linked for initrd.
+%package initramfs
+Summary: LUKS for dm-crypt implemented in cryptsetup - support scripts for initramfs-tools
+Summary(pl.UTF-8): LUKS dla dm-crypta zaimplementowany w cryptsetup - skrypty dla initramfs-tools
+Group: Base
+Requires: %{name} = %{version}-%{release}
+Requires: initramfs-tools
+
+%description initramfs
+LUKS for dm-crypt implemented in cryptsetup - support scripts
+for initramfs-tools.
+
+%description initramfs -l pl.UTF-8
+LUKS dla dm-crypta zaimplementowany w cryptsetup - skrypty dla
+initramfs-tools.
+
%prep
%setup -q -n %{realname}-%{version}
%patch1 -p1
+%patch2 -p1
+%patch3 -p1
+
+install %{SOURCE5} README.initramfs
%build
%{__gettextize}
%if %{with initrd}
%configure \
+%if %{with dietlibc}
+ CC="diet %{__cc} -Os %{rpmldflags}" \
+ ac_cv_lib_popt_poptConfigFileToString=yes \
+ ac_cv_lib_sepol_sepol_bool_set=no \
+ ac_cv_lib_selinux_is_selinux_enabled=no \
+%endif
--disable-shared-library \
--enable-static \
--enable-static-cryptsetup \
--disable-nls
-%{__make}
+
+%{__make} -C luks
+%{__make} -C lib
+
+%if %{with dietlibc}
+# we have to do it by hand cause libtool "know better" and forces
+# static libs from /usr/lib
+diet %{__cc} -Os -I./lib -static -o cryptsetup-initrd src/cryptsetup.c \
+ ./lib/.libs/libcryptsetup.a -lpopt -lgcrypt -lgpg-error -ldevmapper -luuid -lcompat
+%else
+%{__make} -C src
mv src/cryptsetup cryptsetup-initrd
+%endif
+
%{__make} clean
%endif
%install
rm -rf $RPM_BUILD_ROOT
+install -d $RPM_BUILD_ROOT%{_datadir}/initramfs-tools/{conf-hooks.d,hooks,scripts/local-top}
%{__make} install \
DESTDIR=$RPM_BUILD_ROOT
$RPM_BUILD_ROOT%{_libdir}/libcryptsetup.so
%if %{with initrd}
-install cryptsetup-initrd $RPM_BUILD_ROOT%{_sbindir}
+install -d $RPM_BUILD_ROOT%{_libdir}/initrd
+install cryptsetup-initrd $RPM_BUILD_ROOT%{_libdir}/initrd/cryptsetup
%endif
+install %{SOURCE1} $RPM_BUILD_ROOT%{_datadir}/initramfs-tools/conf-hooks.d/cryptsetup
+install %{SOURCE2} $RPM_BUILD_ROOT%{_datadir}/initramfs-tools/hooks/cryptroot
+install %{SOURCE3} $RPM_BUILD_ROOT%{_datadir}/initramfs-tools/scripts/local-top/cryptroot
+install %{SOURCE4} $RPM_BUILD_ROOT%{_datadir}/initramfs-tools/hooks/cryptpassdev
+
%find_lang %{realname}
%clean
%if %{with initrd}
%files initrd
%defattr(644,root,root,755)
-%attr(755,root,root) %{_sbindir}/cryptsetup-initrd
+%attr(755,root,root) %{_libdir}/initrd/cryptsetup
%endif
+
+%files initramfs
+%defattr(644,root,root,755)
+%doc README.initramfs
+%attr(755,root,root) %{_datadir}/initramfs-tools/conf-hooks.d/cryptsetup
+%attr(755,root,root) %{_datadir}/initramfs-tools/hooks/cryptroot
+%attr(755,root,root) %{_datadir}/initramfs-tools/hooks/cryptpassdev
+%attr(755,root,root) %{_datadir}/initramfs-tools/scripts/local-top/cryptroot