File odroidc2-firmware.spec of Package odroidc2-firmware

#
# spec file for package odroidc2-firmware
#
# Copyright (c) 2017 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/
#


Name:           odroidc2-firmware
Version:        20170419
Release:        0
Summary:        Firmware for ODROID-C2 board
License:        GPL-2.0 AND GPL-3.0 AND SUSE-Firmware
Group:          System/Boot
Source0:        https://github.com/hardkernel/u-boot/archive/odroidc2-v2015.01.tar.gz#/u-boot-odroidc2-v2015.01.tar.gz
Source1:        https://github.com/hardkernel/u-boot_firmware/archive/odroidc2-bl301.tar.gz#/u-boot_firmware-odroidc2-bl301.tar.gz
Source10:       LICENSE.bl1
BuildRoot:      %{_tmppath}/%{name}-%{version}-build
BuildRequires:  meson-tools
%ifarch aarch64
BuildRequires:  u-boot-odroid-c2
%endif

%description
Bootloader firmware for Hardkernel ODROID-C2 board

%package tools
Summary:        Tools for ODROID-C2 firmware
Group:          System/Boot

%description tools
Utilities for building Hardkernel ODROID-C2 firmware

%prep
%setup -q -c -T -a 0 -a 1
%ifarch aarch64
cp %SOURCE10 .
%endif

%build
HDIR=u-boot-odroidc2-v2015.01
pushd ${HDIR}
make -C tools/fip_create/ HOSTCFLAGS="%{optflags}"
popd
%ifarch aarch64
${HDIR}/tools/fip_create/fip_create \
  --bl30  ${HDIR}/fip/gxb/bl30.bin \
  --bl301 ${HDIR}/fip/gxb/bl301.bin \
  --bl31  ${HDIR}/fip/gxb/bl31.bin \
  --bl33  /boot/u-boot.bin \
  --dump \
  fip.bin
cat ${HDIR}/fip/gxb/bl2.package fip.bin > boot_new.bin
amlbootsig boot_new.bin u-boot.img
dd if=u-boot.img of=u-boot.odroidc2 bs=512 skip=96
%endif

%install
pushd u-boot-odroidc2-v2015.01
install -D -m 755 tools/fip_create/fip_create %{buildroot}%{_bindir}/odroidc2-fip_create
%ifarch aarch64
install -D -m 644 sd_fuse/bl1.bin.hardkernel %{buildroot}/boot/bl1.bin.hardkernel
install -D -m 644 fip/gxb/bl2.package %{buildroot}/boot/bl2.package
install -D -m 644 fip/gxb/bl30.bin %{buildroot}/boot/bl30.bin
install -D -m 644 fip/gxb/bl301.bin %{buildroot}/boot/bl301.bin
install -D -m 644 fip/gxb/bl31.bin %{buildroot}/boot/bl31.bin
%endif
popd
%ifarch aarch64
install -D -m 644 u-boot.odroidc2 %{buildroot}/boot/u-boot.odroidc2
%endif

%ifarch aarch64
%files
%defattr(-,root,root)
%doc LICENSE.bl1
/boot/bl1.bin.hardkernel
/boot/bl2.package
/boot/bl30.bin
/boot/bl301.bin
/boot/bl31.bin
/boot/u-boot.odroidc2
%endif

%files tools
%defattr(-,root,root)
%{_bindir}/odroidc2-fip_create

%changelog