-
-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathbuild.sh
More file actions
executable file
·126 lines (108 loc) · 4.64 KB
/
Copy pathbuild.sh
File metadata and controls
executable file
·126 lines (108 loc) · 4.64 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
#!/bin/sh
###
# Check admin
##
#if [ $EUID -ne 0 ]; then
# echo "This script must be run as root"
# exit 1
#fi
set -e
# Try sudo
sudo echo
export KT_WITH_UNKNOWN_DEVCODES="1"
###
# Cleanup previous build
###
sudo rm -rf ./build ./build_tmp ./tmp_build_cache
mkdir -p ./build ./build_tmp ./build_cache
###
# Build native stuff
###
echo "* Building natives"
mkdir -p ./src/kmc/armel/lib/
mkdir -p ./src/kmc/armhf/lib/
mkdir -p ./src/kmc/armel/bin/
mkdir -p ./src/kmc/armhf/bin/
echo "* Building sh_integration..."
cd sh_integration
meson setup --buildtype release --cross-file ~/x-tools/arm-kindlepw2-linux-gnueabi/meson-crosscompile.txt builddir_armel
meson setup --buildtype release --cross-file ~/x-tools/arm-kindlehf-linux-gnueabihf/meson-crosscompile.txt builddir_armhf
meson compile -C builddir_armel
meson compile -C builddir_armhf
cd ..
echo "* Copying sh_integration"
for ARCH in armel armhf
do
cp -f "./sh_integration/builddir_${ARCH}/extractor/sh_integration_extractor.so" "./src/kmc/${ARCH}/lib/"
cp -f "./sh_integration/builddir_${ARCH}/launcher/sh_integration_launcher" "./src/kmc/${ARCH}/bin/"
done
echo "* Building fbink..."
cp -rf ./utils/fbink_patch/* ./FBInk/
cd FBInk
meson setup --buildtype release --cross-file ~/x-tools/arm-kindlepw2-linux-gnueabi/meson-crosscompile.txt builddir_armel -Dtarget=Kindle -Dbitmap=enabled -Ddraw=enabled -Dfonts=enabled -Dimage=enabled -Dinputlib=enabled -Dopentype=enabled -Dfbink=enabled -Dinput_scan=enabled -Dfbdepth=enabled
meson setup --buildtype release --cross-file ~/x-tools/arm-kindlehf-linux-gnueabihf/meson-crosscompile.txt builddir_armhf -Dtarget=Kindle -Dbitmap=enabled -Ddraw=enabled -Dfonts=enabled -Dimage=enabled -Dinputlib=enabled -Dopentype=enabled -Dfbink=enabled -Dinput_scan=enabled -Dfbdepth=enabled
meson compile -C builddir_armel
meson compile -C builddir_armhf
cd ..
echo "* Copying FBInk"
for ARCH in armel armhf
do
cp -f "./FBInk/builddir_${ARCH}/libfbink_input.so" "./src/kmc/${ARCH}/lib/"
cp -f "./FBInk/builddir_${ARCH}/libfbink.so" "./src/kmc/${ARCH}/lib/"
cp -f "./FBInk/builddir_${ARCH}/input_scan" "./src/kmc/${ARCH}/bin/"
cp -f "./FBInk/builddir_${ARCH}/fbink" "./src/kmc/${ARCH}/bin/"
cp -f "./FBInk/builddir_${ARCH}/fbdepth" "./src/kmc/${ARCH}/bin/"
done
###
# Generate the updater_keys.sqsh file
# (Based on LanguageBreak hotfix build code from Marek)
###
echo "* Copying source to build dir"
cp -r ./src ./build_tmp/src
echo "* Downloading official firmware from Amazon (PW6)"
if [ ! -f ./build_cache/update_kindle_pw6.bin ]; then
wget https://www.amazon.com/update_KindlePaperwhite_12th_Gen_2024 -q -O ./build_cache/update_kindle_pw6.bin
else
echo "* Official firmware found in cache - SKIPPING"
fi
cp -r build_cache tmp_build_cache
echo "* Extracting and mounting official firmware"
kindletool extract ./build_cache/update_kindle_pw6.bin ./build_tmp/official_firmware
gunzip ./build_tmp/official_firmware/*rootfs*.img.gz
mkdir ./build_tmp/official_firmware_mnt/
sudo mount -o loop ./build_tmp/official_firmware/*rootfs*.img ./build_tmp/official_firmware_mnt/
echo "* Patching UKS SQSH"
mkdir ./build_tmp/patched_uks
mkdir ./build_tmp/mounted_sqsh
if [ -e ./build_tmp/official_firmware_mnt/etc/uks.sqsh ]; then
sudo mount -o loop ./build_tmp/official_firmware_mnt/etc/uks.sqsh ./build_tmp/mounted_sqsh
else
sudo cp -r ./build_tmp/official_firmware_mnt/etc/uks/* ./build_tmp/mounted_sqsh/
fi
cp ./build_tmp/mounted_sqsh/* ./build_tmp/patched_uks/
if [ -e ./build_tmp/official_firmware_mnt/etc/uks.sqsh ]; then
sudo umount ./build_tmp/mounted_sqsh
fi
sudo umount ./build_tmp/official_firmware_mnt/
cat > "./build_tmp/patched_uks/pubdevkey01.pem" << EOF
-----BEGIN PUBLIC KEY-----
MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDJn1jWU+xxVv/eRKfCPR9e47lP
WN2rH33z9QbfnqmCxBRLP6mMjGy6APyycQXg3nPi5fcb75alZo+Oh012HpMe9Lnp
eEgloIdm1E4LOsyrz4kttQtGRlzCErmBGt6+cAVEV86y2phOJ3mLk0Ek9UQXbIUf
rvyJnS2MKLG2cczjlQIDAQAB
-----END PUBLIC KEY-----
EOF
mksquashfs ./build_tmp/patched_uks ./build_tmp/src/mkk/updater_keys.sqsh
echo "* Packing persistent storage folders"
tar -cf ./build_tmp/src/kmc.tar -C ./build_tmp/src/kmc/ .
tar -cf ./build_tmp/src/mkk.tar -C ./build_tmp/src/mkk/ .
rm -rf ./build_tmp/src/kmc
rm -rf ./build_tmp/src/mkk
echo "* Generating device list"
#DEVICE_LIST="$(kindletool convert -i tmp_build_cache/update_kindle*.bin 2>&1 | grep -o "^Device .*" | grep -o "0x[[:xdigit:]]*" | tr "\n" " ")"
#echo $DEVICE_LIST
#DEVICES="$(echo "$DEVICE_LIST" | xargs | sed "s/ / -d /g")"
#echo $DEVICES
echo "* Building Universal Hotfix"
cd ./build_tmp/src
kindletool create ota2 -d kindle4 -d kindle5 -s min -t max -O -C . "../../build/Update_hotfix_universal.bin" -x PackagedBy=Hackerdude