From 76f499de19ccf60fe236e6b8fff721ec7f377844 Mon Sep 17 00:00:00 2001 From: "r.tyminski" Date: Thu, 29 Jun 2017 11:34:29 +0200 Subject: [PATCH] Packaging changes. Adding manifest. Setting root of tee fs to /opt. Little spec cleanup. Adding udev and service configuration. Change-Id: Ife48795a84a2033404a0b76f74c151ce82303820 --- packaging/optee-client.spec | 82 +++++++++++++++++++++++++----------- packaging/tef-optee.manifest | 5 +++ systemd/90-teedaemon.rules | 1 + systemd/CMakeLists.txt | 38 +++++++++++++++++ systemd/tef-optee.service.in | 12 ++++++ tee-supplicant/Makefile | 7 ++- 6 files changed, 119 insertions(+), 26 deletions(-) create mode 100644 packaging/tef-optee.manifest create mode 100644 systemd/90-teedaemon.rules create mode 100644 systemd/CMakeLists.txt create mode 100644 systemd/tef-optee.service.in diff --git a/packaging/optee-client.spec b/packaging/optee-client.spec index 3b31ee9..ebc62d7 100644 --- a/packaging/optee-client.spec +++ b/packaging/optee-client.spec @@ -1,51 +1,85 @@ %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 diff --git a/packaging/tef-optee.manifest b/packaging/tef-optee.manifest new file mode 100644 index 0000000..86dbb26 --- /dev/null +++ b/packaging/tef-optee.manifest @@ -0,0 +1,5 @@ + + + + + diff --git a/systemd/90-teedaemon.rules b/systemd/90-teedaemon.rules new file mode 100644 index 0000000..6cf5550 --- /dev/null +++ b/systemd/90-teedaemon.rules @@ -0,0 +1 @@ +SUBSYSTEM=="tee", KERNEL=="teepriv*", TAG+="systemd", ENV{SYSTEMD_WANTS}+="tef-optee.service" diff --git a/systemd/CMakeLists.txt b/systemd/CMakeLists.txt new file mode 100644 index 0000000..f65e2c1 --- /dev/null +++ b/systemd/CMakeLists.txt @@ -0,0 +1,38 @@ +# 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} +) + diff --git a/systemd/tef-optee.service.in b/systemd/tef-optee.service.in new file mode 100644 index 0000000..5b7498a --- /dev/null +++ b/systemd/tef-optee.service.in @@ -0,0 +1,12 @@ +[Unit] +Description=TEF OpTEE Daemon +DefaultDependencies=no +After=opt.mount + + +[Service] +User=root +Group=root +SmackProcessLabel=@SMACK_DOMAIN_NAME@ +ExecStart=@SYSTEMD_CFG_BIN_DIR@/tee-supplicant +RuntimeDirectory=@SERVICE_NAME@ diff --git a/tee-supplicant/Makefile b/tee-supplicant/Makefile index 808d90c..2ff37d7 100644 --- a/tee-supplicant/Makefile +++ b/tee-supplicant/Makefile @@ -18,7 +18,8 @@ TEES_SRCS := tee_supplicant.c \ teec_ta_load.c \ tee_supp_fs.c \ rpmb.c \ - handle.c + handle.c \ + ../../libteec/src/teec_trace.c ifeq ($(CFG_GP_SOCKETS),y) @@ -58,7 +59,9 @@ ifeq ($(CFG_TA_TEST_PATH),y) TEES_CFLAGS += -DCFG_TA_TEST_PATH=1 endif TEES_FILE := $(OUT_DIR)/$(PACKAGE_NAME) -TEES_LDFLAGS := -L$(OUT_DIR)/../libteec -lteec +# tee-supplicant needed OpTEE libteec to use libteec debugs +# Now we compile debugs source with tee-supplicant +#TEES_LDFLAGS := -L$(OUT_DIR)/../libteec -lteec ifeq ($(CFG_SQL_FS),y) TEES_CFLAGS += -DCFG_SQL_FS -- 2.34.1