Skip to content

Commit

Permalink
Merge pull request #4 from NiLuJe/master
Browse files Browse the repository at this point in the history
Parse KindleTool devices in shell
  • Loading branch information
notmarek authored Nov 1, 2023
2 parents 6232483 + 6c1781d commit e8054db
Show file tree
Hide file tree
Showing 12 changed files with 65 additions and 203 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/master-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ jobs:
# - run: patch originalHotfix/install-bridge.sh < utils/install-bridge.sh.patch
- run: mv originalHotfix/* newHotfix
- run: mkdir build
- name: "Building hotix universally"
- name: "Building universal hotfix"
run: python ./utils/buildHotfixForAllLangs.py "--universal"
- name: Moving LanguageBreak directory
run: cp LanguageBreak build/ -r
Expand All @@ -47,4 +47,4 @@ jobs:
- uses: actions/upload-artifact@v3
with:
name: LanguageBreak-master
path: ${{ github.workspace }}/build/
path: ${{ github.workspace }}/build/
2 changes: 1 addition & 1 deletion README.MD
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ Thank you to Bluebotlabs for all the help along the way and GeorgeYellow for bri
**Post Jailbreak**

1. After the device has rebooted, type ;uzb into the search bar
2. Connect the device to a PC and copy update_hotfix_languagebreak.bin to the root of the Kindle storage
2. Connect the device to a PC and copy Update_hotfix_languagebreak.bin to the root of the Kindle storage
3. Eject the device and either enter ;dsts or swipe down and select the settings icon to enter the device settings menu
4. Select Update Your Kindle to install the custom hotfix
5. This will take your device out of demo mode and clean up unneeded jailbreak files.
Expand Down
30 changes: 16 additions & 14 deletions build.sh
Original file line number Diff line number Diff line change
@@ -1,35 +1,37 @@
#!/bin/sh -e

rm -rf build
echo "extracting and mounting fw"
echo "* extracting and mounting fw"
./utils/extractAndMountFw.sh &> /dev/null
echo "extracting uks.sqsh from official firmware"
echo "* extracting uks.sqsh from official firmware"
./utils/extractUksFromFirmware.sh &> /dev/null
echo "patching uks.sqsh with the sexy pubdevkey01.pem"
echo "* patching uks.sqsh with the sexy pubdevkey01.pem"
./utils/patchUksSqsh.sh &> /dev/null
echo "extracting hotfix"
./utils/extractHotfix.sh &> /dev/null
echo "* extracting hotfix"
./utils/extractHotfix.sh
rm -rf newHotfix
mkdir newHotfix
# echo "moving patched uks to the new hotfix"
# cp patchedUks.sqsh newHotfix
# echo "patching bridge in the new hotfix" # we don't need to patch it anymore
# $(patch originalHotfix/bridge < utils/bridge.patch) &> /dev/null
# $(patch originalHotfix/install-bridge.sh < utils/install-bridge.sh.patch) &> /dev/null
# patch originalHotfix/bridge < utils/bridge.patch &> /dev/null
# patch originalHotfix/install-bridge.sh < utils/install-bridge.sh.patch &> /dev/null
mv originalHotfix/* newHotfix
mkdir build
rm -rf originalHotfix
echo "building the new hotfix for the devices specified in the official firmware"
python ./utils/buildHotfixForAllLangs.py $1 &> /dev/null
echo "* building the new hotfix for the devices specified in the official firmware"
python ./utils/buildHotfixForAllLangs.py "$1"
./utils/unmountAndDeleteFw.sh
rm -rf newHotfix
echo "moving patched uks to LanguageBreak directory"
cp LanguageBreak build/ -r
echo "* moving patched uks to LanguageBreak directory"
cp -r LanguageBreak build/
cp README.MD build/
cp patchedUks.sqsh build/LanguageBreak
rm -rf patchedUks.sqsh
echo "done language break generated for:"
cat build/DEVICES.txt
echo "* done. language break generated for:"
cat build/DEVICES.txt
cd build
tar -czf ../LanguageBreak.tar.gz .
cd ..
rm -rf build/*
mv LanguageBreak.tar.gz build/
mv LanguageBreak.tar.gz build/
24 changes: 19 additions & 5 deletions utils/buildHotfix.sh
Original file line number Diff line number Diff line change
@@ -1,10 +1,24 @@
#!/bin/sh

# Fall back to the bundled KindleTool if there aren't any in PATH
KINDLETOOL="$(command -v kindletool)"
KINDLETOOL="${KINDLETOOL:-${PWD}/utils/kindletool}"

# Build for unknown devices in create, and print raw device codes in convert
export KT_WITH_UNKNOWN_DEVCODES="1"

if [ "$1" = "universal" ] ; then
DEVICES=$(echo "ALL" | python utils/parseKindleToolDevices.py)
DEVICE_LIST="kindle5"
echo "All the things!" > build/DEVICES.txt
else
DEVICES=$(./utils/kindletool convert update_kindle*.bin --info -k 2>&1 | python utils/parseKindleToolDevices.py)
DEVICE_LIST="$(${KINDLETOOL} convert -i update_kindle*.bin 2>&1 | grep -o "^Device .*" | grep -o "0x[[:xdigit:]]*" | tr "\n" " ")"
${KINDLETOOL} convert -i update_kindle*.bin 2>&1 | grep -o "^Device .*" | sed "s/^Device[[:blank:]]*//" > build/DEVICES.txt
fi
echo $DEVICES
echo "* Building for ${DEVICE_LIST}"
DEVICES=""
for dev in ${DEVICE_LIST} ; do
DEVICES="${DEVICES}-d ${dev} "
done

