File optee-imx-mx6qsabrelite.spec of Package optee-os

#
# spec file for package optee-imx-mx6qsabrelite
#
# Copyright (c) 2020 SUSE LLC
#
# 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 https://bugs.opensuse.org/
#


%define platform imx-mx6qsabrelite
%if "%{platform}" == "qemu-armv7a" || "%{platform}" == "imx-mx6qsabrelite"
%define is_32bit 1
%else
%define is_32bit 0
%endif
%define srcversion 3.11.0
Name:           optee-%{platform}
Version:        3.11.0
Release:        0
Summary:        Trusted Execution Environment
License:        BSD-2-Clause AND BSD-3-Clause
Group:          System/Boot
URL:            https://github.com/OP-TEE/optee_os
Source:         https://github.com/OP-TEE/optee_os/archive/%{srcversion}.tar.gz#/optee_os-%{srcversion}.tar.gz
BuildRequires:  fdupes
BuildRequires:  python3
BuildRequires:  python3-pycrypto
BuildRequires:  python3-pycryptodomex
BuildRequires:  python3-pyelftools
#!BuildIgnore:  gcc-PIE
%if ! %{is_32bit}
BuildRequires:  cross-arm-none-gcc%{gcc_version}
%endif
%if %{is_32bit}
ExclusiveArch:  armv7hl
%else
ExclusiveArch:  aarch64
%endif

%description
A Trusted Execution Environment (TEE) as companion to a non-secure OS
on Arm Cortex-A cores using the TrustZone technology.
For a general overview of OP-TEE, please see the Notice.md file.

%package devel
Summary:        Trusted Execution Environment -- development files
# No Requires needed, since this is about firmware
Group:          Development/Sources

%description devel
A Trusted Execution Environment (TEE) as companion to a non-secure OS
on Arm Cortex-A cores using the TrustZone technology.
For a general overview of OP-TEE, please see the Notice.md file.

This sub-package contains development files.

%if ! %{is_32bit}
%package devel-32bit
Summary:        Trusted Execution Environment -- development files
# No Requires needed, since this is about firmware
Group:          Development/Sources

%description devel-32bit
A Trusted Execution Environment (TEE) as companion to a non-secure OS
on Arm Cortex-A cores using the TrustZone technology.
For a general overview of OP-TEE, please see the Notice.md file.

This sub-package contains 32-bit development files.
%endif

%prep
%setup -q -n optee_os-%{srcversion}

%build
make %{?_smp_mflags} V=1 O=out NOWERROR=1 \
%if %{is_32bit}
     ARCH=arm \
     CROSS_COMPILE= \
%else
     ARCH=arm CFG_ARM64_core=y \
     CROSS_COMPILE32=arm-none-eabi- \
     CROSS_COMPILE64= \
%endif
%if "%{platform}" == "qemu-armv7a" || "%{platform}" == "qemu-armv8a"
     PLATFORM=vexpress \
%if "%{platform}" == "qemu-armv8a"
     PLATFORM_FLAVOR=qemu_armv8a \
%else
     PLATFORM_FLAVOR=qemu_virt \
%endif
%else
%if "%{platform}" == "hikey" || "%{platform}" == "hikey960"
     PLATFORM=hikey \
%if "%{platform}" == "hikey960"
     PLATFORM_FLAVOR=hikey960 \
%else
     PLATFORM_FLAVOR=hikey \
%endif
%else
%if "%{platform}" == "armada3700" || "%{platform}" == "armada7k8k"
     PLATFORM=marvell \
%if "%{platform}" == "armada3700"
     PLATFORM_FLAVOR=armada3700 \
%else
     PLATFORM_FLAVOR=armada7k8k \
%endif
%else
     PLATFORM=%{platform} \
%endif # marvell
%endif # hikey
%endif # qemu
     all

%install
export NO_BRP_STRIP_DEBUG=true
export NO_DEBUGINFO_STRIP_DEBUG=true
install -D -m 0644 out/core/tee-header_v2.bin %{buildroot}/boot/tee-header_v2.bin
install -D -m 0644 out/core/tee-pager_v2.bin %{buildroot}/boot/tee-pager_v2.bin
install -D -m 0644 out/core/tee-pageable_v2.bin %{buildroot}/boot/tee-pageable_v2.bin
%fdupes %{buildroot}/boot

for f in out/export-ta_arm*/scripts/*.py; do
  sed -i 's|^#!%{_bindir}/env python|#!%{_bindir}/python|' $f
done
mkdir -p %{buildroot}%{_usrsrc}/optee
cp -a -Rf out/export-ta_arm32 %{buildroot}%{_usrsrc}/optee/ta_arm32
%fdupes %{buildroot}%{_usrsrc}/optee/ta_arm32
%if ! %{is_32bit}
cp -a -Rf out/export-ta_arm64 %{buildroot}%{_usrsrc}/optee/ta_arm64
%fdupes %{buildroot}%{_usrsrc}/optee/ta_arm64
%endif

%files
%defattr(-,root,root)
%license LICENSE
%doc CHANGELOG.md MAINTAINERS README.md
/boot/tee-header_v2.bin
/boot/tee-pager_v2.bin
/boot/tee-pageable_v2.bin

%files devel
%defattr(-,root,root)
%dir %{_usrsrc}/optee/
%if %{is_32bit}
%{_usrsrc}/optee/ta_arm32/
%else
%{_usrsrc}/optee/ta_arm64/
%endif

%if ! %{is_32bit}
%files devel-32bit
%defattr(-,root,root)
%dir %{_usrsrc}/optee/
%{_usrsrc}/optee/ta_arm32/
%endif

%changelog
openSUSE Build Service is sponsored by