File linux-glibc-devel.spec of Package linux-glibc-devel.26130

#
# spec file for package linux-glibc-devel
#
# Copyright (c) 2021 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/
#


Name:           linux-glibc-devel
Version:        5.14
Release:        0
Summary:        Linux headers for userspace development
License:        GPL-2.0-only
Group:          Development/Libraries/C and C++
URL:            http://www.kernel.org/
Source:         %{name}-%{version}.tar.xz
Source1:        install_all.sh
# stable
Patch0:         linux-stable-version-update.patch
Patch1:         binder-fix-freeze-race.patch
Patch2:         bpf-Fix-a-typo-of-reuseport-map-in-bpf.h.patch
Patch3:         fq_codel-reject-silly-quantum-parameters.patch
Patch4:         habanalabs-add-in-device-creation-status.patch
Patch5:         serial-8250-Define-RX-trigger-levels-for-OxSemi-950-.patch
Patch6:         PCI-Add-PCI_EXP_DEVCTL_PAYLOAD_-macros.patch
Patch7:         ethtool-fix-ethtool-msg-len-calculation-for-pause-st.patch
# features/bugs
Patch50:        dmanegine-idxd-add-software-command-status.patch
Patch51:        dmaengine-idxd-fix-setting-up-priv-mode-for-dwq.patch
Patch52:        ethtool-add-two-link-extended-substates-of-bad-signa.patch
Patch53:        ethtool-add-two-coalesce-attributes-for-CQE-mode.patch
Patch54:        msft-hv-2440-hyper-v-Replace-uuid.h-with-types.h.patch
Patch55:        remove-the-lightnvm-subsystem.patch
Patch56:        scsi-fc-Add-EDC-ELS-definition.patch
Patch57:        uapi-linux-prctl-provide-macro-definitions-for-the-PR_SCHED_CORE-type-argument
Patch58:        uapi-fix-linux-nfc.h-userspace-compilation-errors.patch
Patch59:        nfc-uapi-use-kernel-size_t-to-fix-user-space-builds.patch
Patch60:        cifs-remove-pathname-for-file-from-SPDX-header.patch
Patch61:        uapi-Fix-undefined-__always_inline-on-non-glibc-syst.patch
Patch62:        tty-Partially-revert-the-removal-of-the-Cyclades-pub.patch
Patch63:        um-virt-pci-fix-uapi-documentation
Patch64:        net-sched-act_skbmod-Add-SKBMOD_F_ECN-option-support.patch
Patch65:        stddef-Introduce-struct_group-helper-macro.patch
Patch66:        net-smc-add-support-for-user-defined-EIDs
Patch67:        net-smc-add-generic-netlink-support-for-system-EID
Patch68:        net-smc-add-netlink-support-for-SMC-Rv2
Patch69:        net_sched-refactor-TC-action-init-API.patch
Patch70:        0001-mm-mempolicy-add-MPOL_PREFERRED_MANY-for-multiple-pr.patch
Patch71:        0003-mm-mempolicy-wire-up-syscall-set_mempolicy_home_node.patch
Patch72:        devlink-report-maximum-number-of-snapshots-with-regi.patch
Patch73:        mptcp-add-missing-documented-NL-params
Patch74:        stddef-Introduce-DECLARE_FLEX_ARRAY-helper.patch
Patch75:        dmaengine-idxd-update-IAA-definitions-for-user-heade.patch
# KVM - only applied to some architectures, and SLE15 autopatch does not understand -m/-M
Patch90:        kvm-sev-add-support-for-sev-intra-host-migration
# X86 only
Patch91:        0005-efi-generate-secret-key-in-EFI-boot-environment.patch
Patch92:        x86-arch_prctl-add-controls-for-dynamic-xstate-components.patch
# ancient
Patch100:       uapi-add-a-compatibility-layer-between-linux-uio-h-and-glibc
Patch101:       md-display-timeout-error.patch
BuildRequires:  xz
# rpm-build requires gettext-tools; ignore this, in order to shorten cycles (we have no translations)
#!BuildIgnore:  gettext-tools
# glibc-devel requires linux-kernel-headers, which we are in progress of building
#!BuildIgnore:  linux-kernel-headers
PreReq:         coreutils
Provides:       kernel-headers
Provides:       linux-kernel-headers = %{version}
Obsoletes:      linux-kernel-headers < %{version}

%{lua:
function cross_archs()
  return "aarch64", "arm", "hppa", "i386", "m68k", "mips", "ppc64", "ppc64le", "riscv64", "s390x", "sparc", "sparc64", "x86_64"
end

function kernel_arch(arch)
  local map = {
     ["aarch64"] = "arm64",
     ["armv6hl"] = "arm",
     ["armv7hl"] = "arm",
     ["hppa"] = "parisc",
     ["i386"] = "x86",
     ["i586"] = "x86",
     ["i686"] = "x86",
     ["ppc"] = "powerpc",
     ["ppc64"] = "powerpc",
     ["ppc64le"] = "powerpc",
     ["riscv64"] = "riscv",
     ["s390x"] = "s390",
     ["sparc64"] = "sparc",
     ["x86_64"] = "x86",
  }
  return map[arch] or arch
end

function gcc_target(arch)
  local map = {
    ["arm"] = "arm-suse-linux-gnueabi",
    ["i386"] = "i586-suse-linux",
    ["ppc64"] = "powerpc64-suse-linux",
    ["ppc64le"] = "powerpc64le-suse-linux",
  }
  return map[arch] or arch.."-suse-linux"
end
}

%description
This package provides Linux kernel headers, the kernel API description
required for compilation of almost all programs. This is the userspace
interface; compiling external kernel modules requires
kernel-(flavor)-devel, or kernel-syms to pull in all kernel-*-devel,
packages, instead.

%{lua:
  for i,arch in ipairs({cross_archs()}) do
    print(rpm.expand([[

%package -n cross-]]..arch..[[-linux-glibc-devel
Summary:        Linux headers for ]]..arch..[[ userspace cross development
Group:          Development/Libraries/C and C++
BuildArch:      noarch

%description -n cross-]]..arch..[[-linux-glibc-devel
This package provides Linux kernel headers for ]]..arch..[[, the kernel API description
required for compilation of almost all programs.
]]))
  end}

%prep
%setup -q -n linux-glibc-devel-%{version}
for karch in *; do
pushd $karch/usr
%patch -p1 -P  0 -P  1 -P  2 -P  3 -P  4 -P  5 -P  6 -P  7
%patch -p1 -P 50 -P 51 -P 52 -P 53 -P 54 -P 55 -P 56 -P 57 -P 58 -P 59
%patch -p1 -P 60 -P 61 -P 62 -P 63 -P 64 -P 65 -P 66 -P 67 -P 68 -P 69
%patch -p1 -P 70 -P 71 -P 72 -P 73 -P 74 -P 75
%patch -p1 -P 100 -P 101
case $karch in # KVM
  arm64|mips|powerpc|s390|x86)
%patch -p1 -P 90
  ;;
esac
case $karch in
  x86)
%patch -p1 -P 91 -P 92
  ;;
esac
popd
done

%build
for karch in *; do
  cd $karch
  cat > version.h <<\BOGUS
#ifdef __KERNEL__
#error "======================================================="
#error "You should not include %{_includedir}/{linux,asm}/ header"
#error "files directly for the compilation of kernel modules."
#error ""
#error "glibc now uses kernel header files from a well-defined"
#error "working kernel version (as recommended by Linus Torvalds)"
#error "These files are glibc internal and may not match the"
#error "currently running kernel. They should only be"
#error "included via other system header files - user space"
#error "programs should not directly include <linux/*.h> or"
#error "<asm/*.h> as well."
#error ""
#error "Since Linux 2.6, the kernel module build process has been"
#error "updated such that users building modules should not typically"
#error "need to specify additional include directories at all."
#error ""
#error "To build kernel modules, ensure you have the build environment "
#error "available either via the kernel-devel and kernel-<flavor>-devel "
#error "packages or a properly configured kernel source tree."
#error ""
#error "Then, modules can be built using:"
#error "make -C <path> M=$PWD"
#error ""
#error "For the currently running kernel there will be a symbolic "
#error "link pointing to the build environment located at "
#error "/lib/modules/$(uname -r)/build for use as <path>."
#error ""
#error "If you are seeing this message, your environment is "
#error "not configured properly. "
#error ""
#error "Please adjust the Makefile accordingly."
#error "======================================================="
#else
BOGUS
  # Get LINUX_VERSION_CODE and KERNEL_VERSION directly from kernel
  cat usr/include/linux/version.h >> version.h
  cat >> version.h <<\BOGUS
#endif
BOGUS
  cd ..
done

%install
cd %{lua:print(kernel_arch(rpm.expand("%_target_cpu")))}
cp -a usr %{buildroot}/
cp -a version.h %{buildroot}%{_includedir}/linux/
cd ..
%{lua:
  for i,arch in ipairs({cross_archs()}) do
    print(rpm.expand([[
sysroot=%{_prefix}/]]..gcc_target(arch)..[[/sys-root
mkdir -p %{buildroot}${sysroot}/%{_includedir}/linux/
cd ]]..kernel_arch(arch)..[[

cp -a usr %{buildroot}${sysroot}
cp -a version.h %{buildroot}${sysroot}/%{_includedir}/linux/
cd ..
]]))
  end}

%pre
if test -L %{_includedir}/asm; then
  rm -f %{_includedir}/asm
fi

%files
%{_includedir}/*

%{lua:
  for i,arch in ipairs({cross_archs()}) do
    print(rpm.expand([[

%files -n cross-]]..arch..[[-linux-glibc-devel
%{_prefix}/]]..gcc_target(arch).."\n"))
  end}

%changelog
openSUSE Build Service is sponsored by