File sysroot.spec.in of Package sysroot

#
# spec file for package hello
#
# Copyright (c) 2019 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 https://bugs.opensuse.org/
#

%define cross_sysroot  /usr/%{_build_cpu}-suse-linux/sys-root

Name:           sysroot-%{_build_cpu}
BuildArch:      noarch
Summary:        Provides a sysroot for crosscompiling
License:        GPL-3.0-or-later
Group:          Development/Tools/Other
AutoReqProv:    off
# needs to be updated manually via external script atm
Source1:        cross_package_list.aarch64
Requires: libstdc++6-devel-gcc9 cross-aarch64-binutils cross-aarch64-glibc cross-aarch64-linux-glibc-devel cross-aarch64-glibc-devel cross-aarch64-gcc9

# cross packages have currently no correct requires:
Requires: libisl15 libmpc3

Version:        0.1
Release:        0

%description

%prep

%build

%install
mkdir -p %buildroot%cross_sysroot
rsync -aH \
      --exclude=/dev \
      --exclude=/proc \
      --exclude=/sys \
      --exclude=/build-preinstall \
      --exclude=/installed-pkg \
      --exclude=/.\* \
      --exclude=/usr/src/packages/ \
      --exclude=/home \
      --exclude=/root \
      --exclude=/selinux \
      --exclude=/opt \
      --exclude=/boot \
      --exclude=/var/lock \
      --exclude=/run \
      --exclude=/var/lib/dbus/machine-id \
      / %buildroot%cross_sysroot

# broken symlink
rm -f %buildroot%cross_sysroot%_libdir/gcc/*-suse-linux/*/libgomp-plugin-hsa.*
rm -f %buildroot%cross_sysroot/usr/share/licenses/libxslt-tools/COPYING
#rm %buildroot%cross_sysroot/var/lib/xkb/compiled/compiled

# fix absolute links to take sysroot into account
chroot %buildroot%cross_sysroot find / -type l -lname '/*' | while read link; do
    # hack for aarch64, breaks chroot, needs to be done last
    [ "/lib/ld-linux-aarch64.so.1" = "$link" ] && continue
    linktarget="$(chroot %buildroot%cross_sysroot /usr/bin/readlink "$link")"
    ln -sf "%cross_sysroot$linktarget" "%buildroot%cross_sysroot/$link"
done

echo %_prefix/%{_build_cpu}-suse-linux > file_list

# check for files from cross-* packages (not installed during build) and exclude them
cat %{S:1} | while read file; do
 if test -d "%buildroot%cross_sysroot/$file"; then
   echo "%exclude %dir %cross_sysroot$file" >> file_list
 elif test -e "%buildroot%cross_sysroot/$file"; then
   echo "%exclude %cross_sysroot$file" >> file_list
 fi
done

%files -f file_list

openSUSE Build Service is sponsored by