Skip to content

Commit

Permalink
Remove support for starting Plato from rcS
Browse files Browse the repository at this point in the history
Recent firmwares made this harder to achieve.
  • Loading branch information
baskerville committed Nov 28, 2022
1 parent e08db07 commit d04e8dc
Show file tree
Hide file tree
Showing 9 changed files with 19 additions and 86 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
/hyphenation-patterns
/dictionaries
/dist
/standalone
/bundle
/plato-*.zip
/thirdparty/*/*
!/thirdparty/*/*kobo*
24 changes: 9 additions & 15 deletions standalone.sh → bundle.sh
Original file line number Diff line number Diff line change
@@ -1,23 +1,17 @@
#! /bin/sh

if [ "$#" -lt 2 ] ; then
printf "Usage: %s FIRMWARE_ARCHIVE NICKEL_MENU_ARCHIVE\n" "${0##*/}" >&2
if [ "$#" -lt 1 ] ; then
printf "Usage: %s NICKEL_MENU_ARCHIVE\n" "${0##*/}" >&2
exit 1
fi

[ -d dist ] || ./dist.sh
[ -d standalone ] && rm -Rf standalone
[ -d bundle ] && rm -Rf bundle

FIRMWARE_ARCHIVE=$1
NICKEL_MENU_ARCHIVE=$2
NICKEL_MENU_ARCHIVE=$1

mkdir standalone
cd standalone || exit 1

unzip "$FIRMWARE_ARCHIVE" KoboRoot.tgz
tar -xzvf KoboRoot.tgz ./etc/init.d/rcS
patch -p 1 < ../contrib/firmware.patch || exit 1
rm KoboRoot.tgz
mkdir bundle
cd bundle || exit 1

if gzip -tq "$NICKEL_MENU_ARCHIVE"; then
ln -s "$NICKEL_MENU_ARCHIVE" KoboRoot.tgz
Expand All @@ -34,12 +28,12 @@ mv ../dist .adds/plato
cp ../contrib/NickelMenu/* .adds/nm

mkdir .kobo
tar -czvf .kobo/KoboRoot.tgz etc usr
rm -Rf etc usr
tar -czvf .kobo/KoboRoot.tgz usr
rm -Rf usr

FIRMWARE_VERSION=$(basename "$FIRMWARE_ARCHIVE" .zip)
FIRMWARE_VERSION=${FIRMWARE_VERSION##*-}
PLATO_VERSION=$(cargo pkgid -p plato | cut -d '#' -f 2)

zip -r plato-standalone-"$PLATO_VERSION"-fw_"$FIRMWARE_VERSION".zip .adds .kobo
zip -r plato-bundle-"$PLATO_VERSION".zip .adds .kobo
rm -Rf .adds .kobo
4 changes: 1 addition & 3 deletions contrib/NickelMenu/plato
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
menu_item :main :Reboot in Plato :cmd_output :200:quiet:touch /mnt/onboard/.adds/plato/bootlock
chain_success :power :reboot
menu_item :main :Start Plato :cmd_spawn :quiet:/mnt/onboard/.adds/plato/plato.sh
menu_item :main :Plato :cmd_spawn :quiet:/mnt/onboard/.adds/plato/plato.sh
32 changes: 0 additions & 32 deletions contrib/firmware.patch

This file was deleted.

22 changes: 5 additions & 17 deletions contrib/plato.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,10 @@ PLATO_CONVERT_DICTIONARIES=1
# shellcheck disable=SC1091
[ -e config.sh ] && . config.sh

if [ "$PLATO_STANDALONE" ] ; then
# Stop the animation started by rcS
REM_TRIES=10
while [ "$REM_TRIES" -gt 0 ] ; do
killall on-animator.sh && break
REM_TRIES=$((REM_TRIES-1))
usleep 400000
done
else
# shellcheck disable=SC2046
export $(grep -sE '^(INTERFACE|WIFI_MODULE|DBUS_SESSION_BUS_ADDRESS|NICKEL_HOME|LANG)=' /proc/"$(pidof -s nickel)"/environ)
sync
killall -TERM nickel hindenburg sickel fickel adobehost foxitpdf iink dhcpcd-dbus dhcpcd fmon > /dev/null 2>&1
fi
# shellcheck disable=SC2046
export $(grep -sE '^(INTERFACE|WIFI_MODULE|DBUS_SESSION_BUS_ADDRESS|NICKEL_HOME|LANG)=' /proc/"$(pidof -s nickel)"/environ)
sync
killall -TERM nickel hindenburg sickel fickel adobehost foxitpdf iink dhcpcd-dbus dhcpcd fmon > /dev/null 2>&1

# Turn off the LEDs
# https://www.tablix.org/~avian/blog/archives/2013/03/blinken_kindle/
Expand Down Expand Up @@ -90,16 +80,14 @@ fi

[ "$ORIG_BPP" ] && ./bin/utils/fbdepth -q -d 8

LIBC_FATAL_STDERR_=1 ./plato >> info.log 2>&1 || rm bootlock
LIBC_FATAL_STDERR_=1 ./plato >> info.log 2>&1

[ "$ORIG_BPP" ] && ./bin/utils/fbdepth -q -d "$ORIG_BPP"

if [ -e /tmp/reboot ] ; then
reboot
elif [ -e /tmp/power_off ] ; then
poweroff -f
elif [ "$PLATO_STANDALONE" ] ; then
reboot
else
./nickel.sh &
fi
10 changes: 2 additions & 8 deletions crates/core/src/view/common.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
use std::env;
use std::sync::mpsc;
use chrono::Local;
use crate::device::CURRENT_DEVICE;
Expand Down Expand Up @@ -110,13 +109,8 @@ pub fn toggle_main_menu(view: &mut dyn View, rect: Rectangle, enable: Option<boo
EntryKind::SubMenu("Applications".to_string(), apps),
EntryKind::Separator];

if env::var_os("PLATO_STANDALONE").is_some() {
entries.push(EntryKind::Command("Reboot in Nickel".to_string(), EntryId::RebootInNickel));
entries.push(EntryKind::Command("Reboot".to_string(), EntryId::Reboot));
} else {
entries.push(EntryKind::Command("Reboot".to_string(), EntryId::Reboot));
entries.push(EntryKind::Command("Quit".to_string(), EntryId::Quit));
}
entries.push(EntryKind::Command("Reboot".to_string(), EntryId::Reboot));
entries.push(EntryKind::Command("Quit".to_string(), EntryId::Quit));

if CURRENT_DEVICE.has_page_turn_buttons() {
let button_scheme = context.settings.button_scheme;
Expand Down
1 change: 0 additions & 1 deletion crates/core/src/view/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -575,7 +575,6 @@ pub enum EntryId {
Refresh,
TakeScreenshot,
Reboot,
RebootInNickel,
Quit,
}

Expand Down
1 change: 0 additions & 1 deletion crates/core/src/view/reader/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3884,7 +3884,6 @@ impl View for Reader {
},
Event::Select(EntryId::Quit) |
Event::Select(EntryId::Reboot) |
Event::Select(EntryId::RebootInNickel) |
Event::Back |
Event::Suspend => {
self.quit(context);
Expand Down
9 changes: 1 addition & 8 deletions crates/plato/src/app.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use std::fs::{self, File};
use std::fs::File;
use std::env;
use std::thread;
use std::process::Command;
Expand Down Expand Up @@ -951,13 +951,6 @@ pub fn run() -> Result<(), Error> {
Event::Select(EntryId::Quit) => {
break;
},
Event::Select(EntryId::RebootInNickel) => {
fs::remove_file("bootlock").map_err(|e| {
eprintln!("Couldn't remove the bootlock file: {:#}.", e);
}).ok();
exit_status = ExitStatus::Reboot;
break;
},
Event::MightSuspend if context.settings.auto_suspend > 0 => {
if context.shared || tasks.iter().any(|task| task.id == TaskId::PrepareSuspend ||
task.id == TaskId::Suspend) {
Expand Down

0 comments on commit d04e8dc

Please sign in to comment.