Commit 327fff3e1391a27dcc89de6e0481689a865361c9
Exists in
master
and in
20 other branches
Merge branch 'misc' of git://git.kernel.org/pub/scm/linux/kernel/git/mmarek/kbuild
Pull misc kbuild updates from Michal Marek: "In the kbuild misc branch, I have: - make rpm-pkg updates, most importantly the rpm package now calls /sbin/installkernel - make deb-pkg: debuginfo split, correct kernel image path for parisc, mips and powerpc and a couple more minor fixes - New coccinelle check" * 'misc' of git://git.kernel.org/pub/scm/linux/kernel/git/mmarek/kbuild: scripts/checkkconfigsymbols.sh: replace echo -e with printf Provide version number for Debian firmware package coccinelle: replace 0/1 with false/true in functions returning bool deb-pkg: add a hook argument to match debian hooks parameters deb-pkg: fix installed image path on parisc, mips and powerpc deb-pkg: split debug symbols in their own package deb-pkg: use KCONFIG_CONFIG instead of .config file directly rpm-pkg: add generation of kernel-devel rpm-pkg: install firmware files in kernel relative directory rpm-pkg: add %post section to create initramfs and grub hooks
Showing 4 changed files Side-by-side Diff
scripts/checkkconfigsymbols.sh
... | ... | @@ -9,7 +9,7 @@ |
9 | 9 | # Doing this once at the beginning saves a lot of time, on a cache-hot tree. |
10 | 10 | Kconfigs="`find . -name 'Kconfig' -o -name 'Kconfig*[^~]'`" |
11 | 11 | |
12 | -/bin/echo -e "File list \tundefined symbol used" | |
12 | +printf "File list \tundefined symbol used\n" | |
13 | 13 | find $paths -name '*.[chS]' -o -name 'Makefile' -o -name 'Makefile*[^~]'| while read i |
14 | 14 | do |
15 | 15 | # Output the bare Kconfig variable and the filename; the _MODULE part at |
... | ... | @@ -54,7 +54,7 @@ |
54 | 54 | # beyond the purpose of this script. |
55 | 55 | symb_bare=`echo $symb | sed -e 's/_MODULE//'` |
56 | 56 | if ! grep -q "\<$symb_bare\>" $Kconfigs; then |
57 | - /bin/echo -e "$files: \t$symb" | |
57 | + printf "$files: \t$symb\n" | |
58 | 58 | fi |
59 | 59 | done|sort |
scripts/coccinelle/misc/boolreturn.cocci
1 | +/// Return statements in functions returning bool should use | |
2 | +/// true/false instead of 1/0. | |
3 | +// | |
4 | +// Confidence: High | |
5 | +// Options: --no-includes --include-headers | |
6 | + | |
7 | +virtual patch | |
8 | +virtual report | |
9 | +virtual context | |
10 | + | |
11 | +@r1 depends on patch@ | |
12 | +identifier fn; | |
13 | +typedef bool; | |
14 | +symbol false; | |
15 | +symbol true; | |
16 | +@@ | |
17 | + | |
18 | +bool fn ( ... ) | |
19 | +{ | |
20 | +<... | |
21 | +return | |
22 | +( | |
23 | +- 0 | |
24 | ++ false | |
25 | +| | |
26 | +- 1 | |
27 | ++ true | |
28 | +) | |
29 | + ; | |
30 | +...> | |
31 | +} | |
32 | + | |
33 | +@r2 depends on report || context@ | |
34 | +identifier fn; | |
35 | +position p; | |
36 | +@@ | |
37 | + | |
38 | +bool fn ( ... ) | |
39 | +{ | |
40 | +<... | |
41 | +return | |
42 | +( | |
43 | +* 0@p | |
44 | +| | |
45 | +* 1@p | |
46 | +) | |
47 | + ; | |
48 | +...> | |
49 | +} | |
50 | + | |
51 | + | |
52 | +@script:python depends on report@ | |
53 | +p << r2.p; | |
54 | +fn << r2.fn; | |
55 | +@@ | |
56 | + | |
57 | +msg = "WARNING: return of 0/1 in function '%s' with return type bool" % fn | |
58 | +coccilib.report.print_report(p[0], msg) |
scripts/package/builddeb
... | ... | @@ -41,9 +41,9 @@ |
41 | 41 | parisc*) |
42 | 42 | debarch=hppa ;; |
43 | 43 | mips*) |
44 | - debarch=mips$(grep -q CPU_LITTLE_ENDIAN=y .config && echo el) ;; | |
44 | + debarch=mips$(grep -q CPU_LITTLE_ENDIAN=y $KCONFIG_CONFIG && echo el) ;; | |
45 | 45 | arm*) |
46 | - debarch=arm$(grep -q CONFIG_AEABI=y .config && echo el) ;; | |
46 | + debarch=arm$(grep -q CONFIG_AEABI=y $KCONFIG_CONFIG && echo el) ;; | |
47 | 47 | *) |
48 | 48 | echo "" >&2 |
49 | 49 | echo "** ** ** WARNING ** ** **" >&2 |
50 | 50 | |
51 | 51 | |
52 | 52 | |
53 | 53 | |
... | ... | @@ -78,17 +78,35 @@ |
78 | 78 | fwdir="$objtree/debian/fwtmp" |
79 | 79 | kernel_headers_dir="$objtree/debian/hdrtmp" |
80 | 80 | libc_headers_dir="$objtree/debian/headertmp" |
81 | +dbg_dir="$objtree/debian/dbgtmp" | |
81 | 82 | packagename=linux-image-$version |
82 | -fwpackagename=linux-firmware-image | |
83 | +fwpackagename=linux-firmware-image-$version | |
83 | 84 | kernel_headers_packagename=linux-headers-$version |
84 | 85 | libc_headers_packagename=linux-libc-dev |
86 | +dbg_packagename=$packagename-dbg | |
85 | 87 | |
86 | 88 | if [ "$ARCH" = "um" ] ; then |
87 | 89 | packagename=user-mode-linux-$version |
88 | 90 | fi |
89 | 91 | |
92 | +# Not all arches have the same installed path in debian | |
93 | +# XXX: have each arch Makefile export a variable of the canonical image install | |
94 | +# path instead | |
95 | +case $ARCH in | |
96 | +um) | |
97 | + installed_image_path="usr/bin/linux-$version" | |
98 | + ;; | |
99 | +parisc|mips|powerpc) | |
100 | + installed_image_path="boot/vmlinux-$version" | |
101 | + ;; | |
102 | +*) | |
103 | + installed_image_path="boot/vmlinuz-$version" | |
104 | +esac | |
105 | + | |
106 | +BUILD_DEBUG="$(grep -s '^CONFIG_DEBUG_INFO=y' $KCONFIG_CONFIG || true)" | |
107 | + | |
90 | 108 | # Setup the directory structure |
91 | -rm -rf "$tmpdir" "$fwdir" "$kernel_headers_dir" "$libc_headers_dir" | |
109 | +rm -rf "$tmpdir" "$fwdir" "$kernel_headers_dir" "$libc_headers_dir" "$dbg_dir" | |
92 | 110 | mkdir -m 755 -p "$tmpdir/DEBIAN" |
93 | 111 | mkdir -p "$tmpdir/lib" "$tmpdir/boot" "$tmpdir/usr/share/doc/$packagename" |
94 | 112 | mkdir -m 755 -p "$fwdir/DEBIAN" |
95 | 113 | |
96 | 114 | |
97 | 115 | |
98 | 116 | |
99 | 117 | |
... | ... | @@ -101,26 +119,29 @@ |
101 | 119 | if [ "$ARCH" = "um" ] ; then |
102 | 120 | mkdir -p "$tmpdir/usr/lib/uml/modules/$version" "$tmpdir/usr/bin" |
103 | 121 | fi |
122 | +if [ -n "$BUILD_DEBUG" ] ; then | |
123 | + mkdir -p "$dbg_dir/usr/share/doc/$dbg_packagename" | |
124 | + mkdir -m 755 -p "$dbg_dir/DEBIAN" | |
125 | +fi | |
104 | 126 | |
105 | 127 | # Build and install the kernel |
106 | 128 | if [ "$ARCH" = "um" ] ; then |
107 | 129 | $MAKE linux |
108 | 130 | cp System.map "$tmpdir/usr/lib/uml/modules/$version/System.map" |
109 | - cp .config "$tmpdir/usr/share/doc/$packagename/config" | |
131 | + cp $KCONFIG_CONFIG "$tmpdir/usr/share/doc/$packagename/config" | |
110 | 132 | gzip "$tmpdir/usr/share/doc/$packagename/config" |
111 | - cp $KBUILD_IMAGE "$tmpdir/usr/bin/linux-$version" | |
112 | 133 | else |
113 | 134 | cp System.map "$tmpdir/boot/System.map-$version" |
114 | - cp .config "$tmpdir/boot/config-$version" | |
115 | - # Not all arches include the boot path in KBUILD_IMAGE | |
116 | - if [ -e $KBUILD_IMAGE ]; then | |
117 | - cp $KBUILD_IMAGE "$tmpdir/boot/vmlinuz-$version" | |
118 | - else | |
119 | - cp arch/$ARCH/boot/$KBUILD_IMAGE "$tmpdir/boot/vmlinuz-$version" | |
120 | - fi | |
135 | + cp $KCONFIG_CONFIG "$tmpdir/boot/config-$version" | |
121 | 136 | fi |
137 | +# Not all arches include the boot path in KBUILD_IMAGE | |
138 | +if [ -e $KBUILD_IMAGE ]; then | |
139 | + cp $KBUILD_IMAGE "$tmpdir/$installed_image_path" | |
140 | +else | |
141 | + cp arch/$ARCH/boot/$KBUILD_IMAGE "$tmpdir/$installed_image_path" | |
142 | +fi | |
122 | 143 | |
123 | -if grep -q '^CONFIG_MODULES=y' .config ; then | |
144 | +if grep -q '^CONFIG_MODULES=y' $KCONFIG_CONFIG ; then | |
124 | 145 | INSTALL_MOD_PATH="$tmpdir" $MAKE KBUILD_SRC= modules_install |
125 | 146 | rm -f "$tmpdir/lib/modules/$version/build" |
126 | 147 | rm -f "$tmpdir/lib/modules/$version/source" |
... | ... | @@ -128,6 +149,20 @@ |
128 | 149 | mv "$tmpdir/lib/modules/$version"/* "$tmpdir/usr/lib/uml/modules/$version/" |
129 | 150 | rmdir "$tmpdir/lib/modules/$version" |
130 | 151 | fi |
152 | + if [ -n "$BUILD_DEBUG" ] ; then | |
153 | + ( | |
154 | + cd $tmpdir | |
155 | + for module in $(find lib/modules/ -name *.ko); do | |
156 | + mkdir -p $(dirname $dbg_dir/usr/lib/debug/$module) | |
157 | + # only keep debug symbols in the debug file | |
158 | + objcopy --only-keep-debug $module $dbg_dir/usr/lib/debug/$module | |
159 | + # strip original module from debug symbols | |
160 | + objcopy --strip-debug $module | |
161 | + # then add a link to those | |
162 | + objcopy --add-gnu-debuglink=$dbg_dir/usr/lib/debug/$module $module | |
163 | + done | |
164 | + ) | |
165 | + fi | |
131 | 166 | fi |
132 | 167 | |
133 | 168 | if [ "$ARCH" != "um" ]; then |
... | ... | @@ -149,7 +184,7 @@ |
149 | 184 | # Pass maintainer script parameters to hook scripts |
150 | 185 | export DEB_MAINT_PARAMS="\$*" |
151 | 186 | |
152 | -test -d $debhookdir/$script.d && run-parts --arg="$version" $debhookdir/$script.d | |
187 | +test -d $debhookdir/$script.d && run-parts --arg="$version" --arg="/$installed_image_path" $debhookdir/$script.d | |
153 | 188 | exit 0 |
154 | 189 | EOF |
155 | 190 | chmod 755 "$tmpdir/DEBIAN/$script" |
156 | 191 | |
... | ... | @@ -245,11 +280,12 @@ |
245 | 280 | # Build header package |
246 | 281 | (cd $srctree; find . -name Makefile\* -o -name Kconfig\* -o -name \*.pl > "$objtree/debian/hdrsrcfiles") |
247 | 282 | (cd $srctree; find arch/$SRCARCH/include include scripts -type f >> "$objtree/debian/hdrsrcfiles") |
248 | -(cd $objtree; find arch/$SRCARCH/include .config Module.symvers include scripts -type f >> "$objtree/debian/hdrobjfiles") | |
283 | +(cd $objtree; find arch/$SRCARCH/include Module.symvers include scripts -type f >> "$objtree/debian/hdrobjfiles") | |
249 | 284 | destdir=$kernel_headers_dir/usr/src/linux-headers-$version |
250 | 285 | mkdir -p "$destdir" |
251 | 286 | (cd $srctree; tar -c -f - -T "$objtree/debian/hdrsrcfiles") | (cd $destdir; tar -xf -) |
252 | 287 | (cd $objtree; tar -c -f - -T "$objtree/debian/hdrobjfiles") | (cd $destdir; tar -xf -) |
288 | +(cd $objtree; cp $KCONFIG_CONFIG $destdir/.config) # copy .config manually to be where it's expected to be | |
253 | 289 | ln -sf "/usr/src/linux-headers-$version" "$kernel_headers_dir/lib/modules/$version/build" |
254 | 290 | rm -f "$objtree/debian/hdrsrcfiles" "$objtree/debian/hdrobjfiles" |
255 | 291 | arch=$(dpkg --print-architecture) |
... | ... | @@ -298,6 +334,32 @@ |
298 | 334 | fi |
299 | 335 | |
300 | 336 | create_package "$packagename" "$tmpdir" |
337 | + | |
338 | +if [ -n "$BUILD_DEBUG" ] ; then | |
339 | + # Build debug package | |
340 | + # Different tools want the image in different locations | |
341 | + # perf | |
342 | + mkdir -p $dbg_dir/usr/lib/debug/lib/modules/$version/ | |
343 | + cp vmlinux $dbg_dir/usr/lib/debug/lib/modules/$version/ | |
344 | + # systemtap | |
345 | + mkdir -p $dbg_dir/usr/lib/debug/boot/ | |
346 | + ln -s ../lib/modules/$version/vmlinux $dbg_dir/usr/lib/debug/boot/vmlinux-$version | |
347 | + # kdump-tools | |
348 | + ln -s lib/modules/$version/vmlinux $dbg_dir/usr/lib/debug/vmlinux-$version | |
349 | + | |
350 | + cat <<EOF >> debian/control | |
351 | + | |
352 | +Package: $dbg_packagename | |
353 | +Section: debug | |
354 | +Provides: linux-debug, linux-debug-$version | |
355 | +Architecture: any | |
356 | +Description: Linux kernel debugging symbols for $version | |
357 | + This package will come in handy if you need to debug the kernel. It provides | |
358 | + all the necessary debug symbols for the kernel and its modules. | |
359 | +EOF | |
360 | + | |
361 | + create_package "$dbg_packagename" "$dbg_dir" | |
362 | +fi | |
301 | 363 | |
302 | 364 | exit 0 |
scripts/package/mkspec
1 | 1 | #!/bin/sh |
2 | 2 | # |
3 | -# Output a simple RPM spec file that uses no fancy features requiring | |
4 | -# RPM v4. This is intended to work with any RPM distro. | |
3 | +# Output a simple RPM spec file. | |
4 | +# This version assumes a minimum of RPM 4.0.3. | |
5 | 5 | # |
6 | 6 | # The only gothic bit here is redefining install_post to avoid |
7 | 7 | # stripping the symbols from files in the kernel which we want |
... | ... | @@ -59,6 +59,14 @@ |
59 | 59 | echo "building most standard programs and are also needed for rebuilding the" |
60 | 60 | echo "glibc package." |
61 | 61 | echo "" |
62 | +echo "%package devel" | |
63 | +echo "Summary: Development package for building kernel modules to match the $__KERNELRELEASE kernel" | |
64 | +echo "Group: System Environment/Kernel" | |
65 | +echo "AutoReqProv: no" | |
66 | +echo "%description -n kernel-devel" | |
67 | +echo "This package provides kernel headers and makefiles sufficient to build modules" | |
68 | +echo "against the $__KERNELRELEASE kernel package." | |
69 | +echo "" | |
62 | 70 | |
63 | 71 | if ! $PREBUILT; then |
64 | 72 | echo "%prep" |
65 | 73 | |
66 | 74 | |
67 | 75 | |
... | ... | @@ -77,13 +85,14 @@ |
77 | 85 | echo 'KBUILD_IMAGE=$(make image_name)' |
78 | 86 | echo "%ifarch ia64" |
79 | 87 | echo 'mkdir -p $RPM_BUILD_ROOT/boot/efi $RPM_BUILD_ROOT/lib/modules' |
80 | -echo 'mkdir -p $RPM_BUILD_ROOT/lib/firmware' | |
81 | 88 | echo "%else" |
82 | 89 | echo 'mkdir -p $RPM_BUILD_ROOT/boot $RPM_BUILD_ROOT/lib/modules' |
83 | -echo 'mkdir -p $RPM_BUILD_ROOT/lib/firmware' | |
84 | 90 | echo "%endif" |
91 | +echo 'mkdir -p $RPM_BUILD_ROOT'"/lib/firmware/$KERNELRELEASE" | |
85 | 92 | |
86 | -echo 'INSTALL_MOD_PATH=$RPM_BUILD_ROOT make %{?_smp_mflags} KBUILD_SRC= modules_install' | |
93 | +echo 'INSTALL_MOD_PATH=$RPM_BUILD_ROOT make %{?_smp_mflags} KBUILD_SRC= mod-fw= modules_install' | |
94 | +echo 'INSTALL_FW_PATH=$RPM_BUILD_ROOT'"/lib/firmware/$KERNELRELEASE" | |
95 | +echo 'make INSTALL_FW_PATH=$INSTALL_FW_PATH' firmware_install | |
87 | 96 | echo "%ifarch ia64" |
88 | 97 | echo 'cp $KBUILD_IMAGE $RPM_BUILD_ROOT'"/boot/efi/vmlinuz-$KERNELRELEASE" |
89 | 98 | echo 'ln -s '"efi/vmlinuz-$KERNELRELEASE" '$RPM_BUILD_ROOT'"/boot/" |
90 | 99 | |
91 | 100 | |
92 | 101 | |
... | ... | @@ -108,19 +117,44 @@ |
108 | 117 | echo 'mv vmlinux.orig vmlinux' |
109 | 118 | echo "%endif" |
110 | 119 | |
120 | +echo 'rm -f $RPM_BUILD_ROOT'"/lib/modules/$KERNELRELEASE/{build,source}" | |
121 | +echo "mkdir -p "'$RPM_BUILD_ROOT'"/usr/src/kernels/$KERNELRELEASE" | |
122 | +echo "EXCLUDES=\"$RCS_TAR_IGNORE --exclude .tmp_versions --exclude=*vmlinux* --exclude=*.o --exclude=*.ko --exclude=*.cmd --exclude=Documentation --exclude=firmware --exclude .config.old --exclude .missing-syscalls.d\"" | |
123 | +echo "tar "'$EXCLUDES'" -cf- . | (cd "'$RPM_BUILD_ROOT'"/usr/src/kernels/$KERNELRELEASE;tar xvf -)" | |
124 | +echo 'cd $RPM_BUILD_ROOT'"/lib/modules/$KERNELRELEASE" | |
125 | +echo "ln -sf /usr/src/kernels/$KERNELRELEASE build" | |
126 | +echo "ln -sf /usr/src/kernels/$KERNELRELEASE source" | |
127 | + | |
111 | 128 | echo "" |
112 | 129 | echo "%clean" |
113 | 130 | echo 'rm -rf $RPM_BUILD_ROOT' |
114 | 131 | echo "" |
132 | +echo "%post" | |
133 | +echo "if [ -x /sbin/installkernel -a -r /boot/vmlinuz-$KERNELRELEASE -a -r /boot/System.map-$KERNELRELEASE ]; then" | |
134 | +echo "cp /boot/vmlinuz-$KERNELRELEASE /boot/vmlinuz-$KERNELRELEASE-rpm" | |
135 | +echo "cp /boot/System.map-$KERNELRELEASE /boot/System.map-$KERNELRELEASE-rpm" | |
136 | +echo "rm -f /boot/vmlinuz-$KERNELRELEASE /boot/System.map-$KERNELRELEASE" | |
137 | +echo "/sbin/installkernel $KERNELRELEASE /boot/vmlinuz-$KERNELRELEASE-rpm /boot/System.map-$KERNELRELEASE-rpm" | |
138 | +echo "rm -f /boot/vmlinuz-$KERNELRELEASE-rpm /boot/System.map-$KERNELRELEASE-rpm" | |
139 | +echo "fi" | |
140 | +echo "" | |
115 | 141 | echo "%files" |
116 | 142 | echo '%defattr (-, root, root)' |
117 | 143 | echo "%dir /lib/modules" |
118 | 144 | echo "/lib/modules/$KERNELRELEASE" |
119 | -echo "/lib/firmware" | |
145 | +echo "%exclude /lib/modules/$KERNELRELEASE/build" | |
146 | +echo "%exclude /lib/modules/$KERNELRELEASE/source" | |
147 | +echo "/lib/firmware/$KERNELRELEASE" | |
120 | 148 | echo "/boot/*" |
121 | 149 | echo "" |
122 | 150 | echo "%files headers" |
123 | 151 | echo '%defattr (-, root, root)' |
124 | 152 | echo "/usr/include" |
153 | +echo "" | |
154 | +echo "%files devel" | |
155 | +echo '%defattr (-, root, root)' | |
156 | +echo "/usr/src/kernels/$KERNELRELEASE" | |
157 | +echo "/lib/modules/$KERNELRELEASE/build" | |
158 | +echo "/lib/modules/$KERNELRELEASE/source" | |
125 | 159 | echo "" |