Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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

+450 -212
+5
.gitignore
··· 56 56 /Module.markers 57 57 58 58 # 59 + # RPM spec file (make rpm-pkg) 60 + # 61 + /*.spec 62 + 63 + # 59 64 # Debian directory (make deb-pkg) 60 65 # 61 66 /debian/
-3
Documentation/dev-tools/coccinelle.rst
··· 33 33 You can get the latest version released from the Coccinelle homepage at 34 34 http://coccinelle.lip6.fr/ 35 35 36 - Information and tips about Coccinelle are also provided on the wiki 37 - pages at http://cocci.ekstranet.diku.dk/wiki/doku.php 38 - 39 36 Once you have it, run the following command:: 40 37 41 38 ./configure
+14 -12
scripts/coccicheck
··· 123 123 if [ $VERBOSE -ne 0 ] ; then 124 124 echo "Running ($NPROC in parallel): $@" 125 125 fi 126 - if [ "$DEBUG_FILE" != "/dev/null" -a "$DEBUG_FILE" != "" ]; then 127 - if [ -f $DEBUG_FILE ]; then 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 126 + echo $@ >>$DEBUG_FILE 127 + $@ 2>>$DEBUG_FILE 135 128 if [[ $? -ne 0 ]]; then 136 129 echo "coccicheck failed" 137 130 exit $? ··· 169 176 coccinelle () { 170 177 COCCI="$1" 171 178 172 - OPT=`grep "Option" $COCCI | cut -d':' -f2` 173 - REQ=`grep "Requires" $COCCI | cut -d':' -f2 | sed "s| ||"` 179 + OPT=`grep "Options:" $COCCI | cut -d':' -f2` 180 + REQ=`grep "Requires:" $COCCI | cut -d':' -f2 | sed "s| ||"` 174 181 REQ_NUM=$(echo $REQ | ${DIR}/scripts/ld-version.sh) 175 182 if [ "$REQ_NUM" != "0" ] ; then 176 183 if [ "$SPATCH_VERSION_NUM" -lt "$REQ_NUM" ] ; then ··· 187 194 188 195 if [ $VERBOSE -ne 0 -a $ONLINE -eq 0 ] ; then 189 196 190 - FILE=`echo $COCCI | sed "s|$srctree/||"` 197 + FILE=${COCCI#$srctree/} 191 198 192 199 echo "Processing `basename $COCCI`" 193 200 echo "with option(s) \"$OPT\"" ··· 239 246 fi 240 247 241 248 } 249 + 250 + if [ "$DEBUG_FILE" != "/dev/null" -a "$DEBUG_FILE" != "" ]; then 251 + if [ -f $DEBUG_FILE ]; then 252 + echo "Debug file $DEBUG_FILE exists, bailing" 253 + exit 254 + fi 255 + else 256 + DEBUG_FILE="/dev/null" 257 + fi 242 258 243 259 if [ "$COCCI" = "" ] ; then 244 260 for f in `find $srctree/scripts/coccinelle/ -name '*.cocci' -type f | sort`; do
+161
scripts/coccinelle/api/check_bq27xxx_data.cocci
··· 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 + 12 + virtual report 13 + 14 + @initialize:ocaml@ 15 + @@ 16 + 17 + let 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@ 22 + type t; 23 + identifier i,i1,i2; 24 + expression e1,e2; 25 + @@ 26 + 27 + t i[] = { 28 + ..., 29 + [e1] = BQ27XXX_DATA(i1,...), 30 + ..., 31 + [e2] = BQ27XXX_DATA(i2,...), 32 + ..., 33 + }; 34 + 35 + @script:ocaml tocheck@ 36 + i1 << str.i1; 37 + i2 << str.i2; 38 + i1regs; i2regs; 39 + i1dmregs; i2dmregs; 40 + i1props; i2props; 41 + @@ 42 + 43 + if not(i1 = i2) 44 + then 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@ 57 + typedef u8; 58 + identifier tocheck.i1regs; 59 + initializer list i1regs_vals; 60 + position p1; 61 + @@ 62 + 63 + u8 i1regs@p1[...] = { i1regs_vals, }; 64 + 65 + @getregs2@ 66 + identifier tocheck.i2regs; 67 + initializer list i2regs_vals; 68 + position p2; 69 + @@ 70 + 71 + u8 i2regs@p2[...] = { i2regs_vals, }; 72 + 73 + @script:ocaml@ 74 + (_,i1regs_vals) << getregs1.i1regs_vals; 75 + (_,i2regs_vals) << getregs2.i2regs_vals; 76 + i1regs << tocheck.i1regs; 77 + i2regs << tocheck.i2regs; 78 + p1 << getregs1.p1; 79 + p2 << getregs2.p2; 80 + @@ 81 + 82 + if i1regs < i2regs && 83 + List.sort compare i1regs_vals = List.sort compare i2regs_vals 84 + then 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@ 94 + identifier tocheck.i1dmregs; 95 + initializer list i1dmregs_vals; 96 + position p1; 97 + @@ 98 + 99 + struct bq27xxx_dm_reg i1dmregs@p1[] = { i1dmregs_vals, }; 100 + 101 + @getdmregs2@ 102 + identifier tocheck.i2dmregs; 103 + initializer list i2dmregs_vals; 104 + position p2; 105 + @@ 106 + 107 + struct bq27xxx_dm_reg i2dmregs@p2[] = { i2dmregs_vals, }; 108 + 109 + @script:ocaml@ 110 + (_,i1dmregs_vals) << getdmregs1.i1dmregs_vals; 111 + (_,i2dmregs_vals) << getdmregs2.i2dmregs_vals; 112 + i1dmregs << tocheck.i1dmregs; 113 + i2dmregs << tocheck.i2dmregs; 114 + p1 << getdmregs1.p1; 115 + p2 << getdmregs2.p2; 116 + @@ 117 + 118 + if i1dmregs < i2dmregs && 119 + List.sort compare i1dmregs_vals = List.sort compare i2dmregs_vals 120 + then 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@ 130 + identifier tocheck.i1props; 131 + initializer list[n1] i1props_vals; 132 + position p1; 133 + @@ 134 + 135 + enum power_supply_property i1props@p1[] = { i1props_vals, }; 136 + 137 + @getprops2@ 138 + identifier tocheck.i2props; 139 + initializer list[n2] i2props_vals; 140 + position p2; 141 + @@ 142 + 143 + enum power_supply_property i2props@p2[] = { i2props_vals, }; 144 + 145 + @script:ocaml@ 146 + (_,i1props_vals) << getprops1.i1props_vals; 147 + (_,i2props_vals) << getprops2.i2props_vals; 148 + i1props << tocheck.i1props; 149 + i2props << tocheck.i2props; 150 + p1 << getprops1.p1; 151 + p2 << getprops2.p2; 152 + @@ 153 + 154 + if i1props < i2props && 155 + List.sort compare i1props_vals = List.sort compare i2props_vals 156 + then 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
+113 -35
scripts/coccinelle/api/setup_timer.cocci
··· 2 2 /// and data fields 3 3 // Confidence: High 4 4 // Copyright: (C) 2016 Vaishali Thakkar, Oracle. GPLv2 5 + // Copyright: (C) 2017 Kees Cook, Google. GPLv2 5 6 // Options: --no-includes --include-headers 6 7 // Keywords: init_timer, setup_timer 7 8 ··· 11 10 virtual org 12 11 virtual report 13 12 13 + // Match the common cases first to avoid Coccinelle parsing loops with 14 + // "... when" clauses. 15 + 14 16 @match_immediate_function_data_after_init_timer 15 17 depends on patch && !context && !org && !report@ 16 18 expression e, func, da; 17 19 @@ 18 20 19 - -init_timer (&e); 20 - +setup_timer (&e, func, da); 21 + -init_timer 22 + +setup_timer 23 + ( \(&e\|e\) 24 + +, func, da 25 + ); 26 + ( 27 + -\(e.function\|e->function\) = func; 28 + -\(e.data\|e->data\) = da; 29 + | 30 + -\(e.data\|e->data\) = da; 31 + -\(e.function\|e->function\) = func; 32 + ) 33 + 34 + @match_immediate_function_data_before_init_timer 35 + depends on patch && !context && !org && !report@ 36 + expression e, func, da; 37 + @@ 21 38 22 39 ( 23 - -e.function = func; 24 - -e.data = da; 40 + -\(e.function\|e->function\) = func; 41 + -\(e.data\|e->data\) = da; 25 42 | 26 - -e.data = da; 27 - -e.function = func; 43 + -\(e.data\|e->data\) = da; 44 + -\(e.function\|e->function\) = func; 28 45 ) 46 + -init_timer 47 + +setup_timer 48 + ( \(&e\|e\) 49 + +, func, da 50 + ); 29 51 30 52 @match_function_and_data_after_init_timer 31 53 depends on patch && !context && !org && !report@ 32 - expression e1, e2, e3, e4, e5, a, b; 54 + expression e, e2, e3, e4, e5, func, da; 33 55 @@ 34 56 35 - -init_timer (&e1); 36 - +setup_timer (&e1, a, b); 37 - 38 - ... when != a = e2 39 - when != b = e3 57 + -init_timer 58 + +setup_timer 59 + ( \(&e\|e\) 60 + +, func, da 61 + ); 62 + ... when != func = e2 63 + when != da = e3 40 64 ( 41 - -e1.function = a; 42 - ... when != b = e4 43 - -e1.data = b; 65 + -e.function = func; 66 + ... when != da = e4 67 + -e.data = da; 44 68 | 45 - -e1.data = b; 46 - ... when != a = e5 47 - -e1.function = a; 69 + -e->function = func; 70 + ... when != da = e4 71 + -e->data = da; 72 + | 73 + -e.data = da; 74 + ... when != func = e5 75 + -e.function = func; 76 + | 77 + -e->data = da; 78 + ... when != func = e5 79 + -e->function = func; 48 80 ) 49 81 82 + @match_function_and_data_before_init_timer 83 + depends on patch && !context && !org && !report@ 84 + expression e, e2, e3, e4, e5, func, da; 85 + @@ 86 + ( 87 + -e.function = func; 88 + ... when != da = e4 89 + -e.data = da; 90 + | 91 + -e->function = func; 92 + ... when != da = e4 93 + -e->data = da; 94 + | 95 + -e.data = da; 96 + ... when != func = e5 97 + -e.function = func; 98 + | 99 + -e->data = da; 100 + ... when != func = e5 101 + -e->function = func; 102 + ) 103 + ... when != func = e2 104 + when != da = e3 105 + -init_timer 106 + +setup_timer 107 + ( \(&e\|e\) 108 + +, func, da 109 + ); 110 + 50 111 @r1 exists@ 112 + expression t; 51 113 identifier f; 52 114 position p; 53 115 @@ 54 116 55 117 f(...) { ... when any 56 - init_timer@p(...) 118 + init_timer@p(\(&t\|t\)) 57 119 ... when any 58 120 } 59 121 60 122 @r2 exists@ 123 + expression r1.t; 61 124 identifier g != r1.f; 62 - struct timer_list t; 63 125 expression e8; 64 126 @@ 65 127 66 128 g(...) { ... when any 67 - t.data = e8 129 + \(t.data\|t->data\) = e8 68 130 ... when any 69 131 } 70 132 ··· 141 77 cocci.include_match(False) 142 78 143 79 @r3 depends on patch && !context && !org && !report@ 144 - expression e6, e7, c; 80 + expression r1.t, func, e7; 145 81 position r1.p; 146 82 @@ 147 83 148 - -init_timer@p (&e6); 149 - +setup_timer (&e6, c, 0UL); 150 - ... when != c = e7 151 - -e6.function = c; 84 + ( 85 + -init_timer@p(&t); 86 + +setup_timer(&t, func, 0UL); 87 + ... when != func = e7 88 + -t.function = func; 89 + | 90 + -t.function = func; 91 + ... when != func = e7 92 + -init_timer@p(&t); 93 + +setup_timer(&t, func, 0UL); 94 + | 95 + -init_timer@p(t); 96 + +setup_timer(t, func, 0UL); 97 + ... when != func = e7 98 + -t->function = func; 99 + | 100 + -t->function = func; 101 + ... when != func = e7 102 + -init_timer@p(t); 103 + +setup_timer(t, func, 0UL); 104 + ) 152 105 153 106 // ---------------------------------------------------------------------------- 154 107 ··· 185 104 ) 186 105 187 106 @match_function_and_data_after_init_timer_context 188 - depends on !patch && 189 - !match_immediate_function_data_after_init_timer_context && 190 - (context || org || report)@ 107 + depends on !patch && (context || org || report)@ 191 108 expression a, b, e1, e2, e3, e4, e5; 192 - position j0, j1, j2; 109 + position j0 != match_immediate_function_data_after_init_timer_context.j0,j1,j2; 193 110 @@ 194 111 195 112 * init_timer@j0 (&e1); ··· 203 124 * e1@j2.function = a; 204 125 ) 205 126 206 - @r3_context depends on !patch && 207 - !match_immediate_function_data_after_init_timer_context && 208 - !match_function_and_data_after_init_timer_context && 209 - (context || org || report)@ 127 + @r3_context depends on !patch && (context || org || report)@ 210 128 expression c, e6, e7; 211 129 position r1.p; 212 - position j0, j1; 130 + position j0 != 131 + {match_immediate_function_data_after_init_timer_context.j0, 132 + match_function_and_data_after_init_timer_context.j0}, j1; 213 133 @@ 214 134 215 135 * init_timer@j0@p (&e6);
+1 -1
scripts/coccinelle/iterators/list_entry_update.cocci
··· 15 15 virtual org 16 16 virtual report 17 17 18 - @r@ 18 + @r exists@ 19 19 iterator name list_for_each_entry; 20 20 expression x,E; 21 21 position p1,p2;
+4 -4
scripts/coccinelle/misc/ifcol.cocci
··· 3 3 /// Sometimes, code after an if that is indented is actually intended to be 4 4 /// part of the if branch. 5 5 /// 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 8 - /// is not visually aligned may be considered to be in the same column. 9 - /// 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 8 + //# is not visually aligned may be considered to be in the same column. 9 + // 10 10 // Confidence: Low 11 11 // Copyright: (C) 2010 Nicolas Palix, DIKU. GPLv2. 12 12 // Copyright: (C) 2010 Julia Lawall, DIKU. GPLv2.
+29 -14
scripts/coccinelle/misc/orplus.cocci
··· 14 14 virtual context 15 15 16 16 @r@ 17 - constant c; 17 + constant c,c1; 18 + identifier i,i1; 19 + position p; 20 + @@ 21 + 22 + ( 23 + c1 + c - 1 24 + | 25 + c1@i1 +@p c@i 26 + ) 27 + 28 + @s@ 29 + constant r.c, r.c1; 18 30 identifier i; 19 31 expression e; 20 32 @@ ··· 39 27 e |= c@i 40 28 | 41 29 e &= c@i 30 + | 31 + e | c1@i 32 + | 33 + e & c1@i 34 + | 35 + e |= c1@i 36 + | 37 + e &= c1@i 42 38 ) 43 39 44 - @s@ 45 - constant r.c,c1; 46 - identifier i1; 47 - position p; 40 + @depends on s@ 41 + position r.p; 42 + constant c1,c2; 48 43 @@ 49 44 50 - ( 51 - c1 + c - 1 52 - | 53 - *c1@i1 +@p c 54 - ) 45 + * c1 +@p c2 55 46 56 - @script:python depends on org@ 57 - p << s.p; 47 + @script:python depends on s && org@ 48 + p << r.p; 58 49 @@ 59 50 60 51 cocci.print_main("sum of probable bitmasks, consider |",p) 61 52 62 - @script:python depends on report@ 63 - p << s.p; 53 + @script:python depends on s && report@ 54 + p << r.p; 64 55 @@ 65 56 66 57 msg = "WARNING: sum of probable bitmasks, consider |"
+1 -1
scripts/coccinelle/null/badzero.cocci
··· 10 10 // Copyright: (C) 2012 Julia Lawall, INRIA/LIP6. GPLv2. 11 11 // Copyright: (C) 2012 Gilles Muller, INRIA/LiP6. GPLv2. 12 12 // URL: http://coccinelle.lip6.fr/ 13 - // Comments: Requires Coccinelle version 1.0.0-rc20 or later 13 + // Requires: 1.0.0 14 14 // Options: 15 15 16 16 virtual patch
+5 -4
scripts/package/Makefile
··· 50 50 $(MAKE) clean 51 51 $(CONFIG_SHELL) $(MKSPEC) >$(objtree)/kernel.spec 52 52 $(call cmd,src_tar,$(KERNELPATH),kernel.spec) 53 - rpmbuild $(RPMOPTS) --target $(UTS_MACHINE) -ta $(KERNELPATH).tar.gz 54 - rm $(KERNELPATH).tar.gz kernel.spec 53 + +rpmbuild $(RPMOPTS) --target $(UTS_MACHINE) -ta $(KERNELPATH).tar.gz \ 54 + --define='_smp_mflags %{nil}' 55 55 56 56 # binrpm-pkg 57 57 # --------------------------------------------------------------------------- 58 58 binrpm-pkg: FORCE 59 59 $(MAKE) KBUILD_SRC= 60 60 $(CONFIG_SHELL) $(MKSPEC) prebuilt > $(objtree)/binkernel.spec 61 - rpmbuild $(RPMOPTS) --define "_builddir $(objtree)" --target \ 61 + +rpmbuild $(RPMOPTS) --define "_builddir $(objtree)" --target \ 62 62 $(UTS_MACHINE) -bb $(objtree)/binkernel.spec 63 - rm binkernel.spec 63 + 64 + clean-files += $(objtree)/*.spec 64 65 65 66 # Deb target 66 67 # ---------------------------------------------------------------------------
+2 -2
scripts/package/builddeb
··· 408 408 dpkg-source -cdebian/control -ldebian/changelog --format="3.0 (custom)" --target-format="3.0 (quilt)" \ 409 409 -b / ../${sourcename}_${version}.orig.tar.gz ../${sourcename}_${packageversion}.debian.tar.gz 410 410 mv ${sourcename}_${packageversion}*dsc .. 411 - dpkg-genchanges > ../${sourcename}_${packageversion}_${debarch}.changes 411 + dpkg-genchanges -Vkernel:debarch="${debarch}" > ../${sourcename}_${packageversion}_${debarch}.changes 412 412 else 413 - dpkg-genchanges -b > ../${sourcename}_${packageversion}_${debarch}.changes 413 + dpkg-genchanges -b -Vkernel:debarch="${debarch}" > ../${sourcename}_${packageversion}_${debarch}.changes 414 414 fi 415 415 416 416 exit 0
+115 -136
scripts/package/mkspec
··· 10 10 # 11 11 12 12 # how we were called determines which rpms we build and how we build them 13 - if [ "$1" = "prebuilt" ]; then 14 - PREBUILT=true 13 + if [ "$1" = prebuilt ]; then 14 + S=DEL 15 15 else 16 - PREBUILT=false 16 + S= 17 17 fi 18 18 19 - # starting to output the spec 20 - if [ "`grep CONFIG_DRM=y .config | cut -f2 -d\=`" = "y" ]; then 19 + if grep -q CONFIG_MODULES=y .config; then 20 + M= 21 + else 22 + M=DEL 23 + fi 24 + 25 + if grep -q CONFIG_DRM=y .config; then 21 26 PROVIDES=kernel-drm 22 27 fi 23 28 24 29 PROVIDES="$PROVIDES kernel-$KERNELRELEASE" 25 - __KERNELRELEASE=`echo $KERNELRELEASE | sed -e "s/-/_/g"` 30 + __KERNELRELEASE=$(echo $KERNELRELEASE | sed -e "s/-/_/g") 31 + EXCLUDES="$RCS_TAR_IGNORE --exclude=.tmp_versions --exclude=*vmlinux* \ 32 + --exclude=*.o --exclude=*.ko --exclude=*.cmd --exclude=Documentation \ 33 + --exclude=.config.old --exclude=.missing-syscalls.d" 26 34 27 - echo "Name: kernel" 28 - echo "Summary: The Linux Kernel" 29 - echo "Version: $__KERNELRELEASE" 30 - echo "Release: $(cat .version 2>/dev/null || echo 1)" 31 - echo "License: GPL" 32 - echo "Group: System Environment/Kernel" 33 - echo "Vendor: The Linux Community" 34 - echo "URL: http://www.kernel.org" 35 + # We can label the here-doc lines for conditional output to the spec file 36 + # 37 + # Labels: 38 + # $S: this line is enabled only when building source package 39 + # $M: this line is enabled only when CONFIG_MODULES is enabled 40 + sed -e '/^DEL/d' -e 's/^\t*//' <<EOF 41 + Name: kernel 42 + Summary: The Linux Kernel 43 + Version: $__KERNELRELEASE 44 + Release: $(cat .version 2>/dev/null || echo 1) 45 + License: GPL 46 + Group: System Environment/Kernel 47 + Vendor: The Linux Community 48 + URL: http://www.kernel.org 49 + $S Source: kernel-$__KERNELRELEASE.tar.gz 50 + Provides: $PROVIDES 51 + %define __spec_install_post /usr/lib/rpm/brp-compress || : 52 + %define debug_package %{nil} 35 53 36 - if ! $PREBUILT; then 37 - echo "Source: kernel-$__KERNELRELEASE.tar.gz" 38 - fi 54 + %description 55 + The Linux Kernel, the operating system core itself 39 56 40 - echo "BuildRoot: %{_tmppath}/%{name}-%{PACKAGE_VERSION}-root" 41 - echo "Provides: $PROVIDES" 42 - echo "%define __spec_install_post /usr/lib/rpm/brp-compress || :" 43 - echo "%define debug_package %{nil}" 44 - echo "" 45 - echo "%description" 46 - echo "The Linux Kernel, the operating system core itself" 47 - echo "" 48 - echo "%package headers" 49 - echo "Summary: Header files for the Linux kernel for use by glibc" 50 - echo "Group: Development/System" 51 - echo "Obsoletes: kernel-headers" 52 - echo "Provides: kernel-headers = %{version}" 53 - echo "%description headers" 54 - echo "Kernel-headers includes the C header files that specify the interface" 55 - echo "between the Linux kernel and userspace libraries and programs. The" 56 - echo "header files define structures and constants that are needed for" 57 - echo "building most standard programs and are also needed for rebuilding the" 58 - echo "glibc package." 59 - echo "" 60 - echo "%package devel" 61 - echo "Summary: Development package for building kernel modules to match the $__KERNELRELEASE kernel" 62 - echo "Group: System Environment/Kernel" 63 - echo "AutoReqProv: no" 64 - echo "%description -n kernel-devel" 65 - echo "This package provides kernel headers and makefiles sufficient to build modules" 66 - echo "against the $__KERNELRELEASE kernel package." 67 - echo "" 57 + %package headers 58 + Summary: Header files for the Linux kernel for use by glibc 59 + Group: Development/System 60 + Obsoletes: kernel-headers 61 + Provides: kernel-headers = %{version} 62 + %description headers 63 + Kernel-headers includes the C header files that specify the interface 64 + between the Linux kernel and userspace libraries and programs. The 65 + header files define structures and constants that are needed for 66 + building most standard programs and are also needed for rebuilding the 67 + glibc package. 68 68 69 - if ! $PREBUILT; then 70 - echo "%prep" 71 - echo "%setup -q" 72 - echo "" 73 - fi 69 + $S$M %package devel 70 + $S$M Summary: Development package for building kernel modules to match the $__KERNELRELEASE kernel 71 + $S$M Group: System Environment/Kernel 72 + $S$M AutoReqProv: no 73 + $S$M %description -n kernel-devel 74 + $S$M This package provides kernel headers and makefiles sufficient to build modules 75 + $S$M against the $__KERNELRELEASE kernel package. 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 74 105 75 - echo "%build" 106 + %clean 107 + rm -rf %{buildroot} 76 108 77 - if ! $PREBUILT; then 78 - echo "make clean && make %{?_smp_mflags} KBUILD_BUILD_VERSION=%{release}" 79 - echo "" 80 - fi 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 81 117 82 - echo "%install" 83 - echo 'KBUILD_IMAGE=$(make image_name)' 84 - echo "%ifarch ia64" 85 - echo 'mkdir -p $RPM_BUILD_ROOT/boot/efi $RPM_BUILD_ROOT/lib/modules' 86 - echo "%else" 87 - echo 'mkdir -p $RPM_BUILD_ROOT/boot $RPM_BUILD_ROOT/lib/modules' 88 - echo "%endif" 118 + %preun 119 + if [ -x /sbin/new-kernel-pkg ]; then 120 + new-kernel-pkg --remove $KERNELRELEASE --rminitrd --initrdfile=/boot/initramfs-$KERNELRELEASE.img 121 + fi 89 122 90 - echo 'INSTALL_MOD_PATH=$RPM_BUILD_ROOT make %{?_smp_mflags} KBUILD_SRC= modules_install' 91 - echo "%ifarch ia64" 92 - echo 'cp $KBUILD_IMAGE $RPM_BUILD_ROOT'"/boot/efi/vmlinuz-$KERNELRELEASE" 93 - echo 'ln -s '"efi/vmlinuz-$KERNELRELEASE" '$RPM_BUILD_ROOT'"/boot/" 94 - echo "%else" 95 - echo "%ifarch ppc64" 96 - echo "cp vmlinux arch/powerpc/boot" 97 - echo "cp arch/powerpc/boot/"'$KBUILD_IMAGE $RPM_BUILD_ROOT'"/boot/vmlinuz-$KERNELRELEASE" 98 - echo "%else" 99 - echo 'cp $KBUILD_IMAGE $RPM_BUILD_ROOT'"/boot/vmlinuz-$KERNELRELEASE" 100 - echo "%endif" 101 - echo "%endif" 123 + %postun 124 + if [ -x /sbin/update-bootloader ]; then 125 + /sbin/update-bootloader --remove $KERNELRELEASE 126 + fi 102 127 103 - echo 'make %{?_smp_mflags} INSTALL_HDR_PATH=$RPM_BUILD_ROOT/usr KBUILD_SRC= headers_install' 104 - echo 'cp System.map $RPM_BUILD_ROOT'"/boot/System.map-$KERNELRELEASE" 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/* 105 134 106 - echo 'cp .config $RPM_BUILD_ROOT'"/boot/config-$KERNELRELEASE" 107 - 108 - echo "%ifnarch ppc64" 109 - echo 'bzip2 -9 --keep vmlinux' 110 - echo 'mv vmlinux.bz2 $RPM_BUILD_ROOT'"/boot/vmlinux-$KERNELRELEASE.bz2" 111 - echo "%endif" 112 - 113 - if ! $PREBUILT; then 114 - echo 'rm -f $RPM_BUILD_ROOT'"/lib/modules/$KERNELRELEASE/build" 115 - echo 'rm -f $RPM_BUILD_ROOT'"/lib/modules/$KERNELRELEASE/source" 116 - echo "mkdir -p "'$RPM_BUILD_ROOT'"/usr/src/kernels/$KERNELRELEASE" 117 - 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\"" 118 - echo "tar "'$EXCLUDES'" -cf- . | (cd "'$RPM_BUILD_ROOT'"/usr/src/kernels/$KERNELRELEASE;tar xvf -)" 119 - echo 'cd $RPM_BUILD_ROOT'"/lib/modules/$KERNELRELEASE" 120 - echo "ln -sf /usr/src/kernels/$KERNELRELEASE build" 121 - echo "ln -sf /usr/src/kernels/$KERNELRELEASE source" 122 - fi 123 - 124 - echo "" 125 - echo "%clean" 126 - echo 'rm -rf $RPM_BUILD_ROOT' 127 - echo "" 128 - echo "%post" 129 - echo "if [ -x /sbin/installkernel -a -r /boot/vmlinuz-$KERNELRELEASE -a -r /boot/System.map-$KERNELRELEASE ]; then" 130 - echo "cp /boot/vmlinuz-$KERNELRELEASE /boot/.vmlinuz-$KERNELRELEASE-rpm" 131 - echo "cp /boot/System.map-$KERNELRELEASE /boot/.System.map-$KERNELRELEASE-rpm" 132 - echo "rm -f /boot/vmlinuz-$KERNELRELEASE /boot/System.map-$KERNELRELEASE" 133 - echo "/sbin/installkernel $KERNELRELEASE /boot/.vmlinuz-$KERNELRELEASE-rpm /boot/.System.map-$KERNELRELEASE-rpm" 134 - echo "rm -f /boot/.vmlinuz-$KERNELRELEASE-rpm /boot/.System.map-$KERNELRELEASE-rpm" 135 - echo "fi" 136 - echo "" 137 - echo "%preun" 138 - echo "if [ -x /sbin/new-kernel-pkg ]; then" 139 - echo "new-kernel-pkg --remove $KERNELRELEASE --rminitrd --initrdfile=/boot/initramfs-$KERNELRELEASE.img" 140 - echo "fi" 141 - echo "" 142 - echo "%postun" 143 - echo "if [ -x /sbin/update-bootloader ]; then" 144 - echo "/sbin/update-bootloader --remove $KERNELRELEASE" 145 - echo "fi" 146 - echo "" 147 - echo "%files" 148 - echo '%defattr (-, root, root)' 149 - echo "/lib/modules/$KERNELRELEASE" 150 - echo "%exclude /lib/modules/$KERNELRELEASE/build" 151 - echo "%exclude /lib/modules/$KERNELRELEASE/source" 152 - echo "/boot/*" 153 - echo "" 154 - echo "%files headers" 155 - echo '%defattr (-, root, root)' 156 - echo "/usr/include" 157 - echo "" 158 - if ! $PREBUILT; then 159 - echo "%files devel" 160 - echo '%defattr (-, root, root)' 161 - echo "/usr/src/kernels/$KERNELRELEASE" 162 - echo "/lib/modules/$KERNELRELEASE/build" 163 - echo "/lib/modules/$KERNELRELEASE/source" 164 - echo "" 165 - fi 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 144 + EOF