summaryrefslogtreecommitdiffstats
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
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
-rw-r--r--.gitignore5
-rw-r--r--Documentation/dev-tools/coccinelle.rst3
-rwxr-xr-xscripts/coccicheck26
-rw-r--r--scripts/coccinelle/api/check_bq27xxx_data.cocci161
-rw-r--r--scripts/coccinelle/api/setup_timer.cocci144
-rw-r--r--scripts/coccinelle/iterators/list_entry_update.cocci2
-rw-r--r--scripts/coccinelle/misc/ifcol.cocci8
-rw-r--r--scripts/coccinelle/misc/orplus.cocci43
-rw-r--r--scripts/coccinelle/null/badzero.cocci2
-rw-r--r--scripts/package/Makefile9
-rwxr-xr-xscripts/package/builddeb4
-rwxr-xr-xscripts/package/mkspec269
12 files changed, 457 insertions, 219 deletions
diff --git a/.gitignore b/.gitignore
index 6c119eab5d46..f6050b88e95b 100644
--- a/.gitignore
+++ b/.gitignore
@@ -56,6 +56,11 @@ modules.builtin
56/Module.markers 56/Module.markers
57 57
58# 58#
59# RPM spec file (make rpm-pkg)
60#
61/*.spec
62
63#
59# Debian directory (make deb-pkg) 64# Debian directory (make deb-pkg)
60# 65#
61/debian/ 66/debian/
diff --git a/Documentation/dev-tools/coccinelle.rst b/Documentation/dev-tools/coccinelle.rst
index 37e474ff6911..94f41c290bfc 100644
--- a/Documentation/dev-tools/coccinelle.rst
+++ b/Documentation/dev-tools/coccinelle.rst
@@ -33,9 +33,6 @@ of many distributions, e.g. :
33You can get the latest version released from the Coccinelle homepage at 33You can get the latest version released from the Coccinelle homepage at
34http://coccinelle.lip6.fr/ 34http://coccinelle.lip6.fr/
35 35
36Information and tips about Coccinelle are also provided on the wiki
37pages at http://cocci.ekstranet.diku.dk/wiki/doku.php
38
39Once you have it, run the following command:: 36Once you have it, run the following command::
40 37
41 ./configure 38 ./configure
diff --git a/scripts/coccicheck b/scripts/coccicheck
index 28ad1feff9e1..d5f28d5044e7 100755
--- a/scripts/coccicheck
+++ b/scripts/coccicheck
@@ -123,15 +123,8 @@ run_cmd_parmap() {
123 if [ $VERBOSE -ne 0 ] ; then 123 if [ $VERBOSE -ne 0 ] ; then
124 echo "Running ($NPROC in parallel): $@" 124 echo "Running ($NPROC in parallel): $@"
125 fi 125 fi
126 if [ "$DEBUG_FILE" != "/dev/null" -a "$DEBUG_FILE" != "" ]; then 126 echo $@ >>$DEBUG_FILE
127 if [ -f $DEBUG_FILE ]; then 127 $@ 2>>$DEBUG_FILE
128 echo "Debug file $DEBUG_FILE exists, bailing"
129 exit
130 fi
131 else
132 DEBUG_FILE="/dev/null"
133 fi
134 $@ 2>$DEBUG_FILE
135 if [[ $? -ne 0 ]]; then 128 if [[ $? -ne 0 ]]; then
136 echo "coccicheck failed" 129 echo "coccicheck failed"
137 exit $? 130 exit $?
@@ -176,8 +169,8 @@ OPTIONS="$OPTIONS $SPFLAGS"
176coccinelle () { 169coccinelle () {
177 COCCI="$1" 170 COCCI="$1"
178 171
179 OPT=`grep "Option" $COCCI | cut -d':' -f2` 172 OPT=`grep "Options:" $COCCI | cut -d':' -f2`
180 REQ=`grep "Requires" $COCCI | cut -d':' -f2 | sed "s| ||"` 173 REQ=`grep "Requires:" $COCCI | cut -d':' -f2 | sed "s| ||"`
181 REQ_NUM=$(echo $REQ | ${DIR}/scripts/ld-version.sh) 174 REQ_NUM=$(echo $REQ | ${DIR}/scripts/ld-version.sh)
182 if [ "$REQ_NUM" != "0" ] ; then 175 if [ "$REQ_NUM" != "0" ] ; then
183 if [ "$SPATCH_VERSION_NUM" -lt "$REQ_NUM" ] ; then 176 if [ "$SPATCH_VERSION_NUM" -lt "$REQ_NUM" ] ; then
@@ -194,7 +187,7 @@ coccinelle () {
194 187
195 if [ $VERBOSE -ne 0 -a $ONLINE -eq 0 ] ; then 188 if [ $VERBOSE -ne 0 -a $ONLINE -eq 0 ] ; then
196 189
197 FILE=`echo $COCCI | sed "s|$srctree/||"` 190 FILE=${COCCI#$srctree/}
198 191
199 echo "Processing `basename $COCCI`" 192 echo "Processing `basename $COCCI`"
200 echo "with option(s) \"$OPT\"" 193 echo "with option(s) \"$OPT\""
@@ -247,6 +240,15 @@ coccinelle () {
247 240
248} 241}
249 242
243if [ "$DEBUG_FILE" != "/dev/null" -a "$DEBUG_FILE" != "" ]; then
244 if [ -f $DEBUG_FILE ]; then
245 echo "Debug file $DEBUG_FILE exists, bailing"
246 exit
247 fi
248else
249 DEBUG_FILE="/dev/null"
250fi
251
250if [ "$COCCI" = "" ] ; then 252if [ "$COCCI" = "" ] ; then
251 for f in `find $srctree/scripts/coccinelle/ -name '*.cocci' -type f | sort`; do 253 for f in `find $srctree/scripts/coccinelle/ -name '*.cocci' -type f | sort`; do
252 coccinelle $f 254 coccinelle $f
diff --git a/scripts/coccinelle/api/check_bq27xxx_data.cocci b/scripts/coccinelle/api/check_bq27xxx_data.cocci
new file mode 100644
index 000000000000..9212b85169d2
--- /dev/null
+++ b/scripts/coccinelle/api/check_bq27xxx_data.cocci
@@ -0,0 +1,161 @@
1/// Detect BQ27XXX_DATA structures with identical registers, dm registers or
2/// properties.
3//# Doesn't unfold macros used in register or property fields.
4//# Requires OCaml scripting
5///
6// Confidence: High
7// Copyright: (C) 2017 Julia Lawall, Inria/LIP6, GPLv2.
8// URL: http://coccinelle.lip6.fr/
9// Requires: 1.0.7
10// Keywords: BQ27XXX_DATA
11
12virtual report
13
14@initialize:ocaml@
15@@
16
17let print_report p msg =
18 let p = List.hd p in
19 Printf.printf "%s:%d:%d-%d: %s" p.file p.line p.col p.col_end msg
20
21@str depends on report@
22type t;
23identifier i,i1,i2;
24expression e1,e2;
25@@
26
27t i[] = {
28 ...,
29 [e1] = BQ27XXX_DATA(i1,...),
30 ...,
31 [e2] = BQ27XXX_DATA(i2,...),
32 ...,
33};
34
35@script:ocaml tocheck@
36i1 << str.i1;
37i2 << str.i2;
38i1regs; i2regs;
39i1dmregs; i2dmregs;
40i1props; i2props;
41@@
42
43if not(i1 = i2)
44then
45 begin
46 i1regs := make_ident (i1 ^ "_regs");
47 i2regs := make_ident (i2 ^ "_regs");
48 i1dmregs := make_ident (i1 ^ "_dm_regs");
49 i2dmregs := make_ident (i2 ^ "_dm_regs");
50 i1props := make_ident (i1 ^ "_props");
51 i2props := make_ident (i2 ^ "_props")
52 end
53
54(* ---------------------------------------------------------------- *)
55
56@getregs1@
57typedef u8;
58identifier tocheck.i1regs;
59initializer list i1regs_vals;
60position p1;
61@@
62
63u8 i1regs@p1[...] = { i1regs_vals, };
64
65@getregs2@
66identifier tocheck.i2regs;
67initializer list i2regs_vals;
68position p2;
69@@
70
71u8 i2regs@p2[...] = { i2regs_vals, };
72
73@script:ocaml@
74(_,i1regs_vals) << getregs1.i1regs_vals;
75(_,i2regs_vals) << getregs2.i2regs_vals;
76i1regs << tocheck.i1regs;
77i2regs << tocheck.i2regs;
78p1 << getregs1.p1;
79p2 << getregs2.p2;
80@@
81
82if i1regs < i2regs &&
83 List.sort compare i1regs_vals = List.sort compare i2regs_vals
84then
85 let msg =
86 Printf.sprintf
87 "WARNING %s and %s (line %d) are identical\n"
88 i1regs i2regs (List.hd p2).line in
89 print_report p1 msg
90
91(* ---------------------------------------------------------------- *)
92
93@getdmregs1@
94identifier tocheck.i1dmregs;
95initializer list i1dmregs_vals;
96position p1;
97@@
98
99struct bq27xxx_dm_reg i1dmregs@p1[] = { i1dmregs_vals, };
100
101@getdmregs2@
102identifier tocheck.i2dmregs;
103initializer list i2dmregs_vals;
104position p2;
105@@
106
107struct bq27xxx_dm_reg i2dmregs@p2[] = { i2dmregs_vals, };
108
109@script:ocaml@
110(_,i1dmregs_vals) << getdmregs1.i1dmregs_vals;
111(_,i2dmregs_vals) << getdmregs2.i2dmregs_vals;
112i1dmregs << tocheck.i1dmregs;
113i2dmregs << tocheck.i2dmregs;
114p1 << getdmregs1.p1;
115p2 << getdmregs2.p2;
116@@
117
118if i1dmregs < i2dmregs &&
119 List.sort compare i1dmregs_vals = List.sort compare i2dmregs_vals
120then
121 let msg =
122 Printf.sprintf
123 "WARNING %s and %s (line %d) are identical\n"
124 i1dmregs i2dmregs (List.hd p2).line in
125 print_report p1 msg
126
127(* ---------------------------------------------------------------- *)
128
129@getprops1@
130identifier tocheck.i1props;
131initializer list[n1] i1props_vals;
132position p1;
133@@
134
135enum power_supply_property i1props@p1[] = { i1props_vals, };
136
137@getprops2@
138identifier tocheck.i2props;
139initializer list[n2] i2props_vals;
140position p2;
141@@
142
143enum power_supply_property i2props@p2[] = { i2props_vals, };
144
145@script:ocaml@
146(_,i1props_vals) << getprops1.i1props_vals;
147(_,i2props_vals) << getprops2.i2props_vals;
148i1props << tocheck.i1props;
149i2props << tocheck.i2props;
150p1 << getprops1.p1;
151p2 << getprops2.p2;
152@@
153
154if i1props < i2props &&
155 List.sort compare i1props_vals = List.sort compare i2props_vals
156then
157 let msg =
158 Printf.sprintf
159 "WARNING %s and %s (line %d) are identical\n"
160 i1props i2props (List.hd p2).line in
161 print_report p1 msg
diff --git a/scripts/coccinelle/api/setup_timer.cocci b/scripts/coccinelle/api/setup_timer.cocci
index eb6bd9e4ab1a..e4577089dcb9 100644
--- a/scripts/coccinelle/api/setup_timer.cocci
+++ b/scripts/coccinelle/api/setup_timer.cocci
@@ -2,6 +2,7 @@
2/// and data fields 2/// and data fields
3// Confidence: High 3// Confidence: High
4// Copyright: (C) 2016 Vaishali Thakkar, Oracle. GPLv2 4// Copyright: (C) 2016 Vaishali Thakkar, Oracle. GPLv2
5// Copyright: (C) 2017 Kees Cook, Google. GPLv2
5// Options: --no-includes --include-headers 6// Options: --no-includes --include-headers
6// Keywords: init_timer, setup_timer 7// Keywords: init_timer, setup_timer
7 8
@@ -10,60 +11,123 @@ virtual context
10virtual org 11virtual org
11virtual report 12virtual report
12 13
14// Match the common cases first to avoid Coccinelle parsing loops with
15// "... when" clauses.
16
13@match_immediate_function_data_after_init_timer 17@match_immediate_function_data_after_init_timer
14depends on patch && !context && !org && !report@ 18depends on patch && !context && !org && !report@
15expression e, func, da; 19expression e, func, da;
16@@ 20@@
17 21
18-init_timer (&e); 22-init_timer
19+setup_timer (&e, func, da); 23+setup_timer
24 ( \(&e\|e\)
25+, func, da
26 );
27(
28-\(e.function\|e->function\) = func;
29-\(e.data\|e->data\) = da;
30|
31-\(e.data\|e->data\) = da;
32-\(e.function\|e->function\) = func;
33)
34
35@match_immediate_function_data_before_init_timer
36depends on patch && !context && !org && !report@
37expression e, func, da;
38@@
39
40(
41-\(e.function\|e->function\) = func;
42-\(e.data\|e->data\) = da;
43|
44-\(e.data\|e->data\) = da;
45-\(e.function\|e->function\) = func;
46)
47-init_timer
48+setup_timer
49 ( \(&e\|e\)
50+, func, da
51 );
52
53@match_function_and_data_after_init_timer
54depends on patch && !context && !org && !report@
55expression e, e2, e3, e4, e5, func, da;
56@@
20 57
58-init_timer
59+setup_timer
60 ( \(&e\|e\)
61+, func, da
62 );
63 ... when != func = e2
64 when != da = e3
21( 65(
22-e.function = func; 66-e.function = func;
67... when != da = e4
23-e.data = da; 68-e.data = da;
24| 69|
70-e->function = func;
71... when != da = e4
72-e->data = da;
73|
25-e.data = da; 74-e.data = da;
75... when != func = e5
26-e.function = func; 76-e.function = func;
77|
78-e->data = da;
79... when != func = e5
80-e->function = func;
27) 81)
28 82
29@match_function_and_data_after_init_timer 83@match_function_and_data_before_init_timer
30depends on patch && !context && !org && !report@ 84depends on patch && !context && !org && !report@
31expression e1, e2, e3, e4, e5, a, b; 85expression e, e2, e3, e4, e5, func, da;
32@@ 86@@
33
34-init_timer (&e1);
35+setup_timer (&e1, a, b);
36
37... when != a = e2
38 when != b = e3
39( 87(
40-e1.function = a; 88-e.function = func;
41... when != b = e4 89... when != da = e4
42-e1.data = b; 90-e.data = da;
43| 91|
44-e1.data = b; 92-e->function = func;
45... when != a = e5 93... when != da = e4
46-e1.function = a; 94-e->data = da;
95|
96-e.data = da;
97... when != func = e5
98-e.function = func;
99|
100-e->data = da;
101... when != func = e5
102-e->function = func;
47) 103)
104... when != func = e2
105 when != da = e3
106-init_timer
107+setup_timer
108 ( \(&e\|e\)
109+, func, da
110 );
48 111
49@r1 exists@ 112@r1 exists@
113expression t;
50identifier f; 114identifier f;
51position p; 115position p;
52@@ 116@@
53 117
54f(...) { ... when any 118f(...) { ... when any
55 init_timer@p(...) 119 init_timer@p(\(&t\|t\))
56 ... when any 120 ... when any
57} 121}
58 122
59@r2 exists@ 123@r2 exists@
124expression r1.t;
60identifier g != r1.f; 125identifier g != r1.f;
61struct timer_list t;
62expression e8; 126expression e8;
63@@ 127@@
64 128
65g(...) { ... when any 129g(...) { ... when any
66 t.data = e8 130 \(t.data\|t->data\) = e8
67 ... when any 131 ... when any
68} 132}
69 133
@@ -77,14 +141,31 @@ p << r1.p;
77cocci.include_match(False) 141cocci.include_match(False)
78 142
79@r3 depends on patch && !context && !org && !report@ 143@r3 depends on patch && !context && !org && !report@
80expression e6, e7, c; 144expression r1.t, func, e7;
81position r1.p; 145position r1.p;
82@@ 146@@
83 147
84-init_timer@p (&e6); 148(
85+setup_timer (&e6, c, 0UL); 149-init_timer@p(&t);
86... when != c = e7 150+setup_timer(&t, func, 0UL);
87-e6.function = c; 151... when != func = e7
152-t.function = func;
153|
154-t.function = func;
155... when != func = e7
156-init_timer@p(&t);
157+setup_timer(&t, func, 0UL);
158|
159-init_timer@p(t);
160+setup_timer(t, func, 0UL);
161... when != func = e7
162-t->function = func;
163|
164-t->function = func;
165... when != func = e7
166-init_timer@p(t);
167+setup_timer(t, func, 0UL);
168)
88 169
89// ---------------------------------------------------------------------------- 170// ----------------------------------------------------------------------------
90 171
@@ -104,11 +185,9 @@ position j0, j1, j2;
104) 185)
105 186
106@match_function_and_data_after_init_timer_context 187@match_function_and_data_after_init_timer_context
107depends on !patch && 188depends on !patch && (context || org || report)@
108!match_immediate_function_data_after_init_timer_context &&
109 (context || org || report)@
110expression a, b, e1, e2, e3, e4, e5; 189expression a, b, e1, e2, e3, e4, e5;
111position j0, j1, j2; 190position j0 != match_immediate_function_data_after_init_timer_context.j0,j1,j2;
112@@ 191@@
113 192
114* init_timer@j0 (&e1); 193* init_timer@j0 (&e1);
@@ -124,13 +203,12 @@ position j0, j1, j2;
124* e1@j2.function = a; 203* e1@j2.function = a;
125) 204)
126 205
127@r3_context depends on !patch && 206@r3_context depends on !patch && (context || org || report)@
128!match_immediate_function_data_after_init_timer_context &&
129!match_function_and_data_after_init_timer_context &&
130 (context || org || report)@
131expression c, e6, e7; 207expression c, e6, e7;
132position r1.p; 208position r1.p;
133position j0, j1; 209position j0 !=
210 {match_immediate_function_data_after_init_timer_context.j0,
211 match_function_and_data_after_init_timer_context.j0}, j1;
134@@ 212@@
135 213
136* init_timer@j0@p (&e6); 214* init_timer@j0@p (&e6);
diff --git a/scripts/coccinelle/iterators/list_entry_update.cocci b/scripts/coccinelle/iterators/list_entry_update.cocci
index 873f444e7137..be6f9f1abb34 100644
--- a/scripts/coccinelle/iterators/list_entry_update.cocci
+++ b/scripts/coccinelle/iterators/list_entry_update.cocci
@@ -15,7 +15,7 @@ virtual context
15virtual org 15virtual org
16virtual report 16virtual report
17 17
18@r@ 18@r exists@
19iterator name list_for_each_entry; 19iterator name list_for_each_entry;
20expression x,E; 20expression x,E;
21position p1,p2; 21position p1,p2;
diff --git a/scripts/coccinelle/misc/ifcol.cocci b/scripts/coccinelle/misc/ifcol.cocci
index d0d00ef1f12a..ffe75407c5d2 100644
--- a/scripts/coccinelle/misc/ifcol.cocci
+++ b/scripts/coccinelle/misc/ifcol.cocci
@@ -3,10 +3,10 @@
3/// Sometimes, code after an if that is indented is actually intended to be 3/// Sometimes, code after an if that is indented is actually intended to be
4/// part of the if branch. 4/// part of the if branch.
5/// 5///
6/// This has a high rate of false positives, because Coccinelle's column 6//# This has a high rate of false positives, because Coccinelle's column
7/// calculation does not distinguish between spaces and tabs, so code that 7//# calculation does not distinguish between spaces and tabs, so code that
8/// is not visually aligned may be considered to be in the same column. 8//# is not visually aligned may be considered to be in the same column.
9/// 9//
10// Confidence: Low 10// Confidence: Low
11// Copyright: (C) 2010 Nicolas Palix, DIKU. GPLv2. 11// Copyright: (C) 2010 Nicolas Palix, DIKU. GPLv2.
12// Copyright: (C) 2010 Julia Lawall, DIKU. GPLv2. 12// Copyright: (C) 2010 Julia Lawall, DIKU. GPLv2.
diff --git a/scripts/coccinelle/misc/orplus.cocci b/scripts/coccinelle/misc/orplus.cocci
index 81fabf379390..08de5be73693 100644
--- a/scripts/coccinelle/misc/orplus.cocci
+++ b/scripts/coccinelle/misc/orplus.cocci
@@ -14,7 +14,19 @@ virtual report
14virtual context 14virtual context
15 15
16@r@ 16@r@
17constant c; 17constant c,c1;
18identifier i,i1;
19position p;
20@@
21
22(
23 c1 + c - 1
24|
25 c1@i1 +@p c@i
26)
27
28@s@
29constant r.c, r.c1;
18identifier i; 30identifier i;
19expression e; 31expression e;
20@@ 32@@
@@ -27,28 +39,31 @@ e & c@i
27e |= c@i 39e |= c@i
28| 40|
29e &= c@i 41e &= c@i
42|
43e | c1@i
44|
45e & c1@i
46|
47e |= c1@i
48|
49e &= c1@i
30) 50)
31 51
32@s@ 52@depends on s@
33constant r.c,c1; 53position r.p;
34identifier i1; 54constant c1,c2;
35position p;
36@@ 55@@
37 56
38( 57* c1 +@p c2
39 c1 + c - 1
40|
41*c1@i1 +@p c
42)
43 58
44@script:python depends on org@ 59@script:python depends on s && org@
45p << s.p; 60p << r.p;
46@@ 61@@
47 62
48cocci.print_main("sum of probable bitmasks, consider |",p) 63cocci.print_main("sum of probable bitmasks, consider |",p)
49 64
50@script:python depends on report@ 65@script:python depends on s && report@
51p << s.p; 66p << r.p;
52@@ 67@@
53 68
54msg = "WARNING: sum of probable bitmasks, consider |" 69msg = "WARNING: sum of probable bitmasks, consider |"
diff --git a/scripts/coccinelle/null/badzero.cocci b/scripts/coccinelle/null/badzero.cocci
index 5551da2b4fe3..f597c8007b76 100644
--- a/scripts/coccinelle/null/badzero.cocci
+++ b/scripts/coccinelle/null/badzero.cocci
@@ -10,7 +10,7 @@
10// Copyright: (C) 2012 Julia Lawall, INRIA/LIP6. GPLv2. 10// Copyright: (C) 2012 Julia Lawall, INRIA/LIP6. GPLv2.
11// Copyright: (C) 2012 Gilles Muller, INRIA/LiP6. GPLv2. 11// Copyright: (C) 2012 Gilles Muller, INRIA/LiP6. GPLv2.
12// URL: http://coccinelle.lip6.fr/ 12// URL: http://coccinelle.lip6.fr/
13// Comments: Requires Coccinelle version 1.0.0-rc20 or later 13// Requires: 1.0.0
14// Options: 14// Options:
15 15
16virtual patch 16virtual patch
diff --git a/scripts/package/Makefile b/scripts/package/Makefile
index 73f9f3192b9f..9ed96aefc72d 100644
--- a/scripts/package/Makefile
+++ b/scripts/package/Makefile
@@ -50,17 +50,18 @@ rpm-pkg rpm: FORCE
50 $(MAKE) clean 50 $(MAKE) clean
51 $(CONFIG_SHELL) $(MKSPEC) >$(objtree)/kernel.spec 51 $(CONFIG_SHELL) $(MKSPEC) >$(objtree)/kernel.spec
52 $(call cmd,src_tar,$(KERNELPATH),kernel.spec) 52 $(call cmd,src_tar,$(KERNELPATH),kernel.spec)
53 rpmbuild $(RPMOPTS) --target $(UTS_MACHINE) -ta $(KERNELPATH).tar.gz 53 +rpmbuild $(RPMOPTS) --target $(UTS_MACHINE) -ta $(KERNELPATH).tar.gz \
54 rm $(KERNELPATH).tar.gz kernel.spec 54 --define='_smp_mflags %{nil}'
55 55
56# binrpm-pkg 56# binrpm-pkg
57# --------------------------------------------------------------------------- 57# ---------------------------------------------------------------------------
58binrpm-pkg: FORCE 58binrpm-pkg: FORCE
59 $(MAKE) KBUILD_SRC= 59 $(MAKE) KBUILD_SRC=
60 $(CONFIG_SHELL) $(MKSPEC) prebuilt > $(objtree)/binkernel.spec 60 $(CONFIG_SHELL) $(MKSPEC) prebuilt > $(objtree)/binkernel.spec
61 rpmbuild $(RPMOPTS) --define "_builddir $(objtree)" --target \ 61 +rpmbuild $(RPMOPTS) --define "_builddir $(objtree)" --target \
62 $(UTS_MACHINE) -bb $(objtree)/binkernel.spec 62 $(UTS_MACHINE) -bb $(objtree)/binkernel.spec
63 rm binkernel.spec 63
64clean-files += $(objtree)/*.spec
64 65
65# Deb target 66# Deb target
66# --------------------------------------------------------------------------- 67# ---------------------------------------------------------------------------
diff --git a/scripts/package/builddeb b/scripts/package/builddeb
index 0bc87473f68f..b4f0f2b3f8d2 100755
--- a/scripts/package/builddeb
+++ b/scripts/package/builddeb
@@ -408,9 +408,9 @@ EOF
408 dpkg-source -cdebian/control -ldebian/changelog --format="3.0 (custom)" --target-format="3.0 (quilt)" \ 408 dpkg-source -cdebian/control -ldebian/changelog --format="3.0 (custom)" --target-format="3.0 (quilt)" \
409 -b / ../${sourcename}_${version}.orig.tar.gz ../${sourcename}_${packageversion}.debian.tar.gz 409 -b / ../${sourcename}_${version}.orig.tar.gz ../${sourcename}_${packageversion}.debian.tar.gz
410 mv ${sourcename}_${packageversion}*dsc .. 410 mv ${sourcename}_${packageversion}*dsc ..
411 dpkg-genchanges > ../${sourcename}_${packageversion}_${debarch}.changes 411 dpkg-genchanges -Vkernel:debarch="${debarch}" > ../${sourcename}_${packageversion}_${debarch}.changes
412else 412else
413 dpkg-genchanges -b > ../${sourcename}_${packageversion}_${debarch}.changes 413 dpkg-genchanges -b -Vkernel:debarch="${debarch}" > ../${sourcename}_${packageversion}_${debarch}.changes
414fi 414fi
415 415
416exit 0 416exit 0
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