forked from Leseratte10/acsm-calibre-plugin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
bundle_calibre_plugin.sh
executable file
·74 lines (52 loc) · 1.59 KB
/
bundle_calibre_plugin.sh
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
#!/bin/bash
# Copyright (c) 2021-2023 Leseratte10
# This file is part of the ACSM Input Plugin by Leseratte10
# ACSM Input Plugin for Calibre / acsm-calibre-plugin
#
# For more information, see:
# https://github.com/Leseratte10/acsm-calibre-plugin
[ ! -f calibre-plugin/asn1crypto.zip ] && ./package_modules.sh
[ ! -f calibre-plugin/oscrypto.zip ] && ./package_modules.sh
rm -rf calibre-plugin-tmp || /bin/true
cp -r calibre-plugin calibre-plugin-tmp
pushd calibre-plugin-tmp
pushd keyextract
# Compile C programs:
make
base64 decrypt_win32.exe > decrypt_win32_b64.txt
base64 decrypt_win64.exe > decrypt_win64_b64.txt
# Base64-encode binaries and place them inside decryptor.py:
sed "/@@@CALIBRE_DECRYPTOR_WIN32_B64@@@/ {
r decrypt_win32_b64.txt
d
}" -i ../keyextractDecryptor.py
sed "/@@@CALIBRE_DECRYPTOR_WIN64_B64@@@/ {
r decrypt_win64_b64.txt
d
}" -i ../keyextractDecryptor.py
rm decrypt_win32_b64.txt decrypt_win64_b64.txt
rm decrypt_win32.exe decrypt_win64.exe
popd
# Delete cache
rm -r __pycache__
rm *.pyc
# Set module ID. This needs to be changed if any of the module ZIPs change.
echo -n "2023-12-19-01" > module_id.txt
# Copy LICENSE and README.md so it'll be included in the ZIP.
cp ../LICENSE LICENSE
cp ../README.md README.md
shopt -s globstar
echo "Injecting Python2 compat code ..."
for file in **/*.py;
do
#echo $file
# Inject Python2 compat code:
sed '/#@@CALIBRE_COMPAT_CODE@@/ {
r __calibre_compat_code.py
d
}' -i $file
done
# Create ZIP file from calibre-plugin folder.
zip -r ../calibre-plugin.zip *
popd
rm -rf calibre-plugin-tmp