acsm-calibre-plugin/bundle_calibre_plugin.sh

67 lines
1.4 KiB
Bash
Raw Normal View History

2021-09-20 11:24:11 +02:00
#!/bin/bash
2021-09-25 16:24:03 +02:00
[ ! -f calibre-plugin/asn1crypto.zip ] && ./package_modules.sh
[ ! -f calibre-plugin/oscrypto.zip ] && ./package_modules.sh
2021-09-20 11:24:11 +02:00
2022-01-16 17:43:29 +01:00
rm -rf calibre-plugin-tmp || /bin/true
cp -r calibre-plugin calibre-plugin-tmp
pushd calibre-plugin-tmp
pushd keyextract
2021-12-16 22:26:44 +01:00
# 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
2021-09-20 11:24:11 +02:00
2021-12-19 22:13:19 +01:00
# Delete cache
rm -r __pycache__
2022-01-16 18:34:52 +01:00
rm *.pyc
2021-12-19 22:13:19 +01:00
2021-12-16 22:26:44 +01:00
# Set module ID. This needs to be changed if any of the module ZIPs change.
2022-07-31 11:06:21 +02:00
echo -n "2022-07-31-01" > module_id.txt
2021-12-15 10:09:52 +01:00
2022-01-16 10:12:55 +01:00
# Copy LICENSE and README.md so it'll be included in the ZIP.
2021-12-16 22:26:44 +01:00
cp ../LICENSE LICENSE
2022-01-16 10:12:55 +01:00
cp ../README.md README.md
2021-12-16 22:26:44 +01:00
2022-01-16 17:43:29 +01:00
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
2021-12-16 22:26:44 +01:00
# Create ZIP file from calibre-plugin folder.
2021-09-20 11:24:11 +02:00
zip -r ../calibre-plugin.zip *
popd
2022-01-16 17:43:29 +01:00
rm -rf calibre-plugin-tmp
2021-09-20 11:24:11 +02:00