Skip to content

Instantly share code, notes, and snippets.

@psyke83
Last active April 26, 2020 11:48
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save psyke83/cb3ca50561480809c246f42727cb7cf2 to your computer and use it in GitHub Desktop.
Save psyke83/cb3ca50561480809c246f42727cb7cf2 to your computer and use it in GitHub Desktop.
#!/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
Copy link

Thank you for this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment