Сравнение nut-2.7.4-r8 с nut-2.8.0-r2

/usr/portage/sys-power/nut/nut-2.8.0-r2.ebuild 2023-10-09 14:52:35.568368503 +0300
1 1
# Copyright 1999-2023 Gentoo Authors
2 2
# Distributed under the terms of the GNU General Public License v2
3 3

  
4
EAPI=7
4
EAPI=8
5 5

  
6
inherit autotools bash-completion-r1 desktop fixheadtails flag-o-matic systemd toolchain-funcs
6
inherit bash-completion-r1 flag-o-matic linux-info optfeature systemd
7
inherit tmpfiles toolchain-funcs udev
7 8

  
8 9
MY_P=${P/_/-}
9 10

  
10 11
DESCRIPTION="Network-UPS Tools"
11
HOMEPAGE="https://www.networkupstools.org/"
12
SRC_URI="https://networkupstools.org/source/${PV%.*}/${MY_P}.tar.gz"
12
HOMEPAGE="https://networkupstools.org/"
13

  
14
if [[ ${PV} == *9999 ]] ; then
15
	EGIT_REPO_URI="https://github.com/networkupstools/${PN}.git"
16
	inherit git-r3
17
else
18
	SRC_URI="https://networkupstools.org/source/${PV%.*}/${MY_P}.tar.gz"
19
	KEYWORDS="~amd64 ~arm ~arm64 ~ppc ~ppc64 ~riscv ~x86"
20
fi
21

  
22
S="${WORKDIR}/${MY_P}"
23

  
13 24
LICENSE="GPL-2"
14 25
SLOT="0"
15
KEYWORDS="amd64 arm ~arm64 ~ppc ppc64 ~riscv x86"
16

  
17
IUSE="cgi ipmi snmp +usb selinux split-usr ssl tcpd xml zeroconf"
26
IUSE="cgi doc ipmi serial i2c +man snmp +usb modbus selinux split-usr ssl tcpd test xml zeroconf"
27
RESTRICT="!test? ( test )"
18 28

  
19
CDEPEND="
29
DEPEND="
20 30
	acct-group/nut
21 31
	acct-user/nut
22
"
23

  
24
DEPEND="
25 32
	dev-libs/libltdl
26
	net-libs/libnsl:=
27 33
	virtual/udev
28 34
	cgi? ( >=media-libs/gd-2[png] )
35
	i2c? ( sys-apps/i2c-tools )
29 36
	ipmi? ( sys-libs/freeipmi )
37
	modbus? ( dev-libs/libmodbus )
30 38
	snmp? ( net-analyzer/net-snmp:= )
31 39
	ssl? ( >=dev-libs/openssl-1:= )
32 40
	tcpd? ( sys-apps/tcp-wrappers )
33
	usb? ( virtual/libusb:0= )
41
	usb? ( virtual/libusb:1 )
34 42
	xml? ( >=net-libs/neon-0.25.0:= )
35
	zeroconf? ( net-dns/avahi )"
36

  
43
	zeroconf? ( net-dns/avahi )
44
"
37 45
BDEPEND="
38
	${CDEPEND}
39
	virtual/pkgconfig"
40

  
46
	virtual/pkgconfig
47
	man? ( app-text/asciidoc )
48
	test? ( dev-util/cppunit )
49
"
41 50
RDEPEND="
42
	${CDEPEND}
43 51
	${DEPEND}
44
	selinux? ( sec-policy/selinux-nut )"
45

  
46
S="${WORKDIR}/${MY_P}"
47

  
48
# Bug #480664 requested UPS_DRIVERS_IUSE for more flexibility in building this package
49
SERIAL_DRIVERLIST="al175 bcmxcp belkin belkinunv bestfcom bestfortress bestuferrups bestups dummy-ups etapro everups gamatronic genericups isbmex liebert liebert-esp2 masterguard metasys oldmge-shut mge-utalk microdowell mge-shut oneac optiups powercom rhino safenet solis tripplite tripplitesu upscode2 victronups powerpanel blazer_ser clone clone-outlet ivtscd apcsmart apcsmart-old apcupsd-ups riello_ser nutdrv_qx"
50
SNMP_DRIVERLIST="snmp-ups"
51
USB_LIBUSB_DRIVERLIST="usbhid-ups bcmxcp_usb tripplite_usb blazer_usb richcomm_usb riello_usb nutdrv_qx"
52
USB_DRIVERLIST=${USB_LIBUSB_DRIVERLIST}
53
#HAL_DRIVERLIST="usbhid-ups bcmxcp_usb tripplite_usb blazer_usb riello_usb nutdrv_qx"
54
NEONXML_DRIVERLIST="netxml-ups"
55
IPMI_DRIVERLIST="nut-ipmipsu"
56
# Now we build from it:
57
for name in ${SERIAL_DRIVERLIST} ; do
58
	IUSE_UPS_DRIVERS="${IUSE_UPS_DRIVERS} +ups_drivers_${name}"
