1SUMMARY="Ebook management application"
2DESCRIPTION="Calibre is an e-book manager. It can view, convert, edit and \
3catalog e-books in all of the major e-book formats. It can also talk to \
4e-book reader devices. It can go out to the internet and fetch metadata for \
5your books. It can download newspapers and convert them into e-books for \
6convenient reading. It is cross platform, running on Linux, Windows and macOS."
7HOMEPAGE="https://calibre-ebook.com/"
8COPYRIGHT="2008-2019 Kovid Goyal"
9LICENSE="GNU GPL v3"
10REVISION="7"
11SOURCE_URI="https://download.calibre-ebook.com/$portVersion/calibre-$portVersion.tar.xz"
12CHECKSUM_SHA256="3571efc1cc773e453b459096a38b141fd0c7784fb9611505a1f9a55648f47e5e"
13PATCHES="calibre-$portVersion.patchset"
14ADDITIONAL_FILES="calibre.rdef.in"
15
16ARCHITECTURES="all !x86_gcc2"
17SECONDARY_ARCHITECTURES="?x86"
18
19# On x86_gcc2 we don't want to install the commands in bin/<arch>/, but in bin/.
20commandSuffix=$secondaryArchSuffix
21commandBinDir=$binDir
22if [ "$targetArchitecture" = x86_gcc2 ]; then
23	commandSuffix=
24	commandBinDir=$prefix/bin
25fi
26
27PROVIDES="
28	calibre$secondaryArchSuffix = $portVersion
29	cmd:calibre_complete$commandSuffix
30	cmd:calibre_customize$commandSuffix
31	cmd:calibre_debug$commandSuffix
32	cmd:calibre_parallel$commandSuffix
33	cmd:calibre_server$commandSuffix
34	cmd:calibre_smtp$commandSuffix
35	cmd:calibre_uninstall$commandSuffix
36	cmd:calibre$commandSuffix
37	cmd:calibredb$commandSuffix
38	cmd:ebook_convert$commandSuffix
39	cmd:ebook_device$commandSuffix
40	cmd:ebook_edit$commandSuffix
41	cmd:ebook_meta$commandSuffix
42	cmd:ebook_polish$commandSuffix
43	cmd:ebook_viewer$commandSuffix
44	cmd:fetch_ebook_metadata$commandSuffix
45	cmd:lrf2lrs$commandSuffix
46	cmd:lrfviewer$commandSuffix
47	cmd:lrs2lrf$commandSuffix
48	cmd:markdown_calibre$commandSuffix
49	cmd:web2disk$commandSuffix
50	"
51REQUIRES="
52	dbus$secondaryArchSuffix
53	haiku$secondaryArchSuffix
54	cmd:python3.10
55	apsw_python310
56	beautifulsoup4_python310
57	chardet_python310
58	css_parser_python310
59	dateutil_python310
60	dnspython_python310
61	feedparser_python310
62	html2text_python310
63	html5_parser_python310
64	lxml_python310
65	markdown_python310
66	mechanize_python310
67	msgpack_python310
68#	netifaces_python310
69	pillow_python310
70#	psutil_python310
71	pygments_python310
72	pyqt5_python310
73	pyqtwebengine5_python310
74	regex_python310
75	setuptools_python310
76	unrardll_python310
77	pythonzeroconf_python310
78#	lib:libdbus_1$secondaryArchSuffix
79#	lib:libdbus_glib_1$secondaryArchSuffix
80#	lib:libeasylzma$secondaryArchSuffix
81	lib:libexpat$secondaryArchSuffix
82	lib:libffi$secondaryArchSuffix
83	lib:libfontconfig$secondaryArchSuffix
84	lib:libfreetype$secondaryArchSuffix
85	lib:libgcrypt$secondaryArchSuffix
86	lib:libglib_2.0$secondaryArchSuffix
87	lib:libgpg_error$secondaryArchSuffix
88	lib:libhunspell_1.7$secondaryArchSuffix
89	lib:libhyphen$secondaryArchSuffix
90	lib:libiconv$secondaryArchSuffix
91	lib:libicui18n$secondaryArchSuffix >= 66
92	lib:libjpeg$secondaryArchSuffix
93#	lib:libjxrlib$secondaryArchSuffix
94#	lib:libmozjpeg$secondaryArchSuffix
95	lib:libmtp$secondaryArchSuffix
96	lib:libncursesw$secondaryArchSuffix
97	lib:libpng16$secondaryArchSuffix
98	lib:libpodofo$secondaryArchSuffix
99	lib:libpoppler$secondaryArchSuffix
100	lib:libpoppler_qt5$secondaryArchSuffix
101	lib:libQt5Core$secondaryArchSuffix
102	lib:libQt5WebEngine$secondaryArchSuffix
103	lib:libreadline$secondaryArchSuffix
104	lib:libstemmer$secondaryArchSuffix
105	lib:libsqlite3$secondaryArchSuffix
106	lib:libssl$secondaryArchSuffix
107	lib:libusb_1.0$secondaryArchSuffix
108	lib:libwebp$secondaryArchSuffix
109	lib:libxml2$secondaryArchSuffix
110	lib:libxslt$secondaryArchSuffix
111	lib:libz$secondaryArchSuffix
112	"
113
114BUILD_REQUIRES="
115	haiku${secondaryArchSuffix}_devel
116	apsw_python310
117	beautifulsoup4_python310
118	chardet_python310
119	css_parser_python310
120	dateutil_python310
121#	dbuspython_python310
122	dnspython_python310
123	feedparser_python310
124	html2text_python310
125	html5_parser_python310
126	lxml_python310
127	markdown_python310
128	mechanize_python310
129	msgpack_python310
130#	netifaces_python310
131	pillow_python310
132#	psutil_python310
133	pygments_python310
134	pyqt5_python310
135	pyqt_builder_python310
136	regex_python310
137	setuptools_python310
138	sip_python310
139#	sip_pyqt_python310
140	six_python310
141	unrardll_python310
142	pythonzeroconf_python310
143	devel:libchm$secondaryArchSuffix
144#	devel:libdbus_1$secondaryArchSuffix
145#	devel:libdbus_glib_1$secondaryArchSuffix
146#	devel:libeasylzma$secondaryArchSuffix
147	devel:libexpat$secondaryArchSuffix
148	devel:libffi$secondaryArchSuffix
149	devel:libfontconfig$secondaryArchSuffix
150	devel:libfreetype$secondaryArchSuffix
151	devel:libgcrypt$secondaryArchSuffix
152	devel:libglib_2.0$secondaryArchSuffix
153	devel:libgpg_error$secondaryArchSuffix
154	devel:libhunspell_1.7$secondaryArchSuffix
155	devel:libhyphen$secondaryArchSuffix
156	devel:libiconv$secondaryArchSuffix
157	devel:libicui18n$secondaryArchSuffix >= 66
158	devel:libjpeg$secondaryArchSuffix
159#	devel:libjxrlib$secondaryArchSuffix
160#	devel:libmozjpeg$secondaryArchSuffix
161	devel:libmtp$secondaryArchSuffix
162	devel:libncursesw$secondaryArchSuffix
163	devel:libpng16$secondaryArchSuffix
164	devel:libpodofo$secondaryArchSuffix
165	devel:libpoppler$secondaryArchSuffix
166	devel:libpoppler_qt5$secondaryArchSuffix
167	devel:libQt5Core$secondaryArchSuffix
168	devel:libQt5WebEngine$secondaryArchSuffix
169	devel:libreadline$secondaryArchSuffix
170	devel:libstemmer$secondaryArchSuffix
171	devel:libsqlite3$secondaryArchSuffix
172	devel:libssl$secondaryArchSuffix
173	devel:libusb_1.0$secondaryArchSuffix
174	devel:libwebp$secondaryArchSuffix
175	devel:libxml2$secondaryArchSuffix
176	devel:libxslt$secondaryArchSuffix
177	devel:libz$secondaryArchSuffix
178	"
179BUILD_PREREQUIRES="
180	cmd:bzip2
181	cmd:cmake
182	cmd:gcc$secondaryArchSuffix
183	cmd:make
184	cmd:nasm
185	cmd:optipng
186	cmd:pkg_config$secondaryArchSuffix
187	cmd:python3.10
188	cmd:pyrcc5
189	cmd:qmake >= 5
190	cmd:sip
191	cmd:unrar
192	"
193
194BUILD()
195{
196	# For current REQUIMENTS check:
197	# https://github.com/kovidgoyal/build-calibre/blob/master/scripts/sources.json
198
199	export PODOFO_INC_DIR=`finddir B_SYSTEM_HEADERS_DIRECTORY`/podofo
200	python=python3.10
201	installLocation=$prefix/../pyqt5_python310/lib/$python/vendor-packages
202	export BINDINGS_DIR=$installLocation/PyQt5/bindings/
203
204	LANG="en_US.UTF-8" $python setup.py build
205	LANG="en_US.UTF-8" $python setup.py gui
206}
207
208INSTALL()
209{
210	export PODOFO_INC_DIR=`finddir B_SYSTEM_HEADERS_DIRECTORY`/podofo
211
212	python=python3.10
213	$python setup.py install \
214		--prefix=$appsDir/Calibre
215
216	mv $appsDir/Calibre/bin/calibre $appsDir/Calibre/bin/Calibre
217
218	# Fix python path for scripts
219	sed -i 's|/usr/bin/env python3|/bin/python3.10|' $appsDir/Calibre/bin/*
220
221	# Preparing the attributes
222	local MAJOR="`echo "$portVersion" | cut -d. -f1`"
223	local MIDDLE="`echo "$portVersion" | cut -d. -f2`"
224	local MINOR="`echo "$portVersion" | cut -d. -f3`"
225	sed \
226		-e "s|@MAJOR@|$MAJOR|" \
227		-e "s|@MIDDLE@|$MIDDLE|" \
228		-e "s|@MINOR@|$MINOR|" \
229		$portDir/additional-files/calibre.rdef.in \
230			> calibre.rdef
231
232	# Installing extra-attribs
233	rc calibre.rdef
234
235	scriptList="Calibre ebook-edit ebook-viewer lrfviewer"
236	for scriptName in $scriptList; do
237		settype -t application/x-vnd.Be-elfexecutable $appsDir/Calibre/bin/$scriptName
238		resattr -o $appsDir/Calibre/bin/$scriptName calibre.rsrc
239	done
240
241	addAppDeskbarSymlink $appsDir/Calibre/bin/Calibre
242}
243
244TEST()
245{
246	export SIP_DIR=`finddir B_SYSTEM_DATA_DIRECTORY`
247	export PODOFO_INC_DIR=`finddir B_SYSTEM_HEADERS_DIRECTORY`/podofo
248
249	python3.10 setup.py test
250}
251