Skip to content

Instantly share code, notes, and snippets.

@psyke83 psyke83/downgrade_firmware.sh Secret
Last active Aug 28, 2019

Embed
What would you like to do?
#!/bin/bash
list_packages()
{
echo "libraspberrypi-bin libraspberrypi-dev libraspberrypi-doc libraspberrypi0 raspberrypi-bootloader raspberrypi-kernel raspberrypi-kernel-headers"
}
target_version()
{
echo "1.20190401-1_armhf.deb"
}
fetch_archives()
{
local base_url="https://archive.raspberrypi.org/debian/pool/main/r/raspberrypi-firmware"
mkdir -p /tmp/downgrade_packages
for package in $(list_packages); do
wget -P /tmp/downgrade_packages "$base_url"/"$package"_"$(target_version)"
done
}
install_archives()
{
dpkg -i /tmp/downgrade_packages/*.deb
}
set_selections()
{
local op=$1
local package
for package in $(list_packages); do
echo "$package $op" | dpkg --set-selections
done
}
argument=$1
case $argument in
downgrade)
echo "downgrading kernel..."
fetch_archives
install_archives
set_selections hold
echo "downgrade complete! reboot for changes to take effect."
;;
block)
echo "adding package holds..."
set_selections hold
echo "block complete! firmware packages will be held at current version."
;;
unblock)
echo "removing package holds..."
set_selections install
echo "unblock complete! new firmware packages are now installable via apt-get."
;;
*)
echo -e "supported arguments:\n* downgrade: downgrade and hold firmware to version $(target_version)\n* block: hold firmware package updates\n* unblock: allow upgrade of firmware packages"
;;
esac
@copiousOne

This comment has been minimized.

Copy link

copiousOne commented Aug 28, 2019

Thank you for this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.