rdma.m4: check for request_firmware_direct() support
[~tnikolova/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 KERNELS=""
14 KPATH="http://kernel.ubuntu.com/~kernel-ppa/mainline/"
15
16 function get_ubuntu_kernels() {
17
18         ARCH=$(uname -m)
19         TARGET=""
20
21         case $ARCH in
22         "x86_64")
23                 TARGET="amd64"
24                 ;;
25         "i686")
26                 TARGET="i386"
27                 ;;
28         *)
29                 echo -e "Unsupported architecture"
30                 exit
31                 ;;
32         esac
33
34         KERNELS="$KERNELS ${KPATH}/v2.6.24/linux-headers-2.6.24-020624_2.6.24-020624_all.deb"
35         KERNELS="$KERNELS ${KPATH}/v2.6.24/linux-headers-2.6.24-020624-generic_2.6.24-020624_${TARGET}.deb"
36         KERNELS="$KERNELS ${KPATH}/v2.6.24/linux-image-2.6.24-020624-generic_2.6.24-020624_${TARGET}.deb"
37
38         KERNELS="$KERNELS ${KPATH}/v2.6.25/linux-headers-2.6.25-020625_2.6.25-020625_all.deb"
39         KERNELS="$KERNELS ${KPATH}/v2.6.25/linux-headers-2.6.25-020625-generic_2.6.25-020625_${TARGET}.deb"
40         KERNELS="$KERNELS ${KPATH}/v2.6.25/linux-image-2.6.25-020625-generic_2.6.25-020625_${TARGET}.deb"
41
42         KERNELS="$KERNELS ${KPATH}/v2.6.26/linux-headers-2.6.26-020626_2.6.26-020626_all.deb"
43         KERNELS="$KERNELS ${KPATH}/v2.6.26/linux-headers-2.6.26-020626-generic_2.6.26-020626_${TARGET}.deb"
44         KERNELS="$KERNELS ${KPATH}/v2.6.26/linux-image-2.6.26-020626-generic_2.6.26-020626_${TARGET}.deb"
45
46         KERNELS="$KERNELS ${KPATH}/v2.6.27/linux-headers-2.6.27-020627_2.6.27-020627_all.deb"
47         KERNELS="$KERNELS ${KPATH}/v2.6.27/linux-headers-2.6.27-020627-generic_2.6.27-020627_${TARGET}.deb"
48         KERNELS="$KERNELS ${KPATH}/v2.6.27/linux-image-2.6.27-020627-generic_2.6.27-020627_${TARGET}.deb"
49
50         KERNELS="$KERNELS ${KPATH}/v2.6.28.10/linux-headers-2.6.28-02062810_2.6.28-02062810_all.deb"
51         KERNELS="$KERNELS ${KPATH}/v2.6.28.10/linux-headers-2.6.28-02062810-generic_2.6.28-02062810_${TARGET}.deb"
52         KERNELS="$KERNELS ${KPATH}/v2.6.28.10/linux-image-2.6.28-02062810-generic_2.6.28-02062810_${TARGET}.deb"
53
54         KERNELS="$KERNELS ${KPATH}/v2.6.29.6/linux-headers-2.6.29-02062906_2.6.29-02062906_all.deb"
55         KERNELS="$KERNELS ${KPATH}/v2.6.29.6/linux-headers-2.6.29-02062906-generic_2.6.29-02062906_${TARGET}.deb"
56         KERNELS="$KERNELS ${KPATH}/v2.6.29.6/linux-image-2.6.29-02062906-generic_2.6.29-02062906_${TARGET}.deb"
57
58         KERNELS="$KERNELS ${KPATH}/v2.6.30.10/linux-headers-2.6.30-02063010_2.6.30-02063010_all.deb"
59         KERNELS="$KERNELS ${KPATH}/v2.6.30.10/linux-headers-2.6.30-02063010-generic_2.6.30-02063010_${TARGET}.deb"
60         KERNELS="$KERNELS ${KPATH}/v2.6.30.10/linux-image-2.6.30-02063010-generic_2.6.30-02063010_${TARGET}.deb"
61
62         KERNELS="$KERNELS ${KPATH}/v2.6.31.13-karmic/linux-headers-2.6.31-02063113_2.6.31-02063113_all.deb"
63         KERNELS="$KERNELS ${KPATH}/v2.6.31.13-karmic/linux-headers-2.6.31-02063113-generic_2.6.31-02063113_${TARGET}.deb"
64         KERNELS="$KERNELS ${KPATH}/v2.6.31.13-karmic/linux-image-2.6.31-02063113-generic_2.6.31-02063113_${TARGET}.deb"
65
66         KERNELS="$KERNELS ${KPATH}/v2.6.32.55-lucid/linux-headers-2.6.32-02063255_2.6.32-02063255.201201251735_all.deb"
67         KERNELS="$KERNELS ${KPATH}/v2.6.32.55-lucid/linux-headers-2.6.32-02063255-generic_2.6.32-02063255.201201251735_${TARGET}.deb"
68         KERNELS="$KERNELS ${KPATH}/v2.6.32.55-lucid/linux-image-2.6.32-02063255-generic_2.6.32-02063255.201201251735_${TARGET}.deb"
69
70         KERNELS="$KERNELS ${KPATH}/v2.6.33.5-lucid/linux-headers-2.6.33-02063305_2.6.33-02063305_all.deb"
71         KERNELS="$KERNELS ${KPATH}/v2.6.33.5-lucid/linux-headers-2.6.33-02063305-generic_2.6.33-02063305_${TARGET}.deb"
72         KERNELS="$KERNELS ${KPATH}/v2.6.33.5-lucid/linux-image-2.6.33-02063305-generic_2.6.33-02063305_${TARGET}.deb"
73
74         KERNELS="$KERNELS ${KPATH}/v2.6.34.10-maverick/linux-headers-2.6.34-02063410_2.6.34-02063410.201111101535_all.deb"
75         KERNELS="$KERNELS ${KPATH}/v2.6.34.10-maverick/linux-headers-2.6.34-02063410-generic_2.6.34-02063410.201111101535_${TARGET}.deb"
76         KERNELS="$KERNELS ${KPATH}/v2.6.34.10-maverick/linux-image-2.6.34-02063410-generic_2.6.34-02063410.201111101535_${TARGET}.deb"
77
78         KERNELS="$KERNELS ${KPATH}/v2.6.35.13-maverick/linux-headers-2.6.35-02063512_2.6.35-02063512.201111232118_all.deb"
79         KERNELS="$KERNELS ${KPATH}/v2.6.35.13-maverick/linux-headers-2.6.35-02063512-generic_2.6.35-02063512.201111232118_${TARGET}.deb"
80         KERNELS="$KERNELS ${KPATH}/v2.6.35.13-maverick/linux-image-2.6.35-02063512-generic_2.6.35-02063512.201111232118_${TARGET}.deb"
81
82         KERNELS="$KERNELS ${KPATH}/v2.6.36.4-natty/linux-headers-2.6.36-02063604_2.6.36-02063604.201102180911_all.deb"
83         KERNELS="$KERNELS ${KPATH}/v2.6.36.4-natty/linux-headers-2.6.36-02063604-generic_2.6.36-02063604.201102180911_${TARGET}.deb"
84         KERNELS="$KERNELS ${KPATH}/v2.6.36.4-natty/linux-image-2.6.36-02063604-generic_2.6.36-02063604.201102180911_${TARGET}.deb"
85
86         KERNELS="$KERNELS ${KPATH}/v2.6.37.6-natty/linux-headers-2.6.37-02063706_2.6.37-02063706.201103281005_all.deb"
87         KERNELS="$KERNELS ${KPATH}/v2.6.37.6-natty/linux-headers-2.6.37-02063706-generic_2.6.37-02063706.201103281005_${TARGET}.deb"
88         KERNELS="$KERNELS ${KPATH}/v2.6.37.6-natty/linux-image-2.6.37-02063706-generic_2.6.37-02063706.201103281005_${TARGET}.deb"
89
90         KERNELS="$KERNELS ${KPATH}/v2.6.38.8-natty/linux-headers-2.6.38-02063808_2.6.38-02063808.201106040910_all.deb"
91         KERNELS="$KERNELS ${KPATH}/v2.6.38.8-natty/linux-headers-2.6.38-02063808-generic_2.6.38-02063808.201106040910_${TARGET}.deb"
92         KERNELS="$KERNELS ${KPATH}/v2.6.38.8-natty/linux-image-2.6.38-02063808-generic_2.6.38-02063808.201106040910_${TARGET}.deb"
93
94         KERNELS="$KERNELS ${KPATH}/v2.6.39.4-oneiric/linux-headers-2.6.39-02063904_2.6.39-02063904.201108040905_all.deb"
95         KERNELS="$KERNELS ${KPATH}/v2.6.39.4-oneiric/linux-headers-2.6.39-02063904-generic_2.6.39-02063904.201108040905_${TARGET}.deb"
96         KERNELS="$KERNELS ${KPATH}/v2.6.39.4-oneiric/linux-image-2.6.39-02063904-generic_2.6.39-02063904.201108040905_${TARGET}.deb"
97
98         KERNELS="$KERNELS ${KPATH}/v3.0.18-oneiric/linux-headers-3.0.18-030018_3.0.18-030018.201201252135_all.deb"
99         KERNELS="$KERNELS ${KPATH}/v3.0.18-oneiric/linux-headers-3.0.18-030018-generic_3.0.18-030018.201201252135_${TARGET}.deb"
100         KERNELS="$KERNELS ${KPATH}/v3.0.18-oneiric/linux-image-3.0.18-030018-generic_3.0.18-030018.201201252135_${TARGET}.deb"
101
102         KERNELS="$KERNELS ${KPATH}/v3.1.10-precise/linux-headers-3.1.10-030110_3.1.10-030110.201201181135_all.deb"
103         KERNELS="$KERNELS ${KPATH}/v3.1.10-precise/linux-headers-3.1.10-030110-generic_3.1.10-030110.201201181135_${TARGET}.deb"
104         KERNELS="$KERNELS ${KPATH}/v3.1.10-precise/linux-image-3.1.10-030110-generic_3.1.10-030110.201201181135_${TARGET}.deb"
105
106         KERNELS="$KERNELS ${KPATH}/v3.2.2-precise/linux-headers-3.2.2-030202_3.2.2-030202.201201252035_all.deb"
107         KERNELS="$KERNELS ${KPATH}/v3.2.2-precise/linux-headers-3.2.2-030202-generic_3.2.2-030202.201201252035_${TARGET}.deb"
108         KERNELS="$KERNELS ${KPATH}/v3.2.2-precise/linux-image-3.2.2-030202-generic_3.2.2-030202.201201252035_${TARGET}.deb"
109
110         KERNELS="$KERNELS ${KPATH}/v3.3.7-precise/linux-headers-3.3.7-030307_3.3.7-030307.201205211535_all.deb"
111         KERNELS="$KERNELS ${KPATH}/v3.3.7-precise/linux-headers-3.3.7-030307-generic_3.3.7-030307.201205211535_${TARGET}.deb"
112         KERNELS="$KERNELS ${KPATH}/v3.3.7-precise/linux-image-3.3.7-030307-generic_3.3.7-030307.201205211535_${TARGET}.deb"
113
114         KERNELS="$KERNELS ${KPATH}/v3.4-precise/linux-headers-3.4.0-030400_3.4.0-030400.201205210521_all.deb"
115         KERNELS="$KERNELS ${KPATH}/v3.4-precise/linux-headers-3.4.0-030400-generic_3.4.0-030400.201205210521_${TARGET}.deb"
116         KERNELS="$KERNELS ${KPATH}/v3.4-precise/linux-image-3.4.0-030400-generic_3.4.0-030400.201205210521_${TARGET}.deb"
117
118         for i in $KERNELS; do
119                 FILE=$(basename $i)
120                 PKG=$(echo $FILE | awk -F"_" '{print $1}')
121
122                 echo "$i" | grep image 2>&1 > /dev/null
123                 if [[ $? = 0 && $INSTALL_IMAGES != "y" ]]; then
124                         continue
125                 fi
126
127                 # Do not download if installed or deb exists
128                 if [[ ! -d /usr/src/$PKG && ! -f $FILE ]]; then
129                         wget -c $i
130                 fi
131         done
132
133         LSB_RED_ID=$(/usr/bin/lsb_release -i -s)
134         case $LSB_RED_ID in
135         "Ubuntu")
136                 # Install with dpkg
137                 sudo dpkg -i *.deb
138                 ;;
139         *)
140                 # For every other distribution around
141
142                 # Create a temporary directory first
143                 TEMP_DIR=`mktemp -d`
144
145                 for deb in $(ls linux-*.deb); do
146                         DIR_NAME=$(echo $deb | awk -F"_" '{print $1}')
147                         if [[ ! -d /usr/src/$DIR_NAME ]]; then
148                                 echo "Extracting $deb..."
149                                 ar p $deb data.tar.gz | sudo tar xz --exclude=usr/share -C $TEMP_DIR
150                         fi
151                 done
152
153                 # Move the extracted folders into the system
154                 if [[ -d $TEMP_DIR/lib/modules ]]; then
155                         mv $TEMP_DIR/lib/modules/* /lib/modules
156                 fi
157                 if [[ -d $TEMP_DIR/usr/src ]]; then
158                         # Because of a bug in make < 3.82, mixed implicit and normal
159                         # rules do not cause harm. Since the bug is fixed in the new make
160                         # we have to adjust older kernel's Makefiles to fix the bug.
161                         sed -i 's#^/ %/:#%/:#' $TEMP_DIR/usr/src/linux-headers-2.6.2[45678]-0*/Makefile &>/dev/null
162
163                         mv $TEMP_DIR/usr/src/* /usr/src
164                 fi
165
166                 # Remove the temporary directory
167                 rm -rf $TEMP_DIR
168                 ;;
169         esac
170 }
171
172 function usage() {
173         echo -e "Usage: $0 [ -i ]"
174         echo -e ""
175         echo -e "If you specify [ -i ] you will also download all kernel images and install them"
176 }
177
178 INSTALL_IMAGES="n"
179
180 if [[ $# -gt 1 ]]; then
181         usage
182         exit
183 fi
184
185 if [[ $# -eq 1 && $1 != "-i" ]]; then
186         usage
187         exit
188 fi
189
190 if [[ $# -eq 1 && $1 = "-i" ]]; then
191         INSTALL_IMAGES="y"
192 fi
193
194 get_ubuntu_kernels