cd newHotfix
export KT_WITH_UNKNOWN_DEVCODES=1
../utils/kindletool create ota2 $DEVICES -b FC04 -O . ../build/update_hotfix_languagebreak-$2.bin
${KINDLETOOL} create ota2 ${DEVICES} -b FC04 -O -C . "../build/Update_hotfix_languagebreak-${2}.bin"
4 changes: 2 additions & 2 deletions utils/buildHotfixForAllLangs.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/python
#!/usr/bin/env python
from glob import glob
import re
import subprocess
Expand All @@ -21,4 +21,4 @@
linesPatched.append(line.format(lang_code=x))
f.writelines(linesPatched)
os.chmod("newHotfix/install-languagebreak-cleanup.sh", 0o755)
subprocess.Popen(("utils/buildHotfix.sh", "universal" if "--universal" in sys.argv else "", x)).wait()
subprocess.Popen(("utils/buildHotfix.sh", "universal" if "--universal" in sys.argv else "", x)).wait()
149 changes: 0 additions & 149 deletions utils/devices.json

This file was deleted.

10 changes: 8 additions & 2 deletions utils/extractAndMountFw.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
#!/bin/sh

# Fall back to the bundled KindleTool if there aren't any in PATH
KINDLETOOL="$(command -v kindletool)"
KINDLETOOL="${KINDLETOOL:-${PWD}/utils/kindletool}"

rm -rf officialFirmware
./utils/kindletool extract update_kindle*.bin officialFirmware
${KINDLETOOL} extract update_kindle*.bin officialFirmware
gunzip officialFirmware/*rootfs*.img.gz
mkdir mnt
sudo mount -o loop officialFirmware/*rootfs*.img mnt
sudo mount -o loop officialFirmware/*rootfs*.img mnt
10 changes: 8 additions & 2 deletions utils/extractHotfix.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
#!/bin/sh

# Fall back to the bundled KindleTool if there aren't any in PATH
KINDLETOOL="$(command -v kindletool)"
KINDLETOOL="${KINDLETOOL:-${PWD}/utils/kindletool}"

rm -rf originalHotfix
./utils/kindletool extract *hotfix*.bin originalHotfix
rm -rf originalHotfix/*.sig originalHotfix/update-filelist.*
${KINDLETOOL} extract [Uu]pdate_*hotfix*.bin originalHotfix
rm -rfv originalHotfix/*.sig originalHotfix/update-filelist.dat*
4 changes: 3 additions & 1 deletion utils/extractUksFromFirmware.sh
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
cp mnt/etc/uks.sqsh .
#!/bin/sh

cp mnt/etc/uks.sqsh .
23 changes: 0 additions & 23 deletions utils/parseKindleToolDevices.py

This file was deleted.

4 changes: 3 additions & 1 deletion utils/patchUksSqsh.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#!/bin/sh

mkdir mnt
mkdir patchedUks
mkdir mntsqsh
Expand All @@ -15,4 +17,4 @@ rvyJnS2MKLG2cczjlQIDAQAB
EOF
mksquashfs patchedUks patchedUks.sqsh
rm -rf patchedUks
rm -rf uks.sqsh
rm -rf uks.sqsh
4 changes: 3 additions & 1 deletion utils/unmountAndDeleteFw.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#!/bin/sh

sudo umount mnt
rm -rf mnt
rm -rf officialFirmware
rm -rf officialFirmware

0 comments on commit e8054db

Please sign in to comment.