59
done
60
for name in ${USB_DRIVERLIST} ; do
61
	IUSE_UPS_DRIVERS="${IUSE_UPS_DRIVERS} +ups_drivers_${name}"
62
	REQUIRED_USE="${REQUIRED_USE} ups_drivers_${name}? ( usb )"
63
done
64
for name in ${NEONXML_DRIVERLIST}; do
65
	IUSE_UPS_DRIVERS="${IUSE_UPS_DRIVERS} ups_drivers_${name}"
66
	REQUIRED_USE="${REQUIRED_USE} ups_drivers_${name}? ( xml )"
67
done
68
for name in ${SNMP_DRIVERLIST} ; do
69
	IUSE_UPS_DRIVERS="${IUSE_UPS_DRIVERS} ups_drivers_${name}"
70
	REQUIRED_USE="${REQUIRED_USE} ups_drivers_${name}? ( snmp )"
71
done
72
for name in ${IPMI_DRIVERLIST} ; do
73
	IUSE_UPS_DRIVERS="${IUSE_UPS_DRIVERS} ups_drivers_${name}"
74
	REQUIRED_USE="${REQUIRED_USE} ups_drivers_${name}? ( ipmi )"
75
done
76
IUSE="${IUSE} ${IUSE_UPS_DRIVERS}"
77

  
78
# public files should be 644 root:root
79
NUT_PUBLIC_FILES="/etc/nut/{ups,upssched}.conf"
80
# private files should be 640 root:nut - readable by nut, writeable by root,
81
NUT_PRIVATE_FILES="/etc/nut/{upsd.conf,upsd.users,upsmon.conf}"
82
# public files should be 644 root:root, only installed if USE=cgi
83
NUT_CGI_FILES="/etc/nut/{{hosts,upsset}.conf,upsstats{,-single}.html}"
52
	selinux? ( sec-policy/selinux-nut )
