Skip to content

Commit

Permalink
api: prep for apt 3.0
Browse files Browse the repository at this point in the history
incomplete prep for apt 3.0 with apt will output will drastically change. apt-get should be used in all cases where output needs to be stable (eg: for parsing). there are other instances in pi-apps (including the api) where `apt install` is still parsed but these are used heavily and need more regression testing.
  • Loading branch information
theofficialgman committed Aug 15, 2024
1 parent 368f6e3 commit 680491c
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions api
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,7 @@ apt_lock_wait() { #Wait until other apt processes are finished before proceeding
done

#Try to install a non-existent package to see if apt fails due to a lock-file. Repeat until no errors mention 'Could not get lock'
while sudo -E apt install lkqecjhxwqekc 2>&1 | grep -q 'Could not get lock' ;do
while sudo -E apt-get install lkqecjhxwqekc 2>&1 | grep -q 'Could not get lock' ;do
sleep 1
done

Expand Down Expand Up @@ -699,7 +699,7 @@ Package: $package_name" > /tmp/$package_name/DEBIAN/control
echo -e "\e[91mThe Pi-Apps Local Repository was being used, and a package seemed to not be available. Here's the Packages file:\e[39m"
cat /tmp/pi-apps-local-packages/Packages
echo -e "Attempting apt --dry-run installation of the problematic package(s) for debugging purposes:\n"
( echo "$output" | grep 'but it is not installable' || echo "$output" | grep 'but it is not going to be installed' || echo "$output" | grep "but .* is to be installed" ) | awk '{print $4}' | uniq | xargs sudo -E apt install -fy --no-install-recommends --allow-downgrades --dry-run "${apt_flags[@]}"
( echo "$output" | grep 'but it is not installable' || echo "$output" | grep 'but it is not going to be installed' || echo "$output" | grep "but .* is to be installed" ) | awk '{print $4}' | uniq | xargs sudo -E apt-get install -fy --no-install-recommends --allow-downgrades --dry-run "${apt_flags[@]}"
echo -e "Printing apt-cache policy output for debugging purposes:\n"
apt-cache policy
fi
Expand Down Expand Up @@ -1791,7 +1791,7 @@ generate_app_icons() { #This converts the given $1 image into icon-24.png and ic
--button=No!"${DIRECTORY}/icons/exit.png":1 --button=Yes!"${DIRECTORY}/icons/check.png":0
button=$?
if [ $button == 0 ];then
sudo apt install -y --no-install-recommends imagemagick || icon=''
sudo apt-get install -y --no-install-recommends imagemagick || icon=''
else
exit 0
fi
Expand Down Expand Up @@ -2143,13 +2143,13 @@ Pi-Apps cannot work until you solve this issue. If you do not need the problemat
echo -e "Additional log diagnosis for developers below:\n" >> "$logfile"
grep -E "^ .* : Depends:" <<<"$errors" | awk '{print $1, $4}' | tr " " "\n" | sort -u | awk '/:armhf/{print; gsub(/:armhf/, ":arm64")}1' | xargs -r apt-cache show >> "$logfile"
grep -E "^ .* : Depends:" <<<"$errors" | awk '{print $1, $4}' | tr " " "\n" | sed 's/:armhf\|:arm64\|:all//g' | sort -u | xargs -r apt list -a >> "$logfile"
grep -E "^ .* : Depends:" <<<"$errors" | awk '{print $4}' | tr " " "\n" | sort -u | awk '/:armhf/{print; gsub(/:armhf/, ":arm64")}1' | xargs -r apt install -fy --no-install-recommends --allow-downgrades --dry-run >> "$logfile"
grep -E "^ .* : Depends:" <<<"$errors" | awk '{print $4}' | tr " " "\n" | sort -u | awk '/:armhf/{print; gsub(/:armhf/, ":arm64")}1' | xargs -r apt-get install -fy --no-install-recommends --allow-downgrades --dry-run >> "$logfile"
grep -E "^ +Depends:" <<<"$errors" | awk '{print $2}' | sort -u | awk '/:armhf/{print; gsub(/:armhf/, ":arm64")}1' | xargs -r apt-cache show >> "$logfile"
grep -E "^ +Depends:" <<<"$errors" | awk '{print $2}' | sed 's/:armhf\|:arm64\|:all//g' | sort -u | xargs -r apt list -a >> "$logfile"
grep -E "^ +Depends:" <<<"$errors" | awk '{print $2}' | sort -u | awk '/:armhf/{print; gsub(/:armhf/, ":arm64")}1' | xargs -r apt install -fy --no-install-recommends --allow-downgrades --dry-run >> "$logfile"
grep -E "^ +Depends:" <<<"$errors" | awk '{print $2}' | sort -u | awk '/:armhf/{print; gsub(/:armhf/, ":arm64")}1' | xargs -r apt-get install -fy --no-install-recommends --allow-downgrades --dry-run >> "$logfile"
grep -E "^Depends:" <<<"$errors" | cut -d' ' -f2- | sed "s/, /\n/g" | sed "s/| /\n/g" | sed "s/:any//g" | sed 's/([^)]*)//g;s/ / /g' | xargs -r apt-cache show >> "$logfile"
grep -E "^Depends:" <<<"$errors" | cut -d' ' -f2- | sed "s/, /\n/g" | sed "s/| /\n/g" | sed 's/:armhf\|:arm64\|:all//g' | sed 's/([^)]*)//g;s/ / /g' | sort -u | xargs -r apt list -a >> "$logfile"
grep -E "^Depends:" <<<"$errors" | cut -d' ' -f2- | sed "s/, /\n/g" | sed "s/| /\n/g" | sed "s/:any//g" | sed 's/([^)]*)//g;s/ / /g' | xargs -r apt install -fy --no-install-recommends --allow-downgrades --dry-run >> "$logfile"
grep -E "^Depends:" <<<"$errors" | cut -d' ' -f2- | sed "s/, /\n/g" | sed "s/| /\n/g" | sed "s/:any//g" | sed 's/([^)]*)//g;s/ / /g' | xargs -r apt-get install -fy --no-install-recommends --allow-downgrades --dry-run >> "$logfile"

# we also want to see the users apt sources (.list and .sources)
apt-get indextargets --no-release-info --format '$(SITE) $(RELEASE) $(COMPONENT) $(TARGET_OF) $(ARCHITECTURE)' | sort -u >> "$logfile"
Expand Down Expand Up @@ -2189,21 +2189,21 @@ sudo apt-mark unhold $(grep -E "^Depends:" <<<"$errors" | cut -d' ' -f2- | sed "
# missing multiarch (armhf) compatible package for installed (or to be installed) arm64 package
# this does not occur on Debian/Ubuntu but can occur on BAD distros (or PPAs and other 3rd party repos) that do not provide both armhf and arm64 packages for any custom packages of higher priority than the upstream distro packages
for test_package in $(grep -E "^ .* : Depends:" <<<"$errors" | awk '{print $1, $4}' | tr " " "\n" | sed 's/:armhf\|:arm64\|:all//g' | sort -u) ; do
if apt install -fy --no-install-recommends --allow-downgrades --dry-run "$test_package" | grep -q "$test_package : Breaks: $test_package:armhf" ; then
if apt-get install -fy --no-install-recommends --allow-downgrades --dry-run "$test_package" | grep -q "$test_package : Breaks: $test_package:armhf" ; then
error_caption+=("Packages failed to install because $test_package does not have a multiarch (armhf) compatible version.
This issue does not occur on Ubuntu/Debian (where every package is multiarch compatible). Contact your distro maintainer or the packager of $test_package to have this issue resolved.")
error_type="system"
fi
done
for test_package in $(grep -E "^ +Depends:" <<<"$errors" | awk '{print $2}' | sed 's/:armhf\|:arm64\|:all//g' | sort -u) ; do
if apt install -fy --no-install-recommends --allow-downgrades --dry-run "$test_package" | grep -q "$test_package : Breaks: $test_package:armhf" ; then
if apt-get install -fy --no-install-recommends --allow-downgrades --dry-run "$test_package" | grep -q "$test_package : Breaks: $test_package:armhf" ; then
error_caption+=("Packages failed to install because $test_package does not have a multiarch (armhf) compatible version.
This issue does not occur on Ubuntu/Debian (where every package is multiarch compatible). Contact your distro maintainer or the packager of $test_package to have this issue resolved.")
error_type="system"
fi
done
for test_package in $(grep -E "^Depends:" <<<"$errors" | cut -d' ' -f2- | sed "s/, /\n/g" | sed "s/| /\n/g" | sed 's/:armhf\|:arm64\|:all//g' | sed 's/([^)]*)//g;s/ / /g' | sort -u) ; do
if apt install -fy --no-install-recommends --allow-downgrades --dry-run "$test_package" | grep -q "$test_package : Breaks: $test_package:armhf" ; then
if apt-get install -fy --no-install-recommends --allow-downgrades --dry-run "$test_package" | grep -q "$test_package : Breaks: $test_package:armhf" ; then
error_caption+=("Packages failed to install because $test_package does not have a multiarch (armhf) compatible version.
This issue does not occur on Ubuntu/Debian (where every package is multiarch compatible). Contact your distro maintainer or the packager of $test_package to have this issue resolved.")
error_type="system"
Expand Down

0 comments on commit 680491c

Please sign in to comment.