summaryrefslogtreecommitdiff
blob: 21747b2426f6eb030f006dd7b721f7454112ed60 (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
# Copyright 1999-2016 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2

# Upstream guide: http://wiki.sqlitestudio.pl/index.php/Compiling_application_from_sources

EAPI=6

inherit qmake-utils fdo-mime kde5-functions

DESCRIPTION="SQLiteStudio3 is a powerful cross-platform SQLite database manager"
HOMEPAGE="http://sqlitestudio.pl"
LICENSE="GPL-3"
SRC_URI="${HOMEPAGE}/files/sqlitestudio3/complete/tar/${P}.tar.gz"

SLOT="0"
KEYWORDS="~amd64 ~x86"
IUSE="cli cups tcl test"

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

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

src_prepare() {
	PATCHES=(
		"${FILESDIR}"/${PN}-3.0.6-qt5_5-QDataStream.patch
		"${FILESDIR}"/${PN}-3.0.6-portable.patch
		"${FILESDIR}"/${PN}-3.0.7-paths.patch
	)
	default

	disable_modules() {
		[ $# -lt 2 ] && return 0
		local file="$1"; shift

		edos2unix "${file}"

		local regex=""
		for m in "$@"; do
			regex+="\b${m}\b( \\\\|\$)|"
		done
		regex="${regex:0:-1}" # last pipe

		elog "Disabling modules: '$*' in '${file#${S}/}'"
		sed -i -r -e "/${regex}/d" -- "${file}" || return 1
	}

	## Core
	local disabled_modules=(
		$(usex cli '' 'cli')
	)
	disable_modules "${core_src_dir}/SQLiteStudio3.pro" "${disabled_modules[@]}" || die

	## Plugins
	local disabled_plugins=(
		'DbSqlite2'
		$(usex tcl '' 'ScriptingTcl')
		$(usex cups '' 'Printing')
	)
	disable_modules "${plugins_src_dir}/Plugins.pro" "${disabled_plugins[@]}" || die
}

src_configure() {
	local qmake_args=(
		"LIBDIR=${EROOT}usr/$(get_libdir)"
		"BINDIR=${EROOT}usr/bin"
		"DEFINES+=PLUGINS_DIR=${EROOT}usr/$(get_libdir)/${PN}"
		"DEFINES+=ICONS_DIR=${EROOT}usr/share/${PN}/icons"
		"DEFINES+=FORMS_DIR=${EROOT}usr/share/${PN}/forms"

		'DEFINES+=NO_AUTO_UPDATES' # not strictly needed since 3.0.6, but nevermind
		$(usex test 'DEFINES+=tests' '')
	)

	## Core
	mkdir -p "${core_build_dir}" && cd "${core_build_dir}" || die
	eqmake5 "${qmake_args[@]}" "${core_src_dir}"

	## Plugins
	mkdir -p "${plugins_build_dir}" && cd "${plugins_build_dir}" || die
	eqmake5 "${qmake_args[@]}" "${plugins_src_dir}"
}

src_compile() {
	cd "${core_build_dir}"		|| die && emake
	cd "${plugins_build_dir}"	|| die && emake
}

src_install() {
	cd "${core_build_dir}"		|| die && emake INSTALL_ROOT="${ED}" install
	cd "${plugins_build_dir}"	|| die && emake INSTALL_ROOT="${ED}" install

	dodoc "${core_src_dir}/docs/sqlitestudio3_docs.cfg"
	doicon -s scalable "${core_src_dir}/guiSQLiteStudio/img/${PN}.svg"

	make_desktop_entry_args=(
		"${EROOT}usr/bin/${PN} %F"	# exec
		'SQLiteStudio3'				# name
		"${PN}"						# icon
		'Development;Utility'		# categories
	)
	make_desktop_entry_extras=( 'MimeType=application/x-sqlite3;' )
	make_desktop_entry "${make_desktop_entry_args[@]}" \
		"$( printf '%s\n' "${make_desktop_entry_extras[@]}" )"
}

pkg_postinst() {
	fdo-mime_desktop_database_update
}