mirror of
https://github.com/YunoHost/yunohost.git
synced 2024-09-03 20:06:10 +02:00
Merge pull request #638 from YunoHost/broken_dpkg
[enh] Check if dpkg is not broken when calling ynh_wait_dpkg_free
This commit is contained in:
commit
b63c33de4e
1 changed files with 15 additions and 0 deletions
|
@ -17,6 +17,21 @@ ynh_wait_dpkg_free() {
|
|||
# Sleep an exponential time at each round
|
||||
sleep $(( try * try ))
|
||||
else
|
||||
# Check if dpkg hasn't been interrupted and is fully available.
|
||||
# See this for more information: https://sources.debian.org/src/apt/1.4.9/apt-pkg/deb/debsystem.cc/#L141-L174
|
||||
local dpkg_dir="/var/lib/dpkg/updates/"
|
||||
|
||||
# For each file in $dpkg_dir
|
||||
while read dpkg_file <&9
|
||||
do
|
||||
# Check if the name of this file contains only numbers.
|
||||
if echo "$dpkg_file" | grep -Pq "^[[:digit:]]*$"
|
||||
then
|
||||
# If so, that a remaining of dpkg.
|
||||
ynh_print_err "E: dpkg was interrupted, you must manually run 'sudo dpkg --configure -a' to correct the problem."
|
||||
return 1
|
||||
fi
|
||||
done 9<<< "$(ls -1 $dpkg_dir)"
|
||||
return 0
|
||||
fi
|
||||
done
|
||||
|
|
Loading…
Add table
Reference in a new issue