mirror of
https://github.com/koreader/koreader.git
synced 2025-08-10 00:52:38 +00:00
Add ShellCheck and shfmt shell code quality analysis (#2712)
* Add ShellCheck and shfmt shell code quality analysis * kobo/koreader.sh: remove useless $PREFIX * kobo/koreader.sh: fix rotation issue caused by #2731 * Travis: speed up (caching Luarocks should shave a minute off install process)
This commit is contained in:
@@ -1,14 +1,15 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
CI_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
# shellcheck source=/dev/null
|
||||
source "${CI_DIR}/common.sh"
|
||||
|
||||
set +e
|
||||
|
||||
if [ ${TRAVIS_PULL_REQUEST} = false ] && [ ${TRAVIS_BRANCH} = 'master' ]; then
|
||||
if [ "${TRAVIS_PULL_REQUEST}" = false ] && [ "${TRAVIS_BRANCH}" = 'master' ]; then
|
||||
travis_retry luarocks --local install ldoc
|
||||
# get deploy key for doc repo
|
||||
openssl aes-256-cbc -k $doc_build_secret -in .ci/koreader_doc.enc -out ~/.ssh/koreader_doc -d
|
||||
openssl aes-256-cbc -k "${doc_build_secret:?}" -in .ci/koreader_doc.enc -out ~/.ssh/koreader_doc -d
|
||||
chmod 600 ~/.ssh/koreader_doc # make agent happy
|
||||
eval "$(ssh-agent)" > /dev/null
|
||||
ssh-add ~/.ssh/koreader_doc > /dev/null
|
||||
@@ -17,7 +18,7 @@ if [ ${TRAVIS_PULL_REQUEST} = false ] && [ ${TRAVIS_BRANCH} = 'master' ]; then
|
||||
|
||||
# push doc update
|
||||
pushd doc
|
||||
luajit $(which ldoc) . 2> /dev/null
|
||||
luajit "$(which ldoc)" . 2> /dev/null
|
||||
if [ ! -d html ]; then
|
||||
echo "Failed to generate documents..."
|
||||
exit 1
|
||||
@@ -38,5 +39,5 @@ fi
|
||||
|
||||
travis_retry make coverage
|
||||
pushd koreader-*/koreader
|
||||
luajit $(which luacov-coveralls)
|
||||
luajit "$(which luacov-coveralls)"
|
||||
popd
|
||||
|
||||
@@ -6,7 +6,7 @@ if [ "$CXX" = "g++" ];
|
||||
fi
|
||||
# in case anything ignores the environment variables, override through PATH
|
||||
mkdir bin
|
||||
ln -s $(which gcc-4.8) bin/cc
|
||||
ln -s $(which gcc-4.8) bin/gcc
|
||||
ln -s $(which c++-4.8) bin/c++
|
||||
ln -s $(which g++-4.8) bin/g++
|
||||
ln -s "$(which gcc-4.8)" bin/cc
|
||||
ln -s "$(which gcc-4.8)" bin/gcc
|
||||
ln -s "$(which c++-4.8)" bin/c++
|
||||
ln -s "$(which g++-4.8)" bin/g++
|
||||
|
||||
@@ -1,9 +1,13 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -e
|
||||
set -o pipefail
|
||||
|
||||
ANSI_RED="\033[31;1m"
|
||||
# shellcheck disable=SC2034
|
||||
ANSI_GREEN="\033[32;1m"
|
||||
ANSI_RESET="\033[0m"
|
||||
# shellcheck disable=SC2034
|
||||
ANSI_CLEAR="\033[0K"
|
||||
|
||||
travis_retry() {
|
||||
@@ -13,17 +17,17 @@ travis_retry() {
|
||||
|
||||
while [ $count -le 3 ]; do
|
||||
[ $result -ne 0 ] && {
|
||||
echo -e "\n${ANSI_RED}The command \"$@\" failed. Retrying, $count of 3.${ANSI_RESET}\n" >&2
|
||||
echo -e "\n${ANSI_RED}The command \"$*\" failed. Retrying, $count of 3.${ANSI_RESET}\n" >&2
|
||||
}
|
||||
"$@"
|
||||
result=$?
|
||||
[ $result -eq 0 ] && break
|
||||
count=$(($count + 1))
|
||||
count=$((count + 1))
|
||||
sleep 1
|
||||
done
|
||||
|
||||
[ $count -gt 3 ] && {
|
||||
echo -e "\n${ANSI_RED}The command \"$@\" failed 3 times.${ANSI_RESET}\n" >&2
|
||||
echo -e "\n${ANSI_RED}The command \"$*\" failed 3 times.${ANSI_RESET}\n" >&2
|
||||
}
|
||||
|
||||
set -e
|
||||
@@ -38,19 +42,19 @@ retry_cmd() {
|
||||
retry_cnt=$1
|
||||
shift 1
|
||||
|
||||
while [ $count -le ${retry_cnt} ]; do
|
||||
while [ $count -le "${retry_cnt}" ]; do
|
||||
[ $result -ne 0 ] && {
|
||||
echo -e "\n${ANSI_RED}The command \"$@\" failed. Retrying, $count of ${retry_cnt}${ANSI_RESET}\n" >&2
|
||||
echo -e "\n${ANSI_RED}The command \"$*\" failed. Retrying, $count of ${retry_cnt}${ANSI_RESET}\n" >&2
|
||||
}
|
||||
"$@"
|
||||
result=$?
|
||||
[ $result -eq 0 ] && break
|
||||
count=$(($count + 1))
|
||||
count=$((count + 1))
|
||||
sleep 1
|
||||
done
|
||||
|
||||
[ $count -gt ${retry_cnt} ] && {
|
||||
echo -e "\n${ANSI_RED}The command \"$@\" failed ${retry_cnt} times.${ANSI_RESET}\n" >&2
|
||||
[ $count -gt "${retry_cnt}" ] && {
|
||||
echo -e "\n${ANSI_RED}The command \"$*\" failed ${retry_cnt} times.${ANSI_RESET}\n" >&2
|
||||
}
|
||||
|
||||
set -e
|
||||
@@ -59,7 +63,7 @@ retry_cmd() {
|
||||
|
||||
export PATH=$PWD/bin:$PATH
|
||||
export PATH=$PATH:${TRAVIS_BUILD_DIR}/install/bin
|
||||
if [ -f ${TRAVIS_BUILD_DIR}/install/bin/luarocks ]; then
|
||||
if [ -f "${TRAVIS_BUILD_DIR}/install/bin/luarocks" ]; then
|
||||
# add local rocks to $PATH
|
||||
eval $(luarocks path --bin)
|
||||
eval "$(luarocks path --bin)"
|
||||
fi
|
||||
|
||||
@@ -1,19 +1,22 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
CI_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
# shellcheck source=/dev/null
|
||||
source "${CI_DIR}/common.sh"
|
||||
|
||||
# install our own updated luarocks
|
||||
git clone https://github.com/torch/luajit-rocks.git
|
||||
pushd luajit-rocks
|
||||
git checkout 6529891
|
||||
cmake . -DWITH_LUAJIT21=ON -DCMAKE_INSTALL_PREFIX=${TRAVIS_BUILD_DIR}/install
|
||||
make install
|
||||
popd
|
||||
if [ ! -f "${TRAVIS_BUILD_DIR}/install/bin/luarocks" ]; then
|
||||
git clone https://github.com/torch/luajit-rocks.git
|
||||
pushd luajit-rocks
|
||||
git checkout 6529891
|
||||
cmake . -DWITH_LUAJIT21=ON -DCMAKE_INSTALL_PREFIX="${TRAVIS_BUILD_DIR}/install"
|
||||
make install
|
||||
popd
|
||||
fi
|
||||
|
||||
mkdir $HOME/.luarocks
|
||||
cp ${TRAVIS_BUILD_DIR}/install/etc/luarocks/config.lua $HOME/.luarocks/config.lua
|
||||
echo "wrap_bin_scripts = false" >> $HOME/.luarocks/config.lua
|
||||
mkdir "${HOME}/.luarocks"
|
||||
cp "${TRAVIS_BUILD_DIR}/install/etc/luarocks/config.lua" "$HOME/.luarocks/config.lua"
|
||||
echo "wrap_bin_scripts = false" >> "$HOME/.luarocks/config.lua"
|
||||
travis_retry luarocks --local install luafilesystem
|
||||
# for verbose_print module
|
||||
travis_retry luarocks --local install ansicolors
|
||||
@@ -25,3 +28,18 @@ travis_retry luarocks --local install luasec OPENSSL_LIBDIR=/usr/lib/x86_64-linu
|
||||
travis_retry luarocks --local install luacov-coveralls --server=http://rocks.moonscript.org/dev
|
||||
travis_retry luarocks --local install luacheck
|
||||
travis_retry luarocks --local install lanes # for parallel luacheck
|
||||
|
||||
#install our own updated shellcheck
|
||||
SHELLCHECK_URL="https://s3.amazonaws.com/travis-blue-public/binaries/ubuntu/14.04/x86_64/shellcheck-0.4.5.tar.bz2"
|
||||
if ! command -v shellcheck ; then
|
||||
curl -sSL "${SHELLCHECK_URL}" | tar --exclude 'SHA256SUMS' --strip-components=1 -C "${HOME}/bin" -xjf -;
|
||||
chmod +x "${HOME}/bin/shellcheck"
|
||||
shellcheck --version
|
||||
fi
|
||||
|
||||
# install shfmt
|
||||
SHFMT_URL="https://github.com/mvdan/sh/releases/download/v1.2.0/shfmt_v1.2.0_linux_amd64"
|
||||
if ! command -v shfmt ; then
|
||||
curl -sSL "${SHFMT_URL}" -o "${HOME}/bin/shfmt"
|
||||
chmod +x "${HOME}/bin/shfmt"
|
||||
fi
|
||||
|
||||
@@ -1,9 +1,12 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
CI_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
# shellcheck source=/dev/null
|
||||
source "${CI_DIR}/common.sh"
|
||||
|
||||
travis_retry make fetchthirdparty
|
||||
find . -type f -name '*.sh' -not -path "./base/*" -not -path "./luajit-rocks/*" -print0 | xargs --null shellcheck
|
||||
find . -type f -name '*.sh' -not -path "./base/*" -not -path "./luajit-rocks/*" -print0 | xargs shfmt -i 0 -w
|
||||
make all
|
||||
make testfront
|
||||
luajit $(which luacheck) --no-color -q {reader,setupkoenv,datastorage}.lua frontend plugins
|
||||
luajit "$(which luacheck)" --no-color -q {reader,setupkoenv,datastorage}.lua frontend plugins
|
||||
|
||||
10
.travis.yml
10
.travis.yml
@@ -8,12 +8,18 @@ compiler:
|
||||
- gcc
|
||||
|
||||
env:
|
||||
- EMULATE_READER=1
|
||||
global:
|
||||
- "PATH=${HOME}/bin:${PATH}"
|
||||
matrix:
|
||||
- EMULATE_READER=1
|
||||
|
||||
cache:
|
||||
apt: true
|
||||
directories:
|
||||
- $HOME/.ccache
|
||||
- "${HOME}/bin"
|
||||
# compiled luarocks binaries
|
||||
- "${HOME}/build/koreader/koreader/install"
|
||||
- "${HOME}/.ccache"
|
||||
|
||||
addons:
|
||||
apt:
|
||||
|
||||
5
kodev
5
kodev
@@ -12,7 +12,10 @@ function assert_ret_zero {
|
||||
}
|
||||
|
||||
function check_submodules {
|
||||
[ -n "$(git submodule status | grep -E '^\-')" ] && kodev-fetch-thirdparty
|
||||
if git submodule status | grep -qE '^\-'
|
||||
then
|
||||
kodev-fetch-thirdparty
|
||||
fi
|
||||
}
|
||||
|
||||
function setup_env {
|
||||
|
||||
Submodule platform/android/luajit-launcher updated: f304bf8659...3bdf92c127
@@ -9,7 +9,8 @@ KOREADER_DIR="/mnt/us/koreader"
|
||||
|
||||
# Load our helper functions...
|
||||
if [ -f "${KOREADER_DIR}/libkohelper.sh" ] ; then
|
||||
source "${KOREADER_DIR}/libkohelper.sh"
|
||||
# shellcheck source=/dev/null
|
||||
. "${KOREADER_DIR}/libkohelper.sh"
|
||||
else
|
||||
echo "Can't source helper functions, aborting!"
|
||||
exit 1
|
||||
@@ -19,9 +20,9 @@ fi
|
||||
logmsg()
|
||||
{
|
||||
# Use the right tools for the platform
|
||||
if [ "${INIT_TYPE}" == "sysv" ] ; then
|
||||
if [ "${INIT_TYPE}" = "sysv" ] ; then
|
||||
msg "koreader: ${1}" "I"
|
||||
elif [ "${INIT_TYPE}" == "upstart" ] ; then
|
||||
elif [ "${INIT_TYPE}" = "upstart" ] ; then
|
||||
f_log I koreader kual "" "${1}"
|
||||
fi
|
||||
|
||||
@@ -35,7 +36,7 @@ logmsg()
|
||||
update_koreader()
|
||||
{
|
||||
# Check if we were called by install_koreader...
|
||||
if [ "${1}" == "clean" ] ; then
|
||||
if [ "${1}" = "clean" ] ; then
|
||||
do_clean_install="true"
|
||||
else
|
||||
do_clean_install="false"
|
||||
@@ -56,19 +57,19 @@ update_koreader()
|
||||
fi
|
||||
done
|
||||
|
||||
if [ "${found_koreader_package}" == "false" ] ; then
|
||||
if [ "${found_koreader_package}" = "false" ] ; then
|
||||
# Go away
|
||||
logmsg "No KOReader package found"
|
||||
else
|
||||
# Do we want to do a clean install?
|
||||
if [ "${do_clean_install}" == "true" ] ; then
|
||||
if [ "${do_clean_install}" = "true" ] ; then
|
||||
logmsg "Removing current KOReader directory . . ."
|
||||
rm -rf /mnt/us/koreader
|
||||
logmsg "Uninstall finished."
|
||||
fi
|
||||
|
||||
# Get the version of the package...
|
||||
if [ "${koreader_pkg_type}" == "tgz" ] ; then
|
||||
if [ "${koreader_pkg_type}" = "tgz" ] ; then
|
||||
koreader_pkg_ver="${found_koreader_package%.*.*}"
|
||||
else
|
||||
koreader_pkg_ver="${found_koreader_package%.*}"
|
||||
@@ -76,12 +77,14 @@ update_koreader()
|
||||
koreader_pkg_ver="${koreader_pkg_ver#*-v}"
|
||||
# Install it!
|
||||
logmsg "Updating to KOReader ${koreader_pkg_ver} . . ."
|
||||
if [ "${koreader_pkg_type}" == "tgz" ] ; then
|
||||
if [ "${koreader_pkg_type}" = "tgz" ] ; then
|
||||
tar -C "/mnt/us" -xzf "${found_koreader_package}"
|
||||
fail=$?
|
||||
else
|
||||
unzip -q -o "${found_koreader_package}" -d "/mnt/us"
|
||||
fail=$?
|
||||
fi
|
||||
if [ $? -eq 0 ] ; then
|
||||
if [ $fail -eq 0 ] ; then
|
||||
logmsg "Update to v${koreader_pkg_ver} successful :)"
|
||||
# Cleanup behind us...
|
||||
rm -f "${found_koreader_package}"
|
||||
@@ -115,11 +118,12 @@ set_cre_prop()
|
||||
# Check that the config exists...
|
||||
if [ -f "${cre_config}" ] ; then
|
||||
# dos2unix
|
||||
# shellcheck disable=SC2039
|
||||
sed -e "s/$(echo -ne '\r')$//g" -i "${cre_config}"
|
||||
|
||||
# And finally set the prop
|
||||
sed -re "s/^(${cre_prop_key})(=)(.*?)$/\1\2${cre_prop_value}/" -i "${cre_config}"
|
||||
if [ $? -eq 0 ] ; then
|
||||
if sed -re "s/^(${cre_prop_key})(=)(.*?)$/\1\2${cre_prop_value}/" -i "${cre_config}"
|
||||
then
|
||||
logmsg "Set ${cre_prop_key} to ${cre_prop_value}"
|
||||
else
|
||||
logmsg "Failed to set ${cre_prop_key}"
|
||||
|
||||
@@ -11,7 +11,8 @@ KOREADER_DIR="/mnt/us/koreader"
|
||||
|
||||
# Load our helper functions...
|
||||
if [ -f "${KOREADER_DIR}/libkohelper.sh" ] ; then
|
||||
source "${KOREADER_DIR}/libkohelper.sh"
|
||||
# shellcheck source=/dev/null
|
||||
. "${KOREADER_DIR}/libkohelper.sh"
|
||||
else
|
||||
echo "Can't source helper functions, aborting!"
|
||||
exit 1
|
||||
@@ -21,9 +22,9 @@ fi
|
||||
logmsg()
|
||||
{
|
||||
# Use the right tools for the platform
|
||||
if [ "${INIT_TYPE}" == "sysv" ] ; then
|
||||
if [ "${INIT_TYPE}" = "sysv" ] ; then
|
||||
msg "koreader: ${1}" "I"
|
||||
elif [ "${INIT_TYPE}" == "upstart" ] ; then
|
||||
elif [ "${INIT_TYPE}" = "upstart" ] ; then
|
||||
f_log I koreader wrapper "" "${1}"
|
||||
fi
|
||||
|
||||
@@ -32,7 +33,7 @@ logmsg()
|
||||
}
|
||||
|
||||
# Go away if we're on FW 5.0, it's not supported
|
||||
if [ "${INIT_TYPE}" == "upstart" ] ; then
|
||||
if [ "${INIT_TYPE}" = "upstart" ] ; then
|
||||
if grep '^Kindle 5\.0' /etc/prettyversion.txt > /dev/null 2>&1 ; then
|
||||
logmsg "FW 5.0 is not supported. Update to 5.1!"
|
||||
# And... scene!
|
||||
@@ -50,11 +51,11 @@ PASSCODE_DISABLED="no"
|
||||
FROM_KUAL="no"
|
||||
|
||||
# By default, don't stop the framework.
|
||||
if [ "$1" == "--framework_stop" ] ; then
|
||||
if [ "$1" = "--framework_stop" ] ; then
|
||||
shift 1
|
||||
STOP_FRAMEWORK="yes"
|
||||
NO_SLEEP="no"
|
||||
elif [ "$1" == "--asap" ] ; then
|
||||
elif [ "$1" = "--asap" ] ; then
|
||||
# Start as soon as possible, without sleeping to workaround UI quirks
|
||||
shift 1
|
||||
NO_SLEEP="yes"
|
||||
@@ -67,9 +68,9 @@ else
|
||||
fi
|
||||
|
||||
# Detect if we were started by KUAL by checking our nice value...
|
||||
if [ "$(nice)" == "5" ] ; then
|
||||
if [ "$(nice)" = "5" ] ; then
|
||||
FROM_KUAL="yes"
|
||||
if [ "${NO_SLEEP}" == "no" ] ; then
|
||||
if [ "${NO_SLEEP}" = "no" ] ; then
|
||||
# Yield a bit to let stuff stop properly...
|
||||
logmsg "Hush now . . ."
|
||||
# NOTE: This may or may not be terribly useful...
|
||||
@@ -82,7 +83,7 @@ if [ "$(nice)" == "5" ] ; then
|
||||
fi
|
||||
|
||||
# we're always starting from our working directory
|
||||
cd "${KOREADER_DIR}"
|
||||
cd "${KOREADER_DIR}" || exit
|
||||
|
||||
# Handle pending OTA update
|
||||
NEWUPDATE="${KOREADER_DIR}/ota/koreader.updated.tar"
|
||||
@@ -94,14 +95,17 @@ if [ -f "${NEWUPDATE}" ] ; then
|
||||
if [ -x "${GNUTAR_BIN}" ] ; then
|
||||
# Let our checkpoint script handle the detailed visual feedback...
|
||||
eips_print_bottom_centered "Updating koreader" 1
|
||||
# shellcheck disable=SC2016
|
||||
${GNUTAR_BIN} -C "/mnt/us" --no-same-owner --no-same-permissions --checkpoint=200 --checkpoint-action=exec='./kotar_cpoint $TAR_CHECKPOINT' -xf "${NEWUPDATE}"
|
||||
fail=$?
|
||||
else
|
||||
# Fall back to busybox tar
|
||||
eips_print_bottom_centered "Updating koreader . . ." 1
|
||||
tar -C "/mnt/us" -xf "${NEWUPDATE}"
|
||||
fail=$?
|
||||
fi
|
||||
# Cleanup behind us...
|
||||
if [ $? -eq 0 ] ; then
|
||||
if [ $fail -eq 0 ] ; then
|
||||
mv "${NEWUPDATE}" "${INSTALLED}"
|
||||
logmsg "Update sucessful :)"
|
||||
eips_print_bottom_centered "Update successful :)" 1
|
||||
@@ -125,7 +129,7 @@ export STARDICT_DATA_DIR="data/dict"
|
||||
export EXT_FONT_DIR="/mnt/us/fonts"
|
||||
|
||||
# Only setup IPTables on evices where it makes sense to (FW 5.x & K4)
|
||||
if [ "${INIT_TYPE}" == "upstart" -o "$(uname -r)" == "2.6.31-rt11-lab126" ] ; then
|
||||
if [ "${INIT_TYPE}" = "upstart" ] || [ "$(uname -r)" = "2.6.31-rt11-lab126" ] ; then
|
||||
logmsg "Setting up IPTables rules . . ."
|
||||
# accept input ports for zsync plugin
|
||||
iptables -A INPUT -i wlan0 -p udp --dport 5670 -j ACCEPT
|
||||
@@ -176,36 +180,38 @@ if [ -f "/var/local/system/userpasswdenabled" ] ; then
|
||||
fi
|
||||
|
||||
# check if we are supposed to shut down the Amazon framework
|
||||
if [ "${STOP_FRAMEWORK}" == "yes" ] ; then
|
||||
if [ "${STOP_FRAMEWORK}" = "yes" ] ; then
|
||||
logmsg "Stopping the framework . . ."
|
||||
# Upstart or SysV?
|
||||
if [ "${INIT_TYPE}" == "sysv" ] ; then
|
||||
if [ "${INIT_TYPE}" = "sysv" ] ; then
|
||||
/etc/init.d/framework stop
|
||||
else
|
||||
# The framework job sends a SIGTERM on stop, trap it so we don't get killed if we were launched by KUAL
|
||||
trap "" SIGTERM
|
||||
trap "" TERM
|
||||
stop lab126_gui
|
||||
# NOTE: Let the framework teardown finish, so we don't start before the black screen...
|
||||
usleep 1250000
|
||||
# And remove the trap like a ninja now!
|
||||
trap - SIGTERM
|
||||
trap - TERM
|
||||
fi
|
||||
fi
|
||||
|
||||
# check if kpvbooklet was launched for more than once, if not we will disable pillow
|
||||
# there's no pillow if we stopped the framework, and it's only there on systems with upstart anyway
|
||||
if [ "${STOP_FRAMEWORK}" == "no" -a "${INIT_TYPE}" == "upstart" ] ; then
|
||||
if [ "${STOP_FRAMEWORK}" = "no" ] && [ "${INIT_TYPE}" = "upstart" ] ; then
|
||||
count=$(lipc-get-prop -eiq com.github.koreader.kpvbooklet.timer count)
|
||||
if [ "$count" == "" -o "$count" == "0" ] ; then
|
||||
if [ "$count" = "" ] || [ "$count" = "0" ] ; then
|
||||
# NOTE: Dump the fb so we can restore something useful on exit...
|
||||
cat /dev/fb0 > /var/tmp/koreader-fb.dump
|
||||
# NOTE: We want to disable the status bar (at the very least). Unfortunately, the soft hide/unhide method doesn't work properly anymore since FW 5.6.5...
|
||||
# shellcheck disable=SC2046
|
||||
if [ "$(printf "%.3s" $(grep '^Kindle 5' /etc/prettyversion.txt 2>&1 | sed -n -r 's/^(Kindle)([[:blank:]]*)([[:digit:].]*)(.*?)$/\3/p' | tr -d '.'))" -ge "565" ] ; then
|
||||
PILLOW_HARD_DISABLED="yes"
|
||||
# FIXME: So we resort to killing pillow completely on FW >= 5.6.5...
|
||||
logmsg "Disabling pillow . . ."
|
||||
lipc-set-prop com.lab126.pillow disableEnablePillow disable
|
||||
# NOTE: And, oh, joy, on FW >= 5.7.2, this is not enough to prevent the clock from refreshing, so, take the bull by the horns, and SIGSTOP the WM while we run...
|
||||
# shellcheck disable=SC2046
|
||||
if [ "$(printf "%.3s" $(grep '^Kindle 5' /etc/prettyversion.txt 2>&1 | sed -n -r 's/^(Kindle)([[:blank:]]*)([[:digit:].]*)(.*?)$/\3/p' | tr -d '.'))" -ge "572" ] ; then
|
||||
logmsg "Stopping awesome . . ."
|
||||
killall -stop awesome
|
||||
@@ -218,12 +224,12 @@ if [ "${STOP_FRAMEWORK}" == "no" -a "${INIT_TYPE}" == "upstart" ] ; then
|
||||
PILLOW_SOFT_DISABLED="yes"
|
||||
fi
|
||||
# NOTE: We don't need to sleep at all if we've already SIGSTOPped awesome ;)
|
||||
if [ "${NO_SLEEP}" == "no" -a "${AWESOME_STOPPED}" == "no" ] ; then
|
||||
if [ "${NO_SLEEP}" = "no" ] && [ "${AWESOME_STOPPED}" = "no" ] ; then
|
||||
# NOTE: Leave the framework time to refresh the screen, so we don't start before it has finished redrawing after collapsing the title bar
|
||||
usleep 250000
|
||||
# NOTE: If we were started from KUAL, we risk getting a list item to popup right over us, so, wait some more...
|
||||
# The culprit appears to be a I WindowManager:flashTimeoutExpired:window=Root 0 0 600x30
|
||||
if [ "${FROM_KUAL}" == "yes" ] ; then
|
||||
if [ "${FROM_KUAL}" = "yes" ] ; then
|
||||
logmsg "Playing possum to wait for the window manager . . ."
|
||||
usleep 2500000
|
||||
fi
|
||||
@@ -232,7 +238,7 @@ if [ "${STOP_FRAMEWORK}" == "no" -a "${INIT_TYPE}" == "upstart" ] ; then
|
||||
fi
|
||||
|
||||
# stop cvm (sysv & framework up only)
|
||||
if [ "${STOP_FRAMEWORK}" == "no" -a "${INIT_TYPE}" == "sysv" ] ; then
|
||||
if [ "${STOP_FRAMEWORK}" = "no" ] && [ "${INIT_TYPE}" = "sysv" ] ; then
|
||||
logmsg "Stopping cvm . . ."
|
||||
killall -stop cvm
|
||||
fi
|
||||
@@ -240,13 +246,15 @@ fi
|
||||
# finally call reader
|
||||
logmsg "Starting KOReader . . ."
|
||||
# That's not necessary when using KPVBooklet ;).
|
||||
if [ "${FROM_KUAL}" == "yes" ] ; then
|
||||
if [ "${FROM_KUAL}" = "yes" ] ; then
|
||||
eips_print_bottom_centered "Starting KOReader . . ." 1
|
||||
fi
|
||||
|
||||
# we keep maximum 500K worth of crash log
|
||||
cat crash.log 2> /dev/null | tail -c 500000 > crash.log.new
|
||||
mv -f crash.log.new crash.log
|
||||
if [ -e crash.log ]; then
|
||||
tail -c 500000 crash.log > crash.log.new
|
||||
mv -f crash.log.new crash.log
|
||||
fi
|
||||
./reader.lua "$@" >> crash.log 2>&1
|
||||
|
||||
# clean up our own process tree in case the reader crashed (if needed, to avoid flooding KUAL's log)
|
||||
@@ -280,7 +288,7 @@ if grep ${KOREADER_DIR}/fonts/linkfonts /proc/mounts > /dev/null 2>&1 ; then
|
||||
fi
|
||||
|
||||
# Resume cvm (only if we stopped it)
|
||||
if [ "${STOP_FRAMEWORK}" == "no" -a "${INIT_TYPE}" == "sysv" ] ; then
|
||||
if [ "${STOP_FRAMEWORK}" = "no" ] && [ "${INIT_TYPE}" = "sysv" ] ; then
|
||||
logmsg "Resuming cvm . . ."
|
||||
killall -cont cvm
|
||||
# We need to handle the screen refresh ourselves, frontend/device/kindle/device.lua's Kindle3.exit is called before we resume cvm ;).
|
||||
@@ -289,9 +297,9 @@ if [ "${STOP_FRAMEWORK}" == "no" -a "${INIT_TYPE}" == "sysv" ] ; then
|
||||
fi
|
||||
|
||||
# Restart framework (if need be)
|
||||
if [ "${STOP_FRAMEWORK}" == "yes" ] ; then
|
||||
if [ "${STOP_FRAMEWORK}" = "yes" ] ; then
|
||||
logmsg "Restarting framework . . ."
|
||||
if [ "${INIT_TYPE}" == "sysv" ] ; then
|
||||
if [ "${INIT_TYPE}" = "sysv" ] ; then
|
||||
cd / && env -u LD_LIBRARY_PATH /etc/init.d/framework start
|
||||
else
|
||||
cd / && env -u LD_LIBRARY_PATH start lab126_gui
|
||||
@@ -299,13 +307,13 @@ if [ "${STOP_FRAMEWORK}" == "yes" ] ; then
|
||||
fi
|
||||
|
||||
# Display chrome bar if need be (upstart & framework up only)
|
||||
if [ "${STOP_FRAMEWORK}" == "no" -a "${INIT_TYPE}" == "upstart" ] ; then
|
||||
if [ "${STOP_FRAMEWORK}" = "no" ] && [ "${INIT_TYPE}" = "upstart" ] ; then
|
||||
# Depending on the FW version, we may have handled things in a few different manners...
|
||||
if [ "${AWESOME_STOPPED}" == "yes" ] ; then
|
||||
if [ "${AWESOME_STOPPED}" = "yes" ] ; then
|
||||
logmsg "Resuming awesome . . ."
|
||||
killall -cont awesome
|
||||
fi
|
||||
if [ "${PILLOW_HARD_DISABLED}" == "yes" ] ; then
|
||||
if [ "${PILLOW_HARD_DISABLED}" = "yes" ] ; then
|
||||
logmsg "Enabling pillow . . ."
|
||||
lipc-set-prop com.lab126.pillow disableEnablePillow enable
|
||||
# NOTE: Try to leave the user with a slightly more useful FB content than our own last screen...
|
||||
@@ -315,7 +323,7 @@ if [ "${STOP_FRAMEWORK}" == "no" -a "${INIT_TYPE}" == "upstart" ] ; then
|
||||
# NOTE: In case we ever need an extra full flash refresh...
|
||||
#eips -s w=${SCREEN_X_RES},h=${SCREEN_Y_RES} -f
|
||||
fi
|
||||
if [ "${PILLOW_SOFT_DISABLED}" == "yes" ] ; then
|
||||
if [ "${PILLOW_SOFT_DISABLED}" = "yes" ] ; then
|
||||
logmsg "Restoring the status bar . . ."
|
||||
# NOTE: Try to leave the user with a slightly more useful FB content than our own last screen...
|
||||
cat /var/tmp/koreader-fb.dump > /dev/fb0
|
||||
@@ -325,7 +333,7 @@ if [ "${STOP_FRAMEWORK}" == "no" -a "${INIT_TYPE}" == "upstart" ] ; then
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ "${INIT_TYPE}" == "upstart" -o "$(uname -r)" == "2.6.31-rt11-lab126" ] ; then
|
||||
if [ "${INIT_TYPE}" = "upstart" ] || [ "$(uname -r)" = "2.6.31-rt11-lab126" ] ; then
|
||||
logmsg "Restoring IPTables rules . . ."
|
||||
# restore firewall rules
|
||||
iptables -D INPUT -i wlan0 -p udp --dport 8134 -j ACCEPT
|
||||
@@ -333,8 +341,7 @@ if [ "${INIT_TYPE}" == "upstart" -o "$(uname -r)" == "2.6.31-rt11-lab126" ] ; th
|
||||
iptables -D INPUT -i wlan0 -p tcp --dport 49152:49162 -j ACCEPT
|
||||
fi
|
||||
|
||||
if [ "${PASSCODE_DISABLED}" == "yes" ] ; then
|
||||
if [ "${PASSCODE_DISABLED}" = "yes" ] ; then
|
||||
logmsg "Restoring system passcode . . ."
|
||||
touch "/var/local/system/userpasswdenabled"
|
||||
fi
|
||||
|
||||
|
||||
@@ -3,13 +3,15 @@
|
||||
## A bit of helper functions...
|
||||
# Check which type of init system we're running on
|
||||
if [ -d /etc/upstart ] ; then
|
||||
INIT_TYPE="upstart"
|
||||
export INIT_TYPE="upstart"
|
||||
# We'll need that for logging
|
||||
[ -f /etc/upstart/functions ] && source /etc/upstart/functions
|
||||
# shellcheck disable=SC1091
|
||||
[ -f /etc/upstart/functions ] && . /etc/upstart/functions
|
||||
else
|
||||
INIT_TYPE="sysv"
|
||||
export INIT_TYPE="sysv"
|
||||
# We'll need that for logging
|
||||
[ -f /etc/rc.d/functions ] && source /etc/rc.d/functions
|
||||
# shellcheck disable=SC1091
|
||||
[ -f /etc/rc.d/functions ] && . /etc/rc.d/functions
|
||||
fi
|
||||
|
||||
# We need to get the proper constants for our model...
|
||||
@@ -86,8 +88,8 @@ case "${kmodel}" in
|
||||
;;
|
||||
esac
|
||||
# And now we can do the maths ;)
|
||||
EIPS_MAXCHARS="$((${SCREEN_X_RES} / ${EIPS_X_RES}))"
|
||||
EIPS_MAXLINES="$((${SCREEN_Y_RES} / ${EIPS_Y_RES}))"
|
||||
EIPS_MAXCHARS="$((SCREEN_X_RES / EIPS_X_RES))"
|
||||
EIPS_MAXLINES="$((SCREEN_Y_RES / EIPS_Y_RES))"
|
||||
|
||||
# Adapted from libkh[5]
|
||||
eips_print_bottom_centered()
|
||||
@@ -106,10 +108,10 @@ eips_print_bottom_centered()
|
||||
|
||||
# Add the right amount of left & right padding, since we're centered, and eips doesn't trigger a full refresh,
|
||||
# so we'll have to padd our string with blank spaces to make sure two consecutive messages don't run into each other
|
||||
kh_padlen="$(((${EIPS_MAXCHARS} - ${kh_eips_strlen}) / 2))"
|
||||
kh_padlen="$(((EIPS_MAXCHARS - kh_eips_strlen) / 2))"
|
||||
|
||||
# Left padding...
|
||||
while [ ${#kh_eips_string} -lt $((${kh_eips_strlen} + ${kh_padlen})) ] ; do
|
||||
while [ ${#kh_eips_string} -lt $((kh_eips_strlen + kh_padlen)) ] ; do
|
||||
kh_eips_string=" ${kh_eips_string}"
|
||||
done
|
||||
|
||||
@@ -126,5 +128,5 @@ eips_print_bottom_centered()
|
||||
fi
|
||||
|
||||
# And finally, show our formatted message centered on the bottom of the screen (NOTE: Redirect to /dev/null to kill unavailable character & pixel not in range warning messages)
|
||||
eips 0 $((${EIPS_MAXLINES} - 2 - ${kh_eips_y_shift_up})) "${kh_eips_string}" >/dev/null
|
||||
eips 0 $((EIPS_MAXLINES - 2 - kh_eips_y_shift_up)) "${kh_eips_string}" >/dev/null
|
||||
}
|
||||
|
||||
@@ -9,9 +9,9 @@ ifconfig eth0 down
|
||||
|
||||
# Some sleep in between may avoid system getting hung
|
||||
# (we test if a module is actually loaded to avoid unneeded sleeps)
|
||||
if lsmod | grep -q $WIFI_MODULE ; then
|
||||
if lsmod | grep -q "${WIFI_MODULE}" ; then
|
||||
usleep 200000
|
||||
rmmod -r $WIFI_MODULE
|
||||
rmmod -r "${WIFI_MODULE}"
|
||||
fi
|
||||
if lsmod | grep -q sdio_wifi_pwr ; then
|
||||
usleep 200000
|
||||
|
||||
@@ -2,9 +2,9 @@
|
||||
|
||||
# Load wifi modules and enable wifi.
|
||||
|
||||
lsmod | grep -q sdio_wifi_pwr || insmod /drivers/$PLATFORM/wifi/sdio_wifi_pwr.ko
|
||||
lsmod | grep -q sdio_wifi_pwr || insmod "/drivers/${PLATFORM}/wifi/sdio_wifi_pwr.ko"
|
||||
# WIFI_MODULE_PATH = /drivers/$PLATFORM/wifi/$WIFI_MODULE.ko
|
||||
lsmod | grep -q $WIFI_MODULE || insmod $WIFI_MODULE_PATH
|
||||
lsmod | grep -q "${WIFI_MODULE}" || insmod "${WIFI_MODULE_PATH}"
|
||||
sleep 1
|
||||
|
||||
ifconfig eth0 up
|
||||
|
||||
@@ -1 +1,2 @@
|
||||
${root}/.kobo/fmon/fmon "${root}/koreader.png" "${root}/.kobo/koreader/koreader.sh" &
|
||||
#!/bin/sh
|
||||
"${root:?}/.kobo/fmon/fmon" "${root}/koreader.png" "${root}/.kobo/koreader/koreader.sh" &
|
||||
|
||||
@@ -13,7 +13,7 @@ if [ -f "${NEWUPDATE}" ] ; then
|
||||
fi
|
||||
|
||||
# we're always starting from our working directory
|
||||
cd "${KOREADER_DIR}"
|
||||
cd "${KOREADER_DIR}" || exit
|
||||
|
||||
# load our own shared libraries if possible
|
||||
export LD_LIBRARY_PATH="${KOREADER_DIR}/libs:${LD_LIBRARY_PATH}"
|
||||
@@ -47,12 +47,13 @@ if [ "${FROM_NICKEL}" = "true" ] ; then
|
||||
|
||||
if [ "${FROM_KFMON}" = "true" ] ; then
|
||||
# Siphon nickel's full environment, since KFMon inherits such a minimal one, and that apparently confuses the hell out of Nickel for some reason if we decide to restart it without a reboot...
|
||||
for env in $(xargs -n 1 -0 < /proc/$(pidof nickel)/environ) ; do
|
||||
export ${env}
|
||||
for env in $(xargs -n 1 -0 < "/proc/$(pidof nickel)/environ") ; do
|
||||
# shellcheck disable=SC2163
|
||||
export "${env}"
|
||||
done
|
||||
else
|
||||
# Siphon a few things from nickel's env...
|
||||
eval "$(xargs -n 1 -0 < /proc/$(pidof nickel)/environ | grep -e DBUS_SESSION_BUS_ADDRESS -e WIFI_MODULE -e PLATFORM -e WIFI_MODULE_PATH -e INTERFACE -e PRODUCT 2>/dev/null)"
|
||||
eval "$(xargs -n 1 -0 < "/proc/$(pidof nickel)/environ" | grep -e DBUS_SESSION_BUS_ADDRESS -e WIFI_MODULE -e PLATFORM -e WIFI_MODULE_PATH -e INTERFACE -e PRODUCT 2>/dev/null)"
|
||||
export DBUS_SESSION_BUS_ADDRESS WIFI_MODULE PLATFORM WIFI_MODULE_PATH INTERFACE PRODUCT
|
||||
fi
|
||||
|
||||
@@ -81,7 +82,6 @@ fi
|
||||
# check whether PLATFORM & PRODUCT have a value assigned by rcS
|
||||
if [ ! -n "${PRODUCT}" ] ; then
|
||||
PRODUCT="$(/bin/kobo_config.sh 2>/dev/null)"
|
||||
[ "${PRODUCT}" != "trilogy" ] && PREFIX="${PRODUCT}-"
|
||||
export PRODUCT
|
||||
fi
|
||||
|
||||
@@ -112,21 +112,35 @@ if awk '$4~/(^|,)ro($|,)/' /proc/mounts | grep ' /mnt/sd ' ; then
|
||||
fi
|
||||
|
||||
# we keep maximum 500K worth of crash log
|
||||
cat crash.log 2> /dev/null | tail -c 500000 > crash.log.new
|
||||
mv -f crash.log.new crash.log
|
||||
if [ -e crash.log ]; then
|
||||
tail -c 500000 crash.log > crash.log.new
|
||||
mv -f crash.log.new crash.log
|
||||
fi
|
||||
|
||||
# workaround 32-bit without KSM (KSM is indicated by ${ksmroot} being set)
|
||||
# shellcheck disable=2154
|
||||
if [ -z "${ksmroot+x:?}" ]; then
|
||||
# TODO: add support for 32bit framebuffer in koreader. This is a workaround
|
||||
# to run koreader in 16bpp. Useful since FW 4.0
|
||||
CUR_ROTATE="$(cat "/sys/class/graphics/fb0/rotate")"
|
||||
FB_BPP=$(cat /sys/class/graphics/fb0/bits_per_pixel)
|
||||
[ "$FB_BPP" -gt 16 ] && /usr/sbin/fbset -depth 16
|
||||
# fix rotation issues on Kobo Aura HD (dragon) and Kobo Aura H2O (dahlia)
|
||||
case "$PRODUCT" in "dragon" | "dahlia" ) cat /sys/class/graphics/fb0/rotate > /sys/class/graphics/fb0/rotate ;; esac
|
||||
[ "${FB_BPP}" -gt 16 ] && /usr/sbin/fbset -depth 16
|
||||
# this suffices on normal devices, but H2O is stupid and sets the opposite
|
||||
echo "${CUR_ROTATE}" > "/sys/class/graphics/fb0/rotate"
|
||||
# this therefore turns it around on H2O (and other potential idiots) and merely
|
||||
# innocently repeats on sane devices
|
||||
# shellcheck disable=SC2094
|
||||
cat "/sys/class/graphics/fb0/rotate" > "/sys/class/graphics/fb0/rotate"
|
||||
fi
|
||||
|
||||
./reader.lua "${args}" >> crash.log 2>&1
|
||||
RESULT=$?
|
||||
|
||||
# back to default depth in framebuffer.
|
||||
[ "$FB_BPP" -gt 16 ] && /usr/sbin/fbset -depth "$FB_BPP"
|
||||
# workaround 32-bit without KSM (KSM is indicated by s${ksmroot} being set)
|
||||
if [ -z "${ksmroot+x:?}" ]; then
|
||||
# back to default depth in framebuffer.
|
||||
[ "${FB_BPP}" -gt 16 ] && /usr/sbin/fbset -depth "${FB_BPP}"
|
||||
fi
|
||||
|
||||
if [ "${FROM_NICKEL}" = "true" ] ; then
|
||||
if [ "${FROM_KFMON}" != "true" ] ; then
|
||||
|
||||
@@ -88,6 +88,7 @@ fi
|
||||
|
||||
# Rotation weirdness, part II
|
||||
echo "${cur_rotate}" > "/sys/class/graphics/fb0/rotate"
|
||||
# shellcheck disable=SC2094
|
||||
cat "/sys/class/graphics/fb0/rotate" > "/sys/class/graphics/fb0/rotate"
|
||||
|
||||
# Handle sdcard
|
||||
|
||||
@@ -7,13 +7,13 @@ KOREADER_DIR="${0%/*}"
|
||||
# update to new version from OTA directory
|
||||
NEWUPDATE="${KOREADER_DIR}/ota/koreader.updated.tar"
|
||||
INSTALLED="${KOREADER_DIR}/ota/koreader.installed.tar"
|
||||
if [ -f $NEWUPDATE ]; then
|
||||
if [ -f "${NEWUPDATE}" ]; then
|
||||
# TODO: any graphic indication for the updating progress?
|
||||
cd .. && tar xf $NEWUPDATE && mv $NEWUPDATE $INSTALLED
|
||||
cd .. && tar xf "${NEWUPDATE}" && mv "${NEWUPDATE}" "${INSTALLED}"
|
||||
fi
|
||||
|
||||
# we're always starting from our working directory
|
||||
cd $KOREADER_DIR
|
||||
cd "${KOREADER_DIR}" || exit
|
||||
|
||||
# export load library path for some old firmware
|
||||
export LD_LIBRARY_PATH=${KOREADER_DIR}/libs:$LD_LIBRARY_PATH
|
||||
@@ -22,7 +22,7 @@ export LD_LIBRARY_PATH=${KOREADER_DIR}/libs:$LD_LIBRARY_PATH
|
||||
export TESSDATA_PREFIX="data"
|
||||
|
||||
# export external font directory
|
||||
export EXT_FONT_DIR="~/fonts"
|
||||
export EXT_FONT_DIR="${HOME}/fonts"
|
||||
|
||||
# set fullscreen mode
|
||||
export SDL_FULLSCREEN=1
|
||||
|
||||
Reference in New Issue
Block a user