2018-09-05 23:35:48 +00:00
|
|
|
|
#!/bin/sh
|
|
|
|
|
|
2019-01-01 19:06:55 +00:00
|
|
|
|
# Figure out whether that's a delta or a full download given the number of arguments passed...
|
|
|
|
|
if [ $# -lt 7 ]; then
|
|
|
|
|
ZSYNC_MESSAGE="Downloading update data"
|
|
|
|
|
else
|
|
|
|
|
ZSYNC_MESSAGE="Computing zsync delta"
|
|
|
|
|
fi
|
|
|
|
|
|
2018-09-05 23:35:48 +00:00
|
|
|
|
# Small zsync wrapper so we can get a pretty spinner while it works...
|
2019-01-01 19:06:55 +00:00
|
|
|
|
./fbink -q -y -7 -pmh "${ZSYNC_MESSAGE} !"
|
2018-09-05 23:35:48 +00:00
|
|
|
|
# Clear any potential leftover from the local OTA tarball creation.
|
|
|
|
|
./fbink -q -y -6 -pm ' '
|
|
|
|
|
|
|
|
|
|
# Spin in the background while we work ;).
|
|
|
|
|
(
|
|
|
|
|
# See https://stackoverflow.com/questions/2685435 for inspiration
|
|
|
|
|
# as well as https://www.npmjs.com/package/cli-spinners
|
|
|
|
|
# & https://github.com/swelljoe/spinner
|
|
|
|
|
# http://www.fileformat.info/info/unicode/block/block_elements/list.htm
|
|
|
|
|
##
|
|
|
|
|
# Simple bars, they look better when a bit smoother, with a snappier interval (~250ms)
|
|
|
|
|
#SPINNER="<22> ▁ ▂ ▃ ▄ ▅ ▆ ▇ █ ▇ ▆ ▅ ▄ ▃ ▂ ▁"
|
|
|
|
|
#SPINNER="<22> ▏ ▎ ▍ ▌ ▋ ▊ ▉ █ ▉ ▊ ▋ ▌ ▍ ▎ ▏"
|
|
|
|
|
# Spinning blocks
|
|
|
|
|
SPINNER="▖ ▘ ▝ ▗"
|
|
|
|
|
#SPINNER="▜ ▟ ▙ ▛"
|
|
|
|
|
# Snaking blocks
|
|
|
|
|
#SPINNER="▌ ▀ ▐ ▄"
|
|
|
|
|
#SPINNER="▌ ▛ ▀ ▜ ▐ ▟ ▄ ▙"
|
|
|
|
|
while :; do
|
|
|
|
|
for spin in ${SPINNER}; do
|
2019-02-13 00:13:29 +00:00
|
|
|
|
usleep 500000 2>/dev/null || sleep 0.5
|
2018-09-05 23:35:48 +00:00
|
|
|
|
# NOTE: Throw stderr to the void because I'm cheating w/ U+FFFD for a blank character,
|
|
|
|
|
# which FBInk replaces by a blank, but not before shouting at us on stderr ;).
|
2019-01-01 19:06:55 +00:00
|
|
|
|
./fbink -q -y -7 -pmh "${ZSYNC_MESSAGE} ${spin}" 2>/dev/null
|
2018-09-05 23:35:48 +00:00
|
|
|
|
done
|
|
|
|
|
done
|
|
|
|
|
) &
|
|
|
|
|
|
|
|
|
|
# Launch zsync, and remember its exit code...
|
|
|
|
|
./zsync "$@"
|
|
|
|
|
rc=$?
|
|
|
|
|
|
|
|
|
|
# Kill the spinner subshell now that we're done
|
|
|
|
|
kill -15 $!
|
|
|
|
|
|
|
|
|
|
# And return with zsync's exit code, not kill's ;).
|
|
|
|
|
exit ${rc}
|