Browse Source

Unbreak OTA on crappy shells (#5850)

* Unbreak OTA on crappy shells

  Very, very old ash versions abort on set -o failures (as mandated by
POSIX, granted). This makes it impossible to reliably catch failures in
a single step.

So do it from the Lua side instead.

Should fix #5844

* Launch the zsync wrapper through bash on Cervantes
reviewable/pr5853/r1
NiLuJe 1 year ago
committed by GitHub
parent
commit
de15ab3a87
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 28 additions and 11 deletions
  1. +1
    -1
      Makefile
  2. +11
    -2
      frontend/ui/otamanager.lua
  3. +7
    -0
      platform/cervantes/spinning_zsync
  4. +9
    -8
      platform/common/spinning_zsync

+ 1
- 1
Makefile View File

@ -451,8 +451,8 @@ cervantesupdate: all
# remove old package if any
rm -f $(CERVANTES_PACKAGE)
# Cervantes launching scripts
cp $(COMMON_DIR)/spinning_zsync $(INSTALL_DIR)/koreader/spinning_zsync.sh
cp $(CERVANTES_DIR)/*.sh $(INSTALL_DIR)/koreader
cp $(COMMON_DIR)/spinning_zsync $(INSTALL_DIR)/koreader
# create new package
cd $(INSTALL_DIR) && \
zip -9 -r \

+ 11
- 2
frontend/ui/otamanager.lua View File

@ -399,14 +399,22 @@ end
function OTAManager:zsync(full_dl)
if full_dl or self:_buildLocalPackage() == 0 then
local zsync_wrapper = "zsync2"
local use_pipefail = true
-- With visual feedback if supported...
if self.can_pretty_print then
zsync_wrapper = "spinning_zsync"
-- And because everything is terrible, we can't check for pipefail's usability in spinning_zsync,
-- because older ash versions abort on set -o failures...
-- c.f., ko/#5844
-- So, instead, check from this side of the fence...
-- (remember, os.execute is essentially system(), it goes through sh)
use_pipefail = (os.execute("set -o pipefail 2>/dev/null") == 0)
end
-- If that's a full-download fallback, drop the input tarball
if full_dl then
return os.execute(
("./%s -o '%s' -u '%s' '%s%s'"):format(
("env WITH_PIPEFAIL='%s' ./%s -o '%s' -u '%s' '%s%s'"):format(
use_pipefail,
zsync_wrapper,
self.updated_package,
self:getOTAServer(),
@ -415,7 +423,8 @@ function OTAManager:zsync(full_dl)
)
else
return os.execute(
("./%s -i '%s' -o '%s' -u '%s' '%s%s'"):format(
("env WITH_PIPEFAIL='%s' ./%s -i '%s' -o '%s' -u '%s' '%s%s'"):format(
use_pipefail,
zsync_wrapper,
self.installed_package,
self.updated_package,

+ 7
- 0
platform/cervantes/spinning_zsync View File

@ -0,0 +1,7 @@
#!/bin/bash
# NOTE: We can use pipefail via bash on Cervantes
# c.f., #5844 & #5850
export WITH_PIPEFAIL="true"
exec /bin/bash ./spinning_zsync.sh "$@"

+ 9
- 8
platform/common/spinning_zsync View File

@ -1,14 +1,15 @@
#!/bin/sh
# We're going to need to remember failures from the *left* side of a pipeline...
# shellcheck disable=SC2039
if set -o pipefail 2>/dev/null; then
WITH_PIPEFAIL="true"
else
# But because we can't have nice things, some devices (hi, Kindle) may use an extremely old busybox build,
# one in which pipefail was not yet implemented,
# (it appeared in busybox 1.16.0, and is contingent on bash compatibility being enabled in ash).
WITH_PIPEFAIL="true"
# But because we can't have nice things, some devices (hi, Kindle) may use an extremely old busybox build,
# one in which pipefail was not yet implemented,
# (it appeared in busybox 1.16.0, and is contingent on bash compatibility being enabled in ash).
# NOTE: We inherit WITH_PIPEFAIL from the env via OTAManager, because of course old busybox ash versions abort on set -o failures...
# c.f., https://github.com/koreader/koreader/pull/5844
if [ "${WITH_PIPEFAIL}" = "true" ]; then
# shellcheck disable=SC2039
set -o pipefail
fi
# Figure out whether that's a delta or a full download given the number of arguments passed...

Loading…
Cancel
Save