Diff bareos-20.0.8-r2 with a bareos-21.1.7-r2

/usr/portage/app-backup/bareos/bareos-21.1.7-r2.ebuild 2023-10-09 14:52:28.196368317 +0300
3 3

  
4 4
EAPI=7
5 5

  
6
PYTHON_COMPAT=( python3_{9..10} )
6
PYTHON_COMPAT=( python3_{9..11} )
7 7
CMAKE_WARN_UNUSED_CLI=no
8 8
#CMAKE_REMOVE_MODULES=yes
9 9

  
......
12 12
DESCRIPTION="Featureful client/server network backup suite"
13 13
HOMEPAGE="https://www.bareos.org/"
14 14
SRC_URI="https://github.com/${PN}/${PN}/archive/Release/${PV}.tar.gz -> ${P}.tar.gz"
15
RESTRICT="mirror"
15

  
16
# some tests still fail propably due to missing bits in src_test -> TODO
17
RESTRICT="mirror test"
18
#RESTRICT="
19
#	mirror
20
#	!test? ( test )
21
#"
16 22

  
17 23
LICENSE="AGPL-3"
18 24
SLOT="0"
19 25
KEYWORDS="~amd64 ~x86"
20
IUSE="X acl ceph clientonly +director glusterfs ipv6 jansson lmdb
21
	logwatch mysql ndmp +postgres readline scsi-crypto
22
	sqlite static +storage-daemon systemd tcpd vim-syntax vmware xattr"
26
IUSE="X acl ceph clientonly +director glusterfs ipv6 lmdb
27
	logwatch ndmp readline scsi-crypto split-usr
28
	static +storage-daemon systemd tcpd test vim-syntax vmware xattr"
23 29

  
24 30
# get cmake variables from core/cmake/BareosSetVariableDefaults.cmake
25 31
DEPEND="
......
33 39
	dev-libs/gmp:0
34 40
	!clientonly? (
35 41
		acct-user/${PN}
36
		postgres? ( dev-db/postgresql:*[threads(+)] )
37
		mysql? ( virtual/mysql )
38
		sqlite? ( dev-db/sqlite:3 )
42
		dev-db/postgresql:*[threads(+)]
39 43
		director? (
40 44
			virtual/mta
41
			jansson? ( dev-libs/jansson:= )
42 45
		)
43 46
	)
44 47
	logwatch? ( sys-apps/logwatch )
......
47 50
	readline? ( sys-libs/readline:0 )
48 51
	static? (
49 52
		acl? ( virtual/acl[static-libs] )
50
		sys-libs/zlib[static-libs]
53
		dev-libs/jansson:=[static-libs]
51 54
		dev-libs/lzo[static-libs]
52
		sys-libs/ncurses:=[static-libs]
53 55
		dev-libs/openssl:0=[static-libs]
56
		sys-libs/ncurses:=[static-libs]
57
		sys-libs/zlib[static-libs]
54 58
	)
55 59
	!static? (
56 60
		acl? ( virtual/acl )
61
		dev-libs/jansson:=
57 62
		dev-libs/lzo
58 63
		dev-libs/openssl:0=
59 64
		sys-libs/ncurses:=
......
69 74
	)
70 75
	vim-syntax? ( || ( app-editors/vim app-editors/gvim ) )
71 76
	"
72
BDEPEND="${PYTHON_DEPS}"
77

  
78
BDEPEND="
79
	${PYTHON_DEPS}
80
	test? (
81
		dev-cpp/gtest
82
		dev-db/postgresql:*[server,threads(+)]
83
		dev-db/mariadb:*[server]
84
	)
85
"
73 86

  
74 87
REQUIRED_USE="
75
	!clientonly? ( || ( mysql postgres sqlite ) )
76 88
	static? ( clientonly )
77 89
	x86? ( !ceph )
