File buildroot.spec of Package buildroot-xtensa

%define arch xtensa
Name:       buildroot
Version:	2016.05
Release:	1
License:	various
Summary:	crosstool for strace
Url:		https://github.com/buildroot/buildroot
Source0:	%{name}-%{version}.tar.gz
Source1:	buildroot.config
BuildRequires:  gcc-c++ bison flex ncurses-devel python 
BuildRequires:  wget zip unzip gzip patch bzip2 subversion bc rsync
%if 0%{?fedora_version} >= 20
BuildRequires: ncurses
%endif

%if 0%{?suse_version} >= 1300
BuildRequires: ncurses-utils
%endif

%global __os_install_post %{nil}

BuildArch:      x86_64
BuildRoot:      %{_tmppath}/%{name}-%{version}-build
%define pkg_root        /opt/buildroot-%{arch}
%define toolchain_path  %{pkg_root}/toolchain
%define images_path     %{pkg_root}/images
%define debug_package %{nil}

%description
crosstool to build strace on different architectures

%package -n buildroot-toolchain-%{arch}
Version:	0
Release:	1
Summary:	Buildroot Crosstools
AutoReqProv:    off
%if 0%{?fedora_version} >= 20
Requires:   libmpc
%endif

%description -n buildroot-toolchain-%{arch}
Buildroot cross-toolchain.

%package -n buildroot-images-%{arch}
Version:	0
Release:	1
Summary:	Buildroot rootfs images

%description -n buildroot-images-%{arch}
Buildroot root filesystem images.

%prep
%setup -q

%build
cp %{SOURCE1} .config
make oldconfig
make

%install
export DONT_STRIP=1
export NO_BRP_CHECK_RPATH=true
export NO_BRP_STRIP_DEBUG=true

mkdir -p %{buildroot}%{images_path}
tar -C output/images -c . | tar -C %{buildroot}%{images_path} -xf -

chmod 644 %{buildroot}%{images_path}/*

mkdir -p %{buildroot}%{toolchain_path}
rm -rf output/host/usr/share/{man,info,locale,doc}
tar -C output/host -c . | tar -C %{buildroot}%{toolchain_path} -xf -

chmod 644 %{buildroot}%{toolchain_path}/usr/lib/*.a

%clean
rm -rf %{buildroot}

%files -n buildroot-toolchain-%{arch}
%defattr(-,root,root)
%{toolchain_path}

%files -n buildroot-images-%{arch}
%defattr(-,root,root)
%{images_path}