termux-tools: pkg: try to avoid cases where pkgcache is up-to-date but sources.list has been changed
A small percentage of users reporting issue where `pkg install` shows that package is not available, though it is present in our apt repository. This happens when sources.list has been changed without subsequent `apt update`. Now `pkg` will force run `apt update` if sources.list was modified after packages list update but cache still not expired.
This commit is contained in:
parent
3337b9ffee
commit
cf3236e9e8
@ -142,8 +142,17 @@ select_mirror() {
|
||||
}
|
||||
|
||||
update_apt_cache() {
|
||||
local pkgcache="@TERMUX_CACHE_DIR@/apt/pkgcache.bin"
|
||||
if (( $(last_modified "$pkgcache") > 1200 )); then
|
||||
local cache_modified
|
||||
local sources_modified
|
||||
|
||||
if [ -e "@TERMUX_CACHE_DIR@/apt/pkgcache.bin" ]; then
|
||||
cache_modified=$(last_modified "@TERMUX_CACHE_DIR@/apt/pkgcache.bin")
|
||||
sources_modified=$(last_modified "@TERMUX_PREFIX@/etc/apt/sources.list")
|
||||
|
||||
if (( sources_modified <= cache_modified )) || (( cache_modified > 1200 )); then
|
||||
apt update
|
||||
fi
|
||||
else
|
||||
apt update
|
||||
fi
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user