forked from adafruit/Raspberry-Pi-Installer-Scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
rpi-pin-kernel-firmware.sh
39 lines (30 loc) · 1.08 KB
/
rpi-pin-kernel-firmware.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
#!/bin/sh
# rpi-pin-kernel-firmware: Pin a specific version of the rpi kernel and firmware
set -e
if [ $# -ne 1 ]; then
echo "Usage: $0 kernel-version"
echo
echo "e.g., $0 1.20201126-1"
exit 1
fi
if ! dpkg -l raspberrypi-kernel:armhf > /dev/null 2>&1; then
echo "This command is designed to run only on Raspbian with the armhf kernel"
echo 99
fi
if [ `id -u` -ne 0 ]; then
echo "If necessary, enter your password to run this script as root"
exec sudo sh "$0" "$1"
fi
version=$1
base=http://archive.raspberrypi.org/debian/pool/main/r/raspberrypi-firmware/
packagelist="libraspberrypi0 libraspberrypi-bin libraspberrypi-dev libraspberrypi-doc raspberrypi-bootloader raspberrypi-kernel raspberrypi-kernel-headers"
set --
for package in $packagelist; do
filename="${package}_${version}_armhf.deb"
set -- "$@" "$filename"
wget --continue -O "$filename" "$base/$filename"
done
dpkg -i "$@"
for package in $packagelist; do
/usr/bin/printf "Package: $package\nPin: version 1.20201126-1\nPin-Priority:999\n\n"
done > /etc/apt/preferences.d/99-adafruit-pin-kernel