platform: remove leftovers from old install on update (#14637)

Files present in the old `ota/package.index` but not in the new one.
This commit is contained in:
Benoit Pierre
2025-11-25 15:37:58 +01:00
committed by GitHub
parent 3d88d86b82
commit fec9c1ea38
5 changed files with 33 additions and 7 deletions

View File

@@ -4,6 +4,7 @@ export LC_ALL="en_US.UTF-8"
# working directory of koreader
KOREADER_DIR="${0%/*}"
UNPACK_DIR="${KOREADER_DIR%/*}"
# we're always starting from our working directory
cd "${KOREADER_DIR}" || exit
@@ -14,6 +15,8 @@ ko_update_check() {
INSTALLED="${KOREADER_DIR}/ota/koreader.installed.tar"
if [ -f "${NEWUPDATE}" ]; then
./fbink -q -y -7 -pmh "Updating KOReader"
# Keep a copy of the old manifest for cleaning leftovers later.
cp "${KOREADER_DIR}/ota/package.index" /tmp/
# Setup the FBInk daemon
export FBINK_NAMED_PIPE="/tmp/koreader.fbink"
rm -f "${FBINK_NAMED_PIPE}"
@@ -30,6 +33,8 @@ ko_update_check() {
# Cleanup behind us...
if [ "${fail}" -eq 0 ]; then
mv "${NEWUPDATE}" "${INSTALLED}"
# Cleanup leftovers from previous install.
(cd "${UNPACK_DIR}" && grep -xvFf "${KOREADER_DIR}/ota/package.index" /tmp/package.index | xargs -r rm -vf)
./fbink -q -y -6 -pm "Update successful :)"
./fbink -q -y -5 -pm "KOReader will start momentarily . . ."
else
@@ -37,7 +42,7 @@ ko_update_check() {
./fbink -q -y -6 -pmh "Update failed :("
./fbink -q -y -5 -pm "KOReader may fail to function properly!"
fi
rm -f "${NEWUPDATE}" # always purge newupdate to prevent update loops
rm -f /tmp/package.index "${NEWUPDATE}" # always purge newupdate to prevent update loops
unset CPOINTS FBINK_NAMED_PIPE
unset BLOCKS FILESIZE FBINK_PID
# Ensure everything is flushed to disk before we restart. This *will* stall for a while on slow storage!

View File

@@ -17,8 +17,9 @@ PROC_FIVEWAY="/proc/fiveway"
[ -e "${PROC_KEYPAD}" ] && echo unlock >"${PROC_KEYPAD}"
[ -e "${PROC_FIVEWAY}" ] && echo unlock >"${PROC_FIVEWAY}"
UNPACK_DIR='/mnt/us'
# KOReader's working directory
export KOREADER_DIR="/mnt/us/koreader"
export KOREADER_DIR="${UNPACK_DIR}/koreader"
# NOTE: Same vfat+fuse shenanigans needed for FBInk, before we source libko...
cp -pf "${KOREADER_DIR}/fbink" /var/tmp/fbink
@@ -123,6 +124,8 @@ ko_update_check() {
logmsg "Updating KOReader . . ."
# Let our checkpoint script handle the detailed visual feedback...
eips_print_bottom_centered "Updating KOReader" 3
# Keep a copy of the old manifest for cleaning leftovers later.
cp "${KOREADER_DIR}/ota/package.index" /tmp/
# Setup the FBInk daemon
export FBINK_NAMED_PIPE="/tmp/koreader.fbink"
rm -f "${FBINK_NAMED_PIPE}"
@@ -146,6 +149,8 @@ ko_update_check() {
# Cleanup behind us...
if [ "${fail}" -eq 0 ]; then
mv "${NEWUPDATE}" "${INSTALLED}"
# Cleanup leftovers from previous install.
(cd "${UNPACK_DIR}" && grep -xvFf "${KOREADER_DIR}/ota/package.index" /tmp/package.index | xargs -r rm -vf)
logmsg "Update successful :)"
eips_print_bottom_centered "Update successful :)" 2
eips_print_bottom_centered "KOReader will start momentarily . . ." 1
@@ -160,7 +165,7 @@ ko_update_check() {
eips_print_bottom_centered "Update failed :(" 2
eips_print_bottom_centered "KOReader may fail to function properly" 1
fi
rm -f "${NEWUPDATE}" # always purge newupdate to prevent update loops
rm -f /tmp/package.index "${NEWUPDATE}" # always purge newupdate to prevent update loops
unset CPOINTS FBINK_NAMED_PIPE
unset BLOCKS FILESIZE FBINK_PID
# Ensure everything is flushed to disk before we restart. This *will* stall for a while on slow storage!

View File

@@ -5,6 +5,7 @@ export LC_ALL="en_US.UTF-8"
SCRIPT_DIR="$(CDPATH='' cd -- "$(dirname -- "$0")" && pwd -P)"
# NOTE: We need to remember the *actual* KOREADER_DIR, not the relocalized version in /tmp...
export KOREADER_DIR="${KOREADER_DIR:-${SCRIPT_DIR}}"
UNPACK_DIR="${KOREADER_DIR%/*}"
# We rely on starting from our working directory, and it needs to be set, sane and absolute.
cd "${KOREADER_DIR:-/dev/null}" || exit
@@ -95,6 +96,8 @@ ko_update_check() {
# Clear screen to delete UI leftovers
./fbink --cls
./fbink -q -y -7 -pmh "Updating KOReader"
# Keep a copy of the old manifest for cleaning leftovers later.
cp "${KOREADER_DIR}/ota/package.index" /tmp/
# Setup the FBInk daemon
export FBINK_NAMED_PIPE="/tmp/koreader.fbink"
rm -f "${FBINK_NAMED_PIPE}"
@@ -119,6 +122,8 @@ ko_update_check() {
# Cleanup behind us...
if [ "${fail}" -eq 0 ]; then
mv "${NEWUPDATE}" "${INSTALLED}"
# Cleanup leftovers from previous install.
(cd "${UNPACK_DIR}" && grep -xvFf "${KOREADER_DIR}/ota/package.index" /tmp/package.index | xargs -r rm -vf)
./fbink -q -y -6 -pm "Update successful :)"
./fbink -q -y -5 -pm "KOReader will start momentarily . . ."
@@ -131,7 +136,7 @@ ko_update_check() {
./fbink -q -y -6 -pmh "Update failed :("
./fbink -q -y -5 -pm "KOReader may fail to function properly!"
fi
rm -f "${NEWUPDATE}" # always purge newupdate to prevent update loops
rm -f /tmp/package.index "${NEWUPDATE}" # always purge newupdate to prevent update loops
unset CPOINTS FBINK_NAMED_PIPE
unset BLOCKS FILESIZE FBINK_PID
# Ensure everything is flushed to disk before we restart. This *will* stall for a while on slow storage!

View File

@@ -1,8 +1,9 @@
#!/bin/sh
export LC_ALL="en_US.UTF-8"
UNPACK_DIR='/mnt/ext1'
# working directory of koreader
KOREADER_DIR="/mnt/ext1/applications/koreader"
KOREADER_DIR="${UNPACK_DIR}/applications/koreader"
# load our own shared libraries if possible, solely because we don't control InkView, and we'd rather not it have load duplicate system libs...
# (We handle this via DT_RPATH for our own stuff).
@@ -30,6 +31,8 @@ ko_update_check() {
INSTALLED="${KOREADER_DIR}/ota/koreader.installed.tar"
if [ -f "${NEWUPDATE}" ]; then
"${KOREADER_DIR}/fbink" -q -y -7 -pmh "Updating KOReader"
# Keep a copy of the old manifest for cleaning leftovers later.
sed 's,^../,,' "${KOREADER_DIR}/ota/package.index" >/tmp/package.index.old
# Setup the FBInk daemon
export FBINK_NAMED_PIPE="/tmp/.koreader.fbink"
rm -f "${FBINK_NAMED_PIPE}"
@@ -60,6 +63,9 @@ ko_update_check() {
# Cleanup behind us...
if [ "${fail}" -eq 0 ]; then
mv "${NEWUPDATE}" "${INSTALLED}"
# Cleanup leftovers from previous install.
sed 's,^../,,' "${KOREADER_DIR}/ota/package.index" >/tmp/package.index.new
(cd "${UNPACK_DIR}" && grep -xvFf /tmp/package.index.new /tmp/package.index.old | xargs -r rm -vf)
"${KOREADER_DIR}/fbink" -q -y -6 -pm "Update successful :)"
"${KOREADER_DIR}/fbink" -q -y -5 -pm "KOReader will start momentarily . . ."
else
@@ -67,7 +73,7 @@ ko_update_check() {
"${KOREADER_DIR}/fbink" -q -y -6 -pmh "Update failed :("
"${KOREADER_DIR}/fbink" -q -y -5 -pm "KOReader may fail to function properly!"
fi
rm -f "${NEWUPDATE}" # always purge newupdate to prevent update loops
rm -f /tmp/package.index.old /tmp/package.index.new "${NEWUPDATE}" # always purge newupdate to prevent update loops
unset CPOINTS FBINK_NAMED_PIPE
unset BLOCKS FILESIZE FBINK_PID
# Ensure everything is flushed to disk before we restart. This *will* stall for a while on slow storage!

View File

@@ -2,6 +2,7 @@
export LC_ALL="en_US.UTF-8"
# working directory of koreader
KOREADER_DIR="${0%/*}"
UNPACK_DIR="${KOREADER_DIR%/*}"
# we're always starting from our working directory
cd "${KOREADER_DIR}" || exit
@@ -26,6 +27,8 @@ ko_update_check() {
fi
./fbink -q -y -7 -pmh "Updating KOReader"
# Keep a copy of the old manifest for cleaning leftovers later.
cp "${KOREADER_DIR}/ota/package.index" /tmp/
# Setup the FBInk daemon
export FBINK_NAMED_PIPE="/tmp/koreader.fbink"
rm -f "${FBINK_NAMED_PIPE}"
@@ -42,6 +45,8 @@ ko_update_check() {
# Cleanup behind us...
if [ "${fail}" -eq 0 ]; then
mv "${NEWUPDATE}" "${INSTALLED}"
# Cleanup leftovers from previous install.
(cd "${UNPACK_DIR}" && grep -xvFf "${KOREADER_DIR}/ota/package.index" /tmp/package.index | xargs -r rm -vf)
./fbink -q -y -6 -pm "Update successful :)"
./fbink -q -y -5 -pm "KOReader will start momentarily . . ."
else
@@ -49,7 +54,7 @@ ko_update_check() {
./fbink -q -y -6 -pmh "Update failed :("
./fbink -q -y -5 -pm "KOReader may fail to function properly!"
fi
rm -f "${NEWUPDATE}" # always purge newupdate to prevent update loops
rm -f /tmp/package.index "${NEWUPDATE}" # always purge newupdate to prevent update loops
unset CPOINTS FBINK_NAMED_PIPE
unset BLOCKS FILESIZE FBINK_PID
# Ensure everything is flushed to disk before we restart. This *will* stall for a while on slow storage!