Diff freeciv-3.0.1-r1 with a freeciv-3.1.0_beta2

/usr/portage/games-strategy/freeciv/freeciv-3.1.0_beta2.ebuild 2023-10-09 14:52:31.140368392 +0300
3 3

  
4 4
EAPI=8
5 5

  
6
LUA_COMPAT=( lua5-3 )
6
LUA_COMPAT=( lua5-4 )
7 7

  
8
inherit desktop lua-single qmake-utils xdg
9

  
10
MY_PV="${PV/_beta/-beta}"
11
MY_PV="${MY_PV/_rc/-RC}"
12
MY_P="${PN}-${MY_PV}"
8
inherit desktop lua-single meson xdg
13 9

  
14 10
DESCRIPTION="Multiplayer strategy game (Civilization Clone)"
15 11
HOMEPAGE="https://www.freeciv.org/"
16 12

  
17
if [[ ${PV} != *_beta* ]] && [[ ${PV} != *_rc* ]] ; then
18
	SRC_URI="mirror://sourceforge/freeciv/${MY_P}.tar.xz"
13
if [[ ${PV} == 9999 ]] ; then
14
	inherit git-r3
15
	EGIT_REPO_URI="https://github.com/freeciv/freeciv/"
16
else
17
	MY_PV="R${PV//./_}"
18
	SRC_URI="https://github.com/freeciv/freeciv/archive/refs/tags/${MY_PV}.tar.gz -> ${P}.tar.gz"
19 19
	KEYWORDS="~amd64 ~ppc64 ~x86"
20
	MY_P="${PN}-${MY_PV}"
21
	S="${WORKDIR}/${MY_P}"
20 22
fi
21 23

  
22 24
LICENSE="GPL-2+"
23 25
SLOT="0"
24
IUSE="aimodules auth dedicated +gtk ipv6 mapimg modpack mysql nls qt5 readline sdl +server +sound sqlite +system-lua"
26
IUSE="dedicated gtk3 gtk4 json mapimg modpack mysql nls +qt5 qt6 readline rule-editor sdl +sound +system-lua web-server"
25 27

  
26
REQUIRED_USE="system-lua? ( ${LUA_REQUIRED_USE} )"
28
# I'm pretty sure that you can't build both qt flavours at the same time
29
REQUIRED_USE="
30
	system-lua? ( ${LUA_REQUIRED_USE} )
31
	!dedicated? ( || ( gtk3 gtk4 qt5 qt6 sdl ) )
32
	qt5?  ( !qt6 )
33
	qt6?  ( !qt5 )
34
"
27 35

  
28
# postgres isn't yet really supported by upstream
29 36
RDEPEND="
30 37
	app-arch/bzip2
31 38
	app-arch/xz-utils
32
	net-misc/curl
39
	app-arch/zstd:=
40
	dev-db/sqlite:3
33 41
	dev-libs/icu:=
42
	net-misc/curl
43
	sys-devel/libtool
34 44
	sys-libs/zlib
35
	auth? (
36
		!mysql? ( ( !sqlite? ( dev-db/mysql-connector-c:= ) ) )
37
		mysql? ( dev-db/mysql-connector-c:= )
38
		sqlite? ( dev-db/sqlite:3 )
39
	)
40
	dedicated? ( aimodules? ( dev-libs/libltdl ) )
41 45
	!dedicated? (
42 46
		media-libs/libpng
43
		gtk? ( x11-libs/gtk+:3 )
47
		gtk3? ( x11-libs/gtk+:3 )
48
		gtk4? ( gui-libs/gtk:4 )
44 49
		mapimg? ( media-gfx/imagemagick:= )
45
		modpack? ( x11-libs/gtk+:3 )
46 50
		nls? ( virtual/libintl )
47 51
		qt5? (
48 52
			dev-qt/qtcore:5
49 53
			dev-qt/qtgui:5
50 54
			dev-qt/qtwidgets:5
51 55
		)
52
		!sdl? ( !gtk? ( x11-libs/gtk+:3 ) )
56
		qt6? (
57
			dev-qt/qtbase:6[gui,widgets]
58
		)
53 59
		sdl? (
54 60
			media-libs/libsdl2[video]
55 61
			media-libs/sdl2-gfx
56 62
			media-libs/sdl2-image[png]
57 63
			media-libs/sdl2-ttf
58 64
		)
59
		server? ( aimodules? ( sys-devel/libtool ) )
60 65
		sound? (
61 66
			media-libs/libsdl2[sound]
62 67
			media-libs/sdl2-mixer[vorbis]
63 68
		)
64 69
	)
70
	json? ( dev-libs/jansson:= )
65 71
	readline? ( sys-libs/readline:= )
66
	system-lua? ( ${LUA_DEPS} )
72
	system-lua? (
73
		${LUA_DEPS}
74
	)
67 75
"
68 76
DEPEND="${RDEPEND}
69 77
	!dedicated? ( x11-base/xorg-proto )
......
72 80
BDEPEND="
73 81
	app-arch/gzip
74 82
	virtual/pkgconfig
75
	!dedicated? ( nls? ( sys-devel/gettext ) )
83
	nls? ( sys-devel/gettext )
76 84
"
77 85

  
78
S="${WORKDIR}/${MY_P}"
86
PATCHES=(
87
	"${FILESDIR}"/${P}-lua-search.patch
88
)
79 89

  
80 90
pkg_setup() {
81
	if ! use dedicated && ! use server ; then
82
		ewarn "Disabling server USE flag will make it impossible to start local"
83
		ewarn "games, but you will still be able to join multiplayer games."
84
	fi
85

  
86 91
	use system-lua && lua-single_pkg_setup
87 92
}
88 93

  
89
src_prepare() {
90
	default
94
src_configure() {
95
	local myclient=() emesonargs=() myfcmp=()
91 96

  
92
	# install the .desktop in /usr/share/applications
93
	# install the icons in /usr/share/pixmaps
94
	sed -i \
95
		-e 's:^.*\(desktopfiledir = \).*:\1/usr/share/applications:' \
96
		-e 's:^\(icon[0-9]*dir = \)$(prefix)\(.*\):\1/usr\2:' \
97
		-e 's:^\(icon[0-9]*dir = \)$(datadir)\(.*\):\1/usr/share\2:' \
98
		client/Makefile.in \
99
		server/Makefile.in \
100
		tools/Makefile.in \
101
		data/icons/Makefile.in || die
102
}
97
	# Upstream considers meson "experimental" until 3.2.0 according to their roadmap
98
	emesonargs+=( -Dack_experimental=true )
103 99

  
104
src_configure() {
105
	local myclient=() mydatabase=() myeconfargs=()
100
	# meson build drops the ability to _not_ build a server in favour
101
	# of optionally replacing the server binary the freeciv-web backend
102
	emesonargs+=(
103
		$(meson_use web-server freeciv-web)
104
	)
106 105

  
107
	if use auth ; then
108
		if ! use mysql && ! use sqlite ; then
109
			einfo "No database backend chosen, defaulting"
110
			einfo "to mysql!"
111
			mydatabase=( mysql )
112
		else
113
			use mysql && mydatabase+=( mysql )
114
			use sqlite && mydatabase+=( sqlite3 )
115
		fi
106
	# Select any client backends that we want enabled; dedicated server shouldn't build a UI
107
	# for sanity we'll build the modpack bin with the same UIs as the client.
108
	# 'fcmp' = freeciv modpack (client) - gtk3, qt, cli, gtk4
109
	freeciv_enable_ui() {
110
				local flag=$1
111
				local client_name=${2:-${flag}}
112
				local fcmp_name=${3:-${client_name}}
113

  
114
				if use ${flag} ; then
115
					myclient+=( ${client_name} )
116
					use modpack && myfcmp+=( ${fcmp_name} )
117
				fi
118
			}
119

  
120
	if ! use dedicated ; then
121
		# there's no SDL modpack backend; rather than incidentally pull in GTK3 (as is default)
122
		# let's explicitly set the backend to CLI
123
		freeciv_enable_ui sdl sdl2 cli
124
		freeciv_enable_ui gtk3 gtk3.22 gtk3
125
		freeciv_enable_ui gtk4
126
		freeciv_enable_ui qt5 qt
127
		freeciv_enable_ui qt6 qt
128
		use qt5 && emesonargs+=( -Dqtver=qt5 )
129
		use qt6 && emesonargs+=( -Dqtver=qt6 )
116 130
	else
117
		mydatabase=( no )
131
		if use modpack ; then
132
			myfcmp+=( cli )
133
		fi
118 134
	fi
119 135

  
120
	if use dedicated ; then
121
		myclient=( no )
122
		myeconfargs+=(
123
			--enable-server
124
			--enable-freeciv-manual=html
125
		)
126
	else
127
		if use !sdl && use !gtk && ! use qt5 ; then
128
			einfo "No client backend given, defaulting to gtk3 client!"
129
			myclient=( gtk3 )
130
		else
131
			use sdl && myclient+=( sdl2 )
132
			use gtk && myclient+=( gtk3 )
133
			if use qt5 ; then
134
				local -x MOCCMD=$(qt5_get_bindir)/moc
135
				myclient+=( qt )
136
			fi
137
		fi
138
		myeconfargs+=(
139
			$(use_enable server)
140
			$(use_enable server freeciv-manual html )
141
		)
136
	# the client and fpmc arrays are now populated (or not for dedicated); let's add them to emesonargs
137
	emesonargs+=(
138
		-Dclients=$(echo ${myclient[*]} | sed 's/ /,/g')
139
		-Dfcmp=$(echo ${myfcmp[*]} | sed 's/ /,/g')
140
	)
141

  
142
	# If we're building a live ebuild, we want to include the git revision in the version string
143
	if [[ ${PV} == 9999 ]] ; then
144
		emesonargs+=( -Dgitrev=true )
142 145
	fi
143 146

  
144
	myeconfargs+=(
145
		--enable-aimodules="$(usex aimodules "yes" "no")"
146
		--enable-client="${myclient[*]}"
147
		--enable-fcdb="${mydatabase[*]}"
148
		--enable-fcmp="$(usex modpack "gtk3" "no")"
149
		# disabling shared libs will break aimodules USE flag
150
		--enable-shared
151
		--localedir=/usr/share/locale
152
		--with-appdatadir="${EPREFIX}"/usr/share/metainfo
153
		$(use_enable ipv6)
154
		$(use_enable mapimg)
155
		$(use_enable nls)
156
		$(use_enable sound sdl-mixer)
157
		$(use_enable system-lua sys-lua)
158
		$(use_with readline)
147
	# Anything that can be trivially set by meson_use goes here
148
	emesonargs+=(
149
		$(meson_use json json-protocol)
150
		$(meson_use mapimg mwand)
151
		$(meson_use nls)
152
		$(meson_use readline)
153
		$(meson_use rule-editor ruledit)
154
		$(meson_use sound audio)
155
		$(meson_use system-lua syslua)
159 156
	)
160
	econf "${myeconfargs[@]}"
157

  
158
	meson_src_configure
161 159
}
162 160

  
163 161
src_install() {
164
	default
165 162

  
166 163
	if use dedicated ; then
167 164
		rm -rf "${ED}"/usr/share/pixmaps || die
168 165
		rm -f "${ED}"/usr/share/man/man6/freeciv-{client,gtk2,gtk3,modpack,qt,sdl,xaw}* || die
166
	fi
167
	# Create and install the html manual and then cleanup the tool because it's useless.
168
	# TODO: for proper localisation this should be run during postinst but
169
	# that would require a lot of work to avoid orphan files.
170
	# freeciv-manual only supports one ruleset argument at a time.
171
	for RULESET in alien civ1 civ2 civ2civ3 classic experimental multiplayer sandbox
172
	do
173
		$(find "${WORKDIR}" -type d -maxdepth 1 -mindepth 1 -iname '*-build')/freeciv-manual -r ${RULESET} || die
174
		docinto html/rulesets/${RULESET}
175
		dodoc ${RULESET}*.html
176
	done
177
	if use sdl ; then
178
		make_desktop_entry freeciv-sdl "Freeciv (SDL)" freeciv-client
169 179
	else
170
		if use server ; then
171
			# Create and install the html manual. It can't be done for dedicated
172
			# servers, because the 'freeciv-manual' tool is then not built. Also
173
			# delete freeciv-manual from the GAMES_BINDIR, because it's useless.
174
			# Note: to have it localized, it should be ran from _postinst, or
175
			# something like that, but then it's a PITA to avoid orphan files...
176
			# freeciv-manual only supports one ruleset argument at a time.
177
			for RULESET in alien civ1 civ2 civ2civ3 classic experimental multiplayer sandbox
178
			do
179
				./tools/freeciv-manual -r ${RULESET} || die
180
				docinto html/rulesets/${RULESET}
181
				dodoc ${RULESET}*.html
182
			done
183
		fi
184
		if use sdl ; then
185
			make_desktop_entry freeciv-sdl "Freeciv (SDL)" freeciv-client
186
		else
187
			rm -f "${ED}"/usr/share/man/man6/freeciv-sdl* || die
188
		fi
189
		rm -f "${ED}"/usr/share/man/man6/freeciv-xaw* || die
180
		rm -f "${ED}"/usr/share/man/man6/freeciv-sdl* || die
190 181
	fi
182
	rm -f "${ED}"/usr/share/man/man6/freeciv-xaw* || die
191 183
	find "${ED}" -name "freeciv-manual*" -delete || die
192 184

  
193 185
	rm -f "${ED}/usr/$(get_libdir)"/*.a || die
194 186
	find "${ED}" -type f -name "*.la" -delete || die
187
	meson_src_install
188
}
189

  
190
pkg_postinst() {
191
	if [[ -z ${REPLACING_VERSIONS} ]]; then
192
		einfo "There are a number of supported authentication backends."
193
		einfo "sqlite3 is the default, however dedicated servers may wish to"
194
		einfo "use another supported backend; please consult the documentation"
195
		einfo "to configure freeciv for a particular backend:"
196
		einfo "https://github.com/freeciv/freeciv/blob/main/doc/README.fcdb"
197
	fi
195 198
}
Thank you!