%define major_version 2
%define minor_version 4
-Name: optee-client
-Summary: Library for applications which use OPTEE functions.
-Version: %{major_version}.%{minor_version}
+Name: tef-optee
+Summary: TEF TrustZone OpTEE backend
+Version: %{major_version}.%{minor_version}.0
Release: 1%{?dist}
Group: Security/Testing
License: BSD-2-Clause
URL: N/A
Source0: %{name}-%{version}.tar.gz
-Provides: libteec
+Source1: %{name}.manifest
+ExclusiveArch: armv6l armv7hl armv7l aarch64
+Provides: %{name}
BuildRequires: make
+BuildRequires: cmake
+
+%{?systemd_requires}
+
+%define bin_dir %{?TZ_SYS_BIN:%TZ_SYS_BIN}%{!?TZ_SYS_BIN:%_bindir}
+%define udev_dir %_libdir/udev/rules.d/
+%define build_udev_dir %{buildroot}/%{udev_dir}
+%define build_unit_dir %{buildroot}%{_unitdir}
+
+%define smack_domain_name System
+
+%define compile_param CROSS_COMPILE="" MAJOR_VERSION="%{major_version}" MINOR_VERSION="%{minor_version}"
%description
-Library for applications which use OPTEE functions.
+TEF Trustzone OpTEE provides daemon to support OpTEE OS solution.
+
+%package -n %{name}-client
+Summary: TEF TrustZone OpTEE Client contains a libteec library.
+Group: Security/Libraries
+License: BSD-2-Clause
+Provides: %{name}-client
+
+BuildRequires: make
+
+%description -n %{name}-client
+TEF TrustZone OpTEE Client contains a libteec library, which is tef-libteec backend.
%prep
%setup -q
+cp -a %{SOURCE1} .
%build
-make build CROSS_COMPILE="" MAJOR_VERSION=%{major_version} MINOR_VERSION=%{minor_version}
+export TEE_FS_SUBPATH="/opt/data" TEE_FS_PATH="/opt/data/tee"
+make %{compile_param} build
+
+cd systemd
+cmake . \
+ -DUDEV_RULES_DIR=%{build_udev_dir} \
+ -DSYSTEMD_UNIT_DIR=%{build_unit_dir} \
+ -DSYSTEMD_CFG_BIN_DIR=%{bin_dir} \
+ -DSMACK_DOMAIN_NAME=%{smack_domain_name}
+cd -
%install
-make CROSS_COMPILE="" MAJOR_VERSION=%{major_version} MINOR_VERSION=%{minor_version} DESTDIR=%{buildroot}/%{_prefix} install
+make %{compile_param} DESTDIR=%{buildroot}/%{_prefix}/ LIBDIR=%{_lib}/tef/optee install
-if [ "%{_libdir}" == "%{_exec_prefix}/lib64" ]
-then
- mkdir -p %{buildroot}/%{_libdir}
- cp -f %{buildroot}/usr/lib/libteec.so* %{buildroot}/%{_libdir}/
- rm -rf %{buildroot}/usr/lib
-fi
+rm -rf %{buildroot}/%{_includedir}
+cd systemd
+make install
+cd -
+
+%post
+./usr/sbin/tef-update.sh optee
-rm -rf %{buildroot}%{_libdir}/debug
+%postun
+./usr/sbin/tef-update.sh
%files
-%defattr(-, root, root, -)
+%license LICENSE
%{_bindir}/tee-supplicant
-%{_libdir}/libteec.so*
-%{_includedir}/tee_client_api.h
-%{_includedir}/tee_client_api_extensions.h
-%{_includedir}/teec_trace.h
-
-%post
-ln -sf %{_libdir}/libteec.so.%{version} %{_libdir}/libteec.so.%{major_version}
-ln -sf %{_libdir}/libteec.so.%{major_version} %{_libdir}/libteec.so
+%{_unitdir}/tef-optee.service
+%{udev_dir}/90-teedaemon.rules
-/sbin/ldconfig
+%files -n %{name}-client
+%license LICENSE
+%defattr(-, root, root, -)
+%{_libdir}/tef/optee/libteec.so*
%changelog
--- /dev/null
+# Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+# @file
+# @author Lukasz Kostyra (l.kostyra@samsung.com)
+# @author Rafal Tyminski (r.tyminski@partner.samsung.com)
+# @brief CMakeLists for systemd configuration files
+#
+
+CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
+PROJECT("tef-optee")
+
+CONFIGURE_FILE(${CMAKE_SOURCE_DIR}/tef-optee.service.in
+ ${CMAKE_SOURCE_DIR}/tef-optee.service @ONLY)
+
+INSTALL(FILES
+ ${CMAKE_SOURCE_DIR}/tef-optee.service
+ DESTINATION
+ ${SYSTEMD_UNIT_DIR}
+)
+
+INSTALL(FILES
+ ${CMAKE_SOURCE_DIR}/90-teedaemon.rules
+ DESTINATION
+ ${UDEV_RULES_DIR}
+)
+