Kbuild misc updates for v4.16

- Add snap-pkg target to create Linux kernel snap package
 
 - Make out-of-tree creation of source packages fail correctly
 
 - Improve and fix several semantic patches
 -----BEGIN PGP SIGNATURE-----
 Version: GnuPG v1
 
 iQIcBAABAgAGBQJaczbiAAoJED2LAQed4NsGjkQP/i3/+ZCG6Ta8KDZmSnEcSKo4
 9ECukdq0N24WMXAoStdStKoYEeF7wUlA85Za5E10cl9+oj0jmDkmlZvtGit8yJoc
 eCCK8xeSLpHbrjY/k7Sc9ow4QpqKeOzgJzJY0PXdAKp16KCcdW0PN2OqWCvbxkdA
 q/fFIm9hMUbpdsyinFQA5Wn+/8VW829ZjCdfcCLZRzH7LG2BuxQA60Hzqcu2+BcI
 +C9BjP0tLIYM3V9rNcpJQBTB7mFku/SPmQ4ZERBPlc5/X2iQFeWAiNVi5oxFD/pH
 7EE8uYu8mVpzhBVhYCeOxcML77/D7TjSxQugviioZN3X7AdGosyBE8hNgGRfeNIu
 D1PWhwjdKvop3o0jqChcvPYdEijjxwckT5BH6m+yu07B3/TC8/J5JNg3hly0mtxk
 /ynVvz6hatekBem/dQJIgyRAKNrxR1Af+XPW3phyFWBMiz2scHjX2kgPQnWaXB9m
 aNtPqLzjJUVyoM1tTXgcJO1To836/yFEviZHILc1Y3oTOEVKVhvbF5W1HGq6EVJA
 x+GWtx2S1IgGU5fHLEs4EqWyyazSRB1BlGWhtQXkvb+MYwuaO78Wods89KDmvApL
 cybeyZhjrbAxyoin85BRKHo7iQUV0bT7tnpyLaA+J1GQqfLC5V93KoZIPhpziMbC
 LQBYkyhCNzaPLK2pkqek
 =WSoN
 -----END PGP SIGNATURE-----

Merge tag 'kbuild-misc-v4.16' of git://git.kernel.org/pub/scm/linux/kernel/git/masahiroy/linux-kbuild

Pull Kbuild misc updates from Masahiro Yamada:

 - add snap-pkg target to create Linux kernel snap package

 - make out-of-tree creation of source packages fail correctly

 - improve and fix several semantic patches

* tag 'kbuild-misc-v4.16' of git://git.kernel.org/pub/scm/linux/kernel/git/masahiroy/linux-kbuild:
  Coccinelle: coccicheck: fix typo
  Coccinelle: memdup: drop spurious line
  Coccinelle: kzalloc-simple: Rename kzalloc-simple to zalloc-simple
  Coccinelle: ifnullfree: Trim the warning reported in report mode
  Coccinelle: alloc_cast: Add more memory allocating functions to the list
  Coccinelle: array_size: report even if include is missing
  Coccinelle: kzalloc-simple: Add all zero allocating functions
  kbuild: pkg: make out-of-tree rpm/deb-pkg build immediately fail
  scripts/package: snap-pkg target
This commit is contained in:
Linus Torvalds 2018-02-01 11:43:45 -08:00
commit a659f15985
10 changed files with 565 additions and 115 deletions

5
.gitignore vendored
View file

@ -65,6 +65,11 @@ modules.builtin
#
/debian/
#
# Snap directory (make snap-pkg)
#
/snap/
#
# tar directory (make tar*-pkg)
#

View file

