summaryrefslogtreecommitdiff
blob: 529a1a6f5e40d3941acb98c2c54f297473a4fb42 (plain)
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
# Copyright 1999-2018 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2

EAPI=6

PLOCALES="de es fr it pl pt_BR ru sk zh_CN"

inherit eutils l10n qmake-utils xdg

DESCRIPTION="Powerful cross-platform SQLite database manager"
HOMEPAGE="https://sqlitestudio.pl"
SRC_URI="https://sqlitestudio.pl/files/sqlitestudio3/complete/tar/${P}.tar.gz"

KEYWORDS="~amd64 ~x86"
LICENSE="GPL-3"
SLOT="0"
IUSE="cli cups tcl test"

RDEPEND="
	dev-db/sqlite:3
	dev-qt/qtcore:5
	dev-qt/qtgui:5
	dev-qt/qtnetwork:5
	dev-qt/qtscript:5
	dev-qt/qtsvg:5
	dev-qt/qtwidgets:5
	dev-qt/qtxml:5
	cli? ( sys-libs/readline:* )
	cups? ( dev-qt/qtprintsupport:5 )
	tcl? ( dev-lang/tcl:* )
"
DEPEND="${RDEPEND}
	dev-qt/designer:5
	dev-qt/qtconcurrent:5
	test? ( dev-qt/qttest:5 )
"

S="${WORKDIR}"
core_build_dir="${S}/output/build"
plugins_build_dir="${core_build_dir}/Plugins"

PATCHES=( "${FILESDIR}/${P}-qt-5.11.patch" )

src_prepare() {
	xdg_src_prepare

	sed -i -e 's/linux|portable/portable/' \
		SQLiteStudio3/sqlitestudio/sqlitestudio.pro || die

	disable_modules() {
		[[ $# -lt 2 ]] && die "not enough arguments"

		local pro="$1"; shift
		local modules="${@}"

		sed -r -i \
			-e 's/('${modules// /|}')[[:space:]]*(\\?)/\2/' \
			${pro} || die
	}

	use cli || disable_modules SQLiteStudio3/SQLiteStudio3.pro cli

	local mod_lst=( DbSqlite2 )
	use cups || mod_lst+=( Printing )
	use tcl || mod_lst+=( ScriptingTcl )
	disable_modules Plugins/Plugins.pro ${mod_lst[@]}

	local mylrelease="$(qt5_get_bindir)"/lrelease
	local ts_dir_lst=$(find * -type f -name "*.qm" -printf '%h\n' | sort -u)
	local ts_pro_lst=$(find * -type f -name "*.pro" -exec grep -l 'TRANSLATIONS' {} \;)
	local ts_qrc_lst=$(find * -type f -name "*.qrc" -exec grep -l '\.qm' {} \;)

	# delete all "*.qm"
	for ts_dir in ${ts_dir_lst[@]}; do
		rm "${ts_dir}"/*.qm || die
	done

	prepare_locale() {
		for ts_dir in ${ts_dir_lst[@]}; do
			local ts=$(find "${ts_dir}" -type f -name "*${1}.ts" || continue)
			"${mylrelease}" "${ts}" || die "preparing ${1} locale failed"
		done
	}

	rm_locale() {
		for ts_pro in ${ts_pro_lst[@]}; do
			sed -i -r -e 's/[^[:space:]]*'${1}'\.ts//' \
				${ts_pro} || die
		done

		for ts_qrc in ${ts_qrc_lst[@]}; do
			sed -i -e '/'${1}'\.qm/d' \
				${ts_qrc} || die
		done
	}

	local ts_dir_main="SQLiteStudio3/sqlitestudio/translations"
	l10n_find_plocales_changes ${ts_dir_main} "sqlitestudio_" '.ts'
	l10n_for_each_locale_do prepare_locale
	l10n_for_each_disabled_locale_do rm_locale
}

src_configure() {
	# NOTE: QMAKE_CFLAGS_ISYSTEM option prevents
	# build error with tcl use enabled (stdlib.h is missing)
	local myqmakeargs=(
		"BINDIR=${EPREFIX}/usr/bin"
		"LIBDIR=${EPREFIX}/usr/$(get_libdir)"
		"QMAKE_CFLAGS_ISYSTEM=\"\""
		$(usex test 'DEFINES+=tests' '')
	)

	## Core
	mkdir -p "${core_build_dir}" && cd "${core_build_dir}" || die
	eqmake5 "${myqmakeargs[@]}" "${S}/SQLiteStudio3"

	## Plugins
	mkdir -p "${plugins_build_dir}" && cd "${plugins_build_dir}" || die
	eqmake5 "${myqmakeargs[@]}" "${S}/Plugins"
}

src_compile() {
	emake -C "${core_build_dir}"
	emake -C "${plugins_build_dir}"
}

src_install() {
	emake -C "${core_build_dir}" INSTALL_ROOT="${D}" install
	emake -C "${plugins_build_dir}" INSTALL_ROOT="${D}" install

	doicon -s scalable "SQLiteStudio3/guiSQLiteStudio/img/${PN}.svg"

	local make_desktop_entry_args=(
		"${PN} -- %F"
		'SQLiteStudio3'
		"${PN}"
		'Development;Database;Utility'
	)
	make_desktop_entry "${make_desktop_entry_args[@]}" \
		"$( printf '%s\n' "MimeType=application/x-sqlite3;" )"
}