-
Notifications
You must be signed in to change notification settings - Fork 208
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
install_packages: add basic 5-time retry for Other Apt Update
- Loading branch information
Showing
1 changed file
with
25 additions
and
18 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -518,19 +518,6 @@ Package: $package_name" > ~/$package_name/DEBIAN/control | |
echo "$package_name is already installed and no changes would be made. Skipping..." | ||
else | ||
|
||
#Before apt update, check if local repo still exists | ||
if [ "$using_local_packages" == 1 ] && [ ! -f /tmp/pi-apps-local-packages/Packages ];then | ||
error "User error: Uh-oh, the /tmp/pi-apps-local-packages folder went missing while installing packages.\nThis usually happens if you try to install several apps at the same time in multiple terminals." | ||
fi | ||
|
||
#run an apt update | ||
apt_update "${apt_flags[@]}" || exit 1 | ||
|
||
#After apt update, check again if local repo still exists | ||
if [ "$using_local_packages" == 1 ] && [ ! -f /tmp/pi-apps-local-packages/Packages ];then | ||
error "User error: Uh-oh, the /tmp/pi-apps-local-packages folder went missing while installing packages.\nThis usually happens if you try to install several apps at the same time in multiple terminals." | ||
fi | ||
|
||
#Build .deb file for the dummy package | ||
local output="$(dpkg-deb --build ~/$package_name 2>&1)" | ||
if [ $? != 0 ] || [ ! -f ~/$package_name.deb ];then | ||
|
@@ -539,12 +526,32 @@ Package: $package_name" > ~/$package_name/DEBIAN/control | |
error "install_packages(): failed to create dummy deb ${package_name}!" | ||
fi | ||
|
||
#install dummy deb | ||
status "Installing the $package_name package..." | ||
#Before apt update, check if local repo still exists | ||
if [ "$using_local_packages" == 1 ] && [ ! -f /tmp/pi-apps-local-packages/Packages ];then | ||
error "User error: Uh-oh, the /tmp/pi-apps-local-packages folder went missing while installing packages.\nThis usually happens if you try to install several apps at the same time in multiple terminals." | ||
fi | ||
|
||
apt_lock_wait | ||
local output="$(sudo -E apt install -fy --no-install-recommends --allow-downgrades "${apt_flags[@]}" ~/$package_name.deb 2>&1 | less_apt | tee /dev/stderr)" | ||
status "Apt finished." | ||
local i=0 | ||
while [ $i -le 5 ];do #retry loop ; run apt update and apt install again if apt's records of the local repo goes missing | ||
#run an apt update | ||
apt_update "${apt_flags[@]}" || exit 1 | ||
|
||
#install dummy deb | ||
status "Installing the $package_name package..." | ||
|
||
apt_lock_wait | ||
local output="$(sudo -E apt install -fy --no-install-recommends --allow-downgrades "${apt_flags[@]}" ~/$package_name.deb 2>&1 | less_apt | tee /dev/stderr)" | ||
status "Apt finished." | ||
|
||
if [ "$using_local_packages" == 1 ] && [ ! -f /var/lib/apt/lists/_tmp_pi-apps-local-packages_._Packages ];then | ||
#another apt update process deleted apt's knowledge of the pi-apps local repo. Warn the user and try again, up to 5 tries. | ||
i=$((i+1)) | ||
warning "Local packages failed to install because another apt update process erased apt's knowledge of the pi-apps local repository.\nTrying again... (attempt $i of 5)" | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
Botspot
Author
Owner
|
||
else | ||
#apt may have succeeded or failed, but exit retry loop for Other Apt Update | ||
break | ||
fi | ||
done | ||
|
||
errors="$(echo "$output" | grep '^[(E)|(Err]:')" | ||
if [ ! -z "$errors" ];then | ||
|
actually this will run 6 times. see stripped down version of what is here:
check the code again. there are multiple ways to fix