@ -177,7 +177,7 @@ coccinelle () {
REQ_NUM=$(echo $REQ | ${DIR}/scripts/ld-version.sh)
if [ "$REQ_NUM" != "0" ] ; then
if [ "$SPATCH_VERSION_NUM" -lt "$REQ_NUM" ] ; then
echo "Skipping coccinele SmPL patch: $COCCI"
echo "Skipping coccinelle SmPL patch: $COCCI"
echo "You have coccinelle: $SPATCH_VERSION"
echo "This SmPL patch requires: $REQ"
return

View file

@ -5,10 +5,11 @@
//# kmalloc, kzalloc, kcalloc, kmem_cache_alloc, kmem_cache_zalloc,
//# kmem_cache_alloc_node, kmalloc_node and kzalloc_node and removes
//# the casting as it is not required. The result in the patch case may
//#need some reformatting.
//# need some reformatting.
//
// Confidence: High
// Copyright: 2014, Himangi Saraogi GPLv2.
// Copyright: (C) 2014 Himangi Saraogi GPLv2.
// Copyright: (C) 2017 Himanshu Jha GPLv2.
// Comments:
// Options: --no-includes --include-headers
//
@ -18,55 +19,104 @@ virtual patch
virtual org
virtual report
@initialize:python@
@@
import re
pattern = '__'
m = re.compile(pattern)
@r1 depends on context || patch@
type T;
@@
(T *)
\(kmalloc\|kzalloc\|kcalloc\|kmem_cache_alloc\|kmem_cache_zalloc\|
kmem_cache_alloc_node\|kmalloc_node\|kzalloc_node\|vmalloc\|vzalloc\|
dma_alloc_coherent\|dma_zalloc_coherent\|devm_kmalloc\|devm_kzalloc\|
kvmalloc\|kvzalloc\|kvmalloc_node\|kvzalloc_node\|pci_alloc_consistent\|
pci_zalloc_consistent\|kmem_alloc\|kmem_zalloc\|kmem_zone_alloc\|
kmem_zone_zalloc\|vmalloc_node\|vzalloc_node\)(...)
//----------------------------------------------------------
// For context mode
//----------------------------------------------------------
@depends on context@
type T;
@script:python depends on context@
t << r1.T;
@@
if m.search(t) != None:
cocci.include_match(False)
@depends on context && r1@
type r1.T;
@@
* (T *)
\(kmalloc\|kzalloc\|kcalloc\|kmem_cache_alloc\|kmem_cache_zalloc\|
kmem_cache_alloc_node\|kmalloc_node\|kzalloc_node\)(...)
kmem_cache_alloc_node\|kmalloc_node\|kzalloc_node\|vmalloc\|vzalloc\|
dma_alloc_coherent\|dma_zalloc_coherent\|devm_kmalloc\|devm_kzalloc\|
kvmalloc\|kvzalloc\|kvmalloc_node\|kvzalloc_node\|pci_alloc_consistent\|
pci_zalloc_consistent\|kmem_alloc\|kmem_zalloc\|kmem_zone_alloc\|
kmem_zone_zalloc\|vmalloc_node\|vzalloc_node\)(...)
//----------------------------------------------------------
// For patch mode
//----------------------------------------------------------
@depends on patch@
type T;
@script:python depends on patch@
t << r1.T;
@@
if m.search(t) != None:
cocci.include_match(False)
@depends on patch && r1@
type r1.T;
@@
- (T *)
(\(kmalloc\|kzalloc\|kcalloc\|kmem_cache_alloc\|kmem_cache_zalloc\|
kmem_cache_alloc_node\|kmalloc_node\|kzalloc_node\)(...))
\(kmalloc\|kzalloc\|kcalloc\|kmem_cache_alloc\|kmem_cache_zalloc\|
kmem_cache_alloc_node\|kmalloc_node\|kzalloc_node\|vmalloc\|vzalloc\|
dma_alloc_coherent\|dma_zalloc_coherent\|devm_kmalloc\|devm_kzalloc\|
kvmalloc\|kvzalloc\|kvmalloc_node\|kvzalloc_node\|pci_alloc_consistent\|
pci_zalloc_consistent\|kmem_alloc\|kmem_zalloc\|kmem_zone_alloc\|
kmem_zone_zalloc\|vmalloc_node\|vzalloc_node\)(...)
//----------------------------------------------------------
// For org and report mode
//----------------------------------------------------------
@r depends on org || report@
@r2 depends on org || report@
type T;
position p;
@@
(T@p *)\(kmalloc\|kzalloc\|kcalloc\|kmem_cache_alloc\|kmem_cache_zalloc\|
kmem_cache_alloc_node\|kmalloc_node\|kzalloc_node\)(...)
(T@p *)
\(kmalloc\|kzalloc\|kcalloc\|kmem_cache_alloc\|kmem_cache_zalloc\|
kmem_cache_alloc_node\|kmalloc_node\|kzalloc_node\|vmalloc\|vzalloc\|
dma_alloc_coherent\|dma_zalloc_coherent\|devm_kmalloc\|devm_kzalloc\|
kvmalloc\|kvzalloc\|kvmalloc_node\|kvzalloc_node\|pci_alloc_consistent\|
pci_zalloc_consistent\|kmem_alloc\|kmem_zalloc\|kmem_zone_alloc\|
kmem_zone_zalloc\|vmalloc_node\|vzalloc_node\)(...)
@script:python depends on org@
p << r.p;
t << r.T;
p << r2.p;
t << r2.T;
@@
coccilib.org.print_safe_todo(p[0], t)
if m.search(t) != None:
cocci.include_match(False)
else:
coccilib.org.print_safe_todo(p[0], t)
@script:python depends on report@
p << r.p;
t << r.T;
p << r2.p;
t << r2.T;
@@
msg="WARNING: casting value returned by memory allocation function to (%s *) is useless." % (t)
coccilib.report.print_report(p[0], msg)
if m.search(t) != None:
cocci.include_match(False)
else:
msg="WARNING: casting value returned by memory allocation function to (%s *) is useless." % (t)
coccilib.report.print_report(p[0], msg)

View file

@ -1,86 +0,0 @@
///
/// Use kzalloc rather than kmalloc followed by memset with 0
///
/// This considers some simple cases that are common and easy to validate
/// Note in particular that there are no ...s in the rule, so all of the
/// matched code has to be contiguous
///
// Confidence: High
// Copyright: (C) 2009-2010 Julia Lawall, Nicolas Palix, DIKU. GPLv2.
// Copyright: (C) 2009-2010 Gilles Muller, INRIA/LiP6. GPLv2.
// URL: http://coccinelle.lip6.fr/rules/kzalloc.html
// Options: --no-includes --include-headers
//
// Keywords: kmalloc, kzalloc
// Version min: < 2.6.12 kmalloc
// Version min: 2.6.14 kzalloc
//
virtual context
virtual patch
virtual org
virtual report
//----------------------------------------------------------
// For context mode
//----------------------------------------------------------
@depends on context@
type T, T2;
expression x;
expression E1,E2;
statement S;
@@
* x = (T)kmalloc(E1,E2);
if ((x==NULL) || ...) S
* memset((T2)x,0,E1);
//----------------------------------------------------------
// For patch mode
//----------------------------------------------------------
@depends on patch@
type T, T2;
expression x;
expression E1,E2;
statement S;
@@
- x = (T)kmalloc(E1,E2);
+ x = kzalloc(E1,E2);
if ((x==NULL) || ...) S
- memset((T2)x,0,E1);
//----------------------------------------------------------
// For org mode
//----------------------------------------------------------
@r depends on org || report@
type T, T2;
expression x;
expression E1,E2;
statement S;
position p;
@@
x = (T)kmalloc@p(E1,E2);
if ((x==NULL) || ...) S
memset((T2)x,0,E1);
@script:python depends on org@
p << r.p;
x << r.x;
@@
msg="%s" % (x)
msg_safe=msg.replace("[","@(").replace("]",")")
coccilib.org.print_todo(p[0], msg_safe)
@script:python depends on report@
p << r.p;
x << r.x;
@@
msg="WARNING: kzalloc should be used for %s, instead of kmalloc/memset" % (x)
coccilib.report.print_report(p[0], msg)

View file

@ -0,0 +1,448 @@
///
/// Use zeroing allocator rather than allocator followed by memset with 0
///
/// This considers some simple cases that are common and easy to validate
/// Note in particular that there are no ...s in the rule, so all of the
/// matched code has to be contiguous
///
// Confidence: High
// Copyright: (C) 2009-2010 Julia Lawall, Nicolas Palix, DIKU. GPLv2.
// Copyright: (C) 2009-2010 Gilles Muller, INRIA/LiP6. GPLv2.
// Copyright: (C) 2017 Himanshu Jha GPLv2.
// URL: http://coccinelle.lip6.fr/rules/kzalloc.html
// Options: --no-includes --include-headers
//
// Keywords: kmalloc, kzalloc
// Version min: < 2.6.12 kmalloc
// Version min: 2.6.14 kzalloc
//
virtual context
virtual patch
virtual org
virtual report
//----------------------------------------------------------
// For context mode
//----------------------------------------------------------
@depends on context@
type T, T2;
expression x;
expression E1;
statement S;
@@
* x = (T)\(kmalloc(E1, ...)\|vmalloc(E1)\|dma_alloc_coherent(...,E1,...)\|
kmalloc_node(E1, ...)\|kmem_cache_alloc(...)\|kmem_alloc(E1, ...)\|
devm_kmalloc(...,E1,...)\|kvmalloc(E1, ...)\|pci_alloc_consistent(...,E1,...)\|
kvmalloc_node(E1,...)\);
if ((x==NULL) || ...) S
* memset((T2)x,0,E1);
//----------------------------------------------------------
// For patch mode
//----------------------------------------------------------
@depends on patch@
type T, T2;
expression x;
expression E1,E2,E3,E4;
statement S;
@@
(
- x = kmalloc(E1,E2);
+ x = kzalloc(E1,E2);
|
- x = (T *)kmalloc(E1,E2);
+ x = kzalloc(E1,E2);
|
- x = (T)kmalloc(E1,E2);
+ x = (T)kzalloc(E1,E2);
|
- x = vmalloc(E1);
+ x = vzalloc(E1);
|
- x = (T *)vmalloc(E1);
+ x = vzalloc(E1);
|
- x = (T)vmalloc(E1);
+ x = (T)vzalloc(E1);
|
- x = dma_alloc_coherent(E2,E1,E3,E4);
+ x = dma_zalloc_coherent(E2,E1,E3,E4);
|
- x = (T *)dma_alloc_coherent(E2,E1,E3,E4);
+ x = dma_zalloc_coherent(E2,E1,E3,E4);
|
- x = (T)dma_alloc_coherent(E2,E1,E3,E4);
+ x = (T)dma_zalloc_coherent(E2,E1,E3,E4);
|
- x = kmalloc_node(E1,E2,E3);
+ x = kzalloc_node(E1,E2,E3);
|
- x = (T *)kmalloc_node(E1,E2,E3);
+ x = kzalloc_node(E1,E2,E3);
|
- x = (T)kmalloc_node(E1,E2,E3);
+ x = (T)kzalloc_node(E1,E2,E3);
|
- x = kmem_cache_alloc(E3,E4);
+ x = kmem_cache_zalloc(E3,E4);
|
- x = (T *)kmem_cache_alloc(E3,E4);
+ x = kmem_cache_zalloc(E3,E4);
|
- x = (T)kmem_cache_alloc(E3,E4);
+ x = (T)kmem_cache_zalloc(E3,E4);
|
- x = kmem_alloc(E1,E2);
+ x = kmem_zalloc(E1,E2);
|
- x = (T *)kmem_alloc(E1,E2);
+ x = kmem_zalloc(E1,E2);
|
- x = (T)kmem_alloc(E1,E2);
+ x = (T)kmem_zalloc(E1,E2);
|
- x = devm_kmalloc(E2,E1,E3);
+ x = devm_kzalloc(E2,E1,E3);
|
- x = (T *)devm_kmalloc(E2,E1,E3);
+ x = devm_kzalloc(E2,E1,E3);
|
- x = (T)devm_kmalloc(E2,E1,E3);
+ x = (T)devm_kzalloc(E2,E1,E3);
|
- x = kvmalloc(E1,E2);
+ x = kvzalloc(E1,E2);
|
- x = (T *)kvmalloc(E1,E2);
+ x = kvzalloc(E1,E2);
|
- x = (T)kvmalloc(E1,E2);
+ x = (T)kvzalloc(E1,E2);
|
- x = pci_alloc_consistent(E2,E1,E3);
+ x = pci_zalloc_consistent(E2,E1,E3);
|
- x = (T *)pci_alloc_consistent(E2,E1,E3);
+ x = pci_zalloc_consistent(E2,E1,E3);
|
- x = (T)pci_alloc_consistent(E2,E1,E3);
+ x = (T)pci_zalloc_consistent(E2,E1,E3);
|
- x = kvmalloc_node(E1,E2,E3);
+ x = kvzalloc_node(E1,E2,E3);
|
- x = (T *)kvmalloc_node(E1,E2,E3);
+ x = kvzalloc_node(E1,E2,E3);
|
- x = (T)kvmalloc_node(E1,E2,E3);
+ x = (T)kvzalloc_node(E1,E2,E3);
)
if ((x==NULL) || ...) S
- memset((T2)x,0,E1);
//----------------------------------------------------------
// For org mode
//----------------------------------------------------------
@r depends on org || report@
type T, T2;
expression x;
expression E1,E2;
statement S;
position p;
@@
x = (T)kmalloc@p(E1,E2);
if ((x==NULL) || ...) S
memset((T2)x,0,E1);
@script:python depends on org@
p << r.p;
x << r.x;
@@
msg="%s" % (x)
msg_safe=msg.replace("[","@(").replace("]",")")
coccilib.org.print_todo(p[0], msg_safe)
@script:python depends on report@
p << r.p;
x << r.x;
@@
msg="WARNING: kzalloc should be used for %s, instead of kmalloc/memset" % (x)
coccilib.report.print_report(p[0], msg)
//-----------------------------------------------------------------
@r1 depends on org || report@
type T, T2;
expression x;
expression E1;
statement S;
position p;
@@
x = (T)vmalloc@p(E1);
if ((x==NULL) || ...) S
memset((T2)x,0,E1);
@script:python depends on org@
p << r1.p;
x << r1.x;
@@
msg="%s" % (x)
msg_safe=msg.replace("[","@(").replace("]",")")
coccilib.org.print_todo(p[0], msg_safe)
@script:python depends on report@
p << r1.p;
x << r1.x;
@@
msg="WARNING: vzalloc should be used for %s, instead of vmalloc/memset" % (x)
coccilib.report.print_report(p[0], msg)
//-----------------------------------------------------------------
@r2 depends on org || report@
type T, T2;
expression x;
expression E1,E2,E3,E4;
statement S;
position p;
@@
x = (T)dma_alloc_coherent@p(E2,E1,E3,E4);
if ((x==NULL) || ...) S
memset((T2)x,0,E1);
@script:python depends on org@
p << r2.p;
x << r2.x;
@@
msg="%s" % (x)
msg_safe=msg.replace("[","@(").replace("]",")")
coccilib.org.print_todo(p[0], msg_safe)
@script:python depends on report@
p << r2.p;
x << r2.x;
@@
msg="WARNING: dma_zalloc_coherent should be used for %s, instead of dma_alloc_coherent/memset" % (x)
coccilib.report.print_report(p[0], msg)
//-----------------------------------------------------------------
@r3 depends on org || report@
type T, T2;
expression x;
expression E1,E2,E3;
statement S;
position p;
@@
x = (T)kmalloc_node@p(E1,E2,E3);
if ((x==NULL) || ...) S
memset((T2)x,0,E1);
@script:python depends on org@
p << r3.p;
x << r3.x;
@@
msg="%s" % (x)
msg_safe=msg.replace("[","@(").replace("]",")")
coccilib.org.print_todo(p[0], msg_safe)
@script:python depends on report@
p << r3.p;
x << r3.x;
@@
msg="WARNING: kzalloc_node should be used for %s, instead of kmalloc_node/memset" % (x)
coccilib.report.print_report(p[0], msg)
//-----------------------------------------------------------------
@r4 depends on org || report@
type T, T2;
expression x;
expression E1,E2,E3;
statement S;
position p;
@@
x = (T)kmem_cache_alloc@p(E2,E3);
if ((x==NULL) || ...) S
memset((T2)x,0,E1);
@script:python depends on org@
p << r4.p;
x << r4.x;
@@
msg="%s" % (x)
msg_safe=msg.replace("[","@(").replace("]",")")
coccilib.org.print_todo(p[0], msg_safe)
@script:python depends on report@
p << r4.p;
x << r4.x;
@@
msg="WARNING: kmem_cache_zalloc should be used for %s, instead of kmem_cache_alloc/memset" % (x)
coccilib.report.print_report(p[0], msg)
//-----------------------------------------------------------------
@r5 depends on org || report@
type T, T2;
expression x;
expression E1,E2;
statement S;
position p;
@@
x = (T)kmem_alloc@p(E1,E2);
if ((x==NULL) || ...) S
memset((T2)x,0,E1);
@script:python depends on org@
p << r5.p;
x << r5.x;
@@
msg="%s" % (x)
msg_safe=msg.replace("[","@(").replace("]",")")
coccilib.org.print_todo(p[0], msg_safe)
@script:python depends on report@
p << r5.p;
x << r5.x;
@@
msg="WARNING: kmem_zalloc should be used for %s, instead of kmem_alloc/memset" % (x)
coccilib.report.print_report(p[0], msg)
//-----------------------------------------------------------------
@r6 depends on org || report@
type T, T2;
expression x;
expression E1,E2,E3;
statement S;
position p;
@@
x = (T)devm_kmalloc@p(E2,E1,E3);
if ((x==NULL) || ...) S
memset((T2)x,0,E1);
@script:python depends on org@
p << r6.p;
x << r6.x;
@@
msg="%s" % (x)
msg_safe=msg.replace("[","@(").replace("]",")")
coccilib.org.print_todo(p[0], msg_safe)
@script:python depends on report@
p << r6.p;
x << r6.x;
@@
msg="WARNING: devm_kzalloc should be used for %s, instead of devm_kmalloc/memset" % (x)
coccilib.report.print_report(p[0], msg)
//-----------------------------------------------------------------
@r7 depends on org || report@
type T, T2;
expression x;
expression E1,E2;
statement S;
position p;
@@
x = (T)kvmalloc@p(E1,E2);
if ((x==NULL) || ...) S
memset((T2)x,0,E1);
@script:python depends on org@
p << r7.p;
x << r7.x;
@@
msg="%s" % (x)
msg_safe=msg.replace("[","@(").replace("]",")")
coccilib.org.print_todo(p[0], msg_safe)
@script:python depends on report@
p << r7.p;
x << r7.x;
@@
msg="WARNING: kvzalloc should be used for %s, instead of kvmalloc/memset" % (x)
coccilib.report.print_report(p[0], msg)
//-----------------------------------------------------------------
@r8 depends on org || report@
type T, T2;
expression x;
expression E1,E2,E3;
statement S;
position p;
@@
x = (T)pci_alloc_consistent@p(E2,E1,E3);
if ((x==NULL) || ...) S
memset((T2)x,0,E1);
@script:python depends on org@
p << r8.p;
x << r8.x;
@@
msg="%s" % (x)
msg_safe=msg.replace("[","@(").replace("]",")")
coccilib.org.print_todo(p[0], msg_safe)
@script:python depends on report@
p << r8.p;
x << r8.x;
@@
msg="WARNING: pci_zalloc_consistent should be used for %s, instead of pci_alloc_consistent/memset" % (x)
coccilib.report.print_report(p[0], msg)
//-----------------------------------------------------------------
@r9 depends on org || report@
type T, T2;
expression x;
expression E1,E2,E3;
statement S;
position p;
@@
x = (T)kvmalloc_node@p(E1,E2,E3);
if ((x==NULL) || ...) S
memset((T2)x,0,E1);
@script:python depends on org@
p << r9.p;
x << r9.x;
@@
msg="%s" % (x)
msg_safe=msg.replace("[","@(").replace("]",")")
coccilib.org.print_todo(p[0], msg_safe)
@script:python depends on report@
p << r9.p;
x << r9.x;
@@
msg="WARNING: kvzalloc_node should be used for %s, instead of kvmalloc_node/memset" % (x)
coccilib.report.print_report(p[0], msg)

