Merge ~smoser/cirros:feature/4.15-kernel-download into cirros:master

Proposed by Scott Moser
Status: Merged
Merged at revision: 566b84c5836e3c545c15d6da2447bf64f229a7f6
Proposed branch: ~smoser/cirros:feature/4.15-kernel-download
Merge into: cirros:master
Diff against target: 123 lines (+63/-12)
1 file modified
bin/grab-kernels (+63/-12)
Reviewer Review Type Date Requested Status
Paul Martin (community) Approve
cirros developers Pending
Review via email: mp+367475@code.launchpad.net

Commit message

grab-kernels: support downloading kernel version 4.15 (18.04).

The issue with 4.15 kernels in ubuntu is that they do not provide
any powerpc (ppc64 big endian) kernels. So before we could move
there we would need to find ppc64 kernel or drop powerpc and ppc64
arches (ppc64el is fine).

Description of the change

see commit message

To post a comment you must log in.
Revision history for this message
Paul Martin (paul-martin-1) wrote :

Looks good.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/bin/grab-kernels b/bin/grab-kernels
2index 055a83d..ef33bad 100755
3--- a/bin/grab-kernels
4+++ b/bin/grab-kernels
5@@ -17,7 +17,7 @@
6
7 source "${0%/*}/common-functions.sh"
8
9-burl="https://launchpad.net/ubuntu/+archive/primary/+files/linux-image"
10+burl="https://launchpad.net/ubuntu/+archive/primary/+files/"
11 outdir="./download"
12 def_arches="i386 x86_64 arm powerpc ppc64 ppc64le aarch64"
13
14@@ -52,7 +52,6 @@ debs2tar() {
15 return 0
16 }
17
18-[ "$1" = "--outdir" ] && { outdir="$1" && shift; }
19 kver="$1"
20 shift
21
22@@ -69,6 +68,48 @@ fi
23 # version like 3.13.0-52.86
24 # 3.19.0-20.20~14.04.1
25
26+fmt_old() {
27+ # this worked for kernels 3.2 -> 4.4
28+ local xarch="$1"
29+ image="linux-image"
30+ extras=""
31+ case "$xarch" in
32+ amd64|i386|ppc64el|s390x)
33+ extras="linux-image-extra";;
34+ esac
35+}
36+
37+fmt_4_4_new() {
38+ # this is 4.15 format but with 4.4 arch availability.
39+ # was in place for 4.4 kernels >= abi 148.
40+ local xarch="$1"
41+ case "$xarch" in
42+ amd64|i386|ppc64el|s390x)
43+ extras="linux-modules linux-modules-extra";;
44+ arm64|armhf|powerpc)
45+ extras="linux-modules";;
46+ esac
47+ [ "$xarch" = "amd64" ] &&
48+ image="linux-image-unsigned" || image="linux-image"
49+}
50+
51+fmt_4_15() {
52+ # this format, with
53+ # images linux-image and linux-image-unsigned)
54+ # modules linux-modules and linux-modules-extra
55+ # was in place for 4.15.
56+ local xarch="$1"
57+ image="linux-image"
58+ extras="linux-modules linux-modules-extra"
59+ case "$xarch" in
60+ # no big endian kernel or 4.15
61+ amd64|ppc64el) image="linux-image-unsigned";;
62+ arm64|i386|s390x) :;;
63+ powerpc) image=""; extras="";;
64+ armhf) extras="linux-modules";;
65+ esac
66+}
67+
68 kpart=${kver%-*}
69 upart=${kver#*-}
70 abi=${upart%%.*}
71@@ -78,6 +119,7 @@ kmicro=${kpart#*.*.}
72
73 case "$kmajor.$kminor" in
74 3.2|3.13|3.19|4.4) :;;
75+ 4.15) error "WARN: 4.15 does not have a powerpc/ppc64-big-endian kernel.";;
76 *) error "WARN: possibly unknown kernel version $kmajor.$kminor.";;
77 esac
78
79@@ -101,17 +143,26 @@ for arch in "$@"; do
80 *) fail "unknown kernel:arch for $kver:$arch"
81 esac
82 fi
83- case $xarch in
84- amd64|i386|ppc64el|s390x) extra="-extra";;
85- *) extra="";
86+ image=""
87+ extras=""
88+ ffunc="fmt_4_15"
89+ case "$kmajor.$kminor" in
90+ 3.*) ffunc="fmt_old";;
91+ 4.4) [ "$abi" -ge 148 ] && ffunc="fmt_4_4_new" || ffunc=fmt_old;;
92 esac
93+ $ffunc "$xarch"
94+ [ -z "$image" -a -z "$extras" ] && {
95+ echo "WARN: no image/extras for $xarch and $kmajor.$kminor"
96+ continue
97+ }
98 debs=""
99- for epkg in "" $extra; do
100- url="$burl${epkg}-${kmajor}.${kminor}.${kmicro}-${abi}-${flav}_${kver}_${xarch}.deb"
101- dl "$url" "$outdir/${url##*/}" || fail "failed dl $url"
102- ln -sf ${url##*/} "$outdir/kernel-${arch}${epkg}.deb" ||
103- fail "failed symlink for $outdir/kernel-$arch${epkg}.deb"
104- debs="${debs} ${outdir}/${url##*/}"
105+ for epkg in $image $extras; do
106+ debname="${epkg}-${kmajor}.${kminor}.${kmicro}-${abi}-${flav}_${kver}_${xarch}.deb"
107+ url="$burl$debname"
108+ dl "$url" "$outdir/$debname" || fail "failed dl $url"
109+ ln -sf "$debname" "$outdir/kernel-${arch}-${epkg}.deb" ||
110+ fail "failed symlink for $outdir/kernel-$arch-${epkg}.deb"
111+ debs="${debs} ${outdir}/$debname"
112 done
113 tar="linux-image-${kver}-${flav}-${xarch}.tar.gz"
114 if [ -f "$outdir/${tar}" ]; then
115@@ -122,7 +173,7 @@ for arch in "$@"; do
116 error "wrote $outdir/${tar}"
117 fi
118 ln -sf "${tar}" "$outdir/kernel-${arch}.tar.gz" ||
119- fail "failed symlink for $outdir/kernel-$arch${epkg}.deb"
120+ fail "failed symlink for $outdir/kernel-$arch.tar.gz"
121 done
122
123 # vi: tabstop=4 expandtab

Subscribers

People subscribed via source and target branches