Skip to content

Commit

Permalink
api: optimize is_supported_system, correctly filter only deb, and…
Browse files Browse the repository at this point in the history
… add Ubuntu sources.list requirements
  • Loading branch information
theofficialgman committed Aug 30, 2023
1 parent 8c08dfd commit 0952537
Showing 1 changed file with 17 additions and 9 deletions.
26 changes: 17 additions & 9 deletions api
Original file line number Diff line number Diff line change
Expand Up @@ -650,7 +650,7 @@ ubuntu_ppa_installer() { #setup a PPA on an Ubuntu distro. Arguments: ppa_name
[ -z "$1" ] && error "ubuntu_ppa_installer(): This function is used to add a ppa to a ubuntu based install but a required input argument was missing."
local ppa_grep="$ppa_name"
[[ "${ppa_name}" != */ ]] && local ppa_grep="${ppa_name}/"
local ppa_added=$(apt-get indextargets --no-release-info --format '$(SITE) $(RELEASE)' | sort -u | awk 'NF==2 {print}' | grep "$ppa_grep" | wc -l)
local ppa_added=$(apt-get indextargets --no-release-info --format '$(SITE) $(RELEASE) $(TARGET_OF)' | sort -u | awk '{if ($3=="deb") print $1" "$2 }' | grep "$ppa_grep" | wc -l)
if [[ $ppa_added -eq "1" ]]; then
status "Skipping $ppa_name PPA, already added"
else
Expand Down Expand Up @@ -678,7 +678,7 @@ debian_ppa_installer() { #setup a PPA on a Debian distro. Arguments: ppa_name di
[ -z "$1" ] || [ -z "$2" ] || [ -z "$3" ] && error "debian_ppa_installer(): This function is used to add a ppa to a debian based install but a required input argument was missing."
local ppa_grep="$ppa_name"
[[ "${ppa_name}" != */ ]] && local ppa_grep="${ppa_name}/ubuntu ${ppa_dist}"
local ppa_added=$(apt-get indextargets --no-release-info --format '$(SITE) $(RELEASE)' | sort -u | awk 'NF==2 {print}' | grep "$ppa_grep" | wc -l)
local ppa_added=$(apt-get indextargets --no-release-info --format '$(SITE) $(RELEASE) $(TARGET_OF)' | sort -u | awk '{if ($3=="deb") print $1" "$2 }' | grep "$ppa_grep" | wc -l)
if [[ $ppa_added -eq "1" ]]; then
status "Skipping $ppa_name PPA, already added"
else
Expand Down Expand Up @@ -2523,6 +2523,12 @@ files_match() { #$1 and $2 are paths to files

is_supported_system() { #return 0 if system is supported, otherwise return 1
PRETTY_NAME="$(cat /etc/os-release | grep PRETTY_NAME | tr -d '"' | awk -F= '{print $2}')"
local DEFAULT_REPOS="$(apt-get indextargets --no-release-info --format '$(SITE) $(RELEASE) $(TARGET_OF)' | sort -u | awk '{if ($3=="deb") print $1" "$2 }' | grep "raspbian.raspberrypi.org/raspbian\|archive.raspberrypi.org/debian\|\
debian.org/debian\|security.debian.org/\|\
ports.ubuntu.com\|esm.ubuntu.com/apps/ubuntu\|esm.ubuntu.com/infra/ubuntu\|\
repo.huaweicloud.com/debian\|repo.huaweicloud.com/ubuntu-ports\|\
apt.pop-os.org\|\
apt.armbian.com")"
if uname -m | grep -qi 'x86\|i686\|i386'; then
echo "Pi-Apps is not supported on x86 processors. Nearly all apps will fail. Consider switching to this x86 port of Pi-Apps: https://github.com/MCRaspRBX/pi-apps-x86"
return 1
Expand All @@ -2547,12 +2553,7 @@ is_supported_system() { #return 0 if system is supported, otherwise return 1
elif [ "$(id -u)" == 0 ]; then
echo "Pi-Apps is not designed to be run as root user."
return 1
elif local frankendebian="$(apt-get indextargets --no-release-info --format '$(SITE) $(RELEASE)' | sort -u | awk 'NF==2 {print}' | grep "raspbian.raspberrypi.org/raspbian\|archive.raspberrypi.org/debian\|\
debian.org/debian\|security.debian.org/\|\
ports.ubuntu.com\|esm.ubuntu.com/apps/ubuntu\|esm.ubuntu.com/infra/ubuntu\|\
repo.huaweicloud.com/debian\|repo.huaweicloud.com/ubuntu-ports\|\
apt.pop-os.org\|\
apt.armbian.com" | grep -v $__os_codename)" && [ ! -z "$frankendebian" ];then
elif local frankendebian="$(echo "$DEFAULT_REPOS" | grep -v $__os_codename)" && [ ! -z "$frankendebian" ];then
echo "Congratulations, Linux tinkerer, you broke your system. You have made your system a FrankenDebian.
This website explains your mistake in more detail: https://wiki.debian.org/DontBreakDebian
Your current reported release (${__os_codename^}) should not be combined with other releases.
Expand All @@ -2569,10 +2570,17 @@ Specifically, the issue is $(wc -l <<<"$frankendebian" | grep -q 1 && echo 'this
echo "Congratulations, Linux tinkerer, you broke your system. The init package can not be found, which means you have removed the default debian sources from your system.
All apt based application installs will fail. Unless you have a backup of your /etc/apt/sources.list /etc/apt/sources.list.d you will need to reinstall your OS."
return 1
elif [ -z "$(apt-get indextargets --no-release-info --format '$(SITE) $(RELEASE)' | sort -u | awk 'NF==2 {print}')" ];then
elif [ -z "$(apt-get indextargets --no-release-info --format '$(SITE) $(RELEASE) $(TARGET_OF)' | sort -u | awk '{if ($3=="deb") print $1" "$2 }')" ];then
echo "Congratulations, Linux tinkerer, you broke your system. You have removed ALL debian sources from your system.
All apt based application installs will fail. Unless you have a backup of your /etc/apt/sources.list /etc/apt/sources.list.d you will need to reinstall your OS."
return 1
elif [ "$__os_id" == "Ubuntu" ] && ! ( echo "$DEFAULT_REPOS" | grep -q $__os_codename && \
echo "$DEFAULT_REPOS" | grep -q $__os_codename-updates && \
echo "$DEFAULT_REPOS" | grep -q $__os_codename-security ); then
echo "MISSING Default Ubuntu Repositories!
Pi-Apps does NOT support systems without ALL of $__os_codename, $__os_codename-updates, and $__os_codename-security dists present in the sources.list
Please refer to the default sources.list for Ubuntu and restore all required dists."
return 1
elif [ "$(df -a / -B 1 --output=avail | tail -1 | tr -d ' ')" -lt $((500*1024*1024)) ];then
echo "Your system drive has less than 500MB of free space. Watch out for "\""disk full"\"" errors."
return 1
Expand Down

0 comments on commit 0952537

Please sign in to comment.