diff --git a/.ci/after_success.sh b/.ci/after_success.sh index cb5337d6d..fc8b6105c 100755 --- a/.ci/after_success.sh +++ b/.ci/after_success.sh @@ -10,34 +10,36 @@ if [ "${TRAVIS_PULL_REQUEST}" = false ] && [ "${TRAVIS_BRANCH}" = 'master' ]; th 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 - chmod 600 ~/.ssh/koreader_doc # make agent happy - eval "$(ssh-agent)" > /dev/null - ssh-add ~/.ssh/koreader_doc > /dev/null + chmod 600 ~/.ssh/koreader_doc # make agent happy + eval "$(ssh-agent)" >/dev/null + ssh-add ~/.ssh/koreader_doc >/dev/null echo -e "\n${ANSI_GREEN}Check out koreader/doc for update." git clone git@github.com:koreader/doc.git koreader_doc # push doc update - pushd doc - luajit "$(which ldoc)" . 2> /dev/null + pushd doc && { + luajit "$(which ldoc)" . 2>/dev/null if [ ! -d html ]; then echo "Failed to generate documents..." exit 1 fi + } || exit popd cp -r doc/html/* koreader_doc/ - pushd koreader_doc - - git add -A - echo -e "\n${ANSI_GREEN}Pusing document update..." - git -c user.name="KOReader build bot" -c user.email="non-reply@koreader.rocks" \ - commit -a --amend -m 'Automated documentation build from travis-ci.' - git push -f --quiet origin gh-pages > /dev/null - echo -e "\n${ANSI_GREEN}Documentation update pushed." + pushd koreader_doc && { + git add -A + echo -e "\n${ANSI_GREEN}Pusing document update..." + git -c user.name="KOReader build bot" -c user.email="non-reply@koreader.rocks" \ + commit -a --amend -m 'Automated documentation build from travis-ci.' + git push -f --quiet origin gh-pages >/dev/null + echo -e "\n${ANSI_GREEN}Documentation update pushed." + } || exit popd travis_retry make coverage - pushd koreader-*/koreader + pushd koreader-*/koreader && { luajit "$(which luacov-coveralls)" + } || exit popd else echo -e "\n${ANSI_GREEN}Not on official master branch, skip documentation update and coverage." diff --git a/.ci/before_install.sh b/.ci/before_install.sh index c6ff03cd0..ff867e8a3 100755 --- a/.ci/before_install.sh +++ b/.ci/before_install.sh @@ -1,8 +1,8 @@ #!/usr/bin/env bash # don't do this for clang -if [ "$CXX" = "g++" ]; - then export CXX="g++-4.8" CC="gcc-4.8"; +if [ "$CXX" = "g++" ]; then + export CXX="g++-4.8" CC="gcc-4.8" fi # in case anything ignores the environment variables, override through PATH mkdir bin diff --git a/.ci/common.sh b/.ci/common.sh index d09ac2676..2fa297541 100644 --- a/.ci/common.sh +++ b/.ci/common.sh @@ -11,54 +11,54 @@ ANSI_RESET="\033[0m" ANSI_CLEAR="\033[0K" travis_retry() { - local result=0 - local count=1 - set +e + local result=0 + local count=1 + set +e - while [ $count -le 3 ]; do - [ $result -ne 0 ] && { - echo -e "\n${ANSI_RED}The command \"$*\" failed. Retrying, $count of 3.${ANSI_RESET}\n" >&2 - } - "$@" - result=$? - [ $result -eq 0 ] && break - count=$((count + 1)) - sleep 1 - done + while [ $count -le 3 ]; do + [ $result -ne 0 ] && { + echo -e "\n${ANSI_RED}The command \"$*\" failed. Retrying, $count of 3.${ANSI_RESET}\n" >&2 + } + "$@" + result=$? + [ $result -eq 0 ] && break + count=$((count + 1)) + sleep 1 + done - [ $count -gt 3 ] && { - echo -e "\n${ANSI_RED}The command \"$*\" failed 3 times.${ANSI_RESET}\n" >&2 - } + [ $count -gt 3 ] && { + echo -e "\n${ANSI_RED}The command \"$*\" failed 3 times.${ANSI_RESET}\n" >&2 + } - set -e - return $result + set -e + return $result } retry_cmd() { - local result=0 - local count=1 - set +e + local result=0 + local count=1 + set +e - retry_cnt=$1 - shift 1 + retry_cnt=$1 + shift 1 - 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 - } - "$@" - result=$? - [ $result -eq 0 ] && break - count=$((count + 1)) - sleep 1 - done + 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 + } + "$@" + result=$? + [ $result -eq 0 ] && break + 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 - return $result + set -e + return $result } export PATH=$PWD/bin:$PATH diff --git a/.ci/helper_luarocks.sh b/.ci/helper_luarocks.sh index 3dd9b3a32..c50221f5f 100755 --- a/.ci/helper_luarocks.sh +++ b/.ci/helper_luarocks.sh @@ -7,7 +7,7 @@ source "${CI_DIR}/common.sh" rm -rf "${HOME}/.luarocks" 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" +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 @@ -18,4 +18,4 @@ travis_retry luarocks --local install luacov travis_retry luarocks --local install luasec OPENSSL_LIBDIR=/usr/lib/x86_64-linux-gnu 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 +travis_retry luarocks --local install lanes # for parallel luacheck diff --git a/.ci/helper_shellchecks.sh b/.ci/helper_shellchecks.sh index 1f102951d..fe1b6592e 100755 --- a/.ci/helper_shellchecks.sh +++ b/.ci/helper_shellchecks.sh @@ -5,7 +5,7 @@ CI_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" source "${CI_DIR}/common.sh" # shellcheck disable=2016 -mapfile -t shellscript_locations < <( { git grep -lE '^#!(/usr)?/bin/(env )?(bash|sh)' && git submodule --quiet foreach '[ "$path" = "base" ] || git grep -lE "^#!(/usr)?/bin/(env )?(bash|sh)" | sed "s|^|$path/|"' && git ls-files ./*.sh ; } | sort | uniq ) +mapfile -t shellscript_locations < <({ git grep -lE '^#!(/usr)?/bin/(env )?(bash|sh)' && git submodule --quiet foreach '[ "$path" = "base" ] || git grep -lE "^#!(/usr)?/bin/(env )?(bash|sh)" | sed "s|^|$path/|"' && git ls-files ./*.sh; } | sort | uniq) SHELLSCRIPT_ERROR=0 @@ -13,8 +13,10 @@ for shellscript in "${shellscript_locations[@]}"; do echo -e "${ANSI_GREEN}Running shellcheck on ${shellscript}" shellcheck "${shellscript}" || SHELLSCRIPT_ERROR=1 echo -e "${ANSI_GREEN}Running shfmt on ${shellscript}" - [ "$(cat "${shellscript}" )" != "$(shfmt -i 4 "${shellscript}")" ] && echo -e "${ANSI_RED}Warning: ${shellscript} does not abide by coding style" - # @TODO add error handling with something like && shfmt -i 4 "${shellscript}" | diff "${shellscript}" + if [ "$(cat "${shellscript}")" != "$(shfmt -i 4 "${shellscript}")" ]; then + echo -e "${ANSI_RED}Warning: ${shellscript} does not abide by coding style" + shfmt -i 4 "${shellscript}" | diff "${shellscript}" - || SHELLSCRIPT_ERROR=1 + fi done exit "${SHELLSCRIPT_ERROR}" diff --git a/.ci/install.sh b/.ci/install.sh index d611254cd..5ba25a208 100755 --- a/.ci/install.sh +++ b/.ci/install.sh @@ -23,27 +23,28 @@ fi # install our own updated luarocks if [ ! -f "${TRAVIS_BUILD_DIR}/install/bin/luarocks" ]; then git clone https://github.com/torch/luajit-rocks.git - pushd luajit-rocks + pushd luajit-rocks && { git checkout 6529891 cmake . -DWITH_LUAJIT21=ON -DCMAKE_INSTALL_PREFIX="${TRAVIS_BUILD_DIR}/install" make install + } || exit popd else echo -e "${ANSI_GREEN}Using cached luarocks." fi -if [ ! -d "${HOME}/.luarocks" ] || [ ! -f "${HOME}/.luarocks/$(md5sum < "${CI_DIR}/helper_luarocks.sh")" ] ; then +if [ ! -d "${HOME}/.luarocks" ] || [ ! -f "${HOME}/.luarocks/$(md5sum <"${CI_DIR}/helper_luarocks.sh")" ]; then echo -e "${ANSI_GREEN}Grabbing new .luarocks." "${CI_DIR}/helper_luarocks.sh" - touch "${HOME}/.luarocks/$(md5sum < "${CI_DIR}/helper_luarocks.sh")" + touch "${HOME}/.luarocks/$(md5sum <"${CI_DIR}/helper_luarocks.sh")" else echo -e "${ANSI_GREEN}Using cached .luarocks." fi #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 -; +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 else @@ -52,7 +53,7 @@ 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 +if ! command -v shfmt; then curl -sSL "${SHFMT_URL}" -o "${HOME}/bin/shfmt" chmod +x "${HOME}/bin/shfmt" else diff --git a/kodev b/kodev index 75250a426..329d9590d 100755 --- a/kodev +++ b/kodev @@ -1,8 +1,8 @@ #!/bin/bash -CURDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" +CURDIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" -function assert_ret_zero { +function assert_ret_zero() { if [ "$1" -ne 0 ]; then if [ ! -z "$2" ]; then echo "$2" @@ -11,20 +11,19 @@ function assert_ret_zero { fi } -function check_submodules { - if git submodule status | grep -qE '^\-' - then +function check_submodules() { + if git submodule status | grep -qE '^\-'; then kodev-fetch-thirdparty fi } -function setup_env { +function setup_env() { files=$(ls -d ./koreader-emulator-*/koreader) assert_ret_zero $? "Emulator not found, please build it first." export EMU_DIR=${files[0]} } -function kodev-fetch-thirdparty { +function kodev-fetch-thirdparty() { make fetchthirdparty } @@ -41,7 +40,7 @@ SUPPORTED_TARGETS=" win32 " -function kodev-build { +function kodev-build() { BUILD_HELP_MSG=" usage: build @@ -57,13 +56,17 @@ ${SUPPORTED_TARGETS}" VALUE=$(echo "$1" | awk -F= '{print $2}') case $PARAM in -v | --verbose) - export VERBOSE=1 ;; + export VERBOSE=1 + ;; -h | --help) - echo "${BUILD_HELP_MSG}"; exit 0 ;; + echo "${BUILD_HELP_MSG}" + exit 0 + ;; *) echo "ERROR: unknown option \"$PARAM\"" echo "${BUILD_HELP_MSG}" - exit 1 ;; + exit 1 + ;; esac shift 1 done @@ -71,40 +74,61 @@ ${SUPPORTED_TARGETS}" check_submodules case $1 in kindle) - make TARGET=kindle; assert_ret_zero $? ;; + make TARGET=kindle + assert_ret_zero $? + ;; kindle5) - make TARGET=kindle5; assert_ret_zero $? ;; + make TARGET=kindle5 + assert_ret_zero $? + ;; kindlepw2) - make TARGET=kindlepw2; assert_ret_zero $? ;; + make TARGET=kindlepw2 + assert_ret_zero $? + ;; kobo) - make TARGET=kobo; assert_ret_zero $? ;; + make TARGET=kobo + assert_ret_zero $? + ;; kindle-legacy) - make TARGET=kindle-legacy; assert_ret_zero $? ;; + make TARGET=kindle-legacy + assert_ret_zero $? + ;; android) [[ -n ${NDK+x} ]] || export NDK="${CURDIR}/base/toolchain/android-ndk-r12b" - [ -e "${CURDIR}/base/toolchain/android-toolchain/bin/arm-linux-androideabi-gcc" ] || { \ - { [ -e "${NDK}" ] || make -C "${CURDIR}/base/toolchain" android-ndk; }; \ - make android-toolchain; assert_ret_zero $?; \ + [ -e "${CURDIR}/base/toolchain/android-toolchain/bin/arm-linux-androideabi-gcc" ] || { + { [ -e "${NDK}" ] || make -C "${CURDIR}/base/toolchain" android-ndk; } + make android-toolchain + assert_ret_zero $? } echo "Using NDK: ${NDK}..." - make TARGET=android; assert_ret_zero $? ;; + make TARGET=android + assert_ret_zero $? + ;; pocketbook) if [ ! -d "${CURDIR}/base/toolchain/pocketbook-toolchain" ]; then - make pocketbook-toolchain; assert_ret_zero $? + make pocketbook-toolchain + assert_ret_zero $? fi - make TARGET=pocketbook; assert_ret_zero $? ;; + make TARGET=pocketbook + assert_ret_zero $? + ;; ubuntu-touch) - make TARGET=ubuntu-touch; assert_ret_zero $? ;; + make TARGET=ubuntu-touch + assert_ret_zero $? + ;; win32) - make TARGET=win32; assert_ret_zero $? ;; + make TARGET=win32 + assert_ret_zero $? + ;; *) make assert_ret_zero $? "Failed to build emulator! Try run with -v for more information." - setup_env ;; + setup_env + ;; esac } -function kodev-clean { +function kodev-clean() { CLEAN_HELP_MSG=" usage: clean @@ -113,32 +137,44 @@ ${SUPPORTED_TARGETS}" case $1 in -h | --help) - echo "${CLEAN_HELP_MSG}"; exit 0 ;; + echo "${CLEAN_HELP_MSG}" + exit 0 + ;; kindle) - make TARGET=kindle clean ;; + make TARGET=kindle clean + ;; kindle5) - make TARGET=kindle5 clean ;; + make TARGET=kindle5 clean + ;; kindlepw2) - make TARGET=kindlepw2 clean ;; + make TARGET=kindlepw2 clean + ;; kobo) - make TARGET=kobo clean ;; + make TARGET=kobo clean + ;; kindle-legacy) - make TARGET=kindle-legacy clean ;; + make TARGET=kindle-legacy clean + ;; android) make TARGET=android clean - rm -f ./*.apk ;; + rm -f ./*.apk + ;; pocketbook) - make TARGET=pocketbook clean ;; + make TARGET=pocketbook clean + ;; ubuntu-touch) - make TARGET=ubuntu-touch clean ;; + make TARGET=ubuntu-touch clean + ;; win32) - make TARGET=win32 clean ;; + make TARGET=win32 clean + ;; *) - make clean ;; + make clean + ;; esac } -function kodev-release { +function kodev-release() { # SUPPORTED_RELEASE_TARGETS=$(echo ${SUPPORTED_TARGETS} | sed 's/win32//') SUPPORTED_RELEASE_TARGETS="${SUPPORTED_TARGETS/emu*/""}" RELEASE_HELP_MSG=" @@ -146,19 +182,27 @@ usage: release TARGET: ${SUPPORTED_RELEASE_TARGETS}" - [ $# -lt 1 ] && { echo "${RELEASE_HELP_MSG}"; exit 1; } + [ $# -lt 1 ] && { + echo "${RELEASE_HELP_MSG}" + exit 1 + } while [[ $1 == '-'* ]]; do PARAM=$(echo "$1" | awk -F= '{print $1}') VALUE=$(echo "$1" | awk -F= '{print $2}') case $PARAM in -v | --verbose) - export VERBOSE=1 ;; + export VERBOSE=1 + ;; -h | --help) - echo "${RELEASE_HELP_MSG}"; exit 0 ;; + echo "${RELEASE_HELP_MSG}" + exit 0 + ;; *) echo "ERROR: unknown option \"$PARAM\"" - echo "${RELEASE_HELP_MSG}"; exit 1 ;; + echo "${RELEASE_HELP_MSG}" + exit 1 + ;; esac shift 1 done @@ -168,51 +212,61 @@ ${SUPPORTED_RELEASE_TARGETS}" case $1 in kindle) kodev-build kindle - make TARGET=kindle update ;; + make TARGET=kindle update + ;; kindle5) kodev-build kindle5 - make TARGET=kindle5 update ;; + make TARGET=kindle5 update + ;; kindlepw2) kodev-build kindlepw2 - make TARGET=kindlepw2 update ;; + make TARGET=kindlepw2 update + ;; kobo) kodev-build kobo - make TARGET=kobo update ;; + make TARGET=kobo update + ;; kindle-legacy) kodev-build kindle-legacy - make TARGET=kindle-legacy update ;; + make TARGET=kindle-legacy update + ;; android) kodev-build android export PATH=$PATH:${CURDIR}/base/toolchain/android-sdk-linux/tools - which android &> /dev/null || { \ - make -C "${CURDIR}/base/toolchain" android-sdk; \ + which android &>/dev/null || { + make -C "${CURDIR}/base/toolchain" android-sdk } ANDROID_HOME=$(dirname "$(dirname "$(which android)")") export ANDROID_HOME export PATH=$PATH:${NDK} - make TARGET=android update ;; + make TARGET=android update + ;; pocketbook) kodev-build pocketbook - make TARGET=pocketbook update ;; + make TARGET=pocketbook update + ;; ubuntu-touch) kodev-build pocketbook - make TARGET=ubuntu-touch update ;; + make TARGET=ubuntu-touch update + ;; *) echo "Unsupported target for release: $1." - echo "${RELEASE_HELP_MSG}"; exit 1 ;; + echo "${RELEASE_HELP_MSG}" + exit 1 + ;; esac } - -function kodev-wbuilder { +function kodev-wbuilder() { kodev-build echo "[*] Running wbuilder.lua..." - pushd "${EMU_DIR}" + pushd "${EMU_DIR}" && { EMULATE_READER_W=540 EMULATE_READER_H=720 ./luajit ./tools/wbuilder.lua + } || exit popd } -function kodev-run { +function kodev-run() { RUN_HELP_MSG=" usage: run @@ -230,18 +284,26 @@ OPTIONS: VALUE=$(echo "$1" | awk -F= '{print $2}') case $PARAM in --disable-touch) - export DISABLE_TOUCH=1 ;; + export DISABLE_TOUCH=1 + ;; --no-build) - no_build=true ;; + no_build=true + ;; -w | --screen-width) - screen_width=${VALUE} ;; + screen_width=${VALUE} + ;; -h | --screen-height) - screen_height=${VALUE} ;; + screen_height=${VALUE} + ;; -h | --help) - echo "${RUN_HELP_MSG}"; exit 0 ;; + echo "${RUN_HELP_MSG}" + exit 0 + ;; *) echo "ERROR: unknown option \"$PARAM\"" - echo "${RUN_HELP_MSG}"; exit 1 ;; + echo "${RUN_HELP_MSG}" + exit 1 + ;; esac shift done @@ -259,7 +321,7 @@ OPTIONS: fi echo "[*] Running KOReader with arguments: $*..." - pushd "${EMU_DIR}" + pushd "${EMU_DIR}" && { if [ $# -lt 1 ]; then args=${CURDIR}/test else @@ -269,10 +331,11 @@ OPTIONS: EMULATE_READER_W=${screen_width} EMULATE_READER_H=${screen_height} \ ./reader.lua -d "$args" + } || exit popd } -function kodev-test { +function kodev-test() { TEST_HELP_MSG=" usage: test [front|base] @@ -287,17 +350,25 @@ OPTIONS: VALUE=$(echo "$1" | awk -F= '{print $2}') case $PARAM in --tags) - opts="--tags=${VALUE}" ;; + opts="--tags=${VALUE}" + ;; -h | --help) - echo "${TEST_HELP_MSG}"; exit 0 ;; + echo "${TEST_HELP_MSG}" + exit 0 + ;; *) echo "ERROR: unknown option \"$PARAM\"" - echo "${TEST_HELP_MSG}"; exit 1 ;; + echo "${TEST_HELP_MSG}" + exit 1 + ;; esac shift done - [ $# -lt 1 ] && { echo "${TEST_HELP_MSG}"; exit 1; } + [ $# -lt 1 ] && { + echo "${TEST_HELP_MSG}" + exit 1 + } [[ $1 != "front" && $1 != "base" ]] && { echo "Invalid test suite: $1!" echo "${TEST_HELP_MSG}" @@ -307,7 +378,7 @@ OPTIONS: check_submodules && make setup_env make "${EMU_DIR}/.busted" - pushd "${EMU_DIR}" + pushd "${EMU_DIR}" && { test_path="./spec/$1/unit" if [ ! -z "$2" ]; then @@ -320,10 +391,11 @@ OPTIONS: --lazy \ -o "./spec/$1/unit/verbose_print" \ --exclude-tags=notest "${test_path}" + } || exit popd } -function kodev-cov { +function kodev-cov() { COV_HELP_MSG=" usage: cov @@ -339,14 +411,20 @@ OPTIONS: VALUE=$(echo "$1" | awk -F= '{print $2}') case $PARAM in --full) - show_full=1 ;; + show_full=1 + ;; --show-previous) - show_previous=1 ;; + show_previous=1 + ;; -h | --help) - echo "${COV_HELP_MSG}"; exit 0 ;; + echo "${COV_HELP_MSG}" + exit 0 + ;; *) echo "ERROR: unknown option \"$PARAM\"" - echo "${COV_HELP_MSG}"; exit 1 ;; + echo "${COV_HELP_MSG}" + exit 1 + ;; esac shift done @@ -354,7 +432,7 @@ OPTIONS: check_submodules && make setup_env make "${EMU_DIR}/.busted" - pushd "${EMU_DIR}" + pushd "${EMU_DIR}" && { target=front test_path="./spec/${target}/unit" if [ ${show_previous} -eq 0 ]; then @@ -366,21 +444,21 @@ OPTIONS: -o "./spec/${target}/unit/verbose_print" \ --coverage \ --exclude-tags=nocov "${test_path}" || { - echo "Failed to run tests!" && exit 1; - } + echo "Failed to run tests!" && exit 1 + } fi if [ ${show_full} -eq 1 ]; then cat luacov.report.out else tail -n \ - +$(($(grep -nm1 -e '^Summary$' luacov.report.out|cut -d: -f1)-1)) \ + +$(($(grep -nm1 -e '^Summary$' luacov.report.out | cut -d: -f1) - 1)) \ luacov.report.out fi + } || exit popd } - -function kodev-log { +function kodev-log() { LOG_HELP_MSG=" usage: log @@ -388,21 +466,27 @@ TARGET: android " - [ $# -lt 1 ] && { echo "${LOG_HELP_MSG}"; exit 1; } + [ $# -lt 1 ] && { + echo "${LOG_HELP_MSG}" + exit 1 + } case $1 in -h | --help) - echo "${LOG_HELP_MSG}"; exit 0 ;; + echo "${LOG_HELP_MSG}" + exit 0 + ;; android) - adb logcat 'luajit-launcher:D KOReader:D *:S' ;; + adb logcat 'luajit-launcher:D KOReader:D *:S' + ;; *) echo "Unsupported target: $1." - echo "${LOG_HELP_MSG}"; exit 1 ;; + echo "${LOG_HELP_MSG}" + exit 1 + ;; esac } - - HELP_MSG=" usage: $0 COMMAND @@ -418,41 +502,67 @@ Supported commands: test Run tests wbuilder Run wbuilder.lua script (useful for building new UI widget) " -[ $# -lt 1 ] && { echo "Missing command."; echo "${HELP_MSG}"; exit 1; } +[ $# -lt 1 ] && { + echo "Missing command." + echo "${HELP_MSG}" + exit 1 +} case $1 in activate) echo "adding ${CURDIR} to \$PATH..." export PATH="${PATH}:${CURDIR}" eval "$(luarocks path --bin)" - exec "${SHELL}" ;; + exec "${SHELL}" + ;; fetch-thirdparty) - kodev-fetch-thirdparty ;; + kodev-fetch-thirdparty + ;; clean) - shift 1; kodev-clean "$@" ;; + shift 1 + kodev-clean "$@" + ;; build) - shift 1; kodev-build "$@" ;; + shift 1 + kodev-build "$@" + ;; release) - shift 1; kodev-release "$@" ;; + shift 1 + kodev-release "$@" + ;; wbuilder) - kodev-wbuilder ;; + kodev-wbuilder + ;; run) - shift 1; kodev-run "$@" ;; + shift 1 + kodev-run "$@" + ;; test) - shift 1; kodev-test "$@" ;; + shift 1 + kodev-test "$@" + ;; cov) - shift 1; kodev-cov "$@" ;; + shift 1 + kodev-cov "$@" + ;; prompt) kodev-build - pushd "${EMU_DIR}" + pushd "${EMU_DIR}" && { ./luajit -i setupkoenv.lua + } || exit popd ;; log) - shift 1; kodev-log "$@" ;; + shift 1 + kodev-log "$@" + ;; --help | -h) - echo "${HELP_MSG}"; exit 0 ;; + echo "${HELP_MSG}" + exit 0 + ;; *) echo "Unknown command: $1." - echo "${HELP_MSG}"; exit 1 ;; + echo "${HELP_MSG}" + exit 1 + ;; esac diff --git a/platform/android/luajit-launcher b/platform/android/luajit-launcher index 3bdf92c12..7368ab361 160000 --- a/platform/android/luajit-launcher +++ b/platform/android/luajit-launcher @@ -1 +1 @@ -Subproject commit 3bdf92c1272d969af5f419492edf760aa2947cf3 +Subproject commit 7368ab36138a00b38d643a00c940bd4d02475ad1 diff --git a/platform/kindle/extensions/koreader/bin/koreader-ext.sh b/platform/kindle/extensions/koreader/bin/koreader-ext.sh index 8d31c64ee..b5d0de732 100755 --- a/platform/kindle/extensions/koreader/bin/koreader-ext.sh +++ b/platform/kindle/extensions/koreader/bin/koreader-ext.sh @@ -8,180 +8,169 @@ KOREADER_DIR="/mnt/us/koreader" # Load our helper functions... -if [ -f "${KOREADER_DIR}/libkohelper.sh" ] ; then - # shellcheck source=/dev/null - . "${KOREADER_DIR}/libkohelper.sh" +if [ -f "${KOREADER_DIR}/libkohelper.sh" ]; then + # shellcheck source=/dev/null + . "${KOREADER_DIR}/libkohelper.sh" else - echo "Can't source helper functions, aborting!" - exit 1 + echo "Can't source helper functions, aborting!" + exit 1 fi ## Handle logging... -logmsg() -{ - # Use the right tools for the platform - if [ "${INIT_TYPE}" = "sysv" ] ; then - msg "koreader: ${1}" "I" - elif [ "${INIT_TYPE}" = "upstart" ] ; then - f_log I koreader kual "" "${1}" - fi - - # And handle user visual feedback via eips... - eips_print_bottom_centered "${1}" 1 +logmsg() { + # Use the right tools for the platform + if [ "${INIT_TYPE}" = "sysv" ]; then + msg "koreader: ${1}" "I" + elif [ "${INIT_TYPE}" = "upstart" ]; then + f_log I koreader kual "" "${1}" + fi + + # And handle user visual feedback via eips... + eips_print_bottom_centered "${1}" 1 } ## And now the actual useful stuff! # Update koreader -update_koreader() -{ - # Check if we were called by install_koreader... - if [ "${1}" = "clean" ] ; then - do_clean_install="true" - else - do_clean_install="false" - fi - - found_koreader_package="false" - # Try to find a koreader package... Behavior undefined if there are multiple packages... - for file in /mnt/us/koreader-kindle-*.tar.gz ; do - if [ -f "${file}" ] ; then - found_koreader_package="${file}" - koreader_pkg_type="tgz" - fi - done - for file in /mnt/us/koreader-kindle-*.zip ; do - if [ -f "${file}" ] ; then - found_koreader_package="${file}" - koreader_pkg_type="zip" - fi - done - - 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 - 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 - koreader_pkg_ver="${found_koreader_package%.*.*}" - else - koreader_pkg_ver="${found_koreader_package%.*}" - fi - koreader_pkg_ver="${koreader_pkg_ver#*-v}" - # Install it! - logmsg "Updating to KOReader ${koreader_pkg_ver} . . ." - 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 [ $fail -eq 0 ] ; then - logmsg "Update to v${koreader_pkg_ver} successful :)" - # Cleanup behind us... - rm -f "${found_koreader_package}" - else - logmsg "Failed to update to v${koreader_pkg_ver} :(" - fi - fi +update_koreader() { + # Check if we were called by install_koreader... + if [ "${1}" = "clean" ]; then + do_clean_install="true" + else + do_clean_install="false" + fi + + found_koreader_package="false" + # Try to find a koreader package... Behavior undefined if there are multiple packages... + for file in /mnt/us/koreader-kindle-*.tar.gz; do + if [ -f "${file}" ]; then + found_koreader_package="${file}" + koreader_pkg_type="tgz" + fi + done + for file in /mnt/us/koreader-kindle-*.zip; do + if [ -f "${file}" ]; then + found_koreader_package="${file}" + koreader_pkg_type="zip" + fi + done + + 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 + 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 + koreader_pkg_ver="${found_koreader_package%.*.*}" + else + koreader_pkg_ver="${found_koreader_package%.*}" + fi + koreader_pkg_ver="${koreader_pkg_ver#*-v}" + # Install it! + logmsg "Updating to KOReader ${koreader_pkg_ver} . . ." + 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 [ $fail -eq 0 ]; then + logmsg "Update to v${koreader_pkg_ver} successful :)" + # Cleanup behind us... + rm -f "${found_koreader_package}" + else + logmsg "Failed to update to v${koreader_pkg_ver} :(" + fi + fi } # Clean install of koreader -install_koreader() -{ - # Let update_koreader do the job for us ;p. - update_koreader "clean" +install_koreader() { + # Let update_koreader do the job for us ;p. + update_koreader "clean" } # Handle cre's settings... -set_cre_prop() -{ - # We need at least two args - if [ $# -lt 2 ] ; then - logmsg "not enough arg passed to set_cre_prop" - return - fi - - cre_prop_key="${1}" - cre_prop_value="${2}" - - cre_config="/mnt/us/koreader/data/cr3.ini" - - # 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 - 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}" - fi - else - logmsg "No CRe config, launch CRe once first" - fi +set_cre_prop() { + # We need at least two args + if [ $# -lt 2 ]; then + logmsg "not enough arg passed to set_cre_prop" + return + fi + + cre_prop_key="${1}" + cre_prop_value="${2}" + + cre_config="/mnt/us/koreader/data/cr3.ini" + + # 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 + 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}" + fi + else + logmsg "No CRe config, launch CRe once first" + fi } # Handle CRe's font.hinting.mode -cre_autohint() -{ - set_cre_prop "font.hinting.mode" "2" +cre_autohint() { + set_cre_prop "font.hinting.mode" "2" } -cre_bci() -{ - set_cre_prop "font.hinting.mode" "1" +cre_bci() { + set_cre_prop "font.hinting.mode" "1" } -cre_nohinting() -{ - set_cre_prop "font.hinting.mode" "0" +cre_nohinting() { + set_cre_prop "font.hinting.mode" "0" } # Handle CRe's font.kerning.enabled -cre_kerning() -{ - set_cre_prop "font.kerning.enabled" "1" +cre_kerning() { + set_cre_prop "font.kerning.enabled" "1" } -cre_nokerning() -{ - set_cre_prop "font.kerning.enabled" "0" +cre_nokerning() { + set_cre_prop "font.kerning.enabled" "0" } - ## Main case "${1}" in - "update_koreader" ) - ${1} - ;; - "install_koreader" ) - ${1} - ;; - "cre_autohint" ) - ${1} - ;; - "cre_bci" ) - ${1} - ;; - "cre_nohinting" ) - ${1} - ;; - "cre_kerning" ) - ${1} - ;; - "cre_nokerning" ) - ${1} - ;; - * ) - logmsg "invalid action (${1})" - ;; + "update_koreader") + ${1} + ;; + "install_koreader") + ${1} + ;; + "cre_autohint") + ${1} + ;; + "cre_bci") + ${1} + ;; + "cre_nohinting") + ${1} + ;; + "cre_kerning") + ${1} + ;; + "cre_nokerning") + ${1} + ;; + *) + logmsg "invalid action (${1})" + ;; esac diff --git a/platform/kindle/koreader.sh b/platform/kindle/koreader.sh index 7b3a64119..0d3d375ef 100755 --- a/platform/kindle/koreader.sh +++ b/platform/kindle/koreader.sh @@ -3,42 +3,41 @@ export LC_ALL="en_US.UTF-8" PROC_KEYPAD="/proc/keypad" PROC_FIVEWAY="/proc/fiveway" -[ -e $PROC_KEYPAD ] && echo unlock > $PROC_KEYPAD -[ -e $PROC_FIVEWAY ] && echo unlock > $PROC_FIVEWAY +[ -e $PROC_KEYPAD ] && echo unlock >$PROC_KEYPAD +[ -e $PROC_FIVEWAY ] && echo unlock >$PROC_FIVEWAY # KOReader's working directory KOREADER_DIR="/mnt/us/koreader" # Load our helper functions... -if [ -f "${KOREADER_DIR}/libkohelper.sh" ] ; then - # shellcheck source=/dev/null - . "${KOREADER_DIR}/libkohelper.sh" +if [ -f "${KOREADER_DIR}/libkohelper.sh" ]; then + # shellcheck source=/dev/null + . "${KOREADER_DIR}/libkohelper.sh" else - echo "Can't source helper functions, aborting!" - exit 1 + echo "Can't source helper functions, aborting!" + exit 1 fi # Handle logging... -logmsg() -{ - # Use the right tools for the platform - if [ "${INIT_TYPE}" = "sysv" ] ; then - msg "koreader: ${1}" "I" - elif [ "${INIT_TYPE}" = "upstart" ] ; then - f_log I koreader wrapper "" "${1}" - fi - - # And throw that on stdout too, for the DIY crowd ;) - echo "${1}" +logmsg() { + # Use the right tools for the platform + if [ "${INIT_TYPE}" = "sysv" ]; then + msg "koreader: ${1}" "I" + elif [ "${INIT_TYPE}" = "upstart" ]; then + f_log I koreader wrapper "" "${1}" + fi + + # And throw that on stdout too, for the DIY crowd ;) + echo "${1}" } # Go away if we're on FW 5.0, it's not supported -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! - exit 0 - fi +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! + exit 0 + fi fi # Keep track of what we do with pillow... @@ -51,35 +50,35 @@ PASSCODE_DISABLED="no" FROM_KUAL="no" # By default, don't stop the framework. -if [ "$1" = "--framework_stop" ] ; then - shift 1 - STOP_FRAMEWORK="yes" - NO_SLEEP="no" -elif [ "$1" = "--asap" ] ; then - # Start as soon as possible, without sleeping to workaround UI quirks - shift 1 - NO_SLEEP="yes" - STOP_FRAMEWORK="no" - # Don't sleep during eips calls either... - export EIPS_NO_SLEEP="true" +if [ "$1" = "--framework_stop" ]; then + shift 1 + STOP_FRAMEWORK="yes" + NO_SLEEP="no" +elif [ "$1" = "--asap" ]; then + # Start as soon as possible, without sleeping to workaround UI quirks + shift 1 + NO_SLEEP="yes" + STOP_FRAMEWORK="no" + # Don't sleep during eips calls either... + export EIPS_NO_SLEEP="true" else - STOP_FRAMEWORK="no" - NO_SLEEP="no" + STOP_FRAMEWORK="no" + NO_SLEEP="no" fi # Detect if we were started by KUAL by checking our nice value... -if [ "$(nice)" = "5" ] ; then - FROM_KUAL="yes" - 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... - usleep 250000 - fi - - # Kindlet threads spawn with a nice value of 5, go back to a neutral value - logmsg "Be nice!" - renice -n -5 $$ +if [ "$(nice)" = "5" ]; then + FROM_KUAL="yes" + 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... + usleep 250000 + fi + + # Kindlet threads spawn with a nice value of 5, go back to a neutral value + logmsg "Be nice!" + renice -n -5 $$ fi # we're always starting from our working directory @@ -88,32 +87,32 @@ cd "${KOREADER_DIR}" || exit # Handle pending OTA update NEWUPDATE="${KOREADER_DIR}/ota/koreader.updated.tar" INSTALLED="${KOREADER_DIR}/ota/koreader.installed.tar" -if [ -f "${NEWUPDATE}" ] ; then - logmsg "Updating koreader . . ." - # Look for our own GNU tar build to do a fancy progress tracking... - GNUTAR_BIN="${KOREADER_DIR}/tar" - 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 [ $fail -eq 0 ] ; then - mv "${NEWUPDATE}" "${INSTALLED}" - logmsg "Update sucessful :)" - eips_print_bottom_centered "Update successful :)" 1 - else - # Huh ho... - logmsg "Update failed :(" - eips_print_bottom_centered "Update failed :(" 1 - fi +if [ -f "${NEWUPDATE}" ]; then + logmsg "Updating koreader . . ." + # Look for our own GNU tar build to do a fancy progress tracking... + GNUTAR_BIN="${KOREADER_DIR}/tar" + 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 [ $fail -eq 0 ]; then + mv "${NEWUPDATE}" "${INSTALLED}" + logmsg "Update sucessful :)" + eips_print_bottom_centered "Update successful :)" 1 + else + # Huh ho... + logmsg "Update failed :(" + eips_print_bottom_centered "Update failed :(" 1 + fi fi # load our own shared libraries if possible @@ -129,219 +128,219 @@ 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" ] || [ "$(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 - iptables -A INPUT -i wlan0 -p tcp --dport 49152:49162 -j ACCEPT - # accept input ports for calibre companion - iptables -A INPUT -i wlan0 -p udp --dport 8134 -j ACCEPT +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 + iptables -A INPUT -i wlan0 -p tcp --dport 49152:49162 -j ACCEPT + # accept input ports for calibre companion + iptables -A INPUT -i wlan0 -p udp --dport 8134 -j ACCEPT fi # bind-mount system fonts -if ! grep ${KOREADER_DIR}/fonts/host /proc/mounts > /dev/null 2>&1 ; then - logmsg "Mounting system fonts . . ." - mount -o bind /usr/java/lib/fonts ${KOREADER_DIR}/fonts/host +if ! grep ${KOREADER_DIR}/fonts/host /proc/mounts >/dev/null 2>&1; then + logmsg "Mounting system fonts . . ." + mount -o bind /usr/java/lib/fonts ${KOREADER_DIR}/fonts/host fi # bind-mount altfonts -if [ -d /mnt/us/fonts ] ; then - mkdir -p ${KOREADER_DIR}/fonts/altfonts - if ! grep ${KOREADER_DIR}/fonts/altfonts /proc/mounts > /dev/null 2>&1 ; then - logmsg "Mounting altfonts . . ." - mount -o bind /mnt/us/fonts ${KOREADER_DIR}/fonts/altfonts - fi +if [ -d /mnt/us/fonts ]; then + mkdir -p ${KOREADER_DIR}/fonts/altfonts + if ! grep ${KOREADER_DIR}/fonts/altfonts /proc/mounts >/dev/null 2>&1; then + logmsg "Mounting altfonts . . ." + mount -o bind /mnt/us/fonts ${KOREADER_DIR}/fonts/altfonts + fi fi # bind-mount csp fonts -if [ -d /var/local/font/mnt ] ; then - mkdir -p ${KOREADER_DIR}/fonts/cspfonts - if ! grep ${KOREADER_DIR}/fonts/cspfonts /proc/mounts > /dev/null 2>&1 ; then - logmsg "Mounting cspfonts . . ." - mount -o bind /var/local/font/mnt ${KOREADER_DIR}/fonts/cspfonts - fi +if [ -d /var/local/font/mnt ]; then + mkdir -p ${KOREADER_DIR}/fonts/cspfonts + if ! grep ${KOREADER_DIR}/fonts/cspfonts /proc/mounts >/dev/null 2>&1; then + logmsg "Mounting cspfonts . . ." + mount -o bind /var/local/font/mnt ${KOREADER_DIR}/fonts/cspfonts + fi fi # bind-mount linkfonts -if [ -d /mnt/us/linkfonts/fonts ] ; then - mkdir -p ${KOREADER_DIR}/fonts/linkfonts - if ! grep ${KOREADER_DIR}/fonts/linkfonts /proc/mounts > /dev/null 2>&1 ; then - logmsg "Mounting linkfonts . . ." - mount -o bind /mnt/us/linkfonts/fonts ${KOREADER_DIR}/fonts/linkfonts - fi +if [ -d /mnt/us/linkfonts/fonts ]; then + mkdir -p ${KOREADER_DIR}/fonts/linkfonts + if ! grep ${KOREADER_DIR}/fonts/linkfonts /proc/mounts >/dev/null 2>&1; then + logmsg "Mounting linkfonts . . ." + mount -o bind /mnt/us/linkfonts/fonts ${KOREADER_DIR}/fonts/linkfonts + fi fi # check if we need to disable the system passcode, because it messes with us in fun and interesting (and, more to the point, intractable) ways... # NOTE: The most egregious one being that it inhibits the outOfScreenSaver event on wakeup until the passcode is validated, which we can't do, since we capture all input... -if [ -f "/var/local/system/userpasswdenabled" ] ; then - logmsg "Disabling system passcode . . ." - rm -f "/var/local/system/userpasswdenabled" - PASSCODE_DISABLED="yes" +if [ -f "/var/local/system/userpasswdenabled" ]; then + logmsg "Disabling system passcode . . ." + rm -f "/var/local/system/userpasswdenabled" + PASSCODE_DISABLED="yes" fi # check if we are supposed to shut down the Amazon framework -if [ "${STOP_FRAMEWORK}" = "yes" ] ; then - logmsg "Stopping the framework . . ." - # Upstart or SysV? - 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 "" 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 - TERM - fi +if [ "${STOP_FRAMEWORK}" = "yes" ]; then + logmsg "Stopping the framework . . ." + # Upstart or SysV? + 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 "" 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 - 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" ] && [ "${INIT_TYPE}" = "upstart" ] ; then - count=$(lipc-get-prop -eiq com.github.koreader.kpvbooklet.timer count) - 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 - AWESOME_STOPPED="yes" - fi - else - logmsg "Hiding the status bar . . ." - # NOTE: One more great find from eureka (http://www.mobileread.com/forums/showpost.php?p=2454141&postcount=34) - lipc-set-prop com.lab126.pillow interrogatePillow '{"pillowId": "default_status_bar", "function": "nativeBridge.hideMe();"}' - PILLOW_SOFT_DISABLED="yes" - fi - # NOTE: We don't need to sleep at all if we've already SIGSTOPped awesome ;) - 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 - logmsg "Playing possum to wait for the window manager . . ." - usleep 2500000 - fi - fi - fi +if [ "${STOP_FRAMEWORK}" = "no" ] && [ "${INIT_TYPE}" = "upstart" ]; then + count=$(lipc-get-prop -eiq com.github.koreader.kpvbooklet.timer count) + 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 + AWESOME_STOPPED="yes" + fi + else + logmsg "Hiding the status bar . . ." + # NOTE: One more great find from eureka (http://www.mobileread.com/forums/showpost.php?p=2454141&postcount=34) + lipc-set-prop com.lab126.pillow interrogatePillow '{"pillowId": "default_status_bar", "function": "nativeBridge.hideMe();"}' + PILLOW_SOFT_DISABLED="yes" + fi + # NOTE: We don't need to sleep at all if we've already SIGSTOPped awesome ;) + 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 + logmsg "Playing possum to wait for the window manager . . ." + usleep 2500000 + fi + fi + fi fi # stop cvm (sysv & framework up only) -if [ "${STOP_FRAMEWORK}" = "no" ] && [ "${INIT_TYPE}" = "sysv" ] ; then - logmsg "Stopping cvm . . ." - killall -stop cvm +if [ "${STOP_FRAMEWORK}" = "no" ] && [ "${INIT_TYPE}" = "sysv" ]; then + logmsg "Stopping cvm . . ." + killall -stop cvm fi # finally call reader logmsg "Starting KOReader . . ." # That's not necessary when using KPVBooklet ;). -if [ "${FROM_KUAL}" = "yes" ] ; then - eips_print_bottom_centered "Starting KOReader . . ." 1 +if [ "${FROM_KUAL}" = "yes" ]; then + eips_print_bottom_centered "Starting KOReader . . ." 1 fi # we keep maximum 500K worth of crash log if [ -e crash.log ]; then - tail -c 500000 crash.log > crash.log.new - mv -f crash.log.new crash.log + tail -c 500000 crash.log >crash.log.new + mv -f crash.log.new crash.log fi -./reader.lua "$@" >> crash.log 2>&1 +./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) -if pidof reader.lua > /dev/null 2>&1 ; then - logmsg "Sending a SIGTERM to stray KOreader processes . . ." - killall -TERM reader.lua +if pidof reader.lua >/dev/null 2>&1; then + logmsg "Sending a SIGTERM to stray KOreader processes . . ." + killall -TERM reader.lua fi # unmount system fonts -if grep ${KOREADER_DIR}/fonts/host /proc/mounts > /dev/null 2>&1 ; then - logmsg "Unmounting system fonts . . ." - umount ${KOREADER_DIR}/fonts/host +if grep ${KOREADER_DIR}/fonts/host /proc/mounts >/dev/null 2>&1; then + logmsg "Unmounting system fonts . . ." + umount ${KOREADER_DIR}/fonts/host fi # unmount altfonts -if grep ${KOREADER_DIR}/fonts/altfonts /proc/mounts > /dev/null 2>&1 ; then - logmsg "Unmounting altfonts . . ." - umount ${KOREADER_DIR}/fonts/altfonts +if grep ${KOREADER_DIR}/fonts/altfonts /proc/mounts >/dev/null 2>&1; then + logmsg "Unmounting altfonts . . ." + umount ${KOREADER_DIR}/fonts/altfonts fi # unmount cspfonts -if grep ${KOREADER_DIR}/fonts/cspfonts /proc/mounts > /dev/null 2>&1 ; then - logmsg "Unmounting cspfonts . . ." - umount ${KOREADER_DIR}/fonts/cspfonts +if grep ${KOREADER_DIR}/fonts/cspfonts /proc/mounts >/dev/null 2>&1; then + logmsg "Unmounting cspfonts . . ." + umount ${KOREADER_DIR}/fonts/cspfonts fi # unmount linkfonts -if grep ${KOREADER_DIR}/fonts/linkfonts /proc/mounts > /dev/null 2>&1 ; then - logmsg "Unmounting linkfonts . . ." - umount ${KOREADER_DIR}/fonts/linkfonts +if grep ${KOREADER_DIR}/fonts/linkfonts /proc/mounts >/dev/null 2>&1; then + logmsg "Unmounting linkfonts . . ." + umount ${KOREADER_DIR}/fonts/linkfonts fi # Resume cvm (only if we stopped it) -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 ;). - echo 'send 139' > /proc/keypad - echo 'send 139' > /proc/keypad +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 ;). + echo 'send 139' >/proc/keypad + echo 'send 139' >/proc/keypad fi # Restart framework (if need be) -if [ "${STOP_FRAMEWORK}" = "yes" ] ; then - logmsg "Restarting framework . . ." - 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 - fi +if [ "${STOP_FRAMEWORK}" = "yes" ]; then + logmsg "Restarting framework . . ." + 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 + fi fi # Display chrome bar if need be (upstart & framework up only) -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 - logmsg "Resuming awesome . . ." - killall -cont awesome - fi - 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... - cat /var/tmp/koreader-fb.dump > /dev/fb0 - rm -f /var/tmp/koreader-fb.dump - lipc-set-prop com.lab126.appmgrd start app://com.lab126.booklet.home - # 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 - 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 - rm -f /var/tmp/koreader-fb.dump - lipc-set-prop com.lab126.pillow interrogatePillow '{"pillowId": "default_status_bar", "function": "nativeBridge.showMe();"}' - lipc-set-prop com.lab126.appmgrd start app://com.lab126.booklet.home - fi +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 + logmsg "Resuming awesome . . ." + killall -cont awesome + fi + 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... + cat /var/tmp/koreader-fb.dump >/dev/fb0 + rm -f /var/tmp/koreader-fb.dump + lipc-set-prop com.lab126.appmgrd start app://com.lab126.booklet.home + # 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 + 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 + rm -f /var/tmp/koreader-fb.dump + lipc-set-prop com.lab126.pillow interrogatePillow '{"pillowId": "default_status_bar", "function": "nativeBridge.showMe();"}' + lipc-set-prop com.lab126.appmgrd start app://com.lab126.booklet.home + fi fi -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 - iptables -D INPUT -i wlan0 -p udp --dport 5670 -j ACCEPT - iptables -D INPUT -i wlan0 -p tcp --dport 49152:49162 -j ACCEPT +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 + iptables -D INPUT -i wlan0 -p udp --dport 5670 -j ACCEPT + iptables -D INPUT -i wlan0 -p tcp --dport 49152:49162 -j ACCEPT fi -if [ "${PASSCODE_DISABLED}" = "yes" ] ; then - logmsg "Restoring system passcode . . ." - touch "/var/local/system/userpasswdenabled" +if [ "${PASSCODE_DISABLED}" = "yes" ]; then + logmsg "Restoring system passcode . . ." + touch "/var/local/system/userpasswdenabled" fi diff --git a/platform/kindle/kotar_cpoint b/platform/kindle/kotar_cpoint index 064d49908..12b7d70ec 100755 --- a/platform/kindle/kotar_cpoint +++ b/platform/kindle/kotar_cpoint @@ -7,12 +7,12 @@ KOREADER_DIR="/mnt/us/koreader" export EIPS_NO_SLEEP="true" # Load our helper functions... -if [ -f "${KOREADER_DIR}/libkohelper.sh" ] ; then - # shellcheck source=/dev/null - . "${KOREADER_DIR}/libkohelper.sh" +if [ -f "${KOREADER_DIR}/libkohelper.sh" ]; then + # shellcheck source=/dev/null + . "${KOREADER_DIR}/libkohelper.sh" else - echo "Can't source helper functions, aborting!" - exit 1 + echo "Can't source helper functions, aborting!" + exit 1 fi ## First arg is the chekpoint number, and we get one every 200 checkpoints. @@ -20,11 +20,11 @@ CHECKPOINT_NUM="${1}" CHECKPOINT_GRANULARITY="200" # Use that to build a poor man's progress bar, with dots. -PROGRESS_AMOUNT="$(( CHECKPOINT_NUM / CHECKPOINT_GRANULARITY ))" +PROGRESS_AMOUNT="$((CHECKPOINT_NUM / CHECKPOINT_GRANULARITY))" PROGRESS_STRING="Updating koreader " -for _ in $( seq 1 ${PROGRESS_AMOUNT} ) ; do - # Append a dot until we hit the needed amount - PROGRESS_STRING="${PROGRESS_STRING}." +for _ in $(seq 1 ${PROGRESS_AMOUNT}); do + # Append a dot until we hit the needed amount + PROGRESS_STRING="${PROGRESS_STRING}." done # Print our progress :) diff --git a/platform/kindle/libkohelper.sh b/platform/kindle/libkohelper.sh index 070e620b6..8a32f50f7 100644 --- a/platform/kindle/libkohelper.sh +++ b/platform/kindle/libkohelper.sh @@ -2,131 +2,130 @@ ## A bit of helper functions... # Check which type of init system we're running on -if [ -d /etc/upstart ] ; then - export INIT_TYPE="upstart" - # We'll need that for logging - # shellcheck disable=SC1091 - [ -f /etc/upstart/functions ] && . /etc/upstart/functions +if [ -d /etc/upstart ]; then + export INIT_TYPE="upstart" + # We'll need that for logging + # shellcheck disable=SC1091 + [ -f /etc/upstart/functions ] && . /etc/upstart/functions else - export INIT_TYPE="sysv" - # We'll need that for logging - # shellcheck disable=SC1091 - [ -f /etc/rc.d/functions ] && . /etc/rc.d/functions + export INIT_TYPE="sysv" + # We'll need that for logging + # shellcheck disable=SC1091 + [ -f /etc/rc.d/functions ] && . /etc/rc.d/functions fi # We need to get the proper constants for our model... kmodel="$(cut -c3-4 /proc/usid)" case "${kmodel}" in - "13" | "54" | "2A" | "4F" | "52" | "53" ) - # Voyage... - SCREEN_X_RES=1088 # NOTE: Yes, 1088, not 1072 or 1080... - SCREEN_Y_RES=1448 - EIPS_X_RES=16 - EIPS_Y_RES=24 # Manually mesured, should be accurate. - ;; - "24" | "1B" | "1D" | "1F" | "1C" | "20" | "D4" | "5A" | "D5" | "D6" | "D7" | "D8" | "F2" | "17" | "60" | "F4" | "F9" | "62" | "61" | "5F" ) - # PaperWhite... - SCREEN_X_RES=768 # NOTE: Yes, 768, not 758... - SCREEN_Y_RES=1024 - EIPS_X_RES=16 - EIPS_Y_RES=24 # Manually mesured, should be accurate. - ;; - "C6" | "DD" ) - # KT2... - SCREEN_X_RES=608 - SCREEN_Y_RES=800 - EIPS_X_RES=16 - EIPS_Y_RES=24 - ;; - "0F" | "11" | "10" | "12" ) - # Touch - SCREEN_X_RES=600 # _v_width @ upstart/functions - SCREEN_Y_RES=800 # _v_height @ upstart/functions - EIPS_X_RES=12 # from f_puts @ upstart/functions - EIPS_Y_RES=20 # from f_puts @ upstart/functions - ;; - * ) - # Handle legacy devices... - if [ -f "/etc/rc.d/functions" ] && grep "EIPS" "/etc/rc.d/functions" > /dev/null 2>&1 ; then - # Already done... - #. /etc/rc.d/functions - echo "foo" >/dev/null - else - # Try the new device ID scheme... - kmodel="$(cut -c4-6 /proc/usid)" - case "${kmodel}" in - "0G1" | "0G2" | "0G4" | "0G5" | "0G6" | "0G7" | "0KB" | "0KC" | "0KD" | "0KE" | "0KF" | "0KG" ) - # PW3... NOTE: Hopefully matches the KV... - SCREEN_X_RES=1088 - SCREEN_Y_RES=1448 - EIPS_X_RES=16 - EIPS_Y_RES=24 - ;; - "0GC" | "0GD" | "0GP" | "0GQ" | "0GR" | "0GS" ) - # Oasis... NOTE: Hopefully matches the KV... - SCREEN_X_RES=1088 - SCREEN_Y_RES=1448 - EIPS_X_RES=16 - EIPS_Y_RES=24 - ;; - "0DT" | "0K9" | "0KA" ) - # KT3... NOTE: Hopefully matches the KT2... - SCREEN_X_RES=608 - SCREEN_Y_RES=800 - EIPS_X_RES=16 - EIPS_Y_RES=24 - ;; - * ) - # Fallback... We shouldn't ever hit that. - SCREEN_X_RES=600 - SCREEN_Y_RES=800 - EIPS_X_RES=12 - EIPS_Y_RES=20 - ;; - esac - fi - ;; + "13" | "54" | "2A" | "4F" | "52" | "53") + # Voyage... + SCREEN_X_RES=1088 # NOTE: Yes, 1088, not 1072 or 1080... + SCREEN_Y_RES=1448 + EIPS_X_RES=16 + EIPS_Y_RES=24 # Manually mesured, should be accurate. + ;; + "24" | "1B" | "1D" | "1F" | "1C" | "20" | "D4" | "5A" | "D5" | "D6" | "D7" | "D8" | "F2" | "17" | "60" | "F4" | "F9" | "62" | "61" | "5F") + # PaperWhite... + SCREEN_X_RES=768 # NOTE: Yes, 768, not 758... + SCREEN_Y_RES=1024 + EIPS_X_RES=16 + EIPS_Y_RES=24 # Manually mesured, should be accurate. + ;; + "C6" | "DD") + # KT2... + SCREEN_X_RES=608 + SCREEN_Y_RES=800 + EIPS_X_RES=16 + EIPS_Y_RES=24 + ;; + "0F" | "11" | "10" | "12") + # Touch + SCREEN_X_RES=600 # _v_width @ upstart/functions + SCREEN_Y_RES=800 # _v_height @ upstart/functions + EIPS_X_RES=12 # from f_puts @ upstart/functions + EIPS_Y_RES=20 # from f_puts @ upstart/functions + ;; + *) + # Handle legacy devices... + if [ -f "/etc/rc.d/functions" ] && grep "EIPS" "/etc/rc.d/functions" >/dev/null 2>&1; then + # Already done... + #. /etc/rc.d/functions + echo "foo" >/dev/null + else + # Try the new device ID scheme... + kmodel="$(cut -c4-6 /proc/usid)" + case "${kmodel}" in + "0G1" | "0G2" | "0G4" | "0G5" | "0G6" | "0G7" | "0KB" | "0KC" | "0KD" | "0KE" | "0KF" | "0KG") + # PW3... NOTE: Hopefully matches the KV... + SCREEN_X_RES=1088 + SCREEN_Y_RES=1448 + EIPS_X_RES=16 + EIPS_Y_RES=24 + ;; + "0GC" | "0GD" | "0GP" | "0GQ" | "0GR" | "0GS") + # Oasis... NOTE: Hopefully matches the KV... + SCREEN_X_RES=1088 + SCREEN_Y_RES=1448 + EIPS_X_RES=16 + EIPS_Y_RES=24 + ;; + "0DT" | "0K9" | "0KA") + # KT3... NOTE: Hopefully matches the KT2... + SCREEN_X_RES=608 + SCREEN_Y_RES=800 + EIPS_X_RES=16 + EIPS_Y_RES=24 + ;; + *) + # Fallback... We shouldn't ever hit that. + SCREEN_X_RES=600 + SCREEN_Y_RES=800 + EIPS_X_RES=12 + EIPS_Y_RES=20 + ;; + esac + fi + ;; esac # And now we can do the maths ;) EIPS_MAXCHARS="$((SCREEN_X_RES / EIPS_X_RES))" EIPS_MAXLINES="$((SCREEN_Y_RES / EIPS_Y_RES))" # Adapted from libkh[5] -eips_print_bottom_centered() -{ - # We need at least two args - if [ $# -lt 2 ] ; then - echo "not enough arguments passed to eips_print_bottom ($# while we need at least 2)" - return - fi +eips_print_bottom_centered() { + # We need at least two args + if [ $# -lt 2 ]; then + echo "not enough arguments passed to eips_print_bottom ($# while we need at least 2)" + return + fi - kh_eips_string="${1}" - kh_eips_y_shift_up="${2}" + kh_eips_string="${1}" + kh_eips_y_shift_up="${2}" - # Get the real string length now - kh_eips_strlen="${#kh_eips_string}" + # Get the real string length now + kh_eips_strlen="${#kh_eips_string}" - # 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))" + # 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))" - # Left padding... - while [ ${#kh_eips_string} -lt $((kh_eips_strlen + kh_padlen)) ] ; do - kh_eips_string=" ${kh_eips_string}" - done + # Left padding... + while [ ${#kh_eips_string} -lt $((kh_eips_strlen + kh_padlen)) ]; do + kh_eips_string=" ${kh_eips_string}" + done - # Right padding (crop to the edge of the screen) - while [ ${#kh_eips_string} -lt ${EIPS_MAXCHARS} ] ; do - kh_eips_string="${kh_eips_string} " - done + # Right padding (crop to the edge of the screen) + while [ ${#kh_eips_string} -lt ${EIPS_MAXCHARS} ]; do + kh_eips_string="${kh_eips_string} " + done - # Sleep a tiny bit to workaround the logic in the 'new' (K4+) eInk controllers that tries to bundle updates, - # otherwise it may drop part of our messages because of other screen updates from KUAL... - # Unless we really don't want to sleep, for special cases... - if [ ! -n "${EIPS_NO_SLEEP}" ] ; then - usleep 150000 # 150ms - fi + # Sleep a tiny bit to workaround the logic in the 'new' (K4+) eInk controllers that tries to bundle updates, + # otherwise it may drop part of our messages because of other screen updates from KUAL... + # Unless we really don't want to sleep, for special cases... + if [ ! -n "${EIPS_NO_SLEEP}" ]; then + usleep 150000 # 150ms + 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 + # 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 } diff --git a/platform/kobo/disable-wifi.sh b/platform/kobo/disable-wifi.sh index 7c602b9d4..d59ece1b8 100644 --- a/platform/kobo/disable-wifi.sh +++ b/platform/kobo/disable-wifi.sh @@ -9,11 +9,11 @@ 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}" fi -if lsmod | grep -q sdio_wifi_pwr ; then +if lsmod | grep -q sdio_wifi_pwr; then usleep 200000 rmmod -r sdio_wifi_pwr fi diff --git a/platform/kobo/enable-wifi.sh b/platform/kobo/enable-wifi.sh index fa75a8fdf..2c0acc54a 100644 --- a/platform/kobo/enable-wifi.sh +++ b/platform/kobo/enable-wifi.sh @@ -10,6 +10,6 @@ sleep 1 ifconfig eth0 up wlarm_le -i eth0 up -pidof wpa_supplicant >/dev/null || \ - env -u LD_LIBRARY_PATH \ - wpa_supplicant -D wext -s -ieth0 -O /var/run/wpa_supplicant -c/etc/wpa_supplicant/wpa_supplicant.conf -B +pidof wpa_supplicant >/dev/null \ + || env -u LD_LIBRARY_PATH \ + wpa_supplicant -D wext -s -ieth0 -O /var/run/wpa_supplicant -c/etc/wpa_supplicant/wpa_supplicant.conf -B diff --git a/platform/kobo/koreader.sh b/platform/kobo/koreader.sh index 9a98e3f3c..98a7835d2 100755 --- a/platform/kobo/koreader.sh +++ b/platform/kobo/koreader.sh @@ -7,9 +7,9 @@ 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 - # TODO: any graphic indication for the updating progress? - cd "${KOREADER_DIR%/*}" && tar xf "${NEWUPDATE}" && mv "${NEWUPDATE}" "${INSTALLED}" +if [ -f "${NEWUPDATE}" ]; then + # TODO: any graphic indication for the updating progress? + cd "${KOREADER_DIR%/*}" && tar xf "${NEWUPDATE}" && mv "${NEWUPDATE}" "${INSTALLED}" fi # we're always starting from our working directory @@ -31,138 +31,138 @@ export EXT_FONT_DIR="/mnt/onboard/fonts" # through fmon, or from another launcher (KSM or advboot) # Do not delete this line because KSM detects newer versions of KOReader by the presence of the phrase 'from_nickel'. export FROM_NICKEL="false" -if pkill -0 nickel ; then - FROM_NICKEL="true" +if pkill -0 nickel; then + FROM_NICKEL="true" fi -if [ "${FROM_NICKEL}" = "true" ] ; then - # Detect if we were started from KFMon - FROM_KFMON="false" - if pkill -0 kfmon ; then - # That's a start, now check if KFMon truly is our parent... - if [ "$(pidof kfmon)" -eq "${PPID}" ] ; then - FROM_KFMON="true" - fi - fi - - 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 - # 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)" - export DBUS_SESSION_BUS_ADDRESS WIFI_MODULE PLATFORM WIFI_MODULE_PATH INTERFACE PRODUCT - fi - - # flush disks, might help avoid trashing nickel's DB... - sync - # Double the fun! - sleep 1 - sync - # stop kobo software because it's running - killall nickel hindenburg sickel fickel fmon 2>/dev/null - - # NOTE: Not particularly critical, we should be safe leaving it up, but since we reboot on exit anyway... - # Keep KFMon up for now to make sure it's not doing anything overly stupid we might have overlooked ;). - #if [ "${FROM_KFMON}" == "true" ] ; then - # killall kfmon 2>/dev/null - #fi +if [ "${FROM_NICKEL}" = "true" ]; then + # Detect if we were started from KFMon + FROM_KFMON="false" + if pkill -0 kfmon; then + # That's a start, now check if KFMon truly is our parent... + if [ "$(pidof kfmon)" -eq "${PPID}" ]; then + FROM_KFMON="true" + fi + fi + + 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 + # 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)" + export DBUS_SESSION_BUS_ADDRESS WIFI_MODULE PLATFORM WIFI_MODULE_PATH INTERFACE PRODUCT + fi + + # flush disks, might help avoid trashing nickel's DB... + sync + # Double the fun! + sleep 1 + sync + # stop kobo software because it's running + killall nickel hindenburg sickel fickel fmon 2>/dev/null + + # NOTE: Not particularly critical, we should be safe leaving it up, but since we reboot on exit anyway... + # Keep KFMon up for now to make sure it's not doing anything overly stupid we might have overlooked ;). + #if [ "${FROM_KFMON}" == "true" ] ; then + # killall kfmon 2>/dev/null + #fi fi # fallback for old fmon (and advboot) users (-> if no args were passed to the sript, start the FM) -if [ "$#" -eq 0 ] ; then - args="/mnt/onboard" +if [ "$#" -eq 0 ]; then + args="/mnt/onboard" else - args="$*" + args="$*" fi # check whether PLATFORM & PRODUCT have a value assigned by rcS -if [ ! -n "${PRODUCT}" ] ; then - PRODUCT="$(/bin/kobo_config.sh 2>/dev/null)" - export PRODUCT +if [ ! -n "${PRODUCT}" ]; then + PRODUCT="$(/bin/kobo_config.sh 2>/dev/null)" + export PRODUCT fi # PLATFORM is used in koreader for the path to the WiFi drivers -if [ ! -n "${PLATFORM}" ] ; then - PLATFORM="freescale" - if dd if="/dev/mmcblk0" bs=512 skip=1024 count=1 | grep -q "HW CONFIG" ; then - CPU="$(ntx_hwconfig -s -p /dev/mmcblk0 CPU 2>/dev/null)" - PLATFORM="${CPU}-ntx" - fi - - if [ "${PLATFORM}" = "freescale" ] ; then - if [ ! -s "/lib/firmware/imx/epdc_E60_V220.fw" ] ; then - mkdir -p "/lib/firmware/imx" - dd if="/dev/mmcblk0" bs=512K skip=10 count=1 | zcat > "/lib/firmware/imx/epdc_E60_V220.fw" - sync - fi - elif [ ! -e "/etc/u-boot/${PLATFORM}/u-boot.mmc" ] ; then - PLATFORM="ntx508" - fi - export PLATFORM +if [ ! -n "${PLATFORM}" ]; then + PLATFORM="freescale" + if dd if="/dev/mmcblk0" bs=512 skip=1024 count=1 | grep -q "HW CONFIG"; then + CPU="$(ntx_hwconfig -s -p /dev/mmcblk0 CPU 2>/dev/null)" + PLATFORM="${CPU}-ntx" + fi + + if [ "${PLATFORM}" = "freescale" ]; then + if [ ! -s "/lib/firmware/imx/epdc_E60_V220.fw" ]; then + mkdir -p "/lib/firmware/imx" + dd if="/dev/mmcblk0" bs=512K skip=10 count=1 | zcat >"/lib/firmware/imx/epdc_E60_V220.fw" + sync + fi + elif [ ! -e "/etc/u-boot/${PLATFORM}/u-boot.mmc" ]; then + PLATFORM="ntx508" + fi + export PLATFORM fi # end of value check of PLATFORM # Remount the SD card RW if it's inserted and currently RO -if awk '$4~/(^|,)ro($|,)/' /proc/mounts | grep ' /mnt/sd ' ; then - mount -o remount,rw /mnt/sd +if awk '$4~/(^|,)ro($|,)/' /proc/mounts | grep ' /mnt/sd '; then + mount -o remount,rw /mnt/sd fi # we keep maximum 500K worth of crash log if [ -e crash.log ]; then - tail -c 500000 crash.log > crash.log.new - mv -f crash.log.new crash.log + 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 -# 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" + # 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 + # 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 +./reader.lua "${args}" >>crash.log 2>&1 RESULT=$? # 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}" + # 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 - # start kobo software because it was running before koreader - ./nickel.sh & - else - if grep -q 'reboot_on_exit=false' /mnt/onboard/.adds/kfmon/config/koreader.ini 2>/dev/null ; then - # The user wants to try to restart Nickel instead of rebooting! - ./nickel.sh & - else - # By default, if we were called from KFMon, just reboot, because there might be a chance Nickel will get its panties in a serious twist on restore for one reason or another... - # And at best, we'd still restart with slightly broken suspend behavior anyway... - /sbin/reboot - fi - fi +if [ "${FROM_NICKEL}" = "true" ]; then + if [ "${FROM_KFMON}" != "true" ]; then + # start kobo software because it was running before koreader + ./nickel.sh & + else + if grep -q 'reboot_on_exit=false' /mnt/onboard/.adds/kfmon/config/koreader.ini 2>/dev/null; then + # The user wants to try to restart Nickel instead of rebooting! + ./nickel.sh & + else + # By default, if we were called from KFMon, just reboot, because there might be a chance Nickel will get its panties in a serious twist on restore for one reason or another... + # And at best, we'd still restart with slightly broken suspend behavior anyway... + /sbin/reboot + fi + fi else - # if we were called from advboot then we must reboot to go to the menu - # NOTE: This is actually achieved by checking if KSM or a KSM-related script is running: - # This might lead to false-positives if you use neither KSM nor advboot to launch KOReader *without nickel running*. - if ! pgrep -f kbmenu > /dev/null 2>&1 ; then - /sbin/reboot - fi + # if we were called from advboot then we must reboot to go to the menu + # NOTE: This is actually achieved by checking if KSM or a KSM-related script is running: + # This might lead to false-positives if you use neither KSM nor advboot to launch KOReader *without nickel running*. + if ! pgrep -f kbmenu >/dev/null 2>&1; then + /sbin/reboot + fi fi return ${RESULT} diff --git a/platform/kobo/nickel.sh b/platform/kobo/nickel.sh index 73dfaaea0..7e5d655f9 100755 --- a/platform/kobo/nickel.sh +++ b/platform/kobo/nickel.sh @@ -5,20 +5,23 @@ PATH="/sbin:/bin:/usr/sbin:/usr/bin:/usr/lib" cur_rotate="$(cat "/sys/class/graphics/fb0/rotate")" # start fmon again. Note that we don't have to worry about reaping this, nickel kills on-animator.sh on start. -( usleep 400000; /etc/init.d/on-animator.sh ) & +( + usleep 400000 + /etc/init.d/on-animator.sh +) & # environment needed by nickel, from /etc/init.d/rcS: -if [ ! -n "${WIFI_MODULE_PATH}" ] ; then - INTERFACE="wlan0" - WIFI_MODULE="ar6000" - if [ "${PLATFORM}" != "freescale" ] ; then - INTERFACE="eth0" - WIFI_MODULE="dhd" - fi - export INTERFACE - export WIFI_MODULE - export WIFI_MODULE_PATH="/drivers/${PLATFORM}/wifi/${WIFI_MODULE}.ko" +if [ ! -n "${WIFI_MODULE_PATH}" ]; then + INTERFACE="wlan0" + WIFI_MODULE="ar6000" + if [ "${PLATFORM}" != "freescale" ]; then + INTERFACE="eth0" + WIFI_MODULE="dhd" + fi + export INTERFACE + export WIFI_MODULE + export WIFI_MODULE_PATH="/drivers/${PLATFORM}/wifi/${WIFI_MODULE}.ko" fi export NICKEL_HOME="/mnt/onboard/.kobo" @@ -28,13 +31,13 @@ export LANG="en_US.UTF-8" # Make sure we kill the WiFi first, because nickel apparently doesn't like it if it's up... (cf. #1520) # NOTE: That check is possibly wrong on PLATFORM == freescale (because I don't know if the sdio_wifi_pwr module exists there), but we don't terribly care about that. -if lsmod | grep -q sdio_wifi_pwr ; then - killall udhcpc default.script wpa_supplicant 2>/dev/null - wlarm_le -i ${INTERFACE} down - ifconfig ${INTERFACE} down - # NOTE: Kobo's busybox build is weird. rmmod appears to be modprobe in disguise, defaulting to the -r flag. If re-specifying -r starts to fail one day, switch to rmmod without args, or modprobe -r. - rmmod -r ${WIFI_MODULE} - rmmod -r sdio_wifi_pwr +if lsmod | grep -q sdio_wifi_pwr; then + killall udhcpc default.script wpa_supplicant 2>/dev/null + wlarm_le -i ${INTERFACE} down + ifconfig ${INTERFACE} down + # NOTE: Kobo's busybox build is weird. rmmod appears to be modprobe in disguise, defaulting to the -r flag. If re-specifying -r starts to fail one day, switch to rmmod without args, or modprobe -r. + rmmod -r ${WIFI_MODULE} + rmmod -r sdio_wifi_pwr fi # Flush buffers to disk, who knows. @@ -46,54 +49,53 @@ sync # NOTE: Since we're not cold booting, this is technically redundant... On the other hand, it doesn't really hurt either ;). ( - /usr/local/Kobo/pickel disable.rtc.alarm + /usr/local/Kobo/pickel disable.rtc.alarm - if [ ! -e "/etc/wpa_supplicant/wpa_supplicant.conf" ] ; then - cp "/etc/wpa_supplicant/wpa_supplicant.conf.template" "/etc/wpa_supplicant/wpa_supplicant.conf" - fi + if [ ! -e "/etc/wpa_supplicant/wpa_supplicant.conf" ]; then + cp "/etc/wpa_supplicant/wpa_supplicant.conf.template" "/etc/wpa_supplicant/wpa_supplicant.conf" + fi - # FWIW, that appears to be gone from recent rcS scripts. AFAICT, still harmless, though. - echo 1 > "/sys/devices/platform/mxc_dvfs_core.0/enable" + # FWIW, that appears to be gone from recent rcS scripts. AFAICT, still harmless, though. + echo 1 >"/sys/devices/platform/mxc_dvfs_core.0/enable" - /sbin/hwclock -s -u + /sbin/hwclock -s -u ) & # Hey there, nickel! -if [ ! -e "/usr/local/Kobo/platforms/libkobo.so" ] ; then - export QWS_KEYBOARD="imx508kbd:/dev/input/event0" - export QT_PLUGIN_PATH="/usr/local/Kobo/plugins" - if [ -e "/usr/local/Kobo/plugins/gfxdrivers/libimxepd.so" ] ; then - export QWS_DISPLAY="imxepd" - else - export QWS_DISPLAY="Transformed:imx508:Rot90" - export QWS_MOUSE_PROTO="tslib_nocal:/dev/input/event1" - fi - # NOTE: Send the output to the void, to avoid spamming the shell with the output of the string of killall commands they periodically send - /usr/local/Kobo/hindenburg > /dev/null 2>&1 & - /usr/local/Kobo/nickel -qws -skipFontLoad > /dev/null 2>&1 & +if [ ! -e "/usr/local/Kobo/platforms/libkobo.so" ]; then + export QWS_KEYBOARD="imx508kbd:/dev/input/event0" + export QT_PLUGIN_PATH="/usr/local/Kobo/plugins" + if [ -e "/usr/local/Kobo/plugins/gfxdrivers/libimxepd.so" ]; then + export QWS_DISPLAY="imxepd" + else + export QWS_DISPLAY="Transformed:imx508:Rot90" + export QWS_MOUSE_PROTO="tslib_nocal:/dev/input/event1" + fi + # NOTE: Send the output to the void, to avoid spamming the shell with the output of the string of killall commands they periodically send + /usr/local/Kobo/hindenburg >/dev/null 2>&1 & + /usr/local/Kobo/nickel -qws -skipFontLoad >/dev/null 2>&1 & else - /usr/local/Kobo/hindenburg > /dev/null 2>&1 & - lsmod | grep -q lowmem || insmod "/drivers/${PLATFORM}/misc/lowmem.ko" & - if grep -q "dhcpcd=true" "/mnt/onboard/.kobo/Kobo/Kobo eReader.conf" ; then - dhcpcd -d -t 10 & - fi - /usr/local/Kobo/nickel -platform kobo -skipFontLoad > /dev/null 2>&1 & + /usr/local/Kobo/hindenburg >/dev/null 2>&1 & + lsmod | grep -q lowmem || insmod "/drivers/${PLATFORM}/misc/lowmem.ko" & + if grep -q "dhcpcd=true" "/mnt/onboard/.kobo/Kobo/Kobo eReader.conf"; then + dhcpcd -d -t 10 & + fi + /usr/local/Kobo/nickel -platform kobo -skipFontLoad >/dev/null 2>&1 & fi # Ahoy, annoying sickel! -if [ -x /usr/local/Kobo/sickel ] ; then - /usr/local/Kobo/sickel -platform kobo:noscreen > /dev/null 2>&1 & +if [ -x /usr/local/Kobo/sickel ]; then + /usr/local/Kobo/sickel -platform kobo:noscreen >/dev/null 2>&1 & fi - # Rotation weirdness, part II -echo "${cur_rotate}" > "/sys/class/graphics/fb0/rotate" +echo "${cur_rotate}" >"/sys/class/graphics/fb0/rotate" # shellcheck disable=SC2094 -cat "/sys/class/graphics/fb0/rotate" > "/sys/class/graphics/fb0/rotate" +cat "/sys/class/graphics/fb0/rotate" >"/sys/class/graphics/fb0/rotate" # Handle sdcard -if [ -e "/dev/mmcblk1p1" ] ; then - echo sd add /dev/mmcblk1p1 >> /tmp/nickel-hardware-status & +if [ -e "/dev/mmcblk1p1" ]; then + echo sd add /dev/mmcblk1p1 >>/tmp/nickel-hardware-status & fi return 0 diff --git a/platform/pocketbook/koreader.app b/platform/pocketbook/koreader.app index 3e027bc91..17f90db92 100755 --- a/platform/pocketbook/koreader.app +++ b/platform/pocketbook/koreader.app @@ -36,12 +36,12 @@ fi # we keep maximum 500K worth of crash log if [ -e crash.log ]; then - tail -c 500000 crash.log > crash.log.new + tail -c 500000 crash.log >crash.log.new mv -f crash.log.new crash.log fi -./reader.lua "${args}" >> crash.log 2>&1 +./reader.lua "${args}" >>crash.log 2>&1 -if pidof reader.lua > /dev/null 2>&1 ; then +if pidof reader.lua >/dev/null 2>&1; then killall -TERM reader.lua fi diff --git a/platform/ubuntu-touch/koreader.sh b/platform/ubuntu-touch/koreader.sh index 9d4c91453..3c5e5efd2 100755 --- a/platform/ubuntu-touch/koreader.sh +++ b/platform/ubuntu-touch/koreader.sh @@ -28,4 +28,3 @@ export EXT_FONT_DIR="${HOME}/fonts" export SDL_FULLSCREEN=1 ./reader.lua -d ~/Documents -