compat: add x86 support to get-compat-kernels for Ubuntu
[~emulex/for-vlad/old/compat.git] / bin / get-compat-kernels
1 #!/bin/bash
2 #
3 # Copyright (C) 2012, Luis R. Rodriguez <mcgrof@frijolero.org>
4 #
5 # This program is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License version 2 as
7 # published by the Free Software Foundation.
8 #
9 # You can use this script to install all mainline kernels used
10 # to test compile the Linux kernel compatibility module. You can
11 # then use ckmake to cross compile against all supported kernels.
12
13 function get_ubuntu_kernels() {
14
15         ARCH=$(uname -m)
16         TARGET=""
17
18         case $ARCH in
19         "x86_64")
20                 TARGET="amd64"
21                 ;;
22         "i686")
23                 TARGET="i386"
24                 ;;
25         *)
26                 echo -e "Unsupported architecture"
27                 exit
28                 ;;
29         esac
30
31         KERNELS=""
32
33         KPATH="http://kernel.ubuntu.com/~kernel-ppa/mainline/"
34
35         KERNELS="$KERNELS ${KPATH}/v2.6.24/linux-headers-2.6.24-020624_2.6.24-020624_all.deb"
36         KERNELS="$KERNELS ${KPATH}/v2.6.24/linux-headers-2.6.24-020624-generic_2.6.24-020624_${TARGET}.deb"
37         KERNELS="$KERNELS ${KPATH}/v2.6.24/linux-image-2.6.24-020624-generic_2.6.24-020624_${TARGET}.deb"
38
39         KERNELS="$KERNELS ${KPATH}/v2.6.25/linux-headers-2.6.25-020625_2.6.25-020625_all.deb"
40         KERNELS="$KERNELS ${KPATH}/v2.6.25/linux-headers-2.6.25-020625-generic_2.6.25-020625_${TARGET}.deb"
41         KERNELS="$KERNELS ${KPATH}/v2.6.25/linux-image-2.6.25-020625-generic_2.6.25-020625_${TARGET}.deb"
42
43         KERNELS="$KERNELS ${KPATH}/v2.6.26/linux-headers-2.6.26-020626_2.6.26-020626_all.deb"
44         KERNELS="$KERNELS ${KPATH}/v2.6.26/linux-headers-2.6.26-020626-generic_2.6.26-020626_${TARGET}.deb"
45         KERNELS="$KERNELS ${KPATH}/v2.6.26/linux-image-2.6.26-020626-generic_2.6.26-020626_${TARGET}.deb"
46
47         KERNELS="$KERNELS ${KPATH}/v2.6.27/linux-headers-2.6.27-020627_2.6.27-020627_all.deb"
48         KERNELS="$KERNELS ${KPATH}/v2.6.27/linux-headers-2.6.27-020627-generic_2.6.27-020627_${TARGET}.deb"
49         KERNELS="$KERNELS ${KPATH}/v2.6.27/linux-image-2.6.27-020627-generic_2.6.27-020627_${TARGET}.deb"
50
51         KERNELS="$KERNELS ${KPATH}/v2.6.28.10/linux-headers-2.6.28-02062810_2.6.28-02062810_all.deb"
52         KERNELS="$KERNELS ${KPATH}/v2.6.28.10/linux-headers-2.6.28-02062810-generic_2.6.28-02062810_${TARGET}.deb"
53         KERNELS="$KERNELS ${KPATH}/v2.6.28.10/linux-image-2.6.28-02062810-generic_2.6.28-02062810_${TARGET}.deb"
54
55         KERNELS="$KERNELS ${KPATH}/v2.6.29.6/linux-headers-2.6.29-02062906_2.6.29-02062906_all.deb"
56         KERNELS="$KERNELS ${KPATH}/v2.6.29.6/linux-headers-2.6.29-02062906-generic_2.6.29-02062906_${TARGET}.deb"
57         KERNELS="$KERNELS ${KPATH}/v2.6.29.6/linux-image-2.6.29-02062906-generic_2.6.29-02062906_${TARGET}.deb"
58
59         KERNELS="$KERNELS ${KPATH}/v2.6.30.10/linux-headers-2.6.30-02063010_2.6.30-02063010_all.deb"
60         KERNELS="$KERNELS ${KPATH}/v2.6.30.10/linux-headers-2.6.30-02063010-generic_2.6.30-02063010_${TARGET}.deb"
61         KERNELS="$KERNELS ${KPATH}/v2.6.30.10/linux-image-2.6.30-02063010-generic_2.6.30-02063010_${TARGET}.deb"
62
63         KERNELS="$KERNELS ${KPATH}/v2.6.31.13-karmic/linux-headers-2.6.31-02063113_2.6.31-02063113_all.deb"
64         KERNELS="$KERNELS ${KPATH}/v2.6.31.13-karmic/linux-headers-2.6.31-02063113-generic_2.6.31-02063113_${TARGET}.deb"
65         KERNELS="$KERNELS ${KPATH}/v2.6.31.13-karmic/linux-image-2.6.31-02063113-generic_2.6.31-02063113_${TARGET}.deb"
66
67         KERNELS="$KERNELS ${KPATH}/v2.6.32.55-lucid/linux-headers-2.6.32-02063255_2.6.32-02063255.201201251735_all.deb"
68         KERNELS="$KERNELS ${KPATH}/v2.6.32.55-lucid/linux-headers-2.6.32-02063255-generic_2.6.32-02063255.201201251735_${TARGET}.deb"
69         KERNELS="$KERNELS ${KPATH}/v2.6.32.55-lucid/linux-image-2.6.32-02063255-generic_2.6.32-02063255.201201251735_${TARGET}.deb"
70
71         KERNELS="$KERNELS ${KPATH}/v2.6.33.5-lucid/linux-headers-2.6.33-02063305_2.6.33-02063305_all.deb"
72         KERNELS="$KERNELS ${KPATH}/v2.6.33.5-lucid/linux-headers-2.6.33-02063305-generic_2.6.33-02063305_${TARGET}.deb"
73         KERNELS="$KERNELS ${KPATH}/v2.6.33.5-lucid/linux-image-2.6.33-02063305-generic_2.6.33-02063305_${TARGET}.deb"
74
75         KERNELS="$KERNELS ${KPATH}/v2.6.34.10-maverick/linux-headers-2.6.34-02063410_2.6.34-02063410.201111101535_all.deb"
76         KERNELS="$KERNELS ${KPATH}/v2.6.34.10-maverick/linux-headers-2.6.34-02063410-generic_2.6.34-02063410.201111101535_${TARGET}.deb"
77         KERNELS="$KERNELS ${KPATH}/v2.6.34.10-maverick/linux-image-2.6.34-02063410-generic_2.6.34-02063410.201111101535_${TARGET}.deb"
78
79         KERNELS="$KERNELS ${KPATH}/v2.6.35.13-maverick/linux-headers-2.6.35-02063512_2.6.35-02063512.201111232118_all.deb"
80         KERNELS="$KERNELS ${KPATH}/v2.6.35.13-maverick/linux-headers-2.6.35-02063512-generic_2.6.35-02063512.201111232118_${TARGET}.deb"
81         KERNELS="$KERNELS ${KPATH}/v2.6.35.13-maverick/linux-image-2.6.35-02063512-generic_2.6.35-02063512.201111232118_${TARGET}.deb"
82
83         KERNELS="$KERNELS ${KPATH}/v2.6.36.4-natty/linux-headers-2.6.36-02063604_2.6.36-02063604.201102180911_all.deb"
84         KERNELS="$KERNELS ${KPATH}/v2.6.36.4-natty/linux-headers-2.6.36-02063604-generic_2.6.36-02063604.201102180911_${TARGET}.deb"
85         KERNELS="$KERNELS ${KPATH}/v2.6.36.4-natty/linux-image-2.6.36-02063604-generic_2.6.36-02063604.201102180911_${TARGET}.deb"
86
87         KERNELS="$KERNELS ${KPATH}/v2.6.37.6-natty/linux-headers-2.6.37-02063706_2.6.37-02063706.201103281005_all.deb"
88         KERNELS="$KERNELS ${KPATH}/v2.6.37.6-natty/linux-headers-2.6.37-02063706-generic_2.6.37-02063706.201103281005_${TARGET}.deb"
89         KERNELS="$KERNELS ${KPATH}/v2.6.37.6-natty/linux-image-2.6.37-02063706-generic_2.6.37-02063706.201103281005_${TARGET}.deb"
90
91         KERNELS="$KERNELS ${KPATH}/v2.6.38.8-natty/linux-headers-2.6.38-02063808_2.6.38-02063808.201106040910_all.deb"
92         KERNELS="$KERNELS ${KPATH}/v2.6.38.8-natty/linux-headers-2.6.38-02063808-generic_2.6.38-02063808.201106040910_${TARGET}.deb"
93         KERNELS="$KERNELS ${KPATH}/v2.6.38.8-natty/linux-image-2.6.38-02063808-generic_2.6.38-02063808.201106040910_${TARGET}.deb"
94
95         KERNELS="$KERNELS ${KPATH}/v2.6.39.4-oneiric/linux-headers-2.6.39-02063904_2.6.39-02063904.201108040905_all.deb"
96         KERNELS="$KERNELS ${KPATH}/v2.6.39.4-oneiric/linux-headers-2.6.39-02063904-generic_2.6.39-02063904.201108040905_${TARGET}.deb"
97         KERNELS="$KERNELS ${KPATH}/v2.6.39.4-oneiric/linux-image-2.6.39-02063904-generic_2.6.39-02063904.201108040905_${TARGET}.deb"
98
99         KERNELS="$KERNELS ${KPATH}/v3.0.18-oneiric/linux-headers-3.0.18-030018_3.0.18-030018.201201252135_all.deb"
100         KERNELS="$KERNELS ${KPATH}/v3.0.18-oneiric/linux-headers-3.0.18-030018-generic_3.0.18-030018.201201252135_${TARGET}.deb"
101         KERNELS="$KERNELS ${KPATH}/v3.0.18-oneiric/linux-image-3.0.18-030018-generic_3.0.18-030018.201201252135_${TARGET}.deb"
102
103         KERNELS="$KERNELS ${KPATH}/v3.1.10-precise/linux-headers-3.1.10-030110_3.1.10-030110.201201181135_all.deb"
104         KERNELS="$KERNELS ${KPATH}/v3.1.10-precise/linux-headers-3.1.10-030110-generic_3.1.10-030110.201201181135_${TARGET}.deb"
105         KERNELS="$KERNELS ${KPATH}/v3.1.10-precise/linux-image-3.1.10-030110-generic_3.1.10-030110.201201181135_${TARGET}.deb"
106
107         KERNELS="$KERNELS ${KPATH}/v3.2.2-precise/linux-headers-3.2.2-030202_3.2.2-030202.201201252035_all.deb"
108         KERNELS="$KERNELS ${KPATH}/v3.2.2-precise/linux-headers-3.2.2-030202-generic_3.2.2-030202.201201252035_${TARGET}.deb"
109         KERNELS="$KERNELS ${KPATH}/v3.2.2-precise/linux-image-3.2.2-030202-generic_3.2.2-030202.201201252035_${TARGET}.deb"
110
111         KERNELS="$KERNELS ${KPATH}/v3.3-rc2-precise/linux-headers-3.3.0-030300rc2_3.3.0-030300rc2.201201311735_all.deb"
112         KERNELS="$KERNELS ${KPATH}/v3.3-rc2-precise/linux-headers-3.3.0-030300rc2-generic_3.3.0-030300rc2.201201311735_${TARGET}.deb"
113         KERNELS="$KERNELS ${KPATH}/v3.3-rc2-precise/linux-image-3.3.0-030300rc2-generic_3.3.0-030300rc2.201201311735_${TARGET}.deb"
114
115         for i in $KERNELS; do
116                 FILE=$(basename $i)
117                 PKG=$(echo $FILE | awk -F"_" '{print $1}')
118
119                 echo "$i" | grep image 2>&1 > /dev/null
120                 if [[ $? = 0 && $INSTALL_IMAGES != "y" ]]; then
121                         continue
122                 fi
123
124                 if [[ ! -f $FILE ]]; then
125                         wget -c $i
126                 fi
127         done
128
129         # Let dpkg figure out dependency magic.
130         #
131         # XXX: I tried adding some magic to not install a package if
132         # if its already presently installed but then had to deal
133         # with the dependency mess. I welcome someone else to
134         # figure this out. Running this can come in handy once
135         # a new public kernel gets released.
136         sudo dpkg -i *.deb
137 }
138
139 function usage() {
140         echo -e "Usage: $0 [ -i ]"
141         echo -e ""
142         echo -e "If you specify [ -i ] you will also download all kernel images and install them"
143 }
144
145 INSTALL_IMAGES="n"
146
147 if [[ $# -gt 1 ]]; then
148         usage
149         exit
150 fi
151
152 if [[ $# -eq 1 && $1 != "-i" ]]; then
153         usage
154         exit
155 fi
156
157 if [[ $# -eq 1 && $1 = "-i" ]]; then
158         INSTALL_IMAGES="y"
159 fi
160
161
162 LSB_RED_ID=$(/usr/bin/lsb_release -i -s)
163 case $LSB_RED_ID in
164 "Ubuntu")
165         get_ubuntu_kernels
166         ;;
167 *)
168         echo -e "Unsupported distribution"
169         exit
170         ;;
171 esac