Last active
May 11, 2021 00:19
-
-
Save jikamens/520f55ff40a02c0873b63a0dc1bce9e6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash -e | |
# You will probably need to adjust this script if you aren't using | |
# the generic kernel. | |
to_install= | |
to_hold= | |
pd=/tmp/packages.$$ | |
mkdir $pd | |
# Get good Mesa packages | |
while read package arch version; do | |
to_hold="$to_hold $package:$arch" | |
if [ "$version" == "20.3.4-1" ]; then | |
continue | |
fi | |
deb_name="${package}_20.3.4-1_${arch}.deb" | |
echo Downloading $deb_name | |
curl --location --silent --output $pd/$deb_name \ | |
"https://launchpad.net/ubuntu/+archive/primary/+files/$deb_name" | |
to_install="$to_install $pd/$deb_name" | |
done < <(dpkg-query --show --showformat \ | |
'${Package} ${Architecture} ${Version} ${Source}\n' \ | |
'*mesa*' '*libgbm1*' | | |
awk '$4 == "mesa" {print $1, $2, $3}') | |
# Get good Kernel packages | |
while read package arch; do | |
to_hold="$to_hold $package:$arch" | |
if dpkg-query --show $package:$arch 2>/dev/null | | |
grep -q -s '5\.10\.0-14\.15$' | |
then | |
continue | |
fi | |
deb_name="${package}_5.10.0-14.15_${arch}.deb" | |
echo Downloading $deb_name | |
curl --location --silent --output $pd/$deb_name \ | |
"https://launchpad.net/ubuntu/+archive/primary/+files/$deb_name" | |
to_install="$to_install $pd/$deb_name" | |
done < <(dpkg-query --show --showformat \ | |
'${Package} ${Architecture} ${Version} ${Source}\n' '*linux*' | | |
awk '$4 == "linux" || $4 == "linux-signed" {print $1, $2}' | | |
sed 's/-5\.[0-9.]*-[0-9]*/-5.10.0-14/' | sort -u) | |
# Get good Kernel meta-packages | |
while read package arch version; do | |
to_hold="$to_hold $package:$arch" | |
if [ "$version" == "5.10.0.14.16" ]; then | |
continue | |
fi | |
deb_name="${package}_5.10.0.14.16_${arch}.deb" | |
echo Downloading $deb_name | |
curl --location --silent --output $pd/$deb_name \ | |
"https://launchpad.net/ubuntu/+archive/primary/+files/$deb_name" | |
to_install="$to_install $pd/$deb_name" | |
done < <(dpkg-query --show --showformat \ | |
'${Package} ${Architecture} ${Version} ${Source}\n' '*linux*' | | |
awk '$4 == "linux-meta" {print $1, $2, $3}') | |
if [[ $(uname -r) =~ 5\.11 ]]; then | |
echo | |
echo "*** NOTE NOTE NOTE ***" | |
echo | |
echo "The following command is going to fail if you already have" | |
echo "evdi-dkms installed, because the evdi kernel module will" | |
echo "fail to build for kernel 5.11, and this script cannot" | |
echo "uninstall the 5.11 kernel because you are currently" | |
echo "running it. If that happens, then, after the command fails," | |
echo "you need to reboot, select the 5.10 kernel during the boot" | |
echo "process, and then run this script again." | |
echo | |
echo "*** NOTE NOTE NOTE ***" | |
echo | |
fi | |
if [ -n "$to_install" ]; then | |
apt-get install $to_install | |
fi | |
if [[ $(uname -r) =~ 5\.11 ]]; then | |
echo | |
echo "*** NOTE NOTE NOTE ***" | |
echo | |
echo "You need to reboot, select the 5.10 kernel during boot, and" | |
echo "rerun this script." | |
echo | |
echo "Before rebooting, make sure GRUB_TIMEOUT is set to a non-zero value" | |
echo "and GRUB_TIMEOUT_STYLE is set to 'menu' in /etc/default/grub, and if" | |
echo "you have to change either of them, run 'sudo update-grub' before" | |
echo "rebooting. Otherwise, you won't be able to easily select the 5.10" | |
echo "kernel when you reboot." | |
echo | |
echo "*** NOTE NOTE NOTE ***" | |
echo | |
exit 1 | |
fi | |
apt-mark hold $to_hold | |
# Uninstalling the 5.11 kernel | |
to_remove="$(dpkg-query --show --showformat \ | |
'${Package} ${Architecture} ${Version} ${Source}\n' '*linux*' | | |
awk '$4 == "linux" && $3 ~ /^5\.11/ {print $1 ":" $2}')" | |
apt-get remove $to_remove | |
rm -rf $pd |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment