Skip to content

Commit c141f1f

Browse files
committed
fix: can not recover packages when apk upgrade
1 parent 931d5f1 commit c141f1f

3 files changed

Lines changed: 8 additions & 7 deletions

File tree

luci-app-openclash/Makefile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,8 @@ define Package/$(PKG_NAME)/postrm
152152
uci -q delete ucitrack.@openclash[-1]
153153
uci -q commit ucitrack
154154
}
155-
rm -rf /tmp/luci-*
155+
rm -rf /tmp/luci-indexcache /tmp/luci-indexcache.* /var/luci-indexcache /var/luci-indexcache.* >/dev/null 2>&1
156+
rm -rf /tmp/luci-modulecache /var/luci-modulecache >/dev/null 2>&1
156157
exit 0
157158
endef
158159

luci-app-openclash/root/etc/uci-defaults/luci-openclash

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -258,6 +258,6 @@ sed -i '/.*kB maximum content size*/c\export let HTTP_MAX_CONTENT = 1024*10240;
258258

259259
/etc/init.d/uhttpd restart >/dev/null 2>&1
260260

261-
rm -f /tmp/luci-indexcache >/dev/null 2>&1
262-
rm -f /tmp/luci-indexcache.* >/dev/null 2>&1
261+
rm -rf /tmp/luci-indexcache /tmp/luci-indexcache.* /var/luci-indexcache /var/luci-indexcache.* >/dev/null 2>&1
262+
rm -rf /tmp/luci-modulecache /var/luci-modulecache >/dev/null 2>&1
263263
exit 0

luci-app-openclash/root/usr/share/openclash/openclash_update.sh

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ LAST_VER=$(sed -n 1p "$LAST_OPVER" 2>/dev/null |sed "s/^v//g" |tr -d "\n")
5656
if [ -x "/bin/opkg" ]; then
5757
OP_CV=$(rm -f /var/lock/opkg.lock && opkg status luci-app-openclash 2>/dev/null |grep 'Version' |awk -F 'Version: ' '{print $2}' 2>/dev/null)
5858
elif [ -x "/usr/bin/apk" ]; then
59-
OP_CV=$(apk list luci-app-openclash 2>/dev/null|grep 'installed' | grep -oE '[0-9]+(\.[0-9]+)*' | head -1 2>/dev/null)
59+
OP_CV=$(apk list luci-app-openclash 2>/dev/null|grep "installed" | grep -oE '[0-9]+(\.[0-9]+)*' | head -1 2>/dev/null)
6060
fi
6161
OP_LV=$(sed -n 1p "$LAST_OPVER" 2>/dev/null |sed "s/^v//g" |tr -d "\n")
6262
RELEASE_BRANCH=$(uci_get_config "release_branch" || echo "master")
@@ -227,7 +227,7 @@ check_install_success()
227227
if [ -x "/bin/opkg" ]; then
228228
current_version=$(rm -f /var/lock/opkg.lock && opkg status luci-app-openclash 2>/dev/null |grep 'Version' |awk -F 'Version: ' '{print $2}' 2>/dev/null)
229229
elif [ -x "/usr/bin/apk" ]; then
230-
current_version=$(apk list luci-app-openclash 2>/dev/null|grep 'installed' | grep -oE '[0-9]+(\.[0-9]+)*' | head -1 2>/dev/null)
230+
current_version=$(apk list luci-app-openclash 2>/dev/null |grep "installed" | grep -oE '[0-9]+(\.[0-9]+)*' | head -1 2>/dev/null)
231231
fi
232232
233233
if [ -n "$current_version" ] && [ "$current_version" = "$target_version" ]; then
@@ -260,7 +260,7 @@ install_missing_packages() {
260260
done
261261
elif [ -x "/usr/bin/apk" ]; then
262262
for pkg in $installed_before; do
263-
if ! apk info "$pkg" >/dev/null 2>&1; then
263+
if ! apk list "$pkg" |grep "installed" >/dev/null 2>&1; then
264264
local retry_count=0
265265
local max_retries=3
266266
while [ $retry_count -lt $max_retries ]; do
@@ -298,7 +298,7 @@ while [ $install_retry_count -lt $max_install_retries ]; do
298298
opkg install /tmp/openclash.ipk
299299
elif [ -x "/usr/bin/apk" ]; then
300300
for pkg in $packages_to_check; do
301-
if apk info "$pkg" >/dev/null 2>&1; then
301+
if apk list "$pkg" |grep "installed" >/dev/null 2>&1; then
302302
installed_before="$installed_before $pkg"
303303
fi
304304
done

0 commit comments

Comments
 (0)