Kbuild misc updates for v4.15

- Clean up and fix RPM package build
 
 - Fix a warning in DEB package build
 
 - Improve coccicheck script
 
 - Improve some semantic patches
 -----BEGIN PGP SIGNATURE-----
 Version: GnuPG v1
 
 iQIcBAABAgAGBQJaDxwTAAoJED2LAQed4NsGtJAQAK1VnxVqcGznoy0CXg7vA93D
 iIstHN1AR1uFJgTEFU7PwKDd7zJ78R1lN0BeZat70RS4pv8YMvCFpjPajMbF0KHz
 zjRARuy+MKbWQVBGg7BjFaFcQqLrYLasIfp3nXDOBoyTxvaqvV/4HtyKISxYnY1n
 3vSoVm/JacwT9KZ3496eV8hZcO2pbpo4PvT5T/WGKzHCnHRjv40kCMj8a+BDLWWD
 LJ5CHXQRmzMTBR8J7OMVbaUl8JgJb/Gl6yAKnfNXVqaxzSMunWMC0cUEXjJ3kxEf
 wmthF99p4Og8Fe+eT5yUzODwPdH/JDqULaMKo1BSuQbB0ck0BRavlRvvTlv7ptKk
 5eoHoxop0GCNgsbhcXhpTQTDLqkGBtLVUD6pjUVGF5mtHIJ1m4GnNJ+4+cf453lr
 szhg0mOATydkOTQYg1oeWACXfoagbSieQQsQx5LIX3HTx3I+RW9FGEB7TltEGuoL
 cE+ijhIZZmFo7wHjcdW2FPV0A+qRYRPW//O2t7Zu/S/uRkrgTmpvIKPtoAfj7y+4
 c74LcsWyVB1TCMtbc2oJUyY6ltDuwTEA9i/FCr+GgaG3OHbmw7YEYewbhV9m4+Yr
 t3jNwJ+6TuxWX23RQPFgalAlf8XMr5MM0cF89Io0BZEIaoWWIGw1YiMxzL0Su61h
 eauy22XUBzZ2ewkcuq3v
 =7aYW
 -----END PGP SIGNATURE-----

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
This commit is contained in:
Linus Torvalds 2017-11-17 17:51:33 -08:00
commit 2ce079f04d
12 changed files with 450 additions and 212 deletions

5
.gitignore vendored
View File

