File rpm.spec of Package rpm

Name:           rpm
Version:        %(rpm -q cross-%{cross_arch}-rpm | cut -d - -f 4 )
Release:        0
Summary:        Foo
License:        GPL-2.0
Group:          foo
Source1:        rpm-rpmlintrc
BuildArch:      noarch
BuildRoot:      %{_tmppath}/%{name}-%{version}-build
BuildRequires:  cross-%{cross_arch}-rpm
BuildRequires:  cross-%{cross_arch}-rpm-build
BuildRequires:  rpm-build
#!BuildIgnore:  post-build-checks

%description
Bootstrap package

%package build
Summary:        Foo
Requires: rpm = %{version}
Requires: binutils
Requires: bzip2
Requires: coreutils
Requires: diffutils
Requires: file
Requires: findutils
Requires: gawk
Requires: gcc
Requires: gettext-tools
Requires: glibc-devel
Requires: glibc-locale
Requires: grep
Requires: gzip
Requires: make
Requires: net-tools
Requires: patch
Requires: perl-base
Requires: sed
Requires: systemd-rpm-macros
Requires: tar
Requires: util-linux
Requires: which
Requires: xz

%description build
Bootstrap package

%define gcc_target_arch %{cross_arch}-suse-linux

%define sysroot %{_prefix}/%{gcc_target_arch}/sys-root

%define cross_lib lib
%if "%{cross_arch}" == "mips64"
%define cross_lib lib64
%endif
%define cross_libdir %{_prefix}/%{cross_lib}

%prep

%build

%install
export NO_BRP_CHECK_RPATH=true
export NO_BRP_STRIP_DEBUG=true
export NO_DEBUGINFO_STRIP_DEBUG=true
mkdir -p %{buildroot}
rpm -ql cross-%{cross_arch}-rpm | \
while IFS= read -r line; do
  if [ ! -d $line ]; then
    echo $line
  fi
done | grep -v '/man/' > rpm.files
rpm -ql cross-%{cross_arch}-rpm-build | \
while IFS= read -r line; do
  if [ ! -d $line ]; then
    echo $line
  fi
done > rpm-build.files
tar cf - -T rpm.files | tar xf - --strip-components=3 -C %{buildroot}
tar cf - -T rpm-build.files | tar xf - --strip-components=3 -C %{buildroot}
sed -i -e "s|^%{sysroot}||" rpm.files
sed -i -e "s|^%{sysroot}||" rpm-build.files
mkdir -p %{buildroot}%{_sysconfdir}/rpm
mkdir -p %{buildroot}%{_libexecdir}/rpm

%post -p /sbin/ldconfig

%postun -p /sbin/ldconfig

%files -f rpm.files
%defattr(-,root,root)
%dir %{_sysconfdir}/rpm
%dir %{_libexecdir}/rpm

%files build -f rpm-build.files
%defattr(-,root,root)

%changelog