target/realtek: auto fix opkg status after dirty upgrading
(cherry picked from commit 10cf9aebadd800e29db4e348660ec167d9c632b3)
This commit is contained in:
parent
c619db5c34
commit
d027b8bdd1
60
target/linux/realtek/base-files/etc/init.d/rtk_upgrade
Executable file
60
target/linux/realtek/base-files/etc/init.d/rtk_upgrade
Executable file
@ -0,0 +1,60 @@
|
||||
#!/bin/sh /etc/rc.common
|
||||
# Copyright (C) 2016 OpenWrt.org
|
||||
|
||||
START=14
|
||||
|
||||
split_opkg_status() {
|
||||
local line
|
||||
local of=/dev/null
|
||||
rm -rf $2
|
||||
mkdir -p $2
|
||||
cat $1 | while read; do
|
||||
line="$REPLY"
|
||||
if [ -z "$line" ]; then
|
||||
echo >>$of
|
||||
of=/dev/null
|
||||
else
|
||||
if [ "x/dev/null" = "x$of" ] && echo "$line" | grep -q "^Package: "; then
|
||||
of=$2/`echo "$line"|cut -d' ' -f2`
|
||||
fi
|
||||
echo "$line" >>$of
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
split_both_status() {
|
||||
split_opkg_status /usr/lib/opkg/status /tmp/newopkgstatus &
|
||||
split_opkg_status /rom/usr/lib/opkg/status /tmp/romopkgstatus &
|
||||
wait
|
||||
}
|
||||
|
||||
ls_all_pkgs() {
|
||||
( cd /usr/lib/opkg/info ; find . -maxdepth 1 -name '*.control' | sed -E 's#./(.*).control#\1#g' )
|
||||
}
|
||||
|
||||
rebuild_opkg_status() {
|
||||
local line
|
||||
ls_all_pkgs | while read line; do
|
||||
if [ -f /overlay/upper/usr/lib/opkg/info/$line.control ]; then
|
||||
cat /tmp/newopkgstatus/$line
|
||||
else
|
||||
cat /tmp/romopkgstatus/$line
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
clean_tmp_files() {
|
||||
rm -rf /tmp/newopkgstatus
|
||||
rm -rf /tmp/romopkgstatus
|
||||
}
|
||||
|
||||
boot() {
|
||||
[ -f /.recovery_mode ] && return 0
|
||||
|
||||
if [ -f /usr/lib/opkg/.upgrading ]; then
|
||||
rm -f /usr/lib/opkg/.upgrading
|
||||
split_both_status
|
||||
rebuild_opkg_status > /usr/lib/opkg/status
|
||||
clean_tmp_files
|
||||
fi
|
||||
}
|
||||
@ -53,4 +53,6 @@ fi
|
||||
|
||||
uci commit dockerman
|
||||
|
||||
rm -f /usr/lib/opkg/.upgrading
|
||||
|
||||
exit 0
|
||||
|
||||
@ -14,6 +14,12 @@ platform_check_image() {
|
||||
return 0
|
||||
}
|
||||
|
||||
platform_pre_upgrade() {
|
||||
[ -n "$UPGRADE_BACKUP" ] && {
|
||||
touch /overlay/upper/usr/lib/opkg/.upgrading && sync /overlay
|
||||
}
|
||||
}
|
||||
|
||||
platform_do_upgrade() {
|
||||
# $1: image path/url
|
||||
echo "platform_do_upgrade start"
|
||||
|
||||
Loading…
Reference in New Issue
Block a user