@ -55,6 +55,11 @@ modules.builtin
/System.map /System.map
/Module.markers /Module.markers
#
# RPM spec file (make rpm-pkg)
#
/*.spec
# #
# Debian directory (make deb-pkg) # Debian directory (make deb-pkg)
# #

View File

@ -33,9 +33,6 @@ of many distributions, e.g. :
You can get the latest version released from the Coccinelle homepage at You can get the latest version released from the Coccinelle homepage at
http://coccinelle.lip6.fr/ http://coccinelle.lip6.fr/
Information and tips about Coccinelle are also provided on the wiki
pages at http://cocci.ekstranet.diku.dk/wiki/doku.php
Once you have it, run the following command:: Once you have it, run the following command::
./configure ./configure

View File

@ -123,15 +123,8 @@ run_cmd_parmap() {
if [ $VERBOSE -ne 0 ] ; then if [ $VERBOSE -ne 0 ] ; then
echo "Running ($NPROC in parallel): $@" echo "Running ($NPROC in parallel): $@"
fi fi
if [ "$DEBUG_FILE" != "/dev/null" -a "$DEBUG_FILE" != "" ]; then echo $@ >>$DEBUG_FILE
if [ -f $DEBUG_FILE ]; then $@ 2>>$DEBUG_FILE
echo "Debug file $DEBUG_FILE exists, bailing"
exit
fi
else
DEBUG_FILE="/dev/null"
fi
$@ 2>$DEBUG_FILE
if [[ $? -ne 0 ]]; then if [[ $? -ne 0 ]]; then
echo "coccicheck failed" echo "coccicheck failed"
exit $? exit $?
@ -176,8 +169,8 @@ OPTIONS="$OPTIONS $SPFLAGS"
coccinelle () { coccinelle () {
COCCI="$1" COCCI="$1"
OPT=`grep "Option" $COCCI | cut -d':' -f2` OPT=`grep "Options:" $COCCI | cut -d':' -f2`
REQ=`grep "Requires" $COCCI | cut -d':' -f2 | sed "s| ||"` REQ=`grep "Requires:" $COCCI | cut -d':' -f2 | sed "s| ||"`
REQ_NUM=$(echo $REQ | ${DIR}/scripts/ld-version.sh) REQ_NUM=$(echo $REQ | ${DIR}/scripts/ld-version.sh)
if [ "$REQ_NUM" != "0" ] ; then if [ "$REQ_NUM" != "0" ] ; then
if [ "$SPATCH_VERSION_NUM" -lt "$REQ_NUM" ] ; then if [ "$SPATCH_VERSION_NUM" -lt "$REQ_NUM" ] ; then
@ -194,7 +187,7 @@ coccinelle () {
if [ $VERBOSE -ne 0 -a $ONLINE -eq 0 ] ; then if [ $VERBOSE -ne 0 -a $ONLINE -eq 0 ] ; then
FILE=`echo $COCCI | sed "s|$srctree/||"` FILE=${COCCI#$srctree/}
echo "Processing `basename $COCCI`" echo "Processing `basename $COCCI`"
echo "with option(s) \"$OPT\"" echo "with option(s) \"$OPT\""
@ -247,6 +240,15 @@ coccinelle () {
} }
if [ "$DEBUG_FILE" != "/dev/null" -a "$DEBUG_FILE" != "" ]; then
if [ -f $DEBUG_FILE ]; then
echo "Debug file $DEBUG_FILE exists, bailing"
exit
fi
else
DEBUG_FILE="/dev/null"
fi
if [ "$COCCI" = "" ] ; then if [ "$COCCI" = "" ] ; then
for f in `find $srctree/scripts/coccinelle/ -name '*.cocci' -type f | sort`; do for f in `find $srctree/scripts/coccinelle/ -name '*.cocci' -type f | sort`; do
coccinelle $f coccinelle $f

View File

@ -0,0 +1,161 @@
/// Detect BQ27XXX_DATA structures with identical registers, dm registers or
/// properties.
//# Doesn't unfold macros used in register or property fields.
//# Requires OCaml scripting
///
// Confidence: High
// Copyright: (C) 2017 Julia Lawall, Inria/LIP6, GPLv2.
// URL: http://coccinelle.lip6.fr/
// Requires: 1.0.7
// Keywords: BQ27XXX_DATA
virtual report
@initialize:ocaml@
@@
let print_report p msg =
let p = List.hd p in
Printf.printf "%s:%d:%d-%d: %s" p.file p.line p.col p.col_end msg
@str depends on report@
type t;
identifier i,i1,i2;
expression e1,e2;
@@
t i[] = {
...,
[e1] = BQ27XXX_DATA(i1,...),
...,
[e2] = BQ27XXX_DATA(i2,...),
...,
};
@script:ocaml tocheck@
i1 << str.i1;
i2 << str.i2;
i1regs; i2regs;
i1dmregs; i2dmregs;
i1props; i2props;
@@
if not(i1 = i2)
then
begin
i1regs := make_ident (i1 ^ "_regs");
i2regs := make_ident (i2 ^ "_regs");
i1dmregs := make_ident (i1 ^ "_dm_regs");
i2dmregs := make_ident (i2 ^ "_dm_regs");
i1props := make_ident (i1 ^ "_props");
i2props := make_ident (i2 ^ "_props")
end
(* ---------------------------------------------------------------- *)
@getregs1@
typedef u8;
identifier tocheck.i1regs;
initializer list i1regs_vals;
position p1;
@@
u8 i1regs@p1[...] = { i1regs_vals, };
@getregs2@
identifier tocheck.i2regs;
initializer list i2regs_vals;
position p2;
@@
u8 i2regs@p2[...] = { i2regs_vals, };
@script:ocaml@
(_,i1regs_vals) << getregs1.i1regs_vals;
(_,i2regs_vals) << getregs2.i2regs_vals;
i1regs << tocheck.i1regs;
i2regs << tocheck.i2regs;
p1 << getregs1.p1;
p2 << getregs2.p2;
@@
if i1regs < i2regs &&
List.sort compare i1regs_vals = List.sort compare i2regs_vals
then
let msg =
Printf.sprintf
"WARNING %s and %s (line %d) are identical\n"
i1regs i2regs (List.hd p2).line in
print_report p1 msg
(* ---------------------------------------------------------------- *)
@getdmregs1@
identifier tocheck.i1dmregs;
initializer list i1dmregs_vals;
position p1;
@@
struct bq27xxx_dm_reg i1dmregs@p1[] = { i1dmregs_vals, };
@getdmregs2@
identifier tocheck.i2dmregs;
initializer list i2dmregs_vals;
position p2;
@@
struct bq27xxx_dm_reg i2dmregs@p2[] = { i2dmregs_vals, };
@script:ocaml@
(_,i1dmregs_vals) << getdmregs1.i1dmregs_vals;
(_,i2dmregs_vals) << getdmregs2.i2dmregs_vals;
i1dmregs << tocheck.i1dmregs;
i2dmregs << tocheck.i2dmregs;
p1 << getdmregs1.p1;
p2 << getdmregs2.p2;
@@
if i1dmregs < i2dmregs &&
List.sort compare i1dmregs_vals = List.sort compare i2dmregs_vals
then
let msg =
Printf.sprintf
"WARNING %s and %s (line %d) are identical\n"
i1dmregs i2dmregs (List.hd p2).line in
print_report p1 msg
(* ---------------------------------------------------------------- *)
@getprops1@
identifier tocheck.i1props;
initializer list[n1] i1props_vals;
position p1;
@@
enum power_supply_property i1props@p1[] = { i1props_vals, };
@getprops2@
identifier tocheck.i2props;
initializer list[n2] i2props_vals;
position p2;
@@
enum power_supply_property i2props@p2[] = { i2props_vals, };
@script:ocaml@
(_,i1props_vals) << getprops1.i1props_vals;
(_,i2props_vals) << getprops2.i2props_vals;
i1props << tocheck.i1props;
i2props << tocheck.i2props;
p1 << getprops1.p1;
p2 << getprops2.p2;
@@
if i1props < i2props &&
List.sort compare i1props_vals = List.sort compare i2props_vals
then
let msg =
Printf.sprintf
"WARNING %s and %s (line %d) are identical\n"
i1props i2props (List.hd p2).line in
print_report p1 msg

View File

@ -2,6 +2,7 @@
/// and data fields /// and data fields
// Confidence: High // Confidence: High
// Copyright: (C) 2016 Vaishali Thakkar, Oracle. GPLv2 // Copyright: (C) 2016 Vaishali Thakkar, Oracle. GPLv2
// Copyright: (C) 2017 Kees Cook, Google. GPLv2
// Options: --no-includes --include-headers // Options: --no-includes --include-headers
// Keywords: init_timer, setup_timer // Keywords: init_timer, setup_timer
@ -10,60 +11,123 @@ virtual context
virtual org virtual org
virtual report virtual report
// Match the common cases first to avoid Coccinelle parsing loops with
// "... when" clauses.
@match_immediate_function_data_after_init_timer @match_immediate_function_data_after_init_timer
depends on patch && !context && !org && !report@ depends on patch && !context && !org && !report@
expression e, func, da; expression e, func, da;
@@ @@
-init_timer (&e); -init_timer
+setup_timer (&e, func, da); +setup_timer
( \(&e\|e\)
+, func, da
);
(
-\(e.function\|e->function\) = func;
-\(e.data\|e->data\) = da;
|
-\(e.data\|e->data\) = da;
-\(e.function\|e->function\) = func;
)
@match_immediate_function_data_before_init_timer
depends on patch && !context && !org && !report@
expression e, func, da;
@@
( (
-e.function = func; -\(e.function\|e->function\) = func;
-e.data = da; -\(e.data\|e->data\) = da;
| |
-e.data = da; -\(e.data\|e->data\) = da;
-e.function = func; -\(e.function\|e->function\) = func;
) )
-init_timer
+setup_timer
( \(&e\|e\)
+, func, da
);
@match_function_and_data_after_init_timer @match_function_and_data_after_init_timer
depends on patch && !context && !org && !report@ depends on patch && !context && !org && !report@
expression e1, e2, e3, e4, e5, a, b; expression e, e2, e3, e4, e5, func, da;
@@ @@
-init_timer (&e1); -init_timer
+setup_timer (&e1, a, b); +setup_timer
( \(&e\|e\)
... when != a = e2 +, func, da
when != b = e3 );
... when != func = e2
when != da = e3
( (
-e1.function = a; -e.function = func;
... when != b = e4 ... when != da = e4
-e1.data = b; -e.data = da;
| |
-e1.data = b; -e->function = func;
... when != a = e5 ... when != da = e4
-e1.function = a; -e->data = da;
|
-e.data = da;
... when != func = e5
-e.function = func;
|
-e->data = da;
... when != func = e5
-e->function = func;
) )
@match_function_and_data_before_init_timer
depends on patch && !context && !org && !report@
expression e, e2, e3, e4, e5, func, da;
@@
(
-e.function = func;
... when != da = e4
-e.data = da;
|
-e->function = func;
... when != da = e4
-e->data = da;
|
-e.data = da;
... when != func = e5
-e.function = func;
|
-e->data = da;
... when != func = e5
-e->function = func;
)
... when != func = e2
when != da = e3
-init_timer
+setup_timer
( \(&e\|e\)
+, func, da
);
@r1 exists@ @r1 exists@
expression t;
identifier f; identifier f;
position p; position p;
@@ @@
f(...) { ... when any f(...) { ... when any
init_timer@p(...) init_timer@p(\(&t\|t\))
... when any ... when any
} }
@r2 exists@ @r2 exists@
expression r1.t;
identifier g != r1.f; identifier g != r1.f;
struct timer_list t;
expression e8; expression e8;
@@ @@
g(...) { ... when any g(...) { ... when any
t.data = e8 \(t.data\|t->data\) = e8
... when any ... when any
} }
@ -77,14 +141,31 @@ p << r1.p;
cocci.include_match(False) cocci.include_match(False)
@r3 depends on patch && !context && !org && !report@ @r3 depends on patch && !context && !org && !report@
expression e6, e7, c; expression r1.t, func, e7;
position r1.p; position r1.p;
@@ @@
-init_timer@p (&e6); (
+setup_timer (&e6, c, 0UL); -init_timer@p(&t);
... when != c = e7 +setup_timer(&t, func, 0UL);
-e6.function = c; ... when != func = e7
-t.function = func;
|
-t.function = func;
... when != func = e7
-init_timer@p(&t);
+setup_timer(&t, func, 0UL);
|
-init_timer@p(t);
+setup_timer(t, func, 0UL);
... when != func = e7
-t->function = func;
|
-t->function = func;
... when != func = e7
-init_timer@p(t);
+setup_timer(t, func, 0UL);
)
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
@ -104,11 +185,9 @@ position j0, j1, j2;
) )
@match_function_and_data_after_init_timer_context @match_function_and_data_after_init_timer_context
depends on !patch && depends on !patch && (context || org || report)@
!match_immediate_function_data_after_init_timer_context &&
(context || org || report)@
expression a, b, e1, e2, e3, e4, e5; expression a, b, e1, e2, e3, e4, e5;
position j0, j1, j2; position j0 != match_immediate_function_data_after_init_timer_context.j0,j1,j2;
@@ @@
* init_timer@j0 (&e1); * init_timer@j0 (&e1);
@ -124,13 +203,12 @@ position j0, j1, j2;
* e1@j2.function = a; * e1@j2.function = a;
) )
@r3_context depends on !patch && @r3_context depends on !patch && (context || org || report)@
!match_immediate_function_data_after_init_timer_context &&
!match_function_and_data_after_init_timer_context &&
(context || org || report)@
expression c, e6, e7; expression c, e6, e7;
position r1.p; position r1.p;
position j0, j1; position j0 !=
{match_immediate_function_data_after_init_timer_context.j0,
match_function_and_data_after_init_timer_context.j0}, j1;
@@ @@
* init_timer@j0@p (&e6); * init_timer@j0@p (&e6);

View File

@ -15,7 +15,7 @@ virtual context
virtual org virtual org
virtual report virtual report
@r@ @r exists@
iterator name list_for_each_entry; iterator name list_for_each_entry;
expression x,E; expression x,E;
position p1,p2; position p1,p2;

View File

@ -3,10 +3,10 @@
/// Sometimes, code after an if that is indented is actually intended to be /// Sometimes, code after an if that is indented is actually intended to be
/// part of the if branch. /// part of the if branch.
/// ///
/// This has a high rate of false positives, because Coccinelle's column //# This has a high rate of false positives, because Coccinelle's column
/// calculation does not distinguish between spaces and tabs, so code that //# calculation does not distinguish between spaces and tabs, so code that
/// is not visually aligned may be considered to be in the same column. //# is not visually aligned may be considered to be in the same column.
/// //
// Confidence: Low // Confidence: Low
// Copyright: (C) 2010 Nicolas Palix, DIKU. GPLv2. // Copyright: (C) 2010 Nicolas Palix, DIKU. GPLv2.
// Copyright: (C) 2010 Julia Lawall, DIKU. GPLv2. // Copyright: (C) 2010 Julia Lawall, DIKU. GPLv2.

View File

@ -14,7 +14,19 @@ virtual report
virtual context virtual context
@r@ @r@
constant c; constant c,c1;
identifier i,i1;
position p;
@@
(
c1 + c - 1
|
c1@i1 +@p c@i
)
@s@
constant r.c, r.c1;
identifier i; identifier i;
expression e; expression e;
@@ @@
@ -27,28 +39,31 @@ e & c@i
e |= c@i e |= c@i
| |
e &= c@i e &= c@i
|
e | c1@i
|
e & c1@i
|
e |= c1@i
|
e &= c1@i
) )
@s@ @depends on s@
constant r.c,c1; position r.p;
identifier i1; constant c1,c2;
position p;
@@ @@
( * c1 +@p c2
c1 + c - 1
|
*c1@i1 +@p c
)
@script:python depends on org@ @script:python depends on s && org@
p << s.p; p << r.p;
@@ @@
cocci.print_main("sum of probable bitmasks, consider |",p) cocci.print_main("sum of probable bitmasks, consider |",p)
@script:python depends on report@ @script:python depends on s && report@
p << s.p; p << r.p;
@@ @@
msg = "WARNING: sum of probable bitmasks, consider |" msg = "WARNING: sum of probable bitmasks, consider |"

View File

@ -10,7 +10,7 @@
// Copyright: (C) 2012 Julia Lawall, INRIA/LIP6. GPLv2. // Copyright: (C) 2012 Julia Lawall, INRIA/LIP6. GPLv2.
// Copyright: (C) 2012 Gilles Muller, INRIA/LiP6. GPLv2. // Copyright: (C) 2012 Gilles Muller, INRIA/LiP6. GPLv2.
// URL: http://coccinelle.lip6.fr/ // URL: http://coccinelle.lip6.fr/
// Comments: Requires Coccinelle version 1.0.0-rc20 or later // Requires: 1.0.0
// Options: // Options:
virtual patch virtual patch

View File

@ -50,17 +50,18 @@ rpm-pkg rpm: FORCE
$(MAKE) clean $(MAKE) clean
$(CONFIG_SHELL) $(MKSPEC) >$(objtree)/kernel.spec $(CONFIG_SHELL) $(MKSPEC) >$(objtree)/kernel.spec
$(call cmd,src_tar,$(KERNELPATH),kernel.spec) $(call cmd,src_tar,$(KERNELPATH),kernel.spec)
rpmbuild $(RPMOPTS) --target $(UTS_MACHINE) -ta $(KERNELPATH).tar.gz +rpmbuild $(RPMOPTS) --target $(UTS_MACHINE) -ta $(KERNELPATH).tar.gz \
rm $(KERNELPATH).tar.gz kernel.spec --define='_smp_mflags %{nil}'
# binrpm-pkg # binrpm-pkg
# --------------------------------------------------------------------------- # ---------------------------------------------------------------------------
binrpm-pkg: FORCE binrpm-pkg: FORCE
$(MAKE) KBUILD_SRC= $(MAKE) KBUILD_SRC=
$(CONFIG_SHELL) $(MKSPEC) prebuilt > $(objtree)/binkernel.spec $(CONFIG_SHELL) $(MKSPEC) prebuilt > $(objtree)/binkernel.spec
rpmbuild $(RPMOPTS) --define "_builddir $(objtree)" --target \ +rpmbuild $(RPMOPTS) --define "_builddir $(objtree)" --target \
$(UTS_MACHINE) -bb $(objtree)/binkernel.spec $(UTS_MACHINE) -bb $(objtree)/binkernel.spec
rm binkernel.spec
clean-files += $(objtree)/*.spec
# Deb target # Deb target
# --------------------------------------------------------------------------- # ---------------------------------------------------------------------------

View File

@ -408,9 +408,9 @@ EOF
dpkg-source -cdebian/control -ldebian/changelog --format="3.0 (custom)" --target-format="3.0 (quilt)" \ dpkg-source -cdebian/control -ldebian/changelog --format="3.0 (custom)" --target-format="3.0 (quilt)" \
-b / ../${sourcename}_${version}.orig.tar.gz ../${sourcename}_${packageversion}.debian.tar.gz -b / ../${sourcename}_${version}.orig.tar.gz ../${sourcename}_${packageversion}.debian.tar.gz
mv ${sourcename}_${packageversion}*dsc .. mv ${sourcename}_${packageversion}*dsc ..
dpkg-genchanges > ../${sourcename}_${packageversion}_${debarch}.changes dpkg-genchanges -Vkernel:debarch="${debarch}" > ../${sourcename}_${packageversion}_${debarch}.changes
else else
dpkg-genchanges -b > ../${sourcename}_${packageversion}_${debarch}.changes dpkg-genchanges -b -Vkernel:debarch="${debarch}" > ../${sourcename}_${packageversion}_${debarch}.changes
fi fi
exit 0 exit 0

View File

@ -10,156 +10,135 @@
# #
# how we were called determines which rpms we build and how we build them # how we were called determines which rpms we build and how we build them
if [ "$1" = "prebuilt" ]; then if [ "$1" = prebuilt ]; then
PREBUILT=true S=DEL
else else
PREBUILT=false S=
fi fi
# starting to output the spec if grep -q CONFIG_MODULES=y .config; then
if [ "`grep CONFIG_DRM=y .config | cut -f2 -d\=`" = "y" ]; then M=
else
M=DEL
fi
if grep -q CONFIG_DRM=y .config; then
PROVIDES=kernel-drm PROVIDES=kernel-drm
fi fi
PROVIDES="$PROVIDES kernel-$KERNELRELEASE" PROVIDES="$PROVIDES kernel-$KERNELRELEASE"
__KERNELRELEASE=`echo $KERNELRELEASE | sed -e "s/-/_/g"` __KERNELRELEASE=$(echo $KERNELRELEASE | sed -e "s/-/_/g")
EXCLUDES="$RCS_TAR_IGNORE --exclude=.tmp_versions --exclude=*vmlinux* \
--exclude=*.o --exclude=*.ko --exclude=*.cmd --exclude=Documentation \
--exclude=.config.old --exclude=.missing-syscalls.d"
echo "Name: kernel" # We can label the here-doc lines for conditional output to the spec file
echo "Summary: The Linux Kernel" #
echo "Version: $__KERNELRELEASE" # Labels:
echo "Release: $(cat .version 2>/dev/null || echo 1)" # $S: this line is enabled only when building source package
echo "License: GPL" # $M: this line is enabled only when CONFIG_MODULES is enabled
echo "Group: System Environment/Kernel" sed -e '/^DEL/d' -e 's/^\t*//' <<EOF
echo "Vendor: The Linux Community" Name: kernel
echo "URL: http://www.kernel.org" Summary: The Linux Kernel
Version: $__KERNELRELEASE
Release: $(cat .version 2>/dev/null || echo 1)
License: GPL
Group: System Environment/Kernel
Vendor: The Linux Community
URL: http://www.kernel.org
$S Source: kernel-$__KERNELRELEASE.tar.gz
Provides: $PROVIDES
%define __spec_install_post /usr/lib/rpm/brp-compress || :
%define debug_package %{nil}
if ! $PREBUILT; then %description
echo "Source: kernel-$__KERNELRELEASE.tar.gz" The Linux Kernel, the operating system core itself
fi
echo "BuildRoot: %{_tmppath}/%{name}-%{PACKAGE_VERSION}-root" %package headers
echo "Provides: $PROVIDES" Summary: Header files for the Linux kernel for use by glibc
echo "%define __spec_install_post /usr/lib/rpm/brp-compress || :" Group: Development/System
echo "%define debug_package %{nil}" Obsoletes: kernel-headers
echo "" Provides: kernel-headers = %{version}
echo "%description" %description headers
echo "The Linux Kernel, the operating system core itself" Kernel-headers includes the C header files that specify the interface
echo "" between the Linux kernel and userspace libraries and programs. The
echo "%package headers" header files define structures and constants that are needed for
echo "Summary: Header files for the Linux kernel for use by glibc" building most standard programs and are also needed for rebuilding the
echo "Group: Development/System" glibc package.
echo "Obsoletes: kernel-headers"
echo "Provides: kernel-headers = %{version}"
echo "%description headers"
echo "Kernel-headers includes the C header files that specify the interface"
echo "between the Linux kernel and userspace libraries and programs. The"
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 $S$M %package devel
echo "%prep" $S$M Summary: Development package for building kernel modules to match the $__KERNELRELEASE kernel
echo "%setup -q" $S$M Group: System Environment/Kernel
echo "" $S$M AutoReqProv: no
fi $S$M %description -n kernel-devel
$S$M This package provides kernel headers and makefiles sufficient to build modules
$S$M against the $__KERNELRELEASE kernel package.
$S$M
$S %prep
$S %setup -q
$S
$S %build
$S make %{?_smp_mflags} KBUILD_BUILD_VERSION=%{release}
$S
%install
mkdir -p %{buildroot}/boot
%ifarch ia64
mkdir -p %{buildroot}/boot/efi
cp \$(make image_name) %{buildroot}/boot/efi/vmlinuz-$KERNELRELEASE
ln -s efi/vmlinuz-$KERNELRELEASE %{buildroot}/boot/
%else
cp \$(make image_name) %{buildroot}/boot/vmlinuz-$KERNELRELEASE
%endif
$M make %{?_smp_mflags} INSTALL_MOD_PATH=%{buildroot} KBUILD_SRC= modules_install
make %{?_smp_mflags} INSTALL_HDR_PATH=%{buildroot}/usr KBUILD_SRC= headers_install
cp System.map %{buildroot}/boot/System.map-$KERNELRELEASE
cp .config %{buildroot}/boot/config-$KERNELRELEASE
bzip2 -9 --keep vmlinux
mv vmlinux.bz2 %{buildroot}/boot/vmlinux-$KERNELRELEASE.bz2
$S$M rm -f %{buildroot}/lib/modules/$KERNELRELEASE/build
$S$M rm -f %{buildroot}/lib/modules/$KERNELRELEASE/source
$S$M mkdir -p %{buildroot}/usr/src/kernels/$KERNELRELEASE
$S$M tar cf - . $EXCLUDES | tar xf - -C %{buildroot}/usr/src/kernels/$KERNELRELEASE
$S$M cd %{buildroot}/lib/modules/$KERNELRELEASE
$S$M ln -sf /usr/src/kernels/$KERNELRELEASE build
$S$M ln -sf /usr/src/kernels/$KERNELRELEASE source
echo "%build" %clean
rm -rf %{buildroot}
if ! $PREBUILT; then %post
echo "make clean && make %{?_smp_mflags} KBUILD_BUILD_VERSION=%{release}" 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
fi cp /boot/System.map-$KERNELRELEASE /boot/.System.map-$KERNELRELEASE-rpm
rm -f /boot/vmlinuz-$KERNELRELEASE /boot/System.map-$KERNELRELEASE
/sbin/installkernel $KERNELRELEASE /boot/.vmlinuz-$KERNELRELEASE-rpm /boot/.System.map-$KERNELRELEASE-rpm
rm -f /boot/.vmlinuz-$KERNELRELEASE-rpm /boot/.System.map-$KERNELRELEASE-rpm
fi
echo "%install" %preun
echo 'KBUILD_IMAGE=$(make image_name)' if [ -x /sbin/new-kernel-pkg ]; then
echo "%ifarch ia64" new-kernel-pkg --remove $KERNELRELEASE --rminitrd --initrdfile=/boot/initramfs-$KERNELRELEASE.img
echo 'mkdir -p $RPM_BUILD_ROOT/boot/efi $RPM_BUILD_ROOT/lib/modules' fi
echo "%else"
echo 'mkdir -p $RPM_BUILD_ROOT/boot $RPM_BUILD_ROOT/lib/modules'
echo "%endif"
echo 'INSTALL_MOD_PATH=$RPM_BUILD_ROOT make %{?_smp_mflags} KBUILD_SRC= modules_install' %postun
echo "%ifarch ia64" if [ -x /sbin/update-bootloader ]; then
echo 'cp $KBUILD_IMAGE $RPM_BUILD_ROOT'"/boot/efi/vmlinuz-$KERNELRELEASE" /sbin/update-bootloader --remove $KERNELRELEASE
echo 'ln -s '"efi/vmlinuz-$KERNELRELEASE" '$RPM_BUILD_ROOT'"/boot/" fi
echo "%else"
echo "%ifarch ppc64"
echo "cp vmlinux arch/powerpc/boot"
echo "cp arch/powerpc/boot/"'$KBUILD_IMAGE $RPM_BUILD_ROOT'"/boot/vmlinuz-$KERNELRELEASE"
echo "%else"
echo 'cp $KBUILD_IMAGE $RPM_BUILD_ROOT'"/boot/vmlinuz-$KERNELRELEASE"
echo "%endif"
echo "%endif"
echo 'make %{?_smp_mflags} INSTALL_HDR_PATH=$RPM_BUILD_ROOT/usr KBUILD_SRC= headers_install' %files
echo 'cp System.map $RPM_BUILD_ROOT'"/boot/System.map-$KERNELRELEASE" %defattr (-, root, root)
$M /lib/modules/$KERNELRELEASE
$M %exclude /lib/modules/$KERNELRELEASE/build
$M %exclude /lib/modules/$KERNELRELEASE/source
/boot/*
echo 'cp .config $RPM_BUILD_ROOT'"/boot/config-$KERNELRELEASE" %files headers
%defattr (-, root, root)
echo "%ifnarch ppc64" /usr/include
echo 'bzip2 -9 --keep vmlinux' $S$M
echo 'mv vmlinux.bz2 $RPM_BUILD_ROOT'"/boot/vmlinux-$KERNELRELEASE.bz2" $S$M %files devel
echo "%endif" $S$M %defattr (-, root, root)
$S$M /usr/src/kernels/$KERNELRELEASE
if ! $PREBUILT; then $S$M /lib/modules/$KERNELRELEASE/build
echo 'rm -f $RPM_BUILD_ROOT'"/lib/modules/$KERNELRELEASE/build" $S$M /lib/modules/$KERNELRELEASE/source
echo 'rm -f $RPM_BUILD_ROOT'"/lib/modules/$KERNELRELEASE/source" EOF
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 .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"
fi
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 "%preun"
echo "if [ -x /sbin/new-kernel-pkg ]; then"
echo "new-kernel-pkg --remove $KERNELRELEASE --rminitrd --initrdfile=/boot/initramfs-$KERNELRELEASE.img"
echo "fi"
echo ""
echo "%postun"
echo "if [ -x /sbin/update-bootloader ]; then"
echo "/sbin/update-bootloader --remove $KERNELRELEASE"
echo "fi"
echo ""
echo "%files"
echo '%defattr (-, root, root)'
echo "/lib/modules/$KERNELRELEASE"
echo "%exclude /lib/modules/$KERNELRELEASE/build"
echo "%exclude /lib/modules/$KERNELRELEASE/source"
echo "/boot/*"
echo ""
echo "%files headers"
echo '%defattr (-, root, root)'
echo "/usr/include"
echo ""
if ! $PREBUILT; then
echo "%files devel"
echo '%defattr (-, root, root)'
echo "/usr/src/kernels/$KERNELRELEASE"
echo "/lib/modules/$KERNELRELEASE/build"
echo "/lib/modules/$KERNELRELEASE/source"
echo ""
fi