File tpm_emulator.spec of Package tpm_emulator
#
# spec file for package tpm_emulator
#
# Copyright (c) 2018 SUSE LINUX GmbH, Nuernberg, Germany.
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.
# Please submit bugfixes or comments via http://bugs.opensuse.org/
#
%define soname 1_2
%define pkg_soname 1.2
%if !0%{?kernel_source:1}
%global kernel_source() %{_prefix}/src/linux-obj/%{_target_cpu}/%%{1}
%endif
%if 0%{?suse_version} == 1110
%define _udevrulesdir /lib/udev/rules.d
%endif
Name: tpm_emulator
Version: 0.7.5
Release: 0
Summary: Software based Trusted Platform Module Emulator
License: GPL-2.0+
Group: Productivity/Security
#https://developer.berlios.de/projects/tpm-emulator is dead
Url: https://github.com/PeterHuewe/tpm-emulator
Source: https://github.com/PeterHuewe/tpm-emulator/archive/v%{version}.tar.gz#/%{name}-%{version}.tar.gz
Source1: tpm_emulator_preamble
# PATCH-FIX-UPSTREAM tpm_emulator-0.7.5-fix_strncpy_bound.patch
Patch5: tpm_emulator-0.7.5-fix_strncpy_bound.patch
BuildRequires: cmake
%if 0%{?suse_version} == 1110
BuildRequires: gcc48
BuildRequires: gcc48-c++
%else
BuildRequires: gcc
BuildRequires: gcc-c++
%endif
BuildRequires: glibc-devel
BuildRequires: gmp-devel
BuildRequires: make
BuildRequires: udev
ExclusiveArch: %ix86 x86_64
BuildRoot: %{_tmppath}/%{name}-%{version}-build
%if 0%{?suse_version} >= 1120
BuildRequires: %{kernel_module_package_buildreqs}
%else
BuildRequires: kernel-syms
BuildRequires: module-init-tools
%endif
%description
The goal of this project is the implementation of a software-based TPM emulator
for Linux as well as of an appropriate TCG Device Driver Library (TDDL) to give
people the means to easily explore TPMs for educational and experimental
purposes.
%package -n tpmd
Summary: Software based Trusted Platform Module Emulator Daemon
Group: Productivity/Security
%description -n tpmd
The goal of this project is the implementation of a software-based TPM emulator
for Linux as well as of an appropriate TCG Device Driver Library (TDDL) to give
people the means to easily explore TPMs for educational and experimental
purposes.
%package -n libtddl-tpm-emulator%{soname}
Summary: Software based Trusted Platform Module Emulator Library
Group: System/Libraries
%description -n libtddl-tpm-emulator%{soname}
The goal of this project is the implementation of a software-based TPM emulator
for Linux as well as of an appropriate TCG Device Driver Library (TDDL) to give
people the means to easily explore TPMs for educational and experimental
purposes.
%package -n libtddl-tpm-emulator-devel
Summary: Software based Trusted Platform Module Emulator Library
Group: Development/Libraries/C and C++
Requires: gmp-devel
Requires: libtddl-tpm-emulator%{soname} = %{version}-%{release}
%description -n libtddl-tpm-emulator-devel
The goal of this project is the implementation of a software-based TPM emulator
for Linux as well as of an appropriate TCG Device Driver Library (TDDL) to give
people the means to easily explore TPMs for educational and experimental
purposes.
%kernel_module_package -n tpmd_dev -p %{_sourcedir}/tpm_emulator_preamble
%prep
%setup -q -n tpm-emulator-%{version}
%patch5 -p1
%build
export SUSE_ASNEEDED=0
export CFLAGS="%{optflags}"
export CXXFLAGS="%{optflags}"
%if 0%{?suse_version} == 1110
export CC="gcc-4.8"
export CXX="g++-4.8"
%endif
mkdir build
pushd build
cmake ../ \
-DCMAKE_INSTALL_PREFIX="%{_prefix}" \
-DCMAKE_INSTALL_BINDIR="%{_sbindir}" \
-DBUILD_DEV=OFF -DMTM_EMULATOR=ON
make %{?_smp_mflags}
popd
mkdir obj
for flavor in %{flavors_to_build}; do
rm -rf "obj/$flavor"
cp -r tpmd_dev "obj/$flavor"
cp build/config.h "obj/$flavor/linux"
make -C %{kernel_source $flavor} modules M="$PWD/obj/$flavor/linux"
done
%install
pushd build
make %{?_smp_mflags} DESTDIR=%{buildroot} install
popd
export INSTALL_MOD_PATH=%{buildroot}
export INSTALL_MOD_DIR=updates
for flavor in %{flavors_to_build}; do
make -C %{kernel_source $flavor} modules_install "M=$PWD/obj/$flavor/linux"
done
mkdir -p %{buildroot}%{_udevrulesdir}
echo 'KERNEL=="tpm", NAME="tpmd_dev", SYMLINK+="tpm0", GROUP="tpmd", MODE="0660' > \
%{buildroot}%{_udevrulesdir}/80-tpmd_dev.rules
rm %{buildroot}%{_libdir}/libtddl-tpm-emulator.a
%post -n libtddl-tpm-emulator%{soname} -p /sbin/ldconfig
%postun -n libtddl-tpm-emulator%{soname} -p /sbin/ldconfig
%pre -n tpmd
%{_sbindir}/groupadd -r tpmd >/dev/null 2>&1 || :
%{_sbindir}/useradd -c "tpmd daemon user" -d "%{_localstatedir}/lib/tpm" -g tpmd -r tpmd >/dev/null 2>&1 || :
install -m 700 -o tpmd -g tpmd -d %{_localstatedir}/lib/tpm >/dev/null 2>&1 || :
install -m 755 -o tpmd -g tpmd -d %{_localstatedir}/run/tpm >/dev/null 2>&1 || :
%files -n tpmd
%defattr(-,root,root)
%doc AUTHORS ChangeLog README LICENSE
%{_sbindir}/tpmd
%{_udevrulesdir}/80-tpmd_dev.rules
%files -n libtddl-tpm-emulator%{soname}
%defattr(-,root,root)
%{_libdir}/libtddl-tpm-emulator.so.%{pkg_soname}
%{_libdir}/libtddl-tpm-emulator.so.%{pkg_soname}.*
%files -n libtddl-tpm-emulator-devel
%defattr(-,root,root)
%{_includedir}/tddl-tpm-emulator.h
%{_libdir}/libtddl-tpm-emulator.so
%changelog