-
Notifications
You must be signed in to change notification settings - Fork 315
/
kernelsource.sh
executable file
·71 lines (56 loc) · 2.36 KB
/
kernelsource.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#!/bin/bash
kernelinstall() {
echo " ---- VOLUMIO RASPBERRY PI KERNEL SOURCE DOWNLOADER ----"
echo " "
echo "This process might take a long time"
echo " "
ARCH=`/usr/bin/arch`
echo "Checking if build essential is installed"
if [ $(dpkg-query -W -f='${Status}' make 2>/dev/null | grep -c "ok installed") -eq 0 ];
then
echo "Installing build essential"
echo volumio | sudo -S apt-get update && apt-get install -y build-essential bc;
fi
cd /home/volumio
if [ -f "/boot/.firmware_revision_kernel" ]; then
FIRMWARE_REV=`cat /boot/.firmware_revision_kernel`
else
FIRMWARE_REV=`cat /boot/.firmware_revision`
fi
echo "Firmware revision is" $FIRMWARE_REV
KERNEL_REV=`curl -L https://github.com/Hexxeh/rpi-firmware/raw/${FIRMWARE_REV}/git_hash`
echo "Kernel revision is "$KERNEL_REV
if [ "$ARCH" = armv7l ]; then
echo "Getting modules symvers for V7 kernel"
curl -L https://github.com/Hexxeh/rpi-firmware/raw/${FIRMWARE_REV}/Module7.symvers >Module7.symvers
else
echo "Getting modules symvers for V6 kernel"
curl -L https://github.com/Hexxeh/rpi-firmware/raw/${FIRMWARE_REV}/Module.symvers >Module.symvers
fi
echo "Downloading Kernel source tarball from " https://github.com/raspberrypi/linux/archive/${KERNEL_REV}.tar.gz
curl -L https://github.com/raspberrypi/linux/archive/${KERNEL_REV}.tar.gz >rpi-linux.tar.gz
echo "creating /usr/src/rpi-linux folder"
echo volumio | sudo -S mkdir /usr/src/rpi-linux
echo "Extracting Kernel"
echo volumio | sudo -S tar --strip-components 1 -xf rpi-linux.tar.gz -C /usr/src/rpi-linux
cd /usr/src/rpi-linux
echo "Cloning current config"
echo volumio | sudo -S /sbin/modprobe configs
echo volumio | sudo -S gunzip -c /proc/config.gz >.config
echo "Copying modules symverse"
if [ "$ARCH" = armv7l ]; then
echo volumio | sudo -S cp /home/volumio/Module7.symvers Module.symvers
else
echo volumio | sudo -S cp /home/volumio/Module.symvers Module.symvers
fi
echo volumio | sudo -S make LOCALVERSION=+ modules_prepare
echo "Linking Modules"
echo volumio | sudo -S ln -sv /usr/src/rpi-linux /lib/modules/$(uname -r)/build
echo " "
echo "Done, you can now build and install out of kernel modules"
}
if (cat /proc/cpuinfo | grep '^Hardware.*BCM2[78][013][05-9].*' > /dev/null); then
kernelinstall
else
echo "This tool is available only for Raspberry PI, exiting"
fi