94992ac428dd1088c91e507ecd05d10c779098f6
[platform/upstream/linux-glibc-devel.git] / packaging / linux-glibc-devel.spec
1
2 Name:           linux-glibc-devel
3 # this confusing version number has no meaning, it's the version
4 # of the Linux kernel where these headers come from
5 Version:        5.4
6 Release:        0
7 License:        GPL-2.0
8 Summary:        Linux headers for userspace development
9 # A "-" is not allowed in version
10 Url:            http://www.kernel.org/
11 Group:          Development/Libraries
12 Source:         %{name}-%{version}.tar.bz2
13 Source1:        install_all.sh
14 Source1001:     linux-glibc-devel.manifest
15 Requires(pre):  coreutils
16 Provides:       kernel-headers
17 Provides:       linux-kernel-headers = %{version}
18 Obsoletes:      linux-kernel-headers < %{version}
19 BuildRequires:  fdupes
20
21 %description
22 This package provides Linux kernel headers, the kernel API description
23 required for compilation of almost all programs. This is the userspace
24 interface; compiling external kernel modules requires
25 kernel-(flavor)-devel, or kernel-syms to pull in all kernel-*-devel,
26 packages, instead.
27
28 %prep
29 %setup -q -n linux-glibc-devel-%{version}
30 cp %{SOURCE1001} .
31
32 %build
33 cat > version.h <<-BOGUS
34 #ifdef __KERNEL__
35 #error "======================================================="
36 #error "You should not include /usr/include/{linux,asm}/ header"
37 #error "files directly for the compilation of kernel modules."
38 #error ""
39 #error "glibc now uses kernel header files from a well-defined"
40 #error "working kernel version (as recommended by Linus Torvalds)"
41 #error "These files are glibc internal and may not match the"
42 #error "currently running kernel. They should only be"
43 #error "included via other system header files - user space"
44 #error "programs should not directly include <linux/*.h> or"
45 #error "<asm/*.h> as well."
46 #error ""
47 #error "Since Linux 2.6, the kernel module build process has been"
48 #error "updated such that users building modules should not typically"
49 #error "need to specify additional include directories at all."
50 #error ""
51 #error "To build kernel modules, ensure you have the build environment "
52 #error "available either via the kernel-devel and kernel-<flavor>-devel "
53 #error "packages or a properly configured kernel source tree."
54 #error ""
55 #error "Then, modules can be built using:"
56 #error "make -C <path> M=$PWD"
57 #error ""
58 #error "For the currently running kernel there will be a symbolic "
59 #error "link pointing to the build environment located at "
60 #error "/lib/modules/$(uname -r)/build for use as <path>."
61 #error ""
62 #error "If you are seeing this message, your environment is "
63 #error "not configured properly. "
64 #error ""
65 #error "Please adjust the Makefile accordingly."
66 #error "======================================================="
67 #else
68 BOGUS
69 # Get LINUX_VERSION_CODE and KERNEL_VERSION directly from kernel
70 cat usr/include/linux/version.h >> version.h
71 cat >> version.h <<-BOGUS
72 #endif
73 BOGUS
74 cat version.h
75
76 %install
77 cp -a usr %{buildroot}
78 cp -a version.h %{buildroot}/usr/include/linux/
79 # Temporarily exclude i2c header files, which are provided by i2c-tools instead
80 rm -fv   %{buildroot}/usr/include/linux/i2c-dev.h
81 # resolve file conflict with glibc for now
82 rm -fv   %{buildroot}//usr/include/scsi/scsi*
83 # Replace the directory /usr/include/asm with a symlink.
84 # libc contained a symlink /usr/include/asm into kernel-source up to 7.0 (2.1.3)
85 # glibc-devel contained a symlink /usr/include/asm into kernel-source in 7.1 (2.2)
86 # glibc-devel contained a directory /usr/include/asm from 7.2 (2.2.2) up to 10.1/SLES10 (2.4)
87 # The directory moved from glibc-devel to linux-kernel-headers in 10.2 (2.6.18.2)
88 # The directory turned into a symlink in 10.3 (2.6.22)
89 # rpm will remove obsolete files after the post install scripts
90 # A trigger will run after the /usr/include/asm was removed
91 # Create a dummy symlink now for rpmlint happiness, we %%ghost this and create
92 # a proper symlink during %%post:
93 ln -sfn asm-dummy %{buildroot}/usr/include/asm
94 %fdupes %{buildroot}/usr/include
95
96 %postun
97 if test "$1" = 0
98 then
99         rm -f usr/include/asm
100 fi
101 exit 0
102
103 %post
104 asm_link=%{_arch}
105 # Note that you must use the %{_arch} macro instead of "uname -m"
106 # to handle a software platform environment that consists of arm64-based Linux kernel
107 # and arm32-based Platform packages.
108 case "$asm_link" in
109         *arm*)     asm_link=arm        ;;
110         *aarch64*) asm_link=arm64      ;;
111         *parisc*)  asm_link=parisc     ;;
112         *riscv* )  asm_link=riscv      ;;
113         *)         asm_link=x86        ;;
114 esac
115 if test -L usr/include/asm
116 then
117         case "$(readlink usr/include/asm)" in
118                 *../src/linux/include*)
119                 echo "/usr/include/asm points to kernel-source, waiting for triggerpostun to symlink to asm-$asm_link"
120                 rm -fv usr/include/asm
121                 exit 0
122                 ;;
123         esac
124         : symlink is ok, update it below in case of an arch change
125 elif test -d usr/include/asm
126 then
127         echo "/usr/include/asm is a directory, waiting for triggerpostun to symlink to asm-$asm_link"
128         exit 0
129 fi
130 ln -sfn asm-$asm_link usr/include/asm
131 exit 0
132
133 %triggerpostun -- linux-kernel-headers, glibc-devel < 2.5, libc < 2.2
134 asm_link=%{_arch}
135 # Note that you must use the %{_arch} macro instead of "uname -m"
136 # to handle a software platform environment that consists of arm64-based Linux kernel
137 # and arm32-based Platform packages.
138 case "$asm_link" in
139         *arm*)     asm_link=arm        ;;
140         *aarch64*) asm_link=arm64      ;;
141         *riscv* )  asm_link=riscv      ;;
142         *)         asm_link=x86        ;;
143 esac
144 ln -sfn asm-$asm_link usr/include/asm
145 exit 0
146
147 %files
148 %manifest %{name}.manifest
149 %defattr(-,root,root)
150 %{_includedir}/*
151 %ghost %{_includedir}/asm
152
153 %changelog
154
155 * Mon Mar 09 2020 Geunsik Lim <geunsik.lim@samsung.com>
156 - Replaced "uname -m" with "_arch" macro to build platform packages.