From 3c9c7a14b6274074cc3af2b83d56a92547188f27 Mon Sep 17 00:00:00 2001 From: Mike Marciniszyn Date: Mon, 24 Jun 2013 10:38:22 -0400 Subject: rpm-pkg: add %post section to create initramfs and grub hooks /sbin/installkernel is used to insure grub hooks are inserted and the initramfs is created on the target system. The invokation installkernel will work with any kernel as long as: - /sbin/installkernel exists - the kernel and sysem map files are readable Signed-off-by: Mike Marciniszyn Signed-off-by: Michal Marek diff --git a/scripts/package/mkspec b/scripts/package/mkspec index fdd3fbf..0aa6a24 100755 --- a/scripts/package/mkspec +++ b/scripts/package/mkspec @@ -112,6 +112,15 @@ echo "" echo "%clean" echo 'rm -rf $RPM_BUILD_ROOT' echo "" +echo "%post" +echo "if [ -x /sbin/installkernel -a -r /boot/vmlinuz-$KERNELRELEASE -a -r /boot/System.map-$KERNELRELEASE ]; then" +echo "cp /boot/vmlinuz-$KERNELRELEASE /boot/vmlinuz-$KERNELRELEASE-rpm" +echo "cp /boot/System.map-$KERNELRELEASE /boot/System.map-$KERNELRELEASE-rpm" +echo "rm -f /boot/vmlinuz-$KERNELRELEASE /boot/System.map-$KERNELRELEASE" +echo "/sbin/installkernel $KERNELRELEASE /boot/vmlinuz-$KERNELRELEASE-rpm /boot/System.map-$KERNELRELEASE-rpm" +echo "rm -f /boot/vmlinuz-$KERNELRELEASE-rpm /boot/System.map-$KERNELRELEASE-rpm" +echo "fi" +echo "" echo "%files" echo '%defattr (-, root, root)' echo "%dir /lib/modules" -- cgit v0.10.2 From 41612378da980cd98a0191c1307ff62d4ee20fb8 Mon Sep 17 00:00:00 2001 From: Mike Marciniszyn Date: Mon, 24 Jun 2013 10:38:28 -0400 Subject: rpm-pkg: install firmware files in kernel relative directory Prior to this patch, firmware files were being installed in /lib/firmware with a potential conflict with already installed kernels. firmware files are now installed in /lib/firmware/ and packaged with the rest of the modules. Signed-off-by: Mike Marciniszyn Signed-off-by: Michal Marek diff --git a/scripts/package/mkspec b/scripts/package/mkspec index 0aa6a24..514aeb2 100755 --- a/scripts/package/mkspec +++ b/scripts/package/mkspec @@ -77,13 +77,14 @@ echo "%install" echo 'KBUILD_IMAGE=$(make image_name)' echo "%ifarch ia64" echo 'mkdir -p $RPM_BUILD_ROOT/boot/efi $RPM_BUILD_ROOT/lib/modules' -echo 'mkdir -p $RPM_BUILD_ROOT/lib/firmware' echo "%else" echo 'mkdir -p $RPM_BUILD_ROOT/boot $RPM_BUILD_ROOT/lib/modules' -echo 'mkdir -p $RPM_BUILD_ROOT/lib/firmware' echo "%endif" +echo 'mkdir -p $RPM_BUILD_ROOT'"/lib/firmware/$KERNELRELEASE" -echo 'INSTALL_MOD_PATH=$RPM_BUILD_ROOT make %{?_smp_mflags} KBUILD_SRC= modules_install' +echo 'INSTALL_MOD_PATH=$RPM_BUILD_ROOT make %{?_smp_mflags} KBUILD_SRC= mod-fw= modules_install' +echo 'INSTALL_FW_PATH=$RPM_BUILD_ROOT'"/lib/firmware/$KERNELRELEASE" +echo 'make INSTALL_FW_PATH=$INSTALL_FW_PATH' firmware_install echo "%ifarch ia64" echo 'cp $KBUILD_IMAGE $RPM_BUILD_ROOT'"/boot/efi/vmlinuz-$KERNELRELEASE" echo 'ln -s '"efi/vmlinuz-$KERNELRELEASE" '$RPM_BUILD_ROOT'"/boot/" @@ -125,7 +126,7 @@ echo "%files" echo '%defattr (-, root, root)' echo "%dir /lib/modules" echo "/lib/modules/$KERNELRELEASE" -echo "/lib/firmware" +echo "/lib/firmware/$KERNELRELEASE" echo "/boot/*" echo "" echo "%files headers" -- cgit v0.10.2 From 2174d2920151a572df7c9da2946afbc3f84e3191 Mon Sep 17 00:00:00 2001 From: Mike Marciniszyn Date: Mon, 8 Jul 2013 13:14:06 -0400 Subject: rpm-pkg: add generation of kernel-devel Change the spec file to generate a kernel-devel module allowing for compilation of external kernel modules. This patch requires a new minimum RPM level of 4.0.3. Signed-off-by: Mike Marciniszyn Signed-off-by: Michal Marek diff --git a/scripts/package/mkspec b/scripts/package/mkspec index 514aeb2..1395760 100755 --- a/scripts/package/mkspec +++ b/scripts/package/mkspec @@ -1,7 +1,7 @@ #!/bin/sh # -# Output a simple RPM spec file that uses no fancy features requiring -# RPM v4. This is intended to work with any RPM distro. +# Output a simple RPM spec file. +# This version assumes a minimum of RPM 4.0.3. # # The only gothic bit here is redefining install_post to avoid # stripping the symbols from files in the kernel which we want @@ -59,6 +59,14 @@ echo "header files define structures and constants that are needed for" echo "building most standard programs and are also needed for rebuilding the" echo "glibc package." echo "" +echo "%package devel" +echo "Summary: Development package for building kernel modules to match the $__KERNELRELEASE kernel" +echo "Group: System Environment/Kernel" +echo "AutoReqProv: no" +echo "%description -n kernel-devel" +echo "This package provides kernel headers and makefiles sufficient to build modules" +echo "against the $__KERNELRELEASE kernel package." +echo "" if ! $PREBUILT; then echo "%prep" @@ -109,6 +117,14 @@ echo 'mv vmlinux.bz2 $RPM_BUILD_ROOT'"/boot/vmlinux-$KERNELRELEASE.bz2" echo 'mv vmlinux.orig vmlinux' echo "%endif" +echo 'rm -f $RPM_BUILD_ROOT'"/lib/modules/$KERNELRELEASE/{build,source}" +echo "mkdir -p "'$RPM_BUILD_ROOT'"/usr/src/kernels/$KERNELRELEASE" +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\"" +echo "tar "'$EXCLUDES'" -cf- . | (cd "'$RPM_BUILD_ROOT'"/usr/src/kernels/$KERNELRELEASE;tar xvf -)" +echo 'cd $RPM_BUILD_ROOT'"/lib/modules/$KERNELRELEASE" +echo "ln -sf /usr/src/kernels/$KERNELRELEASE build" +echo "ln -sf /usr/src/kernels/$KERNELRELEASE source" + echo "" echo "%clean" echo 'rm -rf $RPM_BUILD_ROOT' @@ -126,6 +142,8 @@ echo "%files" echo '%defattr (-, root, root)' echo "%dir /lib/modules" echo "/lib/modules/$KERNELRELEASE" +echo "%exclude /lib/modules/$KERNELRELEASE/build" +echo "%exclude /lib/modules/$KERNELRELEASE/source" echo "/lib/firmware/$KERNELRELEASE" echo "/boot/*" echo "" @@ -133,3 +151,9 @@ echo "%files headers" echo '%defattr (-, root, root)' echo "/usr/include" echo "" +echo "%files devel" +echo '%defattr (-, root, root)' +echo "/usr/src/kernels/$KERNELRELEASE" +echo "/lib/modules/$KERNELRELEASE/build" +echo "/lib/modules/$KERNELRELEASE/source" +echo "" -- cgit v0.10.2 From d20917670ee1fd4b090555e551faea04b014ca97 Mon Sep 17 00:00:00 2001 From: Anisse Astier Date: Wed, 3 Jul 2013 16:02:03 +0200 Subject: deb-pkg: use KCONFIG_CONFIG instead of .config file directly Signed-off-by: Anisse Astier Reviewed-by: Ben Hutchings Signed-off-by: Michal Marek diff --git a/scripts/package/builddeb b/scripts/package/builddeb index acb8650..a8662ef 100644 --- a/scripts/package/builddeb +++ b/scripts/package/builddeb @@ -41,9 +41,9 @@ create_package() { parisc*) debarch=hppa ;; mips*) - debarch=mips$(grep -q CPU_LITTLE_ENDIAN=y .config && echo el) ;; + debarch=mips$(grep -q CPU_LITTLE_ENDIAN=y $KCONFIG_CONFIG && echo el) ;; arm*) - debarch=arm$(grep -q CONFIG_AEABI=y .config && echo el) ;; + debarch=arm$(grep -q CONFIG_AEABI=y $KCONFIG_CONFIG && echo el) ;; *) echo "" >&2 echo "** ** ** WARNING ** ** **" >&2 @@ -106,12 +106,12 @@ fi if [ "$ARCH" = "um" ] ; then $MAKE linux cp System.map "$tmpdir/usr/lib/uml/modules/$version/System.map" - cp .config "$tmpdir/usr/share/doc/$packagename/config" + cp $KCONFIG_CONFIG "$tmpdir/usr/share/doc/$packagename/config" gzip "$tmpdir/usr/share/doc/$packagename/config" cp $KBUILD_IMAGE "$tmpdir/usr/bin/linux-$version" else cp System.map "$tmpdir/boot/System.map-$version" - cp .config "$tmpdir/boot/config-$version" + cp $KCONFIG_CONFIG "$tmpdir/boot/config-$version" # Not all arches include the boot path in KBUILD_IMAGE if [ -e $KBUILD_IMAGE ]; then cp $KBUILD_IMAGE "$tmpdir/boot/vmlinuz-$version" @@ -120,7 +120,7 @@ else fi fi -if grep -q '^CONFIG_MODULES=y' .config ; then +if grep -q '^CONFIG_MODULES=y' $KCONFIG_CONFIG ; then INSTALL_MOD_PATH="$tmpdir" $MAKE KBUILD_SRC= modules_install rm -f "$tmpdir/lib/modules/$version/build" rm -f "$tmpdir/lib/modules/$version/source" @@ -245,11 +245,12 @@ fi # Build header package (cd $srctree; find . -name Makefile\* -o -name Kconfig\* -o -name \*.pl > "$objtree/debian/hdrsrcfiles") (cd $srctree; find arch/$SRCARCH/include include scripts -type f >> "$objtree/debian/hdrsrcfiles") -(cd $objtree; find arch/$SRCARCH/include .config Module.symvers include scripts -type f >> "$objtree/debian/hdrobjfiles") +(cd $objtree; find arch/$SRCARCH/include Module.symvers include scripts -type f >> "$objtree/debian/hdrobjfiles") destdir=$kernel_headers_dir/usr/src/linux-headers-$version mkdir -p "$destdir" (cd $srctree; tar -c -f - -T "$objtree/debian/hdrsrcfiles") | (cd $destdir; tar -xf -) (cd $objtree; tar -c -f - -T "$objtree/debian/hdrobjfiles") | (cd $destdir; tar -xf -) +(cd $objtree; cp $KCONFIG_CONFIG $destdir/.config) # copy .config manually to be where it's expected to be ln -sf "/usr/src/linux-headers-$version" "$kernel_headers_dir/lib/modules/$version/build" rm -f "$objtree/debian/hdrsrcfiles" "$objtree/debian/hdrobjfiles" arch=$(dpkg --print-architecture) -- cgit v0.10.2 From 810e843746b7297819b0a76b6c105b9bda01fd9c Mon Sep 17 00:00:00 2001 From: Anisse Astier Date: Wed, 3 Jul 2013 16:02:04 +0200 Subject: deb-pkg: split debug symbols in their own package This can reduce almost 3 times the size of the linux-image package, while keeping the debug symbols available for this particular build, in their own package. This mimics the way kernels are built in debian, ubuntu, or with make-kpkg, and comes at the price of a small slowdown in the building of packages. Signed-off-by: Anisse Astier Cc: Ben Hutchings Acked-by: maximilian attems Signed-off-by: Michal Marek diff --git a/scripts/package/builddeb b/scripts/package/builddeb index a8662ef..541a1cf 100644 --- a/scripts/package/builddeb +++ b/scripts/package/builddeb @@ -78,17 +78,21 @@ tmpdir="$objtree/debian/tmp" fwdir="$objtree/debian/fwtmp" kernel_headers_dir="$objtree/debian/hdrtmp" libc_headers_dir="$objtree/debian/headertmp" +dbg_dir="$objtree/debian/dbgtmp" packagename=linux-image-$version fwpackagename=linux-firmware-image kernel_headers_packagename=linux-headers-$version libc_headers_packagename=linux-libc-dev +dbg_packagename=$packagename-dbg if [ "$ARCH" = "um" ] ; then packagename=user-mode-linux-$version fi +BUILD_DEBUG="$(grep -s '^CONFIG_DEBUG_INFO=y' $KCONFIG_CONFIG || true)" + # Setup the directory structure -rm -rf "$tmpdir" "$fwdir" "$kernel_headers_dir" "$libc_headers_dir" +rm -rf "$tmpdir" "$fwdir" "$kernel_headers_dir" "$libc_headers_dir" "$dbg_dir" mkdir -m 755 -p "$tmpdir/DEBIAN" mkdir -p "$tmpdir/lib" "$tmpdir/boot" "$tmpdir/usr/share/doc/$packagename" mkdir -m 755 -p "$fwdir/DEBIAN" @@ -101,6 +105,10 @@ mkdir -p "$kernel_headers_dir/lib/modules/$version/" if [ "$ARCH" = "um" ] ; then mkdir -p "$tmpdir/usr/lib/uml/modules/$version" "$tmpdir/usr/bin" fi +if [ -n "$BUILD_DEBUG" ] ; then + mkdir -p "$dbg_dir/usr/share/doc/$dbg_packagename" + mkdir -m 755 -p "$dbg_dir/DEBIAN" +fi # Build and install the kernel if [ "$ARCH" = "um" ] ; then @@ -128,6 +136,20 @@ if grep -q '^CONFIG_MODULES=y' $KCONFIG_CONFIG ; then mv "$tmpdir/lib/modules/$version"/* "$tmpdir/usr/lib/uml/modules/$version/" rmdir "$tmpdir/lib/modules/$version" fi + if [ -n "$BUILD_DEBUG" ] ; then + ( + cd $tmpdir + for module in $(find lib/modules/ -name *.ko); do + mkdir -p $(dirname $dbg_dir/usr/lib/debug/$module) + # only keep debug symbols in the debug file + objcopy --only-keep-debug $module $dbg_dir/usr/lib/debug/$module + # strip original module from debug symbols + objcopy --strip-debug $module + # then add a link to those + objcopy --add-gnu-debuglink=$dbg_dir/usr/lib/debug/$module $module + done + ) + fi fi if [ "$ARCH" != "um" ]; then @@ -300,4 +322,30 @@ fi create_package "$packagename" "$tmpdir" +if [ -n "$BUILD_DEBUG" ] ; then + # Build debug package + # Different tools want the image in different locations + # perf + mkdir -p $dbg_dir/usr/lib/debug/lib/modules/$version/ + cp vmlinux $dbg_dir/usr/lib/debug/lib/modules/$version/ + # systemtap + mkdir -p $dbg_dir/usr/lib/debug/boot/ + ln -s ../lib/modules/$version/vmlinux $dbg_dir/usr/lib/debug/boot/vmlinux-$version + # kdump-tools + ln -s lib/modules/$version/vmlinux $dbg_dir/usr/lib/debug/vmlinux-$version + + cat <> debian/control + +Package: $dbg_packagename +Section: debug +Provides: linux-debug, linux-debug-$version +Architecture: any +Description: Linux kernel debugging symbols for $version + This package will come in handy if you need to debug the kernel. It provides + all the necessary debug symbols for the kernel and its modules. +EOF + + create_package "$dbg_packagename" "$dbg_dir" +fi + exit 0 -- cgit v0.10.2 From 9de7017644ceda33bec10b6bd564c2bc8120c3fc Mon Sep 17 00:00:00 2001 From: Anisse Astier Date: Wed, 3 Jul 2013 16:02:05 +0200 Subject: deb-pkg: fix installed image path on parisc, mips and powerpc Signed-off-by: Anisse Astier Reviewed-by: Ben Hutchings Signed-off-by: Michal Marek diff --git a/scripts/package/builddeb b/scripts/package/builddeb index 541a1cf..aebc66e 100644 --- a/scripts/package/builddeb +++ b/scripts/package/builddeb @@ -89,6 +89,20 @@ if [ "$ARCH" = "um" ] ; then packagename=user-mode-linux-$version fi +# Not all arches have the same installed path in debian +# XXX: have each arch Makefile export a variable of the canonical image install +# path instead +case $ARCH in +um) + installed_image_path="usr/bin/linux-$version" + ;; +parisc|mips|powerpc) + installed_image_path="boot/vmlinux-$version" + ;; +*) + installed_image_path="boot/vmlinuz-$version" +esac + BUILD_DEBUG="$(grep -s '^CONFIG_DEBUG_INFO=y' $KCONFIG_CONFIG || true)" # Setup the directory structure @@ -116,16 +130,15 @@ if [ "$ARCH" = "um" ] ; then cp System.map "$tmpdir/usr/lib/uml/modules/$version/System.map" cp $KCONFIG_CONFIG "$tmpdir/usr/share/doc/$packagename/config" gzip "$tmpdir/usr/share/doc/$packagename/config" - cp $KBUILD_IMAGE "$tmpdir/usr/bin/linux-$version" else cp System.map "$tmpdir/boot/System.map-$version" cp $KCONFIG_CONFIG "$tmpdir/boot/config-$version" - # Not all arches include the boot path in KBUILD_IMAGE - if [ -e $KBUILD_IMAGE ]; then - cp $KBUILD_IMAGE "$tmpdir/boot/vmlinuz-$version" - else - cp arch/$ARCH/boot/$KBUILD_IMAGE "$tmpdir/boot/vmlinuz-$version" - fi +fi +# Not all arches include the boot path in KBUILD_IMAGE +if [ -e $KBUILD_IMAGE ]; then + cp $KBUILD_IMAGE "$tmpdir/$installed_image_path" +else + cp arch/$ARCH/boot/$KBUILD_IMAGE "$tmpdir/$installed_image_path" fi if grep -q '^CONFIG_MODULES=y' $KCONFIG_CONFIG ; then -- cgit v0.10.2 From c95182bf9bd2df55739b187df8e972cb6cbee895 Mon Sep 17 00:00:00 2001 From: Anisse Astier Date: Wed, 3 Jul 2013 16:02:06 +0200 Subject: deb-pkg: add a hook argument to match debian hooks parameters We now provide the installed image path to the kernel hooks. This should allow the package to better integrate with debian hooks, and should not be too disruptive of hooks supporting only one parameter. Signed-off-by: Anisse Astier Reviewed-by: Ben Hutchings Acked-by: maximilian attems Signed-off-by: Michal Marek diff --git a/scripts/package/builddeb b/scripts/package/builddeb index aebc66e..de89923 100644 --- a/scripts/package/builddeb +++ b/scripts/package/builddeb @@ -184,7 +184,7 @@ set -e # Pass maintainer script parameters to hook scripts export DEB_MAINT_PARAMS="\$*" -test -d $debhookdir/$script.d && run-parts --arg="$version" $debhookdir/$script.d +test -d $debhookdir/$script.d && run-parts --arg="$version" --arg="/$installed_image_path" $debhookdir/$script.d exit 0 EOF chmod 755 "$tmpdir/DEBIAN/$script" -- cgit v0.10.2 From 46b5c9b856e8bcb44d8570cc55c46d19ca2428ff Mon Sep 17 00:00:00 2001 From: Rasmus Villemoes Date: Sun, 11 Aug 2013 21:05:12 +0000 Subject: coccinelle: replace 0/1 with false/true in functions returning bool This semantic patch replaces "return {0,1};" with "return {false,true};" in functions returning bool. Signed-off-by: Rasmus Villemoes Acked-by: Julia Lawall Signed-off-by: Michal Marek diff --git a/scripts/coccinelle/misc/boolreturn.cocci b/scripts/coccinelle/misc/boolreturn.cocci new file mode 100644 index 0000000..a43c7b0 --- /dev/null +++ b/scripts/coccinelle/misc/boolreturn.cocci @@ -0,0 +1,58 @@ +/// Return statements in functions returning bool should use +/// true/false instead of 1/0. +// +// Confidence: High +// Options: --no-includes --include-headers + +virtual patch +virtual report +virtual context + +@r1 depends on patch@ +identifier fn; +typedef bool; +symbol false; +symbol true; +@@ + +bool fn ( ... ) +{ +<... +return +( +- 0 ++ false +| +- 1 ++ true +) + ; +...> +} + +@r2 depends on report || context@ +identifier fn; +position p; +@@ + +bool fn ( ... ) +{ +<... +return +( +* 0@p +| +* 1@p +) + ; +...> +} + + +@script:python depends on report@ +p << r2.p; +fn << r2.fn; +@@ + +msg = "WARNING: return of 0/1 in function '%s' with return type bool" % fn +coccilib.report.print_report(p[0], msg) -- cgit v0.10.2 From 95e2a7d80779850341b45b4fbc2a0041bfc378fb Mon Sep 17 00:00:00 2001 From: Heinrich Schuchardt Date: Sun, 11 Aug 2013 21:55:19 +0200 Subject: Provide version number for Debian firmware package scripts/package/builddeb is used to create Debian packages. Currently the firmware package always gets the same version number irrespective of the Kernel version. The paths inside the firmware package depend on the Kernel version. With the patch supplied the Kernel version becomes part of the Debian firmware package number. Signed-off-by: Heinrich Schuchardt Cc: Ben Hutchings Acked-by: maximilian attems Signed-off-by: Michal Marek diff --git a/scripts/package/builddeb b/scripts/package/builddeb index de89923..90e521f 100644 --- a/scripts/package/builddeb +++ b/scripts/package/builddeb @@ -80,7 +80,7 @@ kernel_headers_dir="$objtree/debian/hdrtmp" libc_headers_dir="$objtree/debian/headertmp" dbg_dir="$objtree/debian/dbgtmp" packagename=linux-image-$version -fwpackagename=linux-firmware-image +fwpackagename=linux-firmware-image-$version kernel_headers_packagename=linux-headers-$version libc_headers_packagename=linux-libc-dev dbg_packagename=$packagename-dbg -- cgit v0.10.2 From 36b5401b7669302bc4c35cea2e2cf4ae22e489dc Mon Sep 17 00:00:00 2001 From: Max Filippov Date: Fri, 23 Aug 2013 00:25:24 +0400 Subject: scripts/checkkconfigsymbols.sh: replace echo -e with printf -e is a non-standard echo option, echo output is implementation-dependent when it is used. Replace echo -e with printf as suggested by POSIX echo manual. Signed-off-by: Max Filippov Signed-off-by: Michal Marek diff --git a/scripts/checkkconfigsymbols.sh b/scripts/checkkconfigsymbols.sh index 2ca49bb..ccb3391 100755 --- a/scripts/checkkconfigsymbols.sh +++ b/scripts/checkkconfigsymbols.sh @@ -9,7 +9,7 @@ paths="$@" # Doing this once at the beginning saves a lot of time, on a cache-hot tree. Kconfigs="`find . -name 'Kconfig' -o -name 'Kconfig*[^~]'`" -/bin/echo -e "File list \tundefined symbol used" +printf "File list \tundefined symbol used\n" find $paths -name '*.[chS]' -o -name 'Makefile' -o -name 'Makefile*[^~]'| while read i do # Output the bare Kconfig variable and the filename; the _MODULE part at @@ -54,6 +54,6 @@ while read symb files; do # beyond the purpose of this script. symb_bare=`echo $symb | sed -e 's/_MODULE//'` if ! grep -q "\<$symb_bare\>" $Kconfigs; then - /bin/echo -e "$files: \t$symb" + printf "$files: \t$symb\n" fi done|sort -- cgit v0.10.2