Travis: enforce shellscript coding style

* enormous coding style update

* update luajit-launcher

All changes are formatting only except for:

* new more correct pushd/popd style
	* keeps useful indentation
	* prevents execution of commands when pushd failed (cf. https://github.com/koalaman/shellcheck/wiki/SC2164 and https://github.com/koalaman/shellcheck/issues/863)

```
pushd some_dir && {
    command1
    command2
} || exit
popd
```
pull/2758/head
Frans de Jonge 7 years ago
parent f51285e89b
commit e8c01274f4

@ -17,27 +17,29 @@ if [ "${TRAVIS_PULL_REQUEST}" = false ] && [ "${TRAVIS_BRANCH}" = 'master' ]; th
git clone git@github.com:koreader/doc.git koreader_doc git clone git@github.com:koreader/doc.git koreader_doc
# push doc update # push doc update
pushd doc pushd doc && {
luajit "$(which ldoc)" . 2>/dev/null luajit "$(which ldoc)" . 2>/dev/null
if [ ! -d html ]; then if [ ! -d html ]; then
echo "Failed to generate documents..." echo "Failed to generate documents..."
exit 1 exit 1
fi fi
} || exit
popd popd
cp -r doc/html/* koreader_doc/ cp -r doc/html/* koreader_doc/
pushd koreader_doc pushd koreader_doc && {
git add -A git add -A
echo -e "\n${ANSI_GREEN}Pusing document update..." echo -e "\n${ANSI_GREEN}Pusing document update..."
git -c user.name="KOReader build bot" -c user.email="non-reply@koreader.rocks" \ git -c user.name="KOReader build bot" -c user.email="non-reply@koreader.rocks" \
commit -a --amend -m 'Automated documentation build from travis-ci.' commit -a --amend -m 'Automated documentation build from travis-ci.'
git push -f --quiet origin gh-pages >/dev/null git push -f --quiet origin gh-pages >/dev/null
echo -e "\n${ANSI_GREEN}Documentation update pushed." echo -e "\n${ANSI_GREEN}Documentation update pushed."
} || exit
popd popd
travis_retry make coverage travis_retry make coverage
pushd koreader-*/koreader pushd koreader-*/koreader && {
luajit "$(which luacov-coveralls)" luajit "$(which luacov-coveralls)"
} || exit
popd popd
else else
echo -e "\n${ANSI_GREEN}Not on official master branch, skip documentation update and coverage." echo -e "\n${ANSI_GREEN}Not on official master branch, skip documentation update and coverage."

@ -1,8 +1,8 @@
#!/usr/bin/env bash #!/usr/bin/env bash
# don't do this for clang # don't do this for clang
if [ "$CXX" = "g++" ]; if [ "$CXX" = "g++" ]; then
then export CXX="g++-4.8" CC="gcc-4.8"; export CXX="g++-4.8" CC="gcc-4.8"
fi fi
# in case anything ignores the environment variables, override through PATH # in case anything ignores the environment variables, override through PATH
mkdir bin mkdir bin

@ -13,8 +13,10 @@ for shellscript in "${shellscript_locations[@]}"; do
echo -e "${ANSI_GREEN}Running shellcheck on ${shellscript}" echo -e "${ANSI_GREEN}Running shellcheck on ${shellscript}"
shellcheck "${shellscript}" || SHELLSCRIPT_ERROR=1 shellcheck "${shellscript}" || SHELLSCRIPT_ERROR=1
echo -e "${ANSI_GREEN}Running shfmt on ${shellscript}" 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" if [ "$(cat "${shellscript}")" != "$(shfmt -i 4 "${shellscript}")" ]; then
# @TODO add error handling with something like && shfmt -i 4 "${shellscript}" | diff "${shellscript}" echo -e "${ANSI_RED}Warning: ${shellscript} does not abide by coding style"
shfmt -i 4 "${shellscript}" | diff "${shellscript}" - || SHELLSCRIPT_ERROR=1
fi
done done
exit "${SHELLSCRIPT_ERROR}" exit "${SHELLSCRIPT_ERROR}"

@ -23,10 +23,11 @@ fi
# install our own updated luarocks # install our own updated luarocks
if [ ! -f "${TRAVIS_BUILD_DIR}/install/bin/luarocks" ]; then if [ ! -f "${TRAVIS_BUILD_DIR}/install/bin/luarocks" ]; then
git clone https://github.com/torch/luajit-rocks.git git clone https://github.com/torch/luajit-rocks.git
pushd luajit-rocks pushd luajit-rocks && {
git checkout 6529891 git checkout 6529891
cmake . -DWITH_LUAJIT21=ON -DCMAKE_INSTALL_PREFIX="${TRAVIS_BUILD_DIR}/install" cmake . -DWITH_LUAJIT21=ON -DCMAKE_INSTALL_PREFIX="${TRAVIS_BUILD_DIR}/install"
make install make install
} || exit
popd popd
else else
echo -e "${ANSI_GREEN}Using cached luarocks." echo -e "${ANSI_GREEN}Using cached luarocks."
@ -43,7 +44,7 @@ fi
#install our own updated shellcheck #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" 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 if ! command -v shellcheck; then
curl -sSL "${SHELLCHECK_URL}" | tar --exclude 'SHA256SUMS' --strip-components=1 -C "${HOME}/bin" -xjf -; curl -sSL "${SHELLCHECK_URL}" | tar --exclude 'SHA256SUMS' --strip-components=1 -C "${HOME}/bin" -xjf -
chmod +x "${HOME}/bin/shellcheck" chmod +x "${HOME}/bin/shellcheck"
shellcheck --version shellcheck --version
else else

306
kodev

@ -2,7 +2,7 @@
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 [ "$1" -ne 0 ]; then
if [ ! -z "$2" ]; then if [ ! -z "$2" ]; then
echo "$2" echo "$2"
@ -11,20 +11,19 @@ function assert_ret_zero {
fi fi
} }
function check_submodules { function check_submodules() {
if git submodule status | grep -qE '^\-' if git submodule status | grep -qE '^\-'; then
then
kodev-fetch-thirdparty kodev-fetch-thirdparty
fi fi
} }
function setup_env { function setup_env() {
files=$(ls -d ./koreader-emulator-*/koreader) files=$(ls -d ./koreader-emulator-*/koreader)
assert_ret_zero $? "Emulator not found, please build it first." assert_ret_zero $? "Emulator not found, please build it first."
export EMU_DIR=${files[0]} export EMU_DIR=${files[0]}
} }
function kodev-fetch-thirdparty { function kodev-fetch-thirdparty() {
make fetchthirdparty make fetchthirdparty
} }
@ -41,7 +40,7 @@ SUPPORTED_TARGETS="
win32 win32
" "
function kodev-build { function kodev-build() {
BUILD_HELP_MSG=" BUILD_HELP_MSG="
usage: build <OPTIONS> <TARGET> usage: build <OPTIONS> <TARGET>
@ -57,13 +56,17 @@ ${SUPPORTED_TARGETS}"
VALUE=$(echo "$1" | awk -F= '{print $2}') VALUE=$(echo "$1" | awk -F= '{print $2}')
case $PARAM in case $PARAM in
-v | --verbose) -v | --verbose)
export VERBOSE=1 ;; export VERBOSE=1
;;
-h | --help) -h | --help)
echo "${BUILD_HELP_MSG}"; exit 0 ;; echo "${BUILD_HELP_MSG}"
exit 0
;;
*) *)
echo "ERROR: unknown option \"$PARAM\"" echo "ERROR: unknown option \"$PARAM\""
echo "${BUILD_HELP_MSG}" echo "${BUILD_HELP_MSG}"
exit 1 ;; exit 1
;;
esac esac
shift 1 shift 1
done done
@ -71,40 +74,61 @@ ${SUPPORTED_TARGETS}"
check_submodules check_submodules
case $1 in case $1 in
kindle) kindle)
make TARGET=kindle; assert_ret_zero $? ;; make TARGET=kindle
assert_ret_zero $?
;;
kindle5) kindle5)
make TARGET=kindle5; assert_ret_zero $? ;; make TARGET=kindle5
assert_ret_zero $?
;;
kindlepw2) kindlepw2)
make TARGET=kindlepw2; assert_ret_zero $? ;; make TARGET=kindlepw2
assert_ret_zero $?
;;
kobo) kobo)
make TARGET=kobo; assert_ret_zero $? ;; make TARGET=kobo
assert_ret_zero $?
;;
kindle-legacy) kindle-legacy)
make TARGET=kindle-legacy; assert_ret_zero $? ;; make TARGET=kindle-legacy
assert_ret_zero $?
;;
android) android)
[[ -n ${NDK+x} ]] || export NDK="${CURDIR}/base/toolchain/android-ndk-r12b" [[ -n ${NDK+x} ]] || export NDK="${CURDIR}/base/toolchain/android-ndk-r12b"
[ -e "${CURDIR}/base/toolchain/android-toolchain/bin/arm-linux-androideabi-gcc" ] || { \ [ -e "${CURDIR}/base/toolchain/android-toolchain/bin/arm-linux-androideabi-gcc" ] || {
{ [ -e "${NDK}" ] || make -C "${CURDIR}/base/toolchain" android-ndk; }; \ { [ -e "${NDK}" ] || make -C "${CURDIR}/base/toolchain" android-ndk; }
make android-toolchain; assert_ret_zero $?; \ make android-toolchain
assert_ret_zero $?
} }
echo "Using NDK: ${NDK}..." echo "Using NDK: ${NDK}..."
make TARGET=android; assert_ret_zero $? ;; make TARGET=android
assert_ret_zero $?
;;
pocketbook) pocketbook)
if [ ! -d "${CURDIR}/base/toolchain/pocketbook-toolchain" ]; then if [ ! -d "${CURDIR}/base/toolchain/pocketbook-toolchain" ]; then
make pocketbook-toolchain; assert_ret_zero $? make pocketbook-toolchain
assert_ret_zero $?
fi fi
make TARGET=pocketbook; assert_ret_zero $? ;; make TARGET=pocketbook
assert_ret_zero $?
;;
ubuntu-touch) ubuntu-touch)
make TARGET=ubuntu-touch; assert_ret_zero $? ;; make TARGET=ubuntu-touch
assert_ret_zero $?
;;
win32) win32)
make TARGET=win32; assert_ret_zero $? ;; make TARGET=win32
assert_ret_zero $?
;;
*) *)
make make
assert_ret_zero $? "Failed to build emulator! Try run with -v for more information." assert_ret_zero $? "Failed to build emulator! Try run with -v for more information."
setup_env ;; setup_env
;;
esac esac
} }
function kodev-clean { function kodev-clean() {
CLEAN_HELP_MSG=" CLEAN_HELP_MSG="
usage: clean <TARGET> usage: clean <TARGET>
@ -113,32 +137,44 @@ ${SUPPORTED_TARGETS}"
case $1 in case $1 in
-h | --help) -h | --help)
echo "${CLEAN_HELP_MSG}"; exit 0 ;; echo "${CLEAN_HELP_MSG}"
exit 0
;;
kindle) kindle)
make TARGET=kindle clean ;; make TARGET=kindle clean
;;
kindle5) kindle5)
make TARGET=kindle5 clean ;; make TARGET=kindle5 clean
;;
kindlepw2) kindlepw2)
make TARGET=kindlepw2 clean ;; make TARGET=kindlepw2 clean
;;
kobo) kobo)
make TARGET=kobo clean ;; make TARGET=kobo clean
;;
kindle-legacy) kindle-legacy)
make TARGET=kindle-legacy clean ;; make TARGET=kindle-legacy clean
;;
android) android)
make TARGET=android clean make TARGET=android clean
rm -f ./*.apk ;; rm -f ./*.apk
;;
pocketbook) pocketbook)
make TARGET=pocketbook clean ;; make TARGET=pocketbook clean
;;
ubuntu-touch) ubuntu-touch)
make TARGET=ubuntu-touch clean ;; make TARGET=ubuntu-touch clean
;;
win32) win32)
make TARGET=win32 clean ;; make TARGET=win32 clean
;;
*) *)
make clean ;; make clean
;;
esac esac
} }
function kodev-release { function kodev-release() {
# SUPPORTED_RELEASE_TARGETS=$(echo ${SUPPORTED_TARGETS} | sed 's/win32//') # SUPPORTED_RELEASE_TARGETS=$(echo ${SUPPORTED_TARGETS} | sed 's/win32//')
SUPPORTED_RELEASE_TARGETS="${SUPPORTED_TARGETS/emu*/""}" SUPPORTED_RELEASE_TARGETS="${SUPPORTED_TARGETS/emu*/""}"
RELEASE_HELP_MSG=" RELEASE_HELP_MSG="
@ -146,19 +182,27 @@ usage: release <TARGET>
TARGET: TARGET:
${SUPPORTED_RELEASE_TARGETS}" ${SUPPORTED_RELEASE_TARGETS}"
[ $# -lt 1 ] && { echo "${RELEASE_HELP_MSG}"; exit 1; } [ $# -lt 1 ] && {
echo "${RELEASE_HELP_MSG}"
exit 1
}
while [[ $1 == '-'* ]]; do while [[ $1 == '-'* ]]; do
PARAM=$(echo "$1" | awk -F= '{print $1}') PARAM=$(echo "$1" | awk -F= '{print $1}')
VALUE=$(echo "$1" | awk -F= '{print $2}') VALUE=$(echo "$1" | awk -F= '{print $2}')
case $PARAM in case $PARAM in
-v | --verbose) -v | --verbose)
export VERBOSE=1 ;; export VERBOSE=1
;;
-h | --help) -h | --help)
echo "${RELEASE_HELP_MSG}"; exit 0 ;; echo "${RELEASE_HELP_MSG}"
exit 0
;;
*) *)
echo "ERROR: unknown option \"$PARAM\"" echo "ERROR: unknown option \"$PARAM\""
echo "${RELEASE_HELP_MSG}"; exit 1 ;; echo "${RELEASE_HELP_MSG}"
exit 1
;;
esac esac
shift 1 shift 1
done done
@ -168,51 +212,61 @@ ${SUPPORTED_RELEASE_TARGETS}"
case $1 in case $1 in
kindle) kindle)
kodev-build kindle kodev-build kindle
make TARGET=kindle update ;; make TARGET=kindle update
;;
kindle5) kindle5)
kodev-build kindle5 kodev-build kindle5
make TARGET=kindle5 update ;; make TARGET=kindle5 update
;;
kindlepw2) kindlepw2)
kodev-build kindlepw2 kodev-build kindlepw2
make TARGET=kindlepw2 update ;; make TARGET=kindlepw2 update
;;
kobo) kobo)
kodev-build kobo kodev-build kobo
make TARGET=kobo update ;; make TARGET=kobo update
;;
kindle-legacy) kindle-legacy)
kodev-build kindle-legacy kodev-build kindle-legacy
make TARGET=kindle-legacy update ;; make TARGET=kindle-legacy update
;;
android) android)
kodev-build android kodev-build android
export PATH=$PATH:${CURDIR}/base/toolchain/android-sdk-linux/tools export PATH=$PATH:${CURDIR}/base/toolchain/android-sdk-linux/tools
which android &> /dev/null || { \ which android &>/dev/null || {
make -C "${CURDIR}/base/toolchain" android-sdk; \ make -C "${CURDIR}/base/toolchain" android-sdk
} }
ANDROID_HOME=$(dirname "$(dirname "$(which android)")") ANDROID_HOME=$(dirname "$(dirname "$(which android)")")
export ANDROID_HOME export ANDROID_HOME
export PATH=$PATH:${NDK} export PATH=$PATH:${NDK}
make TARGET=android update ;; make TARGET=android update
;;
pocketbook) pocketbook)
kodev-build pocketbook kodev-build pocketbook
make TARGET=pocketbook update ;; make TARGET=pocketbook update
;;
ubuntu-touch) ubuntu-touch)
kodev-build pocketbook kodev-build pocketbook
make TARGET=ubuntu-touch update ;; make TARGET=ubuntu-touch update
;;
*) *)
echo "Unsupported target for release: $1." echo "Unsupported target for release: $1."
echo "${RELEASE_HELP_MSG}"; exit 1 ;; echo "${RELEASE_HELP_MSG}"
exit 1
;;
esac esac
} }
function kodev-wbuilder() {
function kodev-wbuilder {
kodev-build kodev-build
echo "[*] Running wbuilder.lua..." echo "[*] Running wbuilder.lua..."
pushd "${EMU_DIR}" pushd "${EMU_DIR}" && {
EMULATE_READER_W=540 EMULATE_READER_H=720 ./luajit ./tools/wbuilder.lua EMULATE_READER_W=540 EMULATE_READER_H=720 ./luajit ./tools/wbuilder.lua
} || exit
popd popd
} }
function kodev-run { function kodev-run() {
RUN_HELP_MSG=" RUN_HELP_MSG="
usage: run <OPTIONS> <ARGS> usage: run <OPTIONS> <ARGS>
@ -230,18 +284,26 @@ OPTIONS:
VALUE=$(echo "$1" | awk -F= '{print $2}') VALUE=$(echo "$1" | awk -F= '{print $2}')
case $PARAM in case $PARAM in
--disable-touch) --disable-touch)
export DISABLE_TOUCH=1 ;; export DISABLE_TOUCH=1
;;
--no-build) --no-build)
no_build=true ;; no_build=true
;;
-w | --screen-width) -w | --screen-width)
screen_width=${VALUE} ;; screen_width=${VALUE}
;;
-h | --screen-height) -h | --screen-height)
screen_height=${VALUE} ;; screen_height=${VALUE}
;;
-h | --help) -h | --help)
echo "${RUN_HELP_MSG}"; exit 0 ;; echo "${RUN_HELP_MSG}"
exit 0
;;
*) *)
echo "ERROR: unknown option \"$PARAM\"" echo "ERROR: unknown option \"$PARAM\""
echo "${RUN_HELP_MSG}"; exit 1 ;; echo "${RUN_HELP_MSG}"
exit 1
;;
esac esac
shift shift
done done
@ -259,7 +321,7 @@ OPTIONS:
fi fi
echo "[*] Running KOReader with arguments: $*..." echo "[*] Running KOReader with arguments: $*..."
pushd "${EMU_DIR}" pushd "${EMU_DIR}" && {
if [ $# -lt 1 ]; then if [ $# -lt 1 ]; then
args=${CURDIR}/test args=${CURDIR}/test
else else
@ -269,10 +331,11 @@ OPTIONS:
EMULATE_READER_W=${screen_width} EMULATE_READER_H=${screen_height} \ EMULATE_READER_W=${screen_width} EMULATE_READER_H=${screen_height} \
./reader.lua -d "$args" ./reader.lua -d "$args"
} || exit
popd popd
} }
function kodev-test { function kodev-test() {
TEST_HELP_MSG=" TEST_HELP_MSG="
usage: test <OPTIONS> [front|base] <TEST_NAME> usage: test <OPTIONS> [front|base] <TEST_NAME>
@ -287,17 +350,25 @@ OPTIONS:
VALUE=$(echo "$1" | awk -F= '{print $2}') VALUE=$(echo "$1" | awk -F= '{print $2}')
case $PARAM in case $PARAM in
--tags) --tags)
opts="--tags=${VALUE}" ;; opts="--tags=${VALUE}"
;;
-h | --help) -h | --help)
echo "${TEST_HELP_MSG}"; exit 0 ;; echo "${TEST_HELP_MSG}"
exit 0
;;
*) *)
echo "ERROR: unknown option \"$PARAM\"" echo "ERROR: unknown option \"$PARAM\""
echo "${TEST_HELP_MSG}"; exit 1 ;; echo "${TEST_HELP_MSG}"
exit 1
;;
esac esac
shift shift
done done
[ $# -lt 1 ] && { echo "${TEST_HELP_MSG}"; exit 1; } [ $# -lt 1 ] && {
echo "${TEST_HELP_MSG}"
exit 1
}
[[ $1 != "front" && $1 != "base" ]] && { [[ $1 != "front" && $1 != "base" ]] && {
echo "Invalid test suite: $1!" echo "Invalid test suite: $1!"
echo "${TEST_HELP_MSG}" echo "${TEST_HELP_MSG}"
@ -307,7 +378,7 @@ OPTIONS:
check_submodules && make check_submodules && make
setup_env setup_env
make "${EMU_DIR}/.busted" make "${EMU_DIR}/.busted"
pushd "${EMU_DIR}" pushd "${EMU_DIR}" && {
test_path="./spec/$1/unit" test_path="./spec/$1/unit"
if [ ! -z "$2" ]; then if [ ! -z "$2" ]; then
@ -320,10 +391,11 @@ OPTIONS:
--lazy \ --lazy \
-o "./spec/$1/unit/verbose_print" \ -o "./spec/$1/unit/verbose_print" \
--exclude-tags=notest "${test_path}" --exclude-tags=notest "${test_path}"
} || exit
popd popd
} }
function kodev-cov { function kodev-cov() {
COV_HELP_MSG=" COV_HELP_MSG="
usage: cov <OPTIONS> usage: cov <OPTIONS>
@ -339,14 +411,20 @@ OPTIONS:
VALUE=$(echo "$1" | awk -F= '{print $2}') VALUE=$(echo "$1" | awk -F= '{print $2}')
case $PARAM in case $PARAM in
--full) --full)
show_full=1 ;; show_full=1
;;
--show-previous) --show-previous)
show_previous=1 ;; show_previous=1
;;
-h | --help) -h | --help)
echo "${COV_HELP_MSG}"; exit 0 ;; echo "${COV_HELP_MSG}"
exit 0
;;
*) *)
echo "ERROR: unknown option \"$PARAM\"" echo "ERROR: unknown option \"$PARAM\""
echo "${COV_HELP_MSG}"; exit 1 ;; echo "${COV_HELP_MSG}"
exit 1
;;
esac esac
shift shift
done done
@ -354,7 +432,7 @@ OPTIONS:
check_submodules && make check_submodules && make
setup_env setup_env
make "${EMU_DIR}/.busted" make "${EMU_DIR}/.busted"
pushd "${EMU_DIR}" pushd "${EMU_DIR}" && {
target=front target=front
test_path="./spec/${target}/unit" test_path="./spec/${target}/unit"
if [ ${show_previous} -eq 0 ]; then if [ ${show_previous} -eq 0 ]; then
@ -366,7 +444,7 @@ OPTIONS:
-o "./spec/${target}/unit/verbose_print" \ -o "./spec/${target}/unit/verbose_print" \
--coverage \ --coverage \
--exclude-tags=nocov "${test_path}" || { --exclude-tags=nocov "${test_path}" || {
echo "Failed to run tests!" && exit 1; echo "Failed to run tests!" && exit 1
} }
fi fi
if [ ${show_full} -eq 1 ]; then if [ ${show_full} -eq 1 ]; then
@ -376,11 +454,11 @@ OPTIONS:
+$(($(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 luacov.report.out
fi fi
} || exit
popd popd
} }
function kodev-log() {
function kodev-log {
LOG_HELP_MSG=" LOG_HELP_MSG="
usage: log <TARGET> usage: log <TARGET>
@ -388,21 +466,27 @@ TARGET:
android android
" "
[ $# -lt 1 ] && { echo "${LOG_HELP_MSG}"; exit 1; } [ $# -lt 1 ] && {
echo "${LOG_HELP_MSG}"
exit 1
}
case $1 in case $1 in
-h | --help) -h | --help)
echo "${LOG_HELP_MSG}"; exit 0 ;; echo "${LOG_HELP_MSG}"
exit 0
;;
android) android)
adb logcat 'luajit-launcher:D KOReader:D *:S' ;; adb logcat 'luajit-launcher:D KOReader:D *:S'
;;
*) *)
echo "Unsupported target: $1." echo "Unsupported target: $1."
echo "${LOG_HELP_MSG}"; exit 1 ;; echo "${LOG_HELP_MSG}"
exit 1
;;
esac esac
} }
HELP_MSG=" HELP_MSG="
usage: $0 COMMAND <ARGS> usage: $0 COMMAND <ARGS>
@ -418,41 +502,67 @@ Supported commands:
test Run tests test Run tests
wbuilder Run wbuilder.lua script (useful for building new UI widget) 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 case $1 in
activate) activate)
echo "adding ${CURDIR} to \$PATH..." echo "adding ${CURDIR} to \$PATH..."
export PATH="${PATH}:${CURDIR}" export PATH="${PATH}:${CURDIR}"
eval "$(luarocks path --bin)" eval "$(luarocks path --bin)"
exec "${SHELL}" ;; exec "${SHELL}"
;;
fetch-thirdparty) fetch-thirdparty)
kodev-fetch-thirdparty ;; kodev-fetch-thirdparty
;;
clean) clean)
shift 1; kodev-clean "$@" ;; shift 1
kodev-clean "$@"
;;
build) build)
shift 1; kodev-build "$@" ;; shift 1
kodev-build "$@"
;;
release) release)
shift 1; kodev-release "$@" ;; shift 1
kodev-release "$@"
;;
wbuilder) wbuilder)
kodev-wbuilder ;; kodev-wbuilder
;;
run) run)
shift 1; kodev-run "$@" ;; shift 1
kodev-run "$@"
;;
test) test)
shift 1; kodev-test "$@" ;; shift 1
kodev-test "$@"
;;
cov) cov)
shift 1; kodev-cov "$@" ;; shift 1
kodev-cov "$@"
;;
prompt) prompt)
kodev-build kodev-build
pushd "${EMU_DIR}" pushd "${EMU_DIR}" && {
./luajit -i setupkoenv.lua ./luajit -i setupkoenv.lua
} || exit
popd popd
;; ;;
log) log)
shift 1; kodev-log "$@" ;; shift 1
kodev-log "$@"
;;
--help | -h) --help | -h)
echo "${HELP_MSG}"; exit 0 ;; echo "${HELP_MSG}"
exit 0
;;
*) *)
echo "Unknown command: $1." echo "Unknown command: $1."
echo "${HELP_MSG}"; exit 1 ;; echo "${HELP_MSG}"
exit 1
;;
esac esac

@ -1 +1 @@
Subproject commit 3bdf92c1272d969af5f419492edf760aa2947cf3 Subproject commit 7368ab36138a00b38d643a00c940bd4d02475ad1

@ -17,8 +17,7 @@ else
fi fi
## Handle logging... ## Handle logging...
logmsg() logmsg() {
{
# Use the right tools for the platform # Use the right tools for the platform
if [ "${INIT_TYPE}" = "sysv" ]; then if [ "${INIT_TYPE}" = "sysv" ]; then
msg "koreader: ${1}" "I" msg "koreader: ${1}" "I"
@ -33,8 +32,7 @@ logmsg()
## And now the actual useful stuff! ## And now the actual useful stuff!
# Update koreader # Update koreader
update_koreader() update_koreader() {
{
# Check if we were called by install_koreader... # Check if we were called by install_koreader...
if [ "${1}" = "clean" ]; then if [ "${1}" = "clean" ]; then
do_clean_install="true" do_clean_install="true"
@ -95,15 +93,13 @@ update_koreader()
} }
# Clean install of koreader # Clean install of koreader
install_koreader() install_koreader() {
{
# Let update_koreader do the job for us ;p. # Let update_koreader do the job for us ;p.
update_koreader "clean" update_koreader "clean"
} }
# Handle cre's settings... # Handle cre's settings...
set_cre_prop() set_cre_prop() {
{
# We need at least two args # We need at least two args
if [ $# -lt 2 ]; then if [ $# -lt 2 ]; then
logmsg "not enough arg passed to set_cre_prop" logmsg "not enough arg passed to set_cre_prop"
@ -122,8 +118,7 @@ set_cre_prop()
sed -e "s/$(echo -ne '\r')$//g" -i "${cre_config}" sed -e "s/$(echo -ne '\r')$//g" -i "${cre_config}"
# And finally set the prop # And finally set the prop
if sed -re "s/^(${cre_prop_key})(=)(.*?)$/\1\2${cre_prop_value}/" -i "${cre_config}" if sed -re "s/^(${cre_prop_key})(=)(.*?)$/\1\2${cre_prop_value}/" -i "${cre_config}"; then
then
logmsg "Set ${cre_prop_key} to ${cre_prop_value}" logmsg "Set ${cre_prop_key} to ${cre_prop_value}"
else else
logmsg "Failed to set ${cre_prop_key}" logmsg "Failed to set ${cre_prop_key}"
@ -134,30 +129,24 @@ set_cre_prop()
} }
# Handle CRe's font.hinting.mode # Handle CRe's font.hinting.mode
cre_autohint() cre_autohint() {
{
set_cre_prop "font.hinting.mode" "2" set_cre_prop "font.hinting.mode" "2"
} }
cre_bci() cre_bci() {
{
set_cre_prop "font.hinting.mode" "1" set_cre_prop "font.hinting.mode" "1"
} }
cre_nohinting() cre_nohinting() {
{
set_cre_prop "font.hinting.mode" "0" set_cre_prop "font.hinting.mode" "0"
} }
# Handle CRe's font.kerning.enabled # Handle CRe's font.kerning.enabled
cre_kerning() cre_kerning() {
{
set_cre_prop "font.kerning.enabled" "1" set_cre_prop "font.kerning.enabled" "1"
} }
cre_nokerning() cre_nokerning() {
{
set_cre_prop "font.kerning.enabled" "0" set_cre_prop "font.kerning.enabled" "0"
} }
## Main ## Main
case "${1}" in case "${1}" in
"update_koreader") "update_koreader")

@ -19,8 +19,7 @@ else
fi fi
# Handle logging... # Handle logging...
logmsg() logmsg() {
{
# Use the right tools for the platform # Use the right tools for the platform
if [ "${INIT_TYPE}" = "sysv" ]; then if [ "${INIT_TYPE}" = "sysv" ]; then
msg "koreader: ${1}" "I" msg "koreader: ${1}" "I"

@ -92,8 +92,7 @@ EIPS_MAXCHARS="$((SCREEN_X_RES / EIPS_X_RES))"
EIPS_MAXLINES="$((SCREEN_Y_RES / EIPS_Y_RES))" EIPS_MAXLINES="$((SCREEN_Y_RES / EIPS_Y_RES))"
# Adapted from libkh[5] # Adapted from libkh[5]
eips_print_bottom_centered() eips_print_bottom_centered() {
{
# We need at least two args # We need at least two args
if [ $# -lt 2 ]; then if [ $# -lt 2 ]; then
echo "not enough arguments passed to eips_print_bottom ($# while we need at least 2)" echo "not enough arguments passed to eips_print_bottom ($# while we need at least 2)"

@ -10,6 +10,6 @@ sleep 1
ifconfig eth0 up ifconfig eth0 up
wlarm_le -i eth0 up wlarm_le -i eth0 up
pidof wpa_supplicant >/dev/null || \ pidof wpa_supplicant >/dev/null \
env -u LD_LIBRARY_PATH \ || env -u LD_LIBRARY_PATH \
wpa_supplicant -D wext -s -ieth0 -O /var/run/wpa_supplicant -c/etc/wpa_supplicant/wpa_supplicant.conf -B wpa_supplicant -D wext -s -ieth0 -O /var/run/wpa_supplicant -c/etc/wpa_supplicant/wpa_supplicant.conf -B

@ -5,7 +5,10 @@ PATH="/sbin:/bin:/usr/sbin:/usr/bin:/usr/lib"
cur_rotate="$(cat "/sys/class/graphics/fb0/rotate")" 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. # 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: # environment needed by nickel, from /etc/init.d/rcS:
@ -85,7 +88,6 @@ if [ -x /usr/local/Kobo/sickel ] ; then
/usr/local/Kobo/sickel -platform kobo:noscreen >/dev/null 2>&1 & /usr/local/Kobo/sickel -platform kobo:noscreen >/dev/null 2>&1 &
fi fi
# Rotation weirdness, part II # Rotation weirdness, part II
echo "${cur_rotate}" >"/sys/class/graphics/fb0/rotate" echo "${cur_rotate}" >"/sys/class/graphics/fb0/rotate"
# shellcheck disable=SC2094 # shellcheck disable=SC2094

@ -28,4 +28,3 @@ export EXT_FONT_DIR="${HOME}/fonts"
export SDL_FULLSCREEN=1 export SDL_FULLSCREEN=1
./reader.lua -d ~/Documents ./reader.lua -d ~/Documents

Loading…
Cancel
Save