diff --git a/Makefile b/Makefile index 58b044ab0..765b6f426 100644 --- a/Makefile +++ b/Makefile @@ -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 \ diff --git a/frontend/ui/otamanager.lua b/frontend/ui/otamanager.lua index 081534650..cc9d40b2f 100644 --- a/frontend/ui/otamanager.lua +++ b/frontend/ui/otamanager.lua @@ -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, diff --git a/platform/cervantes/spinning_zsync b/platform/cervantes/spinning_zsync new file mode 100755 index 000000000..c321c90fd --- /dev/null +++ b/platform/cervantes/spinning_zsync @@ -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 "$@" diff --git a/platform/common/spinning_zsync b/platform/common/spinning_zsync index 6907c6b9e..f6155e2b2 100755 --- a/platform/common/spinning_zsync +++ b/platform/common/spinning_zsync @@ -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...