Skip to content

Commit 5ff4a59

Browse files
authored
Merge pull request #2923 from joolswills/kernel_hold_logic
raspbiantools - rework stretch kernel downgrade / holding logic
2 parents d8e9748 + 23c6280 commit 5ff4a59

File tree

1 file changed

+41
-10
lines changed

1 file changed

+41
-10
lines changed

scriptmodules/supplementary/raspbiantools.sh

Lines changed: 41 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,11 @@ rp_module_section="config"
1515
rp_module_flags="!x11 !mali"
1616

1717
function apt_upgrade_raspbiantools() {
18+
# install an older kernel/firmware for stretch to resolve newer kernel issues or unhold if updating to a newer release
19+
stretch_fix_raspbiantools
20+
1821
aptUpdate
1922
apt-get -y dist-upgrade
20-
21-
# install an older kernel/firmware for stretch to resolve sony bt issues
22-
stretch_fix_raspbiantools
2323
}
2424

2525
function lxde_raspbiantools() {
@@ -43,31 +43,62 @@ function disable_blanker_raspbiantools() {
4343
}
4444

4545
function stretch_fix_raspbiantools() {
46+
# install an older kernel/firmware and hold it for stretch to resolve sony bt, composite
47+
# and overscan issues, but also unhold for newer Raspbian versions to allow upgrading.
4648
local ver="1.20190401-1"
47-
# install an older kernel/firmware for stretch to resolve sony bt, composite and overscan issues
48-
if isPlatform "rpi" && [[ "$__os_debian_ver" -eq 9 ]] && hasPackage raspberrypi-kernel "$ver" ne; then
49-
install_firmware_raspbiantools "$ver" hold
49+
# make sure we are on a rpi and have the raspberrypi-kernel package
50+
if isPlatform "rpi" && hasPackage raspberrypi-kernel; then
51+
if [[ "$__os_debian_ver" -eq 9 ]]; then
52+
# for Raspbian 9 (stretch) we want to install / hold the older kernel
53+
install_firmware_raspbiantools "$ver" hold
54+
elif hasPackage raspberrypi-kernel "$ver" eq; then
55+
# if we are not running Raspbian 9 (stretch), but are running the old kernel
56+
# we want to unhold it to allow kernel updates again
57+
install_firmware_raspbiantools "$ver" unhold
58+
fi
5059
fi
5160
}
5261

5362
function install_firmware_raspbiantools() {
5463
local ver="$1"
5564
local state="$2"
5665
[[ -z "$ver" ]] && return 1
66+
5767
local url="http://archive.raspberrypi.org/debian/pool/main/r/raspberrypi-firmware"
68+
5869
mkdir -p "$md_build"
5970
pushd "$md_build" >/dev/null
71+
6072
local pkg
73+
local pkgs=(raspberrypi-bootloader libraspberrypi0 libraspberrypi-doc libraspberrypi-dev libraspberrypi-bin raspberrypi-kernel-headers raspberrypi-kernel)
6174
local deb
62-
for pkg in raspberrypi-bootloader libraspberrypi0 libraspberrypi-doc libraspberrypi-dev libraspberrypi-bin raspberrypi-kernel-headers raspberrypi-kernel; do
75+
76+
# download all packages then install later to reduce issues if interrupted or a networking issue
77+
for pkg in "${pkgs[@]}"; do
78+
if hasPackage "$pkg" "$ver" ne; then
79+
deb="${pkg}_${ver}_armhf.deb"
80+
if ! wget -O"$deb" "$url/$deb"; then
81+
md_ret_errors+=("Failed to download $deb")
82+
return 1
83+
fi
84+
fi
85+
done
86+
87+
# install packages if needed
88+
for pkg in "${pkgs[@]}"; do
6389
deb="${pkg}_${ver}_armhf.deb"
64-
wget -O"$deb" "$url/$deb"
65-
dpkg -i "$deb"
90+
if hasPackage "$pkg" "$ver" ne && [[ -f "$deb" ]]; then
91+
dpkg -i "$deb"
92+
rm "$deb"
93+
fi
94+
# set package state
6695
[[ -n "$state" ]] && apt-mark "$state" "$pkg"
67-
rm "$deb"
6896
done
97+
6998
popd >/dev/null
7099
rm -rf "$md_build"
100+
101+
return 0
71102
}
72103

73104
function enable_modules_raspbiantools() {

0 commit comments

Comments
 (0)