parent
19cfed5bd7
commit
1372794704
2 changed files with 40 additions and 5 deletions
41
install.sh
41
install.sh
|
@ -1,5 +1,7 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
|
FORCE_KERNEL="1.20190925+1-1"
|
||||||
|
|
||||||
if [[ $EUID -ne 0 ]]; then
|
if [[ $EUID -ne 0 ]]; then
|
||||||
echo "This script must be run as root (use sudo)" 1>&2
|
echo "This script must be run as root (use sudo)" 1>&2
|
||||||
exit 1
|
exit 1
|
||||||
|
@ -100,15 +102,46 @@ function check_kernel_headers() {
|
||||||
apt-get -y --reinstall install raspberrypi-kernel
|
apt-get -y --reinstall install raspberrypi-kernel
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function download_install_debpkg() {
|
||||||
|
local prefix name r
|
||||||
|
prefix=$1
|
||||||
|
name=$2
|
||||||
|
|
||||||
|
for (( i = 0; i < 3; i++ )); do
|
||||||
|
wget $prefix$name -O /tmp/$name && break
|
||||||
|
done
|
||||||
|
dpkg -i /tmp/$name; r=$?
|
||||||
|
rm -f /tmp/$name
|
||||||
|
return $r
|
||||||
|
}
|
||||||
|
|
||||||
|
function install_kernel() {
|
||||||
|
local _url _prefix
|
||||||
|
|
||||||
|
# Instead of retriving the lastest kernel & headers
|
||||||
|
[ "X$FORCE_KERNEL" == "X" ] && {
|
||||||
|
# Raspbian kernel packages
|
||||||
|
apt-get -y --force-yes install raspberrypi-kernel-headers raspberrypi-kernel
|
||||||
|
# Ubuntu kernel packages
|
||||||
|
apt-get -y install linux-raspi linux-headers-raspi linux-image-raspi
|
||||||
|
} || {
|
||||||
|
# We would like to a fixed version
|
||||||
|
KERN_NAME=raspberrypi-kernel_${FORCE_KERNEL}_armhf.deb
|
||||||
|
HDR_NAME=raspberrypi-kernel-headers_${FORCE_KERNEL}_armhf.deb
|
||||||
|
_url=$(apt-get download --print-uris raspberrypi-kernel | sed -nre "s/'([^']+)'.*$/\1/g;p")
|
||||||
|
_prefix=$(echo $_url | sed -nre 's/^(.*)raspberrypi-kernel_.*$/\1/g;p')
|
||||||
|
|
||||||
|
download_install_debpkg "$_prefix" "$KERN_NAME"
|
||||||
|
download_install_debpkg "$_prefix" "$HDR_NAME"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
# update and install required packages
|
# update and install required packages
|
||||||
which apt &>/dev/null
|
which apt &>/dev/null
|
||||||
if [[ $? -eq 0 ]]; then
|
if [[ $? -eq 0 ]]; then
|
||||||
apt update -y
|
apt update -y
|
||||||
# Raspbian kernel packages
|
|
||||||
apt-get -y install raspberrypi-kernel-headers raspberrypi-kernel
|
|
||||||
# Ubuntu kernel packages
|
|
||||||
apt-get -y install linux-raspi linux-headers-raspi linux-image-raspi
|
|
||||||
apt-get -y install dkms git i2c-tools libasound2-plugins
|
apt-get -y install dkms git i2c-tools libasound2-plugins
|
||||||
|
install_kernel
|
||||||
# rpi-update checker
|
# rpi-update checker
|
||||||
check_kernel_headers
|
check_kernel_headers
|
||||||
fi
|
fi
|
||||||
|
|
|
@ -122,7 +122,8 @@ if [ "$overlay" ]; then
|
||||||
rm /etc/asound.conf
|
rm /etc/asound.conf
|
||||||
rm /var/lib/alsa/asound.state
|
rm /var/lib/alsa/asound.state
|
||||||
|
|
||||||
kernel_ver=$(uname -r) # get_kernel_version)
|
: <<\EOF
|
||||||
|
kernel_ver=$(get_kernel_version)
|
||||||
# echo kernel_ver=$kernel_ver
|
# echo kernel_ver=$kernel_ver
|
||||||
|
|
||||||
# TODO: dynamic dtoverlay Bug of v4.19.x
|
# TODO: dynamic dtoverlay Bug of v4.19.x
|
||||||
|
@ -137,6 +138,7 @@ if [ "$overlay" ]; then
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
|
EOF
|
||||||
#make sure the driver loads correctly
|
#make sure the driver loads correctly
|
||||||
dtoverlay -d $OVERLAYS $overlay || true
|
dtoverlay -d $OVERLAYS $overlay || true
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue