summaryrefslogtreecommitdiffstats
path: root/scripts/package/mkspec
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2017-11-17 20:51:33 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2017-11-17 20:51:33 -0500
commit2ce079f04d5914dae14fdc8618f804cc0d2a1b8f (patch)
tree4bafc8b62dc5d334662f8c5e86dec5ba461df3a8 /scripts/package/mkspec
parent09bd7c75e55cbaa6c731b0c3a5512ad89159f26f (diff)
parente9e716ff2d4d8618aefac55691a4c4483abecc37 (diff)
Merge tag 'kbuild-misc-v4.15' of git://git.kernel.org/pub/scm/linux/kernel/git/masahiroy/linux-kbuild
Pull Kbuild misc updates from Masahiro Yamada: - Clean up and fix RPM package build - Fix a warning in DEB package build - Improve coccicheck script - Improve some semantic patches * tag 'kbuild-misc-v4.15' of git://git.kernel.org/pub/scm/linux/kernel/git/masahiroy/linux-kbuild: docs: dev-tools: coccinelle: delete out of date wiki reference coccinelle: orplus: reorganize to improve performance coccinelle: use exists to improve efficiency builddeb: Pass the kernel:debarch substvar to dpkg-genchanges Coccinelle: use false positive annotation coccinelle: fix verbose message about .cocci file being run coccinelle: grep Options and Requires fields more precisely Coccinelle: make DEBUG_FILE option more useful coccinelle: api: detect identical chip data arrays coccinelle: Improve setup_timer.cocci matching Coccinelle: setup_timer: improve messages from setup_timer kbuild: rpm-pkg: do not force -jN in submake kbuild: rpm-pkg: keep spec file until make mrproper kbuild: rpm-pkg: fix jobserver unavailable warning kbuild: rpm-pkg: replace $RPM_BUILD_ROOT with %{buildroot} kbuild: rpm-pkg: fix build error when CONFIG_MODULES is disabled kbuild: rpm-pkg: refactor mkspec with here doc kbuild: rpm-pkg: clean up mkspec kbuild: rpm-pkg: install vmlinux.bz2 unconditionally kbuild: rpm-pkg: remove ppc64 specific image handling
Diffstat (limited to 'scripts/package/mkspec')
-rwxr-xr-xscripts/package/mkspec269
1 files changed, 124 insertions, 145 deletions
diff --git a/scripts/package/mkspec b/scripts/package/mkspec
index f47f17aae135..280027fad991 100755
--- a/scripts/package/mkspec
+++ b/scripts/package/mkspec
@@ -10,156 +10,135 @@
10# 10#
11 11
12# how we were called determines which rpms we build and how we build them 12# how we were called determines which rpms we build and how we build them
13if [ "$1" = "prebuilt" ]; then 13if [ "$1" = prebuilt ]; then
14 PREBUILT=true 14 S=DEL
15else 15else
16 PREBUILT=false 16 S=
17fi 17fi
18 18
19# starting to output the spec 19if grep -q CONFIG_MODULES=y .config; then
20if [ "`grep CONFIG_DRM=y .config | cut -f2 -d\=`" = "y" ]; then 20 M=
21 PROVIDES=kernel-drm 21else
22fi 22 M=DEL
23
24PROVIDES="$PROVIDES kernel-$KERNELRELEASE"
25__KERNELRELEASE=`echo $KERNELRELEASE | sed -e "s/-/_/g"`
26
27echo "Name: kernel"
28echo "Summary: The Linux Kernel"
29echo "Version: $__KERNELRELEASE"
30echo "Release: $(cat .version 2>/dev/null || echo 1)"
31echo "License: GPL"
32echo "Group: System Environment/Kernel"
33echo "Vendor: The Linux Community"
34echo "URL: http://www.kernel.org"
35
36if ! $PREBUILT; then
37echo "Source: kernel-$__KERNELRELEASE.tar.gz"
38fi
39
40echo "BuildRoot: %{_tmppath}/%{name}-%{PACKAGE_VERSION}-root"
41echo "Provides: $PROVIDES"
42echo "%define __spec_install_post /usr/lib/rpm/brp-compress || :"
43echo "%define debug_package %{nil}"
44echo ""
45echo "%description"
46echo "The Linux Kernel, the operating system core itself"
47echo ""
48echo "%package headers"
49echo "Summary: Header files for the Linux kernel for use by glibc"
50echo "Group: Development/System"
51echo "Obsoletes: kernel-headers"
52echo "Provides: kernel-headers = %{version}"
53echo "%description headers"
54echo "Kernel-headers includes the C header files that specify the interface"
55echo "between the Linux kernel and userspace libraries and programs. The"
56echo "header files define structures and constants that are needed for"
57echo "building most standard programs and are also needed for rebuilding the"
58echo "glibc package."
59echo ""
60echo "%package devel"
61echo "Summary: Development package for building kernel modules to match the $__KERNELRELEASE kernel"
62echo "Group: System Environment/Kernel"
63echo "AutoReqProv: no"
64echo "%description -n kernel-devel"
65echo "This package provides kernel headers and makefiles sufficient to build modules"
66echo "against the $__KERNELRELEASE kernel package."
67echo ""
68
69if ! $PREBUILT; then
70echo "%prep"
71echo "%setup -q"
72echo ""
73fi 23fi
74 24
75echo "%build" 25if grep -q CONFIG_DRM=y .config; then
76 26 PROVIDES=kernel-drm
77if ! $PREBUILT; then
78echo "make clean && make %{?_smp_mflags} KBUILD_BUILD_VERSION=%{release}"
79echo ""
80fi 27fi
81 28
82echo "%install" 29PROVIDES="$PROVIDES kernel-$KERNELRELEASE"
83echo 'KBUILD_IMAGE=$(make image_name)' 30__KERNELRELEASE=$(echo $KERNELRELEASE | sed -e "s/-/_/g")
84echo "%ifarch ia64" 31EXCLUDES="$RCS_TAR_IGNORE --exclude=.tmp_versions --exclude=*vmlinux* \
85echo 'mkdir -p $RPM_BUILD_ROOT/boot/efi $RPM_BUILD_ROOT/lib/modules' 32--exclude=*.o --exclude=*.ko --exclude=*.cmd --exclude=Documentation \
86echo "%else" 33--exclude=.config.old --exclude=.missing-syscalls.d"
87echo 'mkdir -p $RPM_BUILD_ROOT/boot $RPM_BUILD_ROOT/lib/modules'
88echo "%endif"
89
90echo 'INSTALL_MOD_PATH=$RPM_BUILD_ROOT make %{?_smp_mflags} KBUILD_SRC= modules_install'
91echo "%ifarch ia64"
92echo 'cp $KBUILD_IMAGE $RPM_BUILD_ROOT'"/boot/efi/vmlinuz-$KERNELRELEASE"
93echo 'ln -s '"efi/vmlinuz-$KERNELRELEASE" '$RPM_BUILD_ROOT'"/boot/"
94echo "%else"
95echo "%ifarch ppc64"
96echo "cp vmlinux arch/powerpc/boot"
97echo "cp arch/powerpc/boot/"'$KBUILD_IMAGE $RPM_BUILD_ROOT'"/boot/vmlinuz-$KERNELRELEASE"
98echo "%else"
99echo 'cp $KBUILD_IMAGE $RPM_BUILD_ROOT'"/boot/vmlinuz-$KERNELRELEASE"
100echo "%endif"
101echo "%endif"
102
103echo 'make %{?_smp_mflags} INSTALL_HDR_PATH=$RPM_BUILD_ROOT/usr KBUILD_SRC= headers_install'
104echo 'cp System.map $RPM_BUILD_ROOT'"/boot/System.map-$KERNELRELEASE"
105
106echo 'cp .config $RPM_BUILD_ROOT'"/boot/config-$KERNELRELEASE"
107
108echo "%ifnarch ppc64"
109echo 'bzip2 -9 --keep vmlinux'
110echo 'mv vmlinux.bz2 $RPM_BUILD_ROOT'"/boot/vmlinux-$KERNELRELEASE.bz2"
111echo "%endif"
112
113if ! $PREBUILT; then
114echo 'rm -f $RPM_BUILD_ROOT'"/lib/modules/$KERNELRELEASE/build"
115echo 'rm -f $RPM_BUILD_ROOT'"/lib/modules/$KERNELRELEASE/source"
116echo "mkdir -p "'$RPM_BUILD_ROOT'"/usr/src/kernels/$KERNELRELEASE"
117echo "EXCLUDES=\"$RCS_TAR_IGNORE --exclude .tmp_versions --exclude=*vmlinux* --exclude=*.o --exclude=*.ko --exclude=*.cmd --exclude=Documentation --exclude .config.old --exclude .missing-syscalls.d\""
118echo "tar "'$EXCLUDES'" -cf- . | (cd "'$RPM_BUILD_ROOT'"/usr/src/kernels/$KERNELRELEASE;tar xvf -)"
119echo 'cd $RPM_BUILD_ROOT'"/lib/modules/$KERNELRELEASE"
120echo "ln -sf /usr/src/kernels/$KERNELRELEASE build"
121echo "ln -sf /usr/src/kernels/$KERNELRELEASE source"
122fi
123 34
124echo "" 35# We can label the here-doc lines for conditional output to the spec file
125echo "%clean" 36#
126echo 'rm -rf $RPM_BUILD_ROOT' 37# Labels:
127echo "" 38# $S: this line is enabled only when building source package
128echo "%post" 39# $M: this line is enabled only when CONFIG_MODULES is enabled
129echo "if [ -x /sbin/installkernel -a -r /boot/vmlinuz-$KERNELRELEASE -a -r /boot/System.map-$KERNELRELEASE ]; then" 40sed -e '/^DEL/d' -e 's/^\t*//' <<EOF
130echo "cp /boot/vmlinuz-$KERNELRELEASE /boot/.vmlinuz-$KERNELRELEASE-rpm" 41 Name: kernel
131echo "cp /boot/System.map-$KERNELRELEASE /boot/.System.map-$KERNELRELEASE-rpm" 42 Summary: The Linux Kernel
132echo "rm -f /boot/vmlinuz-$KERNELRELEASE /boot/System.map-$KERNELRELEASE" 43 Version: $__KERNELRELEASE
133echo "/sbin/installkernel $KERNELRELEASE /boot/.vmlinuz-$KERNELRELEASE-rpm /boot/.System.map-$KERNELRELEASE-rpm" 44 Release: $(cat .version 2>/dev/null || echo 1)
134echo "rm -f /boot/.vmlinuz-$KERNELRELEASE-rpm /boot/.System.map-$KERNELRELEASE-rpm" 45 License: GPL
135echo "fi" 46 Group: System Environment/Kernel
136echo "" 47 Vendor: The Linux Community
137echo "%preun" 48 URL: http://www.kernel.org
138echo "if [ -x /sbin/new-kernel-pkg ]; then" 49$S Source: kernel-$__KERNELRELEASE.tar.gz
139echo "new-kernel-pkg --remove $KERNELRELEASE --rminitrd --initrdfile=/boot/initramfs-$KERNELRELEASE.img" 50 Provides: $PROVIDES
140echo "fi" 51 %define __spec_install_post /usr/lib/rpm/brp-compress || :
141echo "" 52 %define debug_package %{nil}
142echo "%postun" 53
143echo "if [ -x /sbin/update-bootloader ]; then" 54 %description
144echo "/sbin/update-bootloader --remove $KERNELRELEASE" 55 The Linux Kernel, the operating system core itself
145echo "fi" 56
146echo "" 57 %package headers
147echo "%files" 58 Summary: Header files for the Linux kernel for use by glibc
148echo '%defattr (-, root, root)' 59 Group: Development/System
149echo "/lib/modules/$KERNELRELEASE" 60 Obsoletes: kernel-headers
150echo "%exclude /lib/modules/$KERNELRELEASE/build" 61 Provides: kernel-headers = %{version}
151echo "%exclude /lib/modules/$KERNELRELEASE/source" 62 %description headers
152echo "/boot/*" 63 Kernel-headers includes the C header files that specify the interface
153echo "" 64 between the Linux kernel and userspace libraries and programs. The
154echo "%files headers" 65 header files define structures and constants that are needed for
155echo '%defattr (-, root, root)' 66 building most standard programs and are also needed for rebuilding the
156echo "/usr/include" 67 glibc package.
157echo "" 68
158if ! $PREBUILT; then 69$S$M %package devel
159echo "%files devel" 70$S$M Summary: Development package for building kernel modules to match the $__KERNELRELEASE kernel
160echo '%defattr (-, root, root)' 71$S$M Group: System Environment/Kernel
161echo "/usr/src/kernels/$KERNELRELEASE" 72$S$M AutoReqProv: no
162echo "/lib/modules/$KERNELRELEASE/build" 73$S$M %description -n kernel-devel
163echo "/lib/modules/$KERNELRELEASE/source" 74$S$M This package provides kernel headers and makefiles sufficient to build modules
164echo "" 75$S$M against the $__KERNELRELEASE kernel package.
165fi 76$S$M
77$S %prep
78$S %setup -q
79$S
80$S %build
81$S make %{?_smp_mflags} KBUILD_BUILD_VERSION=%{release}
82$S
83 %install
84 mkdir -p %{buildroot}/boot
85 %ifarch ia64
86 mkdir -p %{buildroot}/boot/efi
87 cp \$(make image_name) %{buildroot}/boot/efi/vmlinuz-$KERNELRELEASE
88 ln -s efi/vmlinuz-$KERNELRELEASE %{buildroot}/boot/
89 %else
90 cp \$(make image_name) %{buildroot}/boot/vmlinuz-$KERNELRELEASE
91 %endif
92$M make %{?_smp_mflags} INSTALL_MOD_PATH=%{buildroot} KBUILD_SRC= modules_install
93 make %{?_smp_mflags} INSTALL_HDR_PATH=%{buildroot}/usr KBUILD_SRC= headers_install
94 cp System.map %{buildroot}/boot/System.map-$KERNELRELEASE
95 cp .config %{buildroot}/boot/config-$KERNELRELEASE
96 bzip2 -9 --keep vmlinux
97 mv vmlinux.bz2 %{buildroot}/boot/vmlinux-$KERNELRELEASE.bz2
98$S$M rm -f %{buildroot}/lib/modules/$KERNELRELEASE/build
99$S$M rm -f %{buildroot}/lib/modules/$KERNELRELEASE/source
100$S$M mkdir -p %{buildroot}/usr/src/kernels/$KERNELRELEASE
101$S$M tar cf - . $EXCLUDES | tar xf - -C %{buildroot}/usr/src/kernels/$KERNELRELEASE
102$S$M cd %{buildroot}/lib/modules/$KERNELRELEASE
103$S$M ln -sf /usr/src/kernels/$KERNELRELEASE build
104$S$M ln -sf /usr/src/kernels/$KERNELRELEASE source
105
106 %clean
107 rm -rf %{buildroot}
108
109 %post
110 if [ -x /sbin/installkernel -a -r /boot/vmlinuz-$KERNELRELEASE -a -r /boot/System.map-$KERNELRELEASE ]; then
111 cp /boot/vmlinuz-$KERNELRELEASE /boot/.vmlinuz-$KERNELRELEASE-rpm
112 cp /boot/System.map-$KERNELRELEASE /boot/.System.map-$KERNELRELEASE-rpm
113 rm -f /boot/vmlinuz-$KERNELRELEASE /boot/System.map-$KERNELRELEASE
114 /sbin/installkernel $KERNELRELEASE /boot/.vmlinuz-$KERNELRELEASE-rpm /boot/.System.map-$KERNELRELEASE-rpm
115 rm -f /boot/.vmlinuz-$KERNELRELEASE-rpm /boot/.System.map-$KERNELRELEASE-rpm
116 fi
117
118 %preun
119 if [ -x /sbin/new-kernel-pkg ]; then
120 new-kernel-pkg --remove $KERNELRELEASE --rminitrd --initrdfile=/boot/initramfs-$KERNELRELEASE.img
121 fi
122
123 %postun
124 if [ -x /sbin/update-bootloader ]; then
125 /sbin/update-bootloader --remove $KERNELRELEASE
126 fi
127
128 %files
129 %defattr (-, root, root)
130$M /lib/modules/$KERNELRELEASE
131$M %exclude /lib/modules/$KERNELRELEASE/build
132$M %exclude /lib/modules/$KERNELRELEASE/source
133 /boot/*
134
135 %files headers
136 %defattr (-, root, root)
137 /usr/include
138$S$M
139$S$M %files devel
140$S$M %defattr (-, root, root)
141$S$M /usr/src/kernels/$KERNELRELEASE
142$S$M /lib/modules/$KERNELRELEASE/build
143$S$M /lib/modules/$KERNELRELEASE/source
144EOF