/
kernelsource.sh
executable file
·89 lines (70 loc) · 2.64 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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
#!/bin/bash
if [ "0" != "$(id -u)" ]; then
echo "You must be root to run $0." 1>&2;
logger "$0 : called by $(id -un), not root"
exit 1;
fi
asvolumio() {
sudo -u volumio "$@"
}
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"
apt-get update && apt-get install -y build-essential bc;
fi
echo "Checking if other dependencies are installed"
if [ $(dpkg-query -W -f='${Status}' bison 2>/dev/null | grep -c "ok installed") -eq 0 ];
then
echo "Installing other dependencies essential"
apt-get update && apt-get install -y bison flex libssl-dev;
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=`asvolumio 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"
asvolumio curl -L https://github.com/Hexxeh/rpi-firmware/raw/${FIRMWARE_REV}/Module7.symvers >Module7.symvers
else
echo "Getting modules symvers for V6 kernel"
asvolumio 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
asvolumio curl -L https://github.com/raspberrypi/linux/archive/${KERNEL_REV}.tar.gz >rpi-linux.tar.gz
echo "creating /usr/src/rpi-linux folder"
mkdir -p /usr/src/rpi-linux
echo "Extracting Kernel"
tar --strip-components 1 -xf rpi-linux.tar.gz -C /usr/src/rpi-linux
cd /usr/src/rpi-linux
echo "Cloning current config"
/sbin/modprobe configs
gunzip -c /proc/config.gz >.config
echo "Copying modules symverse"
if [ "$ARCH" = armv7l ]; then
cp /home/volumio/Module7.symvers Module.symvers
else
cp /home/volumio/Module.symvers Module.symvers
fi
make LOCALVERSION=+ modules_prepare
echo "Linking Modules"
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 /etc/os-release | grep 'VOLUMIO_HARDWARE="pi"' > /dev/null); then
kernelinstall
else
echo "This tool is available only for Raspberry PI, exiting"
fi