File linux-glibc-headers-test.spec of Package linux-glibc-headers-test

#
# spec file for package linux-glibc-header-test
#
# Copyright (c) 2021 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:           linux-glibc-header-test
Version:        0
Release:        0
Summary:        Check that linux-glibc-headers contains actual kernel headers
License:        GPL-2.0-only
BuildRequires:  kernel-default-devel
BuildRequires:  kernel-source
BuildRequires:  linux-glibc-devel
BuildRequires:  rsync

%description
Test package - not for installation

%if 0%{?sle_version} && 0%{?sle_version} < 150000
%define tar_filelist -T
%else
%define tar_filelist --verbatim-files-from -T
%endif

%prep

%build
mkdir system-headers
rpm -ql linux-glibc-devel | grep ^/usr/include | while read x ; do
  [ -d "$x" ] || echo "$x"
done | tee filelist
tar -C / %tar_filelist ${PWD}/filelist -cf- | tar -C system-headers -xvf-
mkdir kernel-source
kernel_source="$(rpm -ql kernel-source | cut -d/ -f 4 | head -n1)"
tar -C /usr/src/"$kernel_source" -cf- . | tar -C kernel-source -xf-
cp -av /usr/src/linux-obj/*/default/.config kernel-source
mkdir -p actual-headers/usr/include
make -C kernel-source INSTALL_HDR_PATH=${PWD}/actual-headers/usr headers_install
rm -rf actual-headers/usr/include/drm # DRM headers provided by libdrm
# sound headers are not maintained - provided by ALSA (bsc#1191492)
rm -rf actual-headers/usr/include/sound system-headers/usr/include/sound
# RDMA headers not maintained - provided by rdma-core (bsc#1191550)
rm -rf actual-headers/usr/include/rdma system-headers/usr/include/rdma
find actual-headers -name .install -exec rm -v '{}' '+'
find actual-headers -name ..install.cmd -exec rm -v '{}' ';'
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
  cat actual-headers/usr/include/linux/version.h >> version.h
  cat >> version.h <<\BOGUS
#endif
BOGUS
mv version.h actual-headers/usr/include/linux/
# unistd_x32.h unistd_32.h unistd_64.h unistd-eabi.h unistd-oabi.h file
# presence varies across architectures report the file differences if they
# exist but do not fail if they differ
diff -ur -xunistd_x32.h -xunistd_32.h -xunistd_64.h -xunistd-eabi.h -xunistd-oabi.h system-headers actual-headers
diff -ur system-headers actual-headers ||:

%install

%post
%postun

%files

%changelog

openSUSE Build Service is sponsored by