Skip to content

Fix stale jar in /opt breaking KUAL install after factory reset - #12

Open
cakirefekan wants to merge 1 commit into
KindleTweaks:masterfrom
cakirefekan:fix-stale-jar-check
Open

Fix stale jar in /opt breaking KUAL install after factory reset#12
cakirefekan wants to merge 1 commit into
KindleTweaks:masterfrom
cakirefekan:fix-stale-jar-check

Conversation

@cakirefekan

Copy link
Copy Markdown

Fixes #11

Problem

KUAL.sh decides whether to install based solely on whether /opt/amazon/ebook/booklet/KUALBooklet.jar exists. A factory reset wipes appreg.db but does not remove this jar (it lives in the rootfs overlay), so after a factory reset + re-jailbreak, KUAL is left in a broken state: jar present, no registry entry, and no way to trigger reinstall since the source jar in documents/ gets deleted unconditionally either way.

Fix

Extend the install check to also verify the appreg.db registration exists, not just the jar file:

if [ ! -f /opt/amazon/ebook/booklet/KUALBooklet.jar ] || [ "$(sqlite3 /var/local/appreg.db "SELECT COUNT(*) FROM handlerIds WHERE handlerId='com.mobileread.ixtab.kindlelauncher';" 2>/dev/null)" != "1" ]; then

One-line change, everything else untouched.

Tested

  • Fresh install (no jar, no registry entry) — installs and launches correctly, same as before
  • Stale jar + wiped registry (the actual bug, reproduced without a real factory reset) — now correctly reinstalls and launches
  • Already installed (jar + registry both present) — correctly skips install and launches directly, no unnecessary writes

Fixes KindleTweaks#11

## Problem
`KUAL.sh` decides whether to install based solely on whether `/opt/amazon/ebook/booklet/KUALBooklet.jar` exists. A factory reset wipes `appreg.db` but does not remove this jar (it lives in the rootfs overlay), so after a factory reset + re-jailbreak, KUAL is left in a broken state: jar present, no registry entry, and no way to trigger reinstall since the source jar in `documents/` gets deleted unconditionally either way.

## Fix
Extend the install check to also verify the `appreg.db` registration exists, not just the jar file:

```sh
if [ ! -f /opt/amazon/ebook/booklet/KUALBooklet.jar ] || [ "$(sqlite3 /var/local/appreg.db "SELECT COUNT(*) FROM handlerIds WHERE handlerId='com.mobileread.ixtab.kindlelauncher';" 2>/dev/null)" != "1" ]; then
```

One-line change, everything else untouched.

## Tested
- Fresh install (no jar, no registry entry) — installs and launches correctly, same as before
- Stale jar + wiped registry (the actual bug, reproduced without a real factory reset) — now correctly reinstalls and launches
- Already installed (jar + registry both present) — correctly skips install and launches directly, no unnecessary writes
@penguins184

Copy link
Copy Markdown
Contributor

I have a suspicion this is LLM generated due to use of em-dash but LGTM. I'll double check on desktop and then merge.

@Fdiaz96

Fdiaz96 commented Jul 9, 2026

Copy link
Copy Markdown

@cakirefekan you are the goat! i had this problem after factory reset and re-jailbreak could not install kual again.
thanks!!!!!!!!!!

@Alexum45

Copy link
Copy Markdown

Thanks a lot , i had the same issue.
As i only use usb connection and no ssh, i patched manually KUAL.sh (HUAL.jar isn't modified). Then i reinstalled KUAL and it works
KUAL.sh

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Application Error after factory reset + reinstall

4 participants