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 4 years ago committed by GitHub
parent 24f1f435de
commit de15ab3a87
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

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

@ -399,14 +399,22 @@ end
function OTAManager:zsync(full_dl) function OTAManager:zsync(full_dl)
if full_dl or self:_buildLocalPackage() == 0 then if full_dl or self:_buildLocalPackage() == 0 then
local zsync_wrapper = "zsync2" local zsync_wrapper = "zsync2"
local use_pipefail = true
-- With visual feedback if supported... -- With visual feedback if supported...
if self.can_pretty_print then if self.can_pretty_print then
zsync_wrapper = "spinning_zsync" 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 end
-- If that's a full-download fallback, drop the input tarball -- If that's a full-download fallback, drop the input tarball
if full_dl then if full_dl then
return os.execute( 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, zsync_wrapper,
self.updated_package, self.updated_package,
self:getOTAServer(), self:getOTAServer(),
@ -415,7 +423,8 @@ function OTAManager:zsync(full_dl)
) )
else else
return os.execute( 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, zsync_wrapper,
self.installed_package, self.installed_package,
self.updated_package, self.updated_package,

@ -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 "$@"

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

Loading…
Cancel
Save