View file

@ -49,7 +49,6 @@ statement S;
@@
* to = \(kmalloc@p\|kzalloc@p\)(size,flag);
to = kmemdup(from,size,flag);
if (to==NULL || ...) S
* memcpy(to, from, size);

View file

@ -55,5 +55,5 @@ cocci.print_main("NULL check before that freeing function is not needed", p)
p << r.p;
@@
msg = "WARNING: NULL check before freeing functions like kfree, debugfs_remove, debugfs_remove_recursive or usb_free_urb is not needed. Maybe consider reorganizing relevant code to avoid passing NULL values."
msg = "WARNING: NULL check before some freeing functions is not needed."
coccilib.report.print_report(p[0], msg)

View file

@ -72,13 +72,13 @@ position p;
(sizeof(E)@p /sizeof(T))
)
@script:python depends on i&&org@
@script:python depends on org@
p << r.p;
@@
coccilib.org.print_todo(p[0], "WARNING should use ARRAY_SIZE")
@script:python depends on i&&report@
@script:python depends on report@
p << r.p;
@@

View file

@ -32,10 +32,14 @@ MKSPEC := $(srctree)/scripts/package/mkspec
quiet_cmd_src_tar = TAR $(2).tar.gz
cmd_src_tar = \
set -e; \
if test "$(objtree)" != "$(srctree)"; then \
echo "Building source tarball is not possible outside the"; \
echo "kernel source tree. Don't set KBUILD_OUTPUT, or use the"; \
echo "binrpm-pkg or bindeb-pkg target instead."; \
echo >&2; \
echo >&2 " ERROR:"; \
echo >&2 " Building source tarball is not possible outside the"; \
echo >&2 " kernel source tree. Don't set KBUILD_OUTPUT, or use the"; \
echo >&2 " binrpm-pkg or bindeb-pkg target instead."; \
echo >&2; \
false; \
fi ; \
$(srctree)/scripts/setlocalversion --save-scmversion; \
@ -94,6 +98,21 @@ bindeb-pkg: FORCE
clean-dirs += $(objtree)/debian/
# snap-pkg
# ---------------------------------------------------------------------------
snap-pkg: FORCE
rm -rf $(objtree)/snap
mkdir $(objtree)/snap
$(MAKE) clean
$(call cmd,src_tar,$(KERNELPATH))
sed "s@KERNELRELEASE@$(KERNELRELEASE)@; \
s@SRCTREE@$(shell realpath $(KERNELPATH).tar.gz)@" \
$(srctree)/scripts/package/snapcraft.template > \
$(objtree)/snap/snapcraft.yaml
cd $(objtree)/snap && \
snapcraft --target-arch=$(UTS_MACHINE)
clean-dirs += $(objtree)/snap/
# tarball targets
# ---------------------------------------------------------------------------
@ -138,6 +157,7 @@ help: FORCE
@echo ' binrpm-pkg - Build only the binary kernel RPM package'
@echo ' deb-pkg - Build both source and binary deb kernel packages'
@echo ' bindeb-pkg - Build only the binary kernel deb package'
@echo ' snap-pkg - Build only the binary kernel snap package (will connect to external hosts)'
@echo ' tar-pkg - Build the kernel as an uncompressed tarball'
@echo ' targz-pkg - Build the kernel as a gzip compressed tarball'
@echo ' tarbz2-pkg - Build the kernel as a bzip2 compressed tarball'

View file

@ -0,0 +1,14 @@
name: kernel
version: KERNELRELEASE
summary: Linux kernel
description: The upstream Linux kernel
grade: stable
confinement: strict
type: kernel
parts:
kernel:
plugin: kernel
source: SRCTREE
source-type: tar
kernel-with-firmware: false