53
"
84 54

  
85 55
PATCHES=(
86
	"${FILESDIR}"/${PN}-2.7.1-snmpusb-order.patch
87
	"${FILESDIR}"/${PN}-2.6.2-lowspeed-buffer-size.patch
88
	"${FILESDIR}"/nut-openssl-1.1-support.patch
89
	"${FILESDIR}"/nut-2.7.4-py3.patch
90
	"${FILESDIR}"/nut-2.7.4-nut-scanner.patch
91
	"${FILESDIR}"/nut-2.7.4-slibtool.patch
56
	"${FILESDIR}/${PN}-2.6.2-lowspeed-buffer-size.patch"
92 57
)
93 58

  
94
src_prepare() {
95
	default
96

  
97
	sed -e "s:GD_LIBS.*=.*-L/usr/X11R6/lib \(.*\) -lXpm -lX11:GD_LIBS=\"\1:" \
98
		-e '/systemdsystemunitdir=.*echo.*sed.*libdir/s,^,#,g' \
99
		-i configure.ac || die
100

  
101
	sed -e "s:52.nut-usbups.rules:70-nut-usbups.rules:" \
102
		-i scripts/udev/Makefile.am || die
59
pkg_pretend() {
60
	if use i2c; then
61
		CONFIG_CHECK="~I2C_CHARDEV"
62
		ERROR_I2C_CHARDEV="You must enable I2C_CHARDEV in your kernel to continue"
63
	fi
64
	if use usb; then
65
		CONFIG_CHECK+=" ~HIDRAW ~USB_HIDDEV"
66
		ERROR_HIDRAW="HIDRAW is needed to support USB UPSes"
67
		ERROR_I2C_CHARDEV="USB_HIDDEV is needed to support USB UPSes"
68
	fi
69
	if use serial; then
70
		CONFIG_CHECK="~SERIAL_8250"
71
		ERROR_SERIAL_8250="SERIAL_8250 is needed to support Serial UPSes"
72
	fi
103 73

  
104
	rm ltmain.sh m4/lt* m4/libtool.m4 || die
74
	# Now do the actual checks setup above
75
	check_extra_config
76
}
105 77

  
106
	sed -e 's:@LIBSSL_LDFLAGS@:@LIBSSL_LIBS@:' \
107
		-i lib/libupsclient{.pc,-config}.in || die #361685
78
src_prepare() {
79
	default
108 80

  
109
	eautoreconf
81
	if [[ ${PV} == *9999 ]] ; then
82
		./autogen.sh || die
83
	fi
110 84
}
111 85

  
112 86
src_configure() {
113
	local myconf
87
	local myeconfargs=(
88
		--datadir=/usr/share/nut
89
		--datarootdir=/usr/share/nut
90
		--disable-static
91
		--disable-strip
92
		--disable-Werror
93
		--sysconfdir=/etc/nut
94
		--with-dev
95
		--with-drvpath="/$(get_libdir)/nut"
96
		--with-group=nut
97
		--with-htmlpath=/usr/share/nut/html
98
		--with-logfacility=LOG_DAEMON
99
		--with-statepath=/var/lib/nut
100
		--with-systemdsystemunitdir="$(systemd_get_systemunitdir)"
101
		--with-systemdtmpfilesdir="/usr/lib/tmpfiles.d"
102
		--with-udev-dir="$(get_udevdir)"
103
		--with-user=nut
104
		--without-powerman
105
		--without-python
106
		--without-python2
107
		--without-python3
108
		--with-altpidpath=/run/nut
109
		--with-pidpath=/run/nut
110
		$(use_enable test cppunit)
111
		$(use_with cgi)
112
		$(use_with i2c linux_i2c)
113
		$(use_with ipmi freeipmi)
114
		$(use_with ipmi)
115
		$(use_with serial)
116
		$(use_with snmp)
117
		$(use_with ssl)
118
		$(use_with tcpd wrap)
119
		$(use_with usb)
120
		$(use_with xml neon)
121
		$(use_with zeroconf avahi)
122
	)
114 123

  
115 124
	filter-lto
116
	# bug #786702
117
	append-cxxflags -std=c++14
125
	append-flags -fno-lto
126
	tc-export CC CXX AR
118 127

  
119
	tc-export CC
120
	tc-export CXX
121
	tc-export AR
122

  
123
	local UPS_DRIVERS=""
124
	for u in $USE ; do
125
		u2=${u#ups_drivers_}
126
		[[ "${u}" != "${u2}" ]] && UPS_DRIVERS="${UPS_DRIVERS} ${u2}"
127
	done
128
	UPS_DRIVERS="${UPS_DRIVERS# }" UPS_DRIVERS="${UPS_DRIVERS% }"
129
	myconf="${myconf} --with-drivers=${UPS_DRIVERS// /,}"
128
	use cgi && myeconfargs+=( --with-cgipath=/usr/share/nut/cgi )
129
	use man && myeconfargs+=( --with-doc=man )
130 130

  
131
	use cgi && myconf="${myconf} --with-cgipath=/usr/share/nut/cgi"
131
	export bashcompdir="$(get_bashcompdir)"
132 132

  
133
	# TODO: USE flag for sys-power/powerman
134
	econf \
135
		--sysconfdir=/etc/nut \
136
		--datarootdir=/usr/share/nut \
137
		--datadir=/usr/share/nut \
138
		--disable-static \
139
		--with-statepath=/var/lib/nut \
140
		--with-drvpath=/$(get_libdir)/nut \
141
		--with-htmlpath=/usr/share/nut/html \
142
		--with-user=nut \
143
		--with-group=nut \
144
		--with-logfacility=LOG_DAEMON \
145
		--with-dev \
146
		--with-serial \
147
		--with-systemdsystemunitdir="$(systemd_get_systemunitdir)" \
148
		--without-powerman \
149
		$(use_with cgi) \
150
		$(use_with ipmi) \
151
		$(use_with ipmi freeipmi) \
152
		$(use_with snmp) \
153
		$(use_with ssl) \
154
		$(use_with tcpd wrap) \
155
		$(use_with usb) \
156
		$(use_with xml neon) \
157
		$(use_with zeroconf avahi) \
158
		${myconf}
133
	econf "${myeconfargs[@]}"
159 134
}
160 135

  
161 136
src_install() {
162
	emake DESTDIR="${D}" install
137
	default
163 138

  
164
	find "${D}" -name '*.la' -delete || die
139
	rm -rf "${ED}/etc/hotplug" || die
140

  
141
	find "${ED}" -name '*.la' -delete || die
165 142

  
166 143
	dodir /sbin
167 144
	use split-usr && dosym ../usr/sbin/upsdrvctl /sbin/upsdrvctl
168 145

  
169 146
	if use cgi; then
170
		elog "CGI monitoring scripts are installed in /usr/share/nut/cgi."
147
		elog "CGI monitoring scripts are installed in ${EPREFIX}/usr/share/nut/cgi."
171 148
		elog "copy them to your web server's ScriptPath to activate (this is a"
172 149
		elog "change from the old location)."
173 150
		elog "If you use lighttpd, see lighttpd_nut.conf in the documentation."
151
		elog
152
		elog "Use script aliases according to the web server you use (apache, nginx, lighttpd, etc...)"
174 153
	fi
175 154

  
176
	# this must be done after all of the install phases
177
	for i in "${D}"/etc/nut/*.sample ; do
155
	# This must be done after all of the install phases
156
	local i
157
	for i in "${ED}"/etc/nut/*.sample ; do
178 158
		mv "${i}" "${i/.sample/}" || die
179 159
	done
180 160

  
181
	local DOCS=( AUTHORS ChangeLog docs/*.txt MAINTAINERS NEWS README TODO UPGRADING )
161
	local DOCS=( AUTHORS MAINTAINERS NEWS README TODO UPGRADING )
182 162
	einstalldocs
183 163

  
184
	newdoc lib/README README.lib
185
	newdoc "${FILESDIR}"/lighttpd_nut.conf-2.2.0 lighttpd_nut.conf
186

  
187
	docinto cables
188
	dodoc docs/cables/*
164
	if use doc; then
165
		newdoc lib/README README.lib
166
		dodoc docs/*.txt
167
		docinto cables
168
		dodoc docs/cables/*
169
	fi
189 170

  
190
	newinitd "${FILESDIR}"/nut-2.6.5-init.d-upsd upsd
171
	newinitd "${FILESDIR}"/nut-2.8.0-init.d-upsd upsd
191 172
	newinitd "${FILESDIR}"/nut-2.2.2-init.d-upsdrv upsdrv
192 173
	newinitd "${FILESDIR}"/nut-2.6.5-init.d-upsmon upsmon
193 174
	newinitd "${FILESDIR}"/nut-2.6.5-init.d-upslog upslog
194 175
	newinitd "${FILESDIR}"/nut.powerfail.initd nut.powerfail
195 176

  
196
	keepdir /var/lib/nut
197

  
198
	einfo "Setting up permissions on files and directories"
199
	fperms 0700 /var/lib/nut
200
	fowners nut:nut /var/lib/nut
201

  
202
	# Do not remove eval here, because the variables contain shell expansions.
203
	eval fperms 0640 ${NUT_PRIVATE_FILES}
204
	eval fowners root:nut ${NUT_PRIVATE_FILES}
205

  
206
	# Do not remove eval here, because the variables contain shell expansions.
207
	eval fperms 0644 ${NUT_PUBLIC_FILES}
208
	eval fowners root:root ${NUT_PUBLIC_FILES}
177
	newbashcomp "${S}"/scripts/misc/nut.bash_completion upsc
178
	bashcomp_alias upsc upscmd upsd upsdrvctl upsmon upsrw
209 179

  
210
	# Do not remove eval here, because the variables contain shell expansions.
211
	if use cgi; then
212
		eval fperms 0644 ${NUT_CGI_FILES}
213
		eval fowners root:root ${NUT_CGI_FILES}
180
	if use zeroconf; then
181
		insinto /etc/avahi/services
182
		doins scripts/avahi/nut.service
214 183
	fi
215 184

  
216
	# this is installed for 2.4 and fbsd guys
217
	if ! has_version virtual/udev; then
218
		einfo "Installing non-udev hotplug support"
219
		insinto /etc/hotplug/usb
220
		insopts -m 755
221
		doins scripts/hotplug/nut-usbups.hotplug
222
	fi
185
	mv "${ED}"/usr/lib/tmpfiles.d/nut-common.tmpfiles "${ED}"/usr/lib/tmpfiles.d/nut-common-tmpfiles.conf || die
223 186

  
224
	newbashcomp "${S}"/scripts/misc/nut.bash_completion upsc
225
	bashcomp_alias upsc upscmd upsd upsdrvctl upsmon upsrw
187
	# Fix double directory
188
	sed -i -e 's:/nut/nut:/nut:g' "${ED}"/usr/lib/tmpfiles.d/nut-common-tmpfiles.conf || die
226 189
}
227 190

  
228 191
pkg_postinst() {
229
	# this is to ensure that everybody that installed old versions still has
230
	# correct permissions
192
	elog "Please note that NUT now runs under the 'nut' user."
193
	elog "NUT is in the uucp group for access to RS-232 UPS."
194
	elog "However if you use a USB UPS you may need to look at the udev or"
195
	elog "hotplug rules that are installed, and alter them suitably."
196
	elog
197
	elog "You are strongly advised to read the UPGRADING file provided by upstream."
198
	elog
199
	elog "Please note that upsdrv is NOT automatically started by upsd anymore."
200
	elog "If you have multiple UPS units, you can use their NUT names to"
201
	elog "have a service per UPS:"
202
	elog "ln -s /etc/init.d/upsdrv /etc/init.d/upsdrv.\$UPSNAME"
203
	elog
204
	elog 'If you want apcupsd to power off your UPS when it'
205
	elog 'shuts down your system in a power failure, you must'
206
	elog 'add nut.powerfail to your shutdown runlevel:'
207
	elog
208
	elog 'rc-update add nut.powerfail shutdown'
209
	elog
231 210

  
232
	chown nut:nut "${ROOT}"/var/lib/nut 2>/dev/null
233
	chmod 0700 "${ROOT}"/var/lib/nut 2>/dev/null
211
	optfeature "all notify events generate a global message (wall) to all users, plus they are logged via the syslog" \
212
		sys-apps/util-linux[logger,tty-helpers]
234 213

  
235
	# Do not remove eval here, because the variables contain shell expansions.
236
	eval chown root:nut "${ROOT}"${NUT_PRIVATE_FILES} 2>/dev/null
237
	eval chmod 0640 "${ROOT}"${NUT_PRIVATE_FILES} 2>/dev/null
214
	udev_reload
238 215

  
239
	# Do not remove eval here, because the variables contain shell expansions.
240
	eval chown root:root "${ROOT}"${NUT_PUBLIC_FILES} 2>/dev/null
241
	eval chmod 0644 "${ROOT}"${NUT_PUBLIC_FILES} 2>/dev/null
242

  
243
	# Do not remove eval here, because the variables contain shell expansions.
244
	if use cgi; then
245
		eval chown root:root "${ROOT}"${NUT_CGI_FILES} 2>/dev/null
246
		eval chmod 0644 "${ROOT}"${NUT_CGI_FILES} 2>/dev/null
247
	fi
248

  
249
	warningmsg elog
216
	tmpfiles_process nut-common-tmpfiles.conf
250 217
}
251 218

  
252
warningmsg() {
253
	msgfunc="$1"
254
	[ -z "$msgfunc" ] && die "msgfunc not specified in call to warningmsg!"
255
	${msgfunc} "Please note that NUT now runs under the 'nut' user."
256
	${msgfunc} "NUT is in the uucp group for access to RS-232 UPS."
257
	${msgfunc} "However if you use a USB UPS you may need to look at the udev or"
258
	${msgfunc} "hotplug rules that are installed, and alter them suitably."
259
	${msgfunc} ''
260
	${msgfunc} "You are strongly advised to read the UPGRADING file provided by upstream."
261
	${msgfunc} ''
262
	${msgfunc} "Please note that upsdrv is NOT automatically started by upsd anymore."
263
	${msgfunc} "If you have multiple UPS units, you can use their NUT names to"
264
	${msgfunc} "have a service per UPS:"
265
	${msgfunc} "ln -s /etc/init.d/upsdrv /etc/init.d/upsdrv.\$UPSNAME"
266
	${msgfunc} ''
267
	${msgfunc} 'If you want apcupsd to power off your UPS when it'
268
	${msgfunc} 'shuts down your system in a power failure, you must'
269
	${msgfunc} 'add nut.powerfail to your shutdown runlevel:'
270
	${msgfunc} ''
271
	${msgfunc} 'rc-update add nut.powerfail shutdown'
272
	${msgfunc} ''
273

  
219
pkg_postrm() {
220
	udev_reload
274 221
}
Спасибо!