-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.sh
executable file
·190 lines (157 loc) · 7.83 KB
/
build.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
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
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
#!/bin/sh
set -e # stop on first error
if [ "${1}" = "SKIP_COMICS" ]
then
echo command line SKIP_COMICS
SKIP_COMICS=true
fi
echo about to generate test media
echo 'REQUIRES pandoc - known to work with version 2.7.3 (issues with 1.19.2.4)'
# pandoc 1.19.2.4 - use SKIP_PANDOC_EOL (no issue with FB2 links)
# pandoc: unrecognized option `--eol=lf'
# pandoc 2.5 - no workaround other than removing two href links from source_test_book_fb2.fb2
# Couldn't parse FB2 file: link without required href.
echo pandoc check...
pandoc --version
echo REQUIRES zip
echo REQUIRES tar
echo REQUIRES 7z
echo REQUIRES rar
# TODO hand crafted html
# TODO hand crafted html with embedded images (of different formats; png, gif, jpg, svg, webp)
# TODO mobi
# TODO prc/pdb? https://github.com/clach04/pyrite-publisher
# TODO azw
# TODO azw3
echo Text formats
cp test_book.md test_book_md.md
cp test_book.md test_book_txt.txt
if [ -z "${SKIP_PANDOC_EOL}" ]
then
# skip for VERY old versions of pandoc (e.g. 1.19.2.4)
pandoc -s -o test_book_txt_lf_unix.txt --eol=lf test_book_md.md
pandoc -s -o test_book_txt_crlf_win.txt --eol=crlf test_book_md.md
else
echo SKIPping different EOL
fi
echo HTML format
# add -s for all textual formats e.g. html, fb2.... BUT especially RTF (required for that)
echo TODO add auto TOC generation when possible
pandoc -s -o test_book_html.html test_book.md
echo Microsoft doc related
#pandoc -o test_book.rtf test_book.md # does not generate correct RTF (unlike other formats with Pandoc), missing head/template - see https://github.com/jgm/pandoc/issues/857 and https://github.com/jgm/pandoc/issues/2140
pandoc -s -o test_book_rtf.rtf test_book.md
pandoc -s -o test_book_odt.odt test_book.md
pandoc -s -o test_book_docx.docx test_book.md
if [ -z "${SKIP_PDF}" ]
then
echo PDF format
pandoc -s -o test_book_pdf.pdf --metadata title=test_book_pdf --pdf-engine wkhtmltopdf test_book.md
pandoc -s -o test_book_pdf_more_detail.pdf --pdf-engine wkhtmltopdf source_test_book_fb2.fb2
else
echo SKIPping PDF
fi
echo ebook formats
pandoc -s -o test_book_fb2.fb2 test_book.md
pandoc -s -o test_book_epub.epub --metadata title=test_book_epub test_book.md
pandoc -s -o test_book_epub_more_detail.epub source_test_book_fb2.fb2
#pandoc -s -o test_book.mobi test_book.md # generates html!?
#which 7z || alias 7z=p7zi
myzip()
{
echo myzip tool zip ${*}
#zip ${*}
#return
# NOTE 7z defaults to creating 7z file if filename does not end in .ZIP
# this function MUST create zip/pkzip files - if using 7z binary use .zip and then rename
#7z a ${*}
archive_name=${1}
shift
7z a ${archive_name}.zip ${*}
mv ${archive_name}.zip ${archive_name}
}
myzip_uncompressed()
{
echo myzip_uncompressed tool zip ${*}
# do not use 7z if file name does not end in .ZIP
# this function MUST create zip/pkzip files - is using 7z use .zip and then rename
zip -0 ${*}
}
my7z()
{
# 7z takes different arguments to p7zip
7z a ${*}
}
my7z_uncompressed()
{
# 7z takes different arguments to p7zip
7z a -mx0 ${*}
}
myrar()
{
# m<0..5> Set compression level (0-store...3-default...5-maximal)
rar a ${*}
}
myrar_uncompressed()
{
rar a -m0 ${*}
}
echo ZIP compressed books
# NOTE files named for use with koreader which requires specific filenames
# see:
# - https://github.com/koreader/koreader/issues/9986
# - https://github.com/koreader/koreader/wiki/ZIP
# ensure zip and format is in the file name for tools that hide file extensions
#
myzip test_book_md_zip.md.zip test_book_md.md
myzip test_book_txt_zip.txt.zip test_book_txt.txt
myzip test_book_rtf_zip.rtf.zip test_book_rtf.rtf
myzip test_book_html_zip.html.zip test_book_html.html
myzip test_book_fb2_zip.fb2.zip test_book_fb2.fb2
myzip source_test_book_fb2_zip.fbz source_test_book_fb2.fb2
myzip source_test_book_fb2_dot_zip.fb2.zip source_test_book_fb2.fb2
# Comics
create_comics()
{
base_comic_name=$1
shift
myzip ${base_comic_name}.cbz ${*}
my7z ${base_comic_name}.cb7 ${*}
myzip_uncompressed ${base_comic_name}_uncompressed.cbz ${*}
my7z_uncompressed ${base_comic_name}_uncompressed.cb7 ${*}
tar -cvf ${base_comic_name}.cbt ${*}
myrar ${base_comic_name}.cbr ${*}
myrar_uncompressed ${base_comic_name}_uncompressed.cbr ${*}
}
if [ -z "${SKIP_COMICS}" ]
then
#if [ ! -f "Elf Receiver Radio-Craft August 1936.cbz" ]
if [ ! -f Elf_Receiver_Radio-Craft_August_1936.cbz ]
then
# From https://www.contrapositivediary.com/?p=1197
wget "http://www.copperwood.com/pub/Elf%20Receiver%20Radio-Craft%20August%201936.cbz" # download with original name
mv "Elf Receiver Radio-Craft August 1936.cbz" Elf_Receiver_Radio-Craft_August_1936.cbz
fi
# FIXME use create_comics instead
myzip bobby_make_believe_sample_dir.cbz images/bobby_make_believe/Bobby-Make-Believe_1915__0.jpg images/bobby_make_believe/Bobby-Make-Believe_1915__1.jpg images/bobby_make_believe/Bobby-Make-Believe_1915__2.jpg images/bobby_make_believe/Bobby-Make-Believe_1915__3.jpg
my7z bobby_make_believe_sample_dir.cb7 images/bobby_make_believe/Bobby-Make-Believe_1915__0.jpg images/bobby_make_believe/Bobby-Make-Believe_1915__1.jpg images/bobby_make_believe/Bobby-Make-Believe_1915__2.jpg images/bobby_make_believe/Bobby-Make-Believe_1915__3.jpg
myzip_uncompressed bobby_make_believe_sample_dir_uncompressed.cbz images/bobby_make_believe/Bobby-Make-Believe_1915__0.jpg images/bobby_make_believe/Bobby-Make-Believe_1915__1.jpg images/bobby_make_believe/Bobby-Make-Believe_1915__2.jpg images/bobby_make_believe/Bobby-Make-Believe_1915__3.jpg
my7z_uncompressed bobby_make_believe_sample_dir_uncompressed.cb7 images/bobby_make_believe/Bobby-Make-Believe_1915__0.jpg images/bobby_make_believe/Bobby-Make-Believe_1915__1.jpg images/bobby_make_believe/Bobby-Make-Believe_1915__2.jpg images/bobby_make_believe/Bobby-Make-Believe_1915__3.jpg
tar -cvf bobby_make_believe_sample_dir.cbt images/bobby_make_believe/Bobby-Make-Believe_1915__0.jpg images/bobby_make_believe/Bobby-Make-Believe_1915__1.jpg images/bobby_make_believe/Bobby-Make-Believe_1915__2.jpg images/bobby_make_believe/Bobby-Make-Believe_1915__3.jpg
create_comics mono_numbered_png_dir images/mono_numbered_png/01.png images/mono_numbered_png/02.png images/mono_numbered_png/03.png images/mono_numbered_png/04.png images/mono_numbered_png/05.png images/mono_numbered_png/06.png images/mono_numbered_png/07.png images/mono_numbered_png/08.png images/mono_numbered_png/09.png images/mono_numbered_png/10.png
cd images/bobby_make_believe/
myzip ../../bobby_make_believe_sample.cbz Bobby-Make-Believe_1915__0.jpg Bobby-Make-Believe_1915__1.jpg Bobby-Make-Believe_1915__2.jpg Bobby-Make-Believe_1915__3.jpg
my7z ../../bobby_make_believe_sample.cb7 Bobby-Make-Believe_1915__0.jpg Bobby-Make-Believe_1915__1.jpg Bobby-Make-Believe_1915__2.jpg Bobby-Make-Believe_1915__3.jpg
myzip_uncompressed ../../bobby_make_believe_sample_uncompressed.cbz Bobby-Make-Believe_1915__0.jpg Bobby-Make-Believe_1915__1.jpg Bobby-Make-Believe_1915__2.jpg Bobby-Make-Believe_1915__3.jpg
my7z_uncompressed ../../bobby_make_believe_sample_uncompressed.cb7 Bobby-Make-Believe_1915__0.jpg Bobby-Make-Believe_1915__1.jpg Bobby-Make-Believe_1915__2.jpg Bobby-Make-Believe_1915__3.jpg
tar -cvf ../../bobby_make_believe_sample.cbt Bobby-Make-Believe_1915__0.jpg Bobby-Make-Believe_1915__1.jpg Bobby-Make-Believe_1915__2.jpg Bobby-Make-Believe_1915__3.jpg
rar a -m0 ..\..\bobby_make_believe_sample.cbr Bobby-Make-Believe_1915__0.jpg Bobby-Make-Believe_1915__1.jpg Bobby-Make-Believe_1915__2.jpg Bobby-Make-Believe_1915__3.jpg
cd ../..
cd images/mono_numbered_png/
create_comics ../../mono_numbered_png 01.png 02.png 03.png 04.png 05.png 06.png 07.png 08.png 09.png 10.png
cd ../..
else
echo SKIPping comics
fi # end of if not SKIP_COMICS
# generate release
#myzip sample_reading_media.zip *