78 90
"
79 91

  
80 92
S=${WORKDIR}/${PN}-Release-${PV}
81 93

  
82
src_prepare() {
83
	use mysql    && export mydbtypes+=( mysql )
84
	use postgres && export mydbtypes+=( postgresql )
85
	use sqlite   && export mydbtypes+=( sqlite )
86

  
87
	# enables default database driver in catalog
88
	pushd core/src/defaultconfigs >&/dev/null || die
89
		sed -i -e 's/#dbdriver/dbdriver/' -e '/XXX_REPLACE_WITH_DATABASE_DRIVER_XXX/d' \
90
			$(grep -rl XXX_REPLACE_WITH_DATABASE_DRIVER_XXX) || die "sed on MyCatalog.conf.in failed"
91
	popd >&/dev/null || die
94
pkg_pretend() {
95
	local active_removed_backend=""
96
	if has_version "<app-backup/bareos-21[director,mysql]"; then
97
		if grep -qhriE "dbdriver.*=.*mysql" /etc/bareos/; then
98
			active_removed_backend=MySQL
99
		fi
100
	elif has_version "<app-backup/bareos-21[director,sqlite]"; then
101
		if grep -qhriE "dbdriver.*=.*sqlite" /etc/bareos/; then
102
			active_removed_backend=SQLite
103
		fi
104
	fi
105
	if [[ -n $active_removed_backend ]]; then
106
		ewarn
107
		ewarn "You are currently using bareos with the $active_removed_backend"
108
		ewarn "catalog backend."
109
		ewarn
110
		ewarn "THIS IS NOT SUPPORTED ANYMORE"
111
		ewarn
112
		ewarn "Beginning with version 21.0.0 bareos has dropped support for"
113
		ewarn "MySQL and SQLite catalog backends."
114
		ewarn
115
		ewarn "To upgrade to bareos >=21.0.0 you need to migrate to PostgreSQL"
116
		ewarn "catalog backend using the 'bareos-dbcopy' tool of your current"
117
		ewarn "installation first."
118
		ewarn
119
		die "current catalog backend not supported anymore"
120
	fi
121
}
122

  
123
src_test() {
124
	# initialze catalog test database
125
	initdb -D "${T}"/pgsql || die
126
	pg_ctl -w -D "${T}"/pgsql start \
127
		-o "-h '' -k '${T}'" || die
128
	createuser -h "${T}" bareos || die
129
	createdb -h "${T}" --owner bareos bareos || die
130
	export PGHOST="${T}"
131

  
132
	# initiale mariadb database for backup tests
133
	# $USER must be set and != root
134
	export USER=portage
92 135

  
136
	default
137
	cmake_src_test
138

  
139
	pg_ctl -w -D "${T}"/pgsql stop || die
140
	rm -rvf "${T}"/pgsql
141
}
142

  
143
src_prepare() {
93 144
	# fix gentoo platform support
94
	eapply -p1 "${FILESDIR}/${PN}-20.0.2-cmake-gentoo.patch"
145
	eapply -p1 "${FILESDIR}/${PN}-21-cmake-gentoo.patch"
146
	eapply "${FILESDIR}/${PN}-21.1.2-werror.patch"
147
	eapply "${FILESDIR}/${PN}-21.1.2-no-automagic-ccache.patch"
95 148
	eapply "${FILESDIR}/${PN}-gcc13-fixes.patch"
96 149

  
97 150
	# fix missing DESTDIR in symlink creation
98 151
	sed -i '/bareos-symlink-default-db-backend.cmake/d' "${S}/core/src/cats/CMakeLists.txt"
99 152

  
100
	# disable dird and stored plugins, because of
101
	# py2 dependency
102
	cd "${S}/core/src/plugins"
103
	cmake_comment_add_subdirectory dird
104
	cmake_comment_add_subdirectory stored
105
	cd -
106

  
107
	CMAKE_USE_DIR="$S/core"
108 153
	cmake_src_prepare
109 154
}
110 155

  
111 156
src_configure() {
112 157
	local mycmakeargs=()
113 158

  
114
	CMAKE_USE_DIR="$S/core"
115

  
116
	pushd core/platforms >&/dev/null || die
117
	cmake_comment_add_subdirectory '${DISTNAME}'
118
	popd >&/dev/null || die
159
	cmake_comment_add_subdirectory webui
119 160

  
120 161
	if use clientonly; then
121 162
		mycmakeargs+=(
......
126 167
	fi
127 168

  
128 169
	for useflag in acl ipv6 ndmp scsi-crypto \
129
		systemd mysql lmdb; do
170
		systemd lmdb; do
130 171
		mycmakeargs+=( -D$useflag=$(usex $useflag) )
131 172
	done
132 173

  
133 174
	mycmakeargs+=(
134 175
		-DHAVE_PYTHON=0
135
		-DDEFAULT_DB_TYPE=${mydbtypes[0]}
136 176
		-Darchivedir=/var/lib/bareos/storage
137 177
		-Dbackenddir=/usr/$(get_libdir)/${PN}/backend
138 178
		-Dbasename="`hostname -s`"
......
159 199
		-Dmon-dir-password="`cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 32 | head -n 1`"
160 200
		-Dmon-fd-password="`cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 32 | head -n 1`"
161 201
		-Dmon-sd-password="`cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 32 | head -n 1`"
162
		-Dmysql=$(usex mysql)
163 202
		-Dopenssl=yes
164 203
		-Dpiddir=/run/bareos
165 204
		-Dplugindir=/usr/$(get_libdir)/${PN}/plugin
166
		-Dpostgresql=$(usex postgres)
167 205
		-Dsbin-perm=0755
168 206
		-Dsbindir=/usr/sbin
169 207
		-Dscriptdir=/usr/libexec/bareos
170 208
		-Dsd-group=bareos
171 209
		-Dsd-password="`cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 32 | head -n 1`"
172 210
		-Dsd-user=root
173
		-Dsqlite3=$(usex sqlite)
174 211
		-Dsubsysdir=/run/lock/subsys
175 212
		-Dsysconfdir=/etc
176 213
		-Dworkingdir=/var/lib/bareos
......
188 225
	cmake_src_install
189 226

  
190 227
	# remove some scripts we don't need at all
191
	rm -f "${D}"/usr/libexec/bareos/{bareos,bareos-ctl-dir,bareos-ctl-fd,bareos-ctl-sd,startmysql,stopmysql}
228
	rm -f "${D}"/usr/libexec/bareos/{bareos,bareos-ctl-dir,bareos-ctl-fd,bareos-ctl-sd}
192 229
	rm -f "${D}"/usr/sbin/bareos
193 230

  
194 231
	# remove upstream init scripts and systemd units
......
198 235
	rm -f "${D}"/etc/bareos/bareos-regress.conf
199 236
	rm -f "${D}"/etc/logrotate.d/bareos-dir
200 237

  
238
	# remove duplicate binaries being installed in /usr/sbin and replace
239
	# them by symlinks to not break systems that still use split-usr
240
	if use split-usr; then
241
		for f in bwild bregex bsmtp bconsole; do
242
			rm -f "${D}/usr/sbin/$f" || die
243
			ln -s "../bin/$f" "${D}/usr/sbin/$f" || die
244
		done
245
	fi
246

  
201 247
	# get rid of py2 stuff
202
	rm -rf "$D"/usr/lib64/python2.7
203
	rm -f "$D"/usr/lib64/bareos/plugin/python-fd.so
248
	rm -rf "$D"/usr/lib64/python2.7 || die
249
	rm -f "$D"/usr/lib64/bareos/plugin/python-fd.so || die
204 250
	if ! use vmware; then
205 251
		rm -f "$D"/usr/lib64/bareos/plugin/{BareosFdPluginVMware.py,bareos-fd-vmware.py}
206 252
	fi
......
305 351
		fi
306 352
	fi
307 353
	for script in ${myscripts}; do
308
		# copy over init script and config to a temporary location
309
		# so we can modify them as needed
310
		cp "${FILESDIR}/${script}".confd "${T}/${script}".confd || die "failed to copy ${script}.confd"
311
		cp "${FILESDIR}/${script}".initd "${T}/${script}".initd || die "failed to copy ${script}.initd"
312

  
313
		# now set the database dependency for the director init script
314
		case "${script}" in
315
			bareos-dir)
316
				sed -i -e "s:%databasetypes%:${mydbtypes[*]}:" "${T}/${script}".confd || die
317
				;;
318
			*)
319
				;;
320
		esac
321

  
322 354
		# install init script and config
323
		newinitd "${T}/${script}".initd "${script}"
324
		newconfd "${T}/${script}".confd "${script}"
355
		newinitd "${FILESDIR}/${script}-21-r1".initd "${script}"
356
		newconfd "${FILESDIR}/${script}-21".confd "${script}"
325 357
	done
326 358

  
327 359
	# install systemd unit files
328 360
	if use systemd; then
329 361
		if ! use clientonly; then
330
			use director && systemd_dounit "${FILESDIR}"/bareos-dir.service
362
			use director && systemd_newunit "${FILESDIR}"/bareos-dir-21.service bareos-dir.service
331 363
			use storage-daemon && systemd_dounit "${FILESDIR}"/bareos-sd.service
332 364
		fi
333 365
		systemd_dounit "${FILESDIR}"/bareos-fd.service
......
338 370
	keepdir /var/lib/bareos
339 371
	keepdir /var/lib/bareos/storage
340 372

  
341
	diropts -m0755 -o bareos -g bareos
373
	# set log directory ownership
374
	if ! use clientonly; then
375
		diropts -m0755 -o bareos -g bareos
376
	fi
342 377
	keepdir /var/log/bareos
343 378

  
344 379
	newtmpfiles "${FILESDIR}"/tmpfiles.d-bareos.conf bareos.conf
......
359 394
	if ! use clientonly && use director; then
360 395
		einfo
361 396
		einfo "If this is a new install, you must create the database:"
362
		if use postgres; then
363
			einfo
364
			einfo "For postgresql:"
365
			einfo "  su postgres -c '/usr/libexec/bareos/create_bareos_database postgresql'"
366
			einfo "  su postgres -c '/usr/libexec/bareos/make_bareos_tables postgresql'"
367
			einfo "  su postgres -c '/usr/libexec/bareos/grant_bareos_privileges postgresql'"
368
		fi
369
		if use mysql; then
370
			einfo
371
			einfo "For mysql:"
372
			einfo
373
			einfo "  Make sure root has direct access to your mysql server. You may want to"
374
			einfo "  create a /root/.my.cnf file with"
375
			einfo "    [client]"
376
			einfo "    user=root"
377
			einfo "    password=YourPasswordForAccessingMysqlAsRoot"
378
			einfo "  before running:"
379
			einfo "  /usr/libexec/bareos/create_bareos_database mysql"
380
			einfo "  /usr/libexec/bareos/make_bareos_tables mysql"
381
			einfo "  /usr/libexec/bareos/grant_bareos_privileges mysql"
382
		fi
383 397
		einfo
384
	fi
385

  
386
	if use sqlite; then
398
		einfo "  su postgres -c '/usr/libexec/bareos/create_bareos_database'"
399
		einfo "  su postgres -c '/usr/libexec/bareos/make_bareos_tables'"
400
		einfo "  su postgres -c '/usr/libexec/bareos/grant_bareos_privileges'"
401
		einfo
402
		einfo "or run"
387 403
		einfo
388
		einfo "Be aware that Bareos does not officially support SQLite database."
389
		einfo "Best use it only for a client-only installation. See Bug #445540."
404
		einfo " emerge --config app-backup/bareos"
390 405
		einfo
391
		einfo "It is strongly recommended to use either postgresql or mysql as"
392
		einfo "catalog database backend."
406
		einfo "to do this"
393 407
	fi
394 408
}
409

  
410
pkg_config() {
411
	su postgres -c '/usr/libexec/bareos/create_bareos_database' || die "could not create bareos database"
412
	su postgres -c '/usr/libexec/bareos/make_bareos_tables' || die "could not create bareos database tables"
413
	su postgres -c '/usr/libexec/bareos/grant_bareos_privileges' || die "could not grant bareos database privileges"
414
}
Thank you!