pkg-install: add check for "Conflicting distribution" & sort the checks

pull/953/head
Botspot 3 years ago
parent 81fdc04f83
commit 15c6037244

@ -33,6 +33,10 @@ $1
apt_diagnose() { #Explain stdin-inputted apt errors to user and list ways to fix them
errors="$(cat /dev/stdin)"
#------------------------------------------
#repo issues below
#------------------------------------------
#check for 'E: The repository'
if echo "$errors" | grep -qF 'E: The repository' || echo "$errors" | grep -qF 'sources.list entry misspelt' ;then
message_to_user "APT reported a faulty repository, and you must fix it before Pi-Apps will work.
@ -52,7 +56,7 @@ APT reported an unsigned repository. This script will try to repair it.
Waiting 10 seconds... Press Ctrl+C to cancel.\e[39m"
sleep 10
echo -e '\n\e[93mAttempting to sign unsigned repositories...\e[39m'
sudo -E apt update 2>&1 1>/dev/null | sed -ne 's/.*NO_PUBKEY //p' | while read key; do if ! [[ ${keys[*]} =~ "$key" ]]; then sudo -E apt-key adv --keyserver hkp://pool.sks-keyservers.net:80 --recv-keys "$key"; keys+=("$key"); fi; done
sudo -E apt update 2>&1 | sed -ne 's/.*NO_PUBKEY //p' | while read key; do if ! [[ ${keys[*]} =~ "$key" ]]; then sudo -E apt-key adv --keyserver hkp://pool.sks-keyservers.net:80 --recv-keys "$key"; keys+=("$key"); fi; done
if [ $? == 0 ];then
echo -e '\e[93mDone. Please try installing the same app again.\e[39m'
else
@ -79,6 +83,36 @@ the /etc/apt/sources.list.d folder.
sources.list requires root permissions to edit: sudo mousepad /path/to/file"
fi
#check for "W: Conflicting distribution: "
if echo "$errors" | grep -qF "W: Conflicting distribution: " ;then
message_to_user "Dpkg, apt, and Pi-Apps will not work until you fix the conflicting repository.
Read the errors above, then look through /etc/apt/sources.list and /etc/apt/sources.list.d, making changes as necessary.
Perhaps doing a Google search for the exact error you received would help."
fi
#check for "Release file for <repo-url> is not valid yet"
if echo "$errors" | grep -q "Release file for .* is not valid yet" ;then
message_to_user "One or more repositories has a release file that becomes valid in the future.
Please look at the above errors to see how long you have to wait."
fi
#check for typo in sources.list and list.d
if echo "$errors" | grep -qF "The list of sources could not be read." ;then
message_to_user "One or more sources contain a typo. Before APT or Pi-Apps will work, you must look around in /etc/apt/sources.list and /etc/apt/sources.list.d and fix the typo."
fi
#check for "W: Did not understand pin type releace"
if echo "$errors" | grep -qF "Did not understand pin type" ;then
message_to_user "This error was not caused by Pi-Apps. Looks like there is a typo in your /etc/apt/sources.list"
fi
#------------------------------------------
#repo issues above, apt/dpkg issues below
#------------------------------------------
#check for "--fix-broken"
if echo "$errors" | grep -qF "\-\-fix\-broken" || echo "$errors" | grep -qF "needs to be reinstalled" ;then
message_to_user "APT reported a broken package, and you must fix it before Pi-Apps will work.
@ -93,13 +127,6 @@ Please run this command: sudo apt --fix-broken install"
Please run this command: sudo dpkg --configure -a"
fi
#check for faulty dphys-swapfile package
if echo "$errors" | grep -qF "error processing package dphys-swapfile" ;then
message_to_user "Before dpkg, apt, or Pi-Apps will work, dphys-swapfile must be fixed.
Try Googling the above errors, or ask the Pi-Apps developers for help."
fi
#check for insufficient space errors
if echo "$errors" | grep -qF "You don't have enough free space in" ;then
message_to_user "Package(s) failed to install because your system has insufficient disk space.
@ -107,33 +134,6 @@ Try Googling the above errors, or ask the Pi-Apps developers for help."
Please free up some space, then try again."
fi
#check for unconfigured boot-firmware package
if echo "$errors" | grep -qF "missing /boot/firmware, did you forget to mount it" || echo "$errors" | grep -q "u-boot-rpi" ;then
message_to_user "Package(s) failed to install because your boot drive is not working.
You must fix the u-boot-rpi package before dpkg, apt, or Pi-Apps will work."
fi
#check for "Release file for http://httpredir.debian.org/debian/dists/buster-backports/InRelease is not valid yet"
if echo "$errors" | grep -q "Release file for .* is not valid yet" ;then
message_to_user "One or more repositories has a release file that becomes valid in the future.
Please look at the above errors to see how long you have to wait."
fi
#check for typo in sources.list and list.d
if echo "$errors" | grep -qF "The list of sources could not be read." ;then
message_to_user "One or more sources contain a typo. Before APT or Pi-Apps will work, you must look around in /etc/apt/sources.list and /etc/apt/sources.list.d and fix the typo."
fi
#check for "files list file for package 'package-name' is missing final newline"
if echo "$errors" | grep -q "files list file for package .* is missing final newline" ;then
message_to_user "Before dpkg, apt, or Pi-Apps will work, your system must be repaired.
Try Googling the above errors, or ask the Pi-Apps developers for help.
Perhaps this link will help: https://askubuntu.com/questions/909719/dpkg-unrecoverable-fatal-error-aborting-files-list-file-for-package-linux-ge"
fi
#check for "Command line option --allow-releaseinfo-change is not understood"
if echo "$errors" | grep -qF "Command line option --allow-releaseinfo-change is not understood" ;then
message_to_user "The Debian Project recently upgraded from Buster to version Bullseye. As a result, all Raspberry Pi OS Buster users will receive APT errors saying the repositories changed from 'stable' to 'oldstable'.
@ -146,13 +146,39 @@ Unfortunately for you, your operating system is too old for apt to understand th
Please flash your SD card with the latest release of Raspberry Pi OS: https://www.raspberrypi.org/software"
fi
#check for "installed package-name package post-installation script subprocess returned error exit status 10"
#------------------------------------------
#apt/dpkg issues above, package issues below
#------------------------------------------
#check for "installed <package-name> package post-installation script subprocess returned error exit status 10"
if echo "$errors" | grep -q "installed .* post-installation script subprocess returned error exit status 10" ;then
message_to_user "Some other package on your system is causing problems. As a result, dpkg and APT won't work properly.
Perhaps reinstalling the package would help?"
fi
#check for faulty dphys-swapfile package
if echo "$errors" | grep -qF "error processing package dphys-swapfile" ;then
message_to_user "Before dpkg, apt, or Pi-Apps will work, dphys-swapfile must be fixed.
Try Googling the above errors, or ask the Pi-Apps developers for help."
fi
#check for unconfigured boot-firmware package
if echo "$errors" | grep -qF "missing /boot/firmware, did you forget to mount it" || echo "$errors" | grep -q "u-boot-rpi" ;then
message_to_user "Package(s) failed to install because your boot drive is not working.
You must fix the u-boot-rpi package before dpkg, apt, or Pi-Apps will work."
fi
#check for "files list file for package 'package-name' is missing final newline"
if echo "$errors" | grep -q "files list file for package .* is missing final newline" ;then
message_to_user "Before dpkg, apt, or Pi-Apps will work, your system must be repaired.
Try Googling the above errors, or ask the Pi-Apps developers for help.
Perhaps this link will help: https://askubuntu.com/questions/909719/dpkg-unrecoverable-fatal-error-aborting-files-list-file-for-package-linux-ge"
fi
#check for "installed raspberrypi-kernel package post-installation script subprocess returned error exit status 1"
if echo "$errors" | grep -qF "raspberrypi-kernel package post-installation script subprocess returned error exit status" ;then
message_to_user "The raspberrypi-kernel package on your system is causing problems.
@ -184,13 +210,8 @@ sudo apt install --reinstall nginx-full"
message_to_user "This error was not caused by Pi-Apps, it is caused by your libwine-development package."
fi
#check for "W: Did not understand pin type releace"
if echo "$errors" | grep -qF "Did not understand pin type" ;then
message_to_user "This error was not caused by Pi-Apps. Looks like there is a typo in your /etc/apt/sources.list"
fi
#no need for this function to exit with return code 1 just because the last if statement evaluated to 1
exit 0
#no need for this function to exit with return code 1 just because the last if statement evaluated as false
return 0
}
echo "Running pkg-install..."

Loading…
Cancel
Save