这是indexloc提供的服务,不要输入任何密码
Skip to content

Commit cf3236e

Browse files
author
Leonid Pliushch
committed
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.
1 parent 3337b9f commit cf3236e

File tree

1 file changed

+11
-2
lines changed
  • packages/termux-tools

1 file changed

+11
-2
lines changed

packages/termux-tools/pkg

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,8 +142,17 @@ select_mirror() {
142142
}
143143

144144
update_apt_cache() {
145-
local pkgcache="@TERMUX_CACHE_DIR@/apt/pkgcache.bin"
146-
if (( $(last_modified "$pkgcache") > 1200 )); then
145+
local cache_modified
146+
local sources_modified
147+
148+
if [ -e "@TERMUX_CACHE_DIR@/apt/pkgcache.bin" ]; then
149+
cache_modified=$(last_modified "@TERMUX_CACHE_DIR@/apt/pkgcache.bin")
150+
sources_modified=$(last_modified "@TERMUX_PREFIX@/etc/apt/sources.list")
151+
152+
if (( sources_modified <= cache_modified )) || (( cache_modified > 1200 )); then
153+
apt update
154+
fi
155+
else
147156
apt update
148157
fi
149158
}

0 commit comments

Comments
 (0)