Skip to content

Commit aa4e727

Browse files
authored
Merge pull request #3311 from jimklimov/fix-fedora-43
More warnings and docs fix to build under Fedora 43
2 parents 9bd31ff + 6ebc852 commit aa4e727

11 files changed

Lines changed: 111 additions & 33 deletions

clients/upsclient.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -501,7 +501,7 @@ int upscli_init(int certverify, const char *certpath,
501501
void upscli_add_host_cert(const char* hostname, const char* certname, int certverify, int forcessl)
502502
{
503503
#ifdef WITH_NSS
504-
HOST_CERT_t* cert = xmalloc(sizeof(HOST_CERT_t));
504+
HOST_CERT_t* cert = (HOST_CERT_t *)xmalloc(sizeof(HOST_CERT_t));
505505
cert->next = first_host_cert;
506506
cert->host = xstrdup(hostname);
507507
cert->certname = xstrdup(certname);

docs/config-prereqs.txt

Lines changed: 51 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -313,16 +313,21 @@ NOTE: For Jenkins agents, also need to `apt-get install openjdk-21-jdk-headless`
313313
You may have to ensure that `/proc` is mounted in the target chroot
314314
(or do this from the running container).
315315

316-
CentOS 6 and 7
317-
~~~~~~~~~~~~~~
316+
CentOS 6 and 7, Fedora 43
317+
~~~~~~~~~~~~~~~~~~~~~~~~~
318318

319319
CentOS is another popular baseline among Linux distributions, being a free
320320
derivative of the RedHat Linux, upon which many other distros are based as
321321
well. These systems typically use the RPM package manager, using directly
322322
`rpm` command, or `yum` or `dnf` front-ends depending on their generation.
323323

324+
In fact, most of the instructions directly apply to much newer distributions
325+
like Fedora 43.
326+
324327
For CI farm container setup, prepared root filesystem archives from
325328
http://download.proxmox.com/images/system/ worked sufficiently well.
329+
For Fedora, https://images.linuxcontainers.org/images/fedora/43/amd64/default
330+
nightly image was used.
326331

327332
Prepare CentOS repository mirrors
328333
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -388,6 +393,7 @@ enable it:
388393
:; yum install \
389394
openssh-server openssh-clients
390395

396+
# On CentOS 6/7:
391397
:; chkconfig sshd on
392398
:; service sshd start
393399

@@ -400,8 +406,8 @@ NOTE: Below we request to install generic `python` per system defaults.
400406
You may request specifically `python2` or `python3` (or both): current
401407
NUT should be compatible with both (2.7+ at least).
402408

403-
NOTE: On CentOS, `libusb` means 0.1.x and `libusbx` means 1.x.x API version
404-
(latter is not available for CentOS 6).
409+
NOTE: On CentOS, `libusb` means 0.1.x (not available on modern Fedora),
410+
and `libusbx` means 1.x.x API version (latter is not available for CentOS 6).
405411

406412
NOTE: On CentOS, it seems that development against libi2c/smbus is not
407413
supported. Neither the suitable devel packages were found, nor i2c-based
@@ -435,6 +441,8 @@ drivers in distro packaging of NUT. Resolution and doc PRs are welcome.
435441
# You can find a list of what is (pre-)installed with:
436442
# :; rpm -qa | grep -Ei 'perl|python'
437443
# Note that CentOS 6 includes python-2.6.x and does not serve newer versions
444+
# For Fedora 43, further packages can be installed to test more:
445+
# :; yum install python3-qt5 python3-setuptools
438446

439447
# For spell-checking, highly recommended if you would propose pull requests:
440448
:; yum install \
@@ -445,6 +453,10 @@ drivers in distro packaging of NUT. Resolution and doc PRs are welcome.
445453
:; yum install \
446454
asciidoc source-highlight python-pygments dblatex
447455

456+
# For PDF generation, you may need explicitly (at least on Fedora 43):
457+
:; yum install \
458+
texlive 'tex(upquote.sty)'
459+
448460
# For CGI graph generation - massive packages (X11):
449461
:; yum install \
450462
gd-devel
@@ -454,34 +466,57 @@ drivers in distro packaging of NUT. Resolution and doc PRs are welcome.
454466
systemd-devel
455467

456468
# NOTE: "libusbx" is the CentOS way of naming "libusb-1.0" (not in CentOS 6)
457-
# vs. the older "libusb" as the package with "libusb-0.1"
469+
# vs. the older "libusb" as the package with "libusb-0.1" (not in recent Fedora)
470+
:; yum install \
471+
libusb-devel
472+
473+
:; yum install \
474+
libusbx-devel
475+
458476
:; yum install \
459477
cppunit-devel \
460478
openssl-devel nss-devel \
461479
augeas augeas-devel \
462-
libusb-devel libusbx-devel \
463480
glib2-devel \
464481
i2c-tools \
465482
libmodbus-devel \
466483
net-snmp-devel \
467-
powerman-devel \
468484
freeipmi-devel \
469485
avahi-devel \
470486
neon-devel
487+
488+
# Not in recent Fedora releases:
489+
:; yum install \
490+
powerman-devel
491+
492+
# Not in CentOS, some present in Fedora:
471493
#?# is python-augeas needed? exists at least...
472494
#?# no (lib)i2c-devel ...
473495
#?# no (lib)ipmimonitoring-devel ... would "freeipmi-ipmidetectd"
474496
#?# cut it at least for run-time?
475497
#?# no (lib)gpio(d)-devel - starts with CentOS 8 (or extra repositories
476498
#?# for later minor releases of CentOS 7)
477499

500+
# In Fedora:
501+
:; yum install \
502+
libi2c-devel \
503+
libgpiod-devel
504+
478505
# Some NUT code related to lua may be currently limited to lua-5.1
479506
# or possibly 5.2; the former is default in CentOS 7 releases...
480507
:; yum install \
481508
lua-devel
482509

483510
:; yum install \
484511
bash dash ksh
512+
513+
# If available:
514+
:; yum install \
515+
bash-completion
516+
517+
# In Fedora:
518+
:; yum install \
519+
busybox
485520
------
486521

487522
NOTE: `busybox` is not packaged for CentOS 7 release; a static binary can
@@ -499,8 +534,15 @@ other described environments by adding a symlink `/usr/lib/ccache`:
499534
======
500535
For Jenkins agents, also need to install JDK 17 or newer, which is not
501536
available for CentOS 6 nor 7 directly (in distribution packaging).
502-
Alternative packaging, such as Temurin from the Adoptium project, is possible
503-
(checked for at least CentOS 7), see
537+
538+
In Fedora e.g.:
539+
------
540+
:; yum install \
541+
java-21-openjdk-headless
542+
------
543+
544+
Alternative packaging for older distros, such as Temurin from the Adoptium
545+
project, is possible (checked for at least CentOS 7), see
504546
link:https://adoptium.net/installation/linux/#_centosrhelfedora_instructions[their
505547
instructions] for specific details. This may require updated library package
506548
versions as dependencies from the OS distribution, so you may also have to make

docs/download.txt

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,9 +79,13 @@ workspace to try subsequent iterations), although the latter are now also
7979
available for development iterations.
8080

8181
See the live Wiki article on
82-
https://github.com/networkupstools/nut/wiki/Building-NUT-for-in%E2%80%90place-upgrades-or-non%E2%80%90disruptive-tests
83-
for latest suggestions for building, testing and installing the latest
84-
NUT code base.
82+
link:https://github.com/networkupstools/nut/wiki/Building-NUT-for-in%E2%80%90place-upgrades-or-non%E2%80%90disruptive-tests[Building
83+
NUT for in-place upgrades or non-disruptive tests]
84+
for the most up-to-date suggestions for building, testing and installing
85+
the latest (or experimental) revisions of the NUT code base, and
86+
link:https://github.com/networkupstools/nut/wiki/Finding-recent-development-iteration-artifacts[Finding
87+
recent development iteration artifacts] about fetching the results of
88+
the hard work done by the NUT CI farm.
8589

8690
Code repository
8791
^^^^^^^^^^^^^^^

docs/nut.dict

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
personal_ws-1.1 en 3655 utf-8
1+
personal_ws-1.1 en 3659 utf-8
22
AAC
33
AAS
44
ABI
@@ -3137,6 +3137,7 @@ setproctag
31373137
setq
31383138
setuid
31393139
setupCommands
3140+
setuptools
31403141
setvar
31413142
setvar's
31423143
sfr
@@ -3335,6 +3336,8 @@ testime
33353336
testtime
33363337
testuser
33373338
testvar
3339+
tex
3340+
texlive
33383341
textproc
33393342
tgcware
33403343
tgt
@@ -3436,6 +3439,7 @@ unstash
34363439
updateinfo
34373440
upexia
34383441
upower
3442+
upquote
34393443
upsBypassCurrent
34403444
upsBypassPower
34413445
upsBypassVoltage

drivers/generic_gpio_common.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -75,13 +75,13 @@ struct gpioups_t *generic_gpio_open(const char *chipName) {
7575
if (!rules) /* rules is required configuration parameter */
7676
fatalx(EXIT_FAILURE, "UPS status calculation rules not specified");
7777

78-
upsfdlocal = xcalloc(1, sizeof(*upsfdlocal));
78+
upsfdlocal = (struct gpioups_t *)xcalloc(1, sizeof(*upsfdlocal));
7979

8080
upsfdlocal->runOptions = 0; /* don't use ROPT_REQRES and ROPT_EVMODE yet */
8181
upsfdlocal->chipName = chipName;
8282

8383
get_ups_rules(upsfdlocal, (unsigned char *)rules);
84-
upsfdlocal->upsLinesStates = xcalloc(upsfdlocal->upsLinesCount, sizeof(int));
84+
upsfdlocal->upsLinesStates = (int *)xcalloc(upsfdlocal->upsLinesCount, sizeof(int));
8585

8686
return upsfdlocal;
8787
}
@@ -122,7 +122,7 @@ void add_rule_item(struct gpioups_t *upsfdlocal, int newValue) {
122122
int subCount = (upsfdlocal->rules[upsfdlocal->rulesCount - 1]) ? upsfdlocal->rules[upsfdlocal->rulesCount - 1]->subCount + 1 : 1;
123123
int itemSize = subCount * sizeof(upsfdlocal->rules[0]->cRules[0]) + sizeof(rulesint);
124124

125-
upsfdlocal->rules[upsfdlocal->rulesCount - 1] = xrealloc(upsfdlocal->rules[upsfdlocal->rulesCount - 1], itemSize);
125+
upsfdlocal->rules[upsfdlocal->rulesCount - 1] = (struct rulesint_t *)xrealloc(upsfdlocal->rules[upsfdlocal->rulesCount - 1], itemSize);
126126
upsfdlocal->rules[upsfdlocal->rulesCount - 1]->subCount = subCount;
127127
upsfdlocal->rules[upsfdlocal->rulesCount - 1]->cRules[subCount - 1] = newValue;
128128
}
@@ -197,8 +197,8 @@ void get_ups_rules(struct gpioups_t *upsfdlocal, unsigned char *rulesString) {
197197
} else {
198198
lexStatus = 1;
199199
upsfdlocal->rulesCount++;
200-
upsfdlocal->rules = xrealloc(upsfdlocal->rules, (size_t)(sizeof(upsfdlocal->rules[0])*upsfdlocal->rulesCount));
201-
upsfdlocal->rules[upsfdlocal->rulesCount -1 ] = xcalloc(1, sizeof(rulesint));
200+
upsfdlocal->rules = (struct rulesint_t **)xrealloc(upsfdlocal->rules, (size_t)(sizeof(upsfdlocal->rules[0])*upsfdlocal->rulesCount));
201+
upsfdlocal->rules[upsfdlocal->rulesCount -1 ] = (struct rulesint_t *)xcalloc(1, sizeof(rulesint));
202202
strncpy(upsfdlocal->rules[upsfdlocal->rulesCount - 1]->stateName, (char *)(rulesString + startPos), endPos - startPos);
203203
upsfdlocal->rules[upsfdlocal->rulesCount - 1]->stateName[endPos - startPos] = 0;
204204
}
@@ -291,7 +291,7 @@ void get_ups_rules(struct gpioups_t *upsfdlocal, unsigned char *rulesString) {
291291
if (!pinOnList) {
292292
if (upsfdlocal->rules[i]->cRules[j] >= 0) {
293293
upsfdlocal->upsLinesCount++;
294-
upsfdlocal->upsLines = xrealloc(upsfdlocal->upsLines, sizeof(upsfdlocal->upsLines[0])*upsfdlocal->upsLinesCount);
294+
upsfdlocal->upsLines = (int *)xrealloc(upsfdlocal->upsLines, sizeof(upsfdlocal->upsLines[0])*upsfdlocal->upsLinesCount);
295295
upsfdlocal->upsLines[upsfdlocal->upsLinesCount - 1] = upsfdlocal->rules[i]->cRules[j];
296296
if (upsfdlocal->upsLines[upsfdlocal->upsLinesCount - 1] > upsfdlocal->upsMaxLine) {
297297
upsfdlocal->upsMaxLine = upsfdlocal->upsLines[upsfdlocal->upsLinesCount - 1];

drivers/generic_gpio_libgpiod.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -121,15 +121,15 @@ static void reserve_lines_libgpiod(struct gpioups_t *gpioupsfdlocal, int inner)
121121
* and check lines numbers validity - consistency with h/w chip
122122
*/
123123
void gpio_open(struct gpioups_t *gpioupsfdlocal) {
124-
struct libgpiod_data_t *libgpiod_data = xcalloc(1, sizeof(struct libgpiod_data_t));
124+
struct libgpiod_data_t *libgpiod_data = (struct libgpiod_data_t *)xcalloc(1, sizeof(struct libgpiod_data_t));
125125
gpioupsfdlocal->lib_data = libgpiod_data;
126126

127127
#if WITH_LIBGPIO_VERSION < 0x00020000
128128
libgpiod_data->gpioChipHandle = gpiod_chip_open_by_name(gpioupsfdlocal->chipName);
129129
#else /* #if WITH_LIBGPIO_VERSION >= 0x00020000 */
130130
if(!strchr(gpioupsfdlocal->chipName, '/')) {
131131
size_t pathNameLen = strlen(gpioupsfdlocal->chipName)+6;
132-
char *pathName = xcalloc(pathNameLen, sizeof(char));
132+
char *pathName = (char *)xcalloc(pathNameLen, sizeof(char));
133133
strncpy(pathName, "/dev/", pathNameLen);
134134
strncat(pathName, gpioupsfdlocal->chipName, pathNameLen);
135135
libgpiod_data->gpioChipHandle = gpiod_chip_open(pathName);
@@ -182,7 +182,7 @@ void gpio_open(struct gpioups_t *gpioupsfdlocal) {
182182
&libgpiod_data->gpioLines
183183
);
184184
#else /* #if WITH_LIBGPIO_VERSION >= 0x00020000 */
185-
libgpiod_data->values = xcalloc(gpioupsfdlocal->upsLinesCount, sizeof(*libgpiod_data->values));
185+
libgpiod_data->values = (enum gpiod_line_value *)xcalloc(gpioupsfdlocal->upsLinesCount, sizeof(*libgpiod_data->values));
186186
lineSettings = gpiod_line_settings_new();
187187
libgpiod_data->lineConfig = gpiod_line_config_new();
188188
libgpiod_data->config = gpiod_request_config_new();

drivers/nutdrv_qx_voltronic-axpert.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2419,7 +2419,7 @@ static int voltronic_sunny_energy_hour(item_t *item, char *command, const size_t
24192419
return -1;
24202420
}
24212421

2422-
buf = xcalloc(commandlen, sizeof(char));
2422+
buf = (char *)xcalloc(commandlen, sizeof(char));
24232423
if (!buf) {
24242424
upsdebugx(2, "%s: cannot allocate buffer", __func__);
24252425
return -1;
@@ -2448,7 +2448,7 @@ static int voltronic_sunny_energy_day(item_t *item, char *command, const size_t
24482448
return -1;
24492449
}
24502450

2451-
buf = xcalloc(commandlen, sizeof(char));
2451+
buf = (char *)xcalloc(commandlen, sizeof(char));
24522452
if (!buf) {
24532453
upsdebugx(2, "%s: cannot allocate buffer", __func__);
24542454
return -1;
@@ -2477,7 +2477,7 @@ static int voltronic_sunny_energy_month(item_t *item, char *command, const size_
24772477
return -1;
24782478
}
24792479

2480-
buf = xcalloc(commandlen, sizeof(char));
2480+
buf = (char *)xcalloc(commandlen, sizeof(char));
24812481
if (!buf) {
24822482
upsdebugx(2, "%s: cannot allocate buffer", __func__);
24832483
return -1;
@@ -2506,7 +2506,7 @@ static int voltronic_sunny_energy_year(item_t *item, char *command, const size_t
25062506
return -1;
25072507
}
25082508

2509-
buf = xcalloc(commandlen, sizeof(char));
2509+
buf = (char *)xcalloc(commandlen, sizeof(char));
25102510
if (!buf) {
25112511
upsdebugx(2, "%s: cannot allocate buffer", __func__);
25122512
return -1;

scripts/augeas/gen-nutupsconf-aug.py.in

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,15 @@ import os
2727
import re
2828
import glob
2929

30+
HAVE_WARNINGS = False
31+
try:
32+
import warnings
33+
warnings.filterwarnings("error")
34+
HAVE_WARNINGS = True
35+
except Exception as x:
36+
# sys.stderr.write("WARNING: failed to import warnings or configure them: %s" % str(x))
37+
pass
38+
3039
try:
3140
# NOTE: Deprecated as of python3.14
3241
import codecs
@@ -47,6 +56,9 @@ except Exception as x:
4756
HAVE_CODECS = False
4857
USE_CODECS = False
4958

59+
if HAVE_WARNINGS:
60+
warnings.resetwarnings()
61+
5062
# Return a sorted list of unique entries, based on the input 'list'
5163
def sortUnique(list):
5264
newVarList = []
@@ -129,9 +141,11 @@ if __name__ == '__main__':
129141
defRow = re.findall(r'"([^"]*)",?', varDefine)
130142
if (len(defRow) == 1):
131143
variableNames.append(defRow[0])
144+
defFd.close()
132145
else:
133146
# Remove quotes
134147
variableNames.append(row[1].replace('"', '').lstrip())
148+
fd.close()
135149

136150
# Filter multiply defined variables
137151
variableNames = sortUnique(variableNames)
@@ -148,6 +162,7 @@ if __name__ == '__main__':
148162

149163
# 2.1/ Search for the pattern to replace
150164
outputText = tplFd.read()
165+
tplFd.close()
151166
outputText = outputText.replace('@SPECIFIC_DRV_VARS@', specificVars)
152167

153168
# 3/ Output final lens
@@ -156,3 +171,4 @@ if __name__ == '__main__':
156171
else:
157172
outFd = open(outputFilename, mode='w', encoding='utf-8')
158173
outFd.write(outputText)
174+
outFd.close()

scripts/python/module/setup.py.in

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,15 @@ import sys
1010

1111
here = os.path.abspath(os.path.dirname(__file__))
1212

13+
HAVE_WARNINGS = False
14+
try:
15+
import warnings
16+
warnings.filterwarnings("error")
17+
HAVE_WARNINGS = True
18+
except Exception as x:
19+
# sys.stderr.write("WARNING: failed to import warnings or configure them: %s" % str(x))
20+
pass
21+
1322
try:
1423
# NOTE: Deprecated as of python3.14
1524
import codecs
@@ -30,6 +39,9 @@ except Exception as x:
3039
HAVE_CODECS = False
3140
USE_CODECS = False
3241

42+
if HAVE_WARNINGS:
43+
warnings.resetwarnings()
44+
3345
# README.txt appears from README.adoc during package or CI build
3446
if USE_CODECS:
3547
with codecs.open(os.path.join(here, "README.txt"), encoding="utf-8") as fh:

tests/generic_gpio_liblocal.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,7 @@ int gpiod_line_request_get_values(
271271
return -1;
272272
}
273273
for(i=0; i<num_lines; i++) {
274-
values[i]=(gStatus&pinPos)!=0;
274+
values[i]= ( (gStatus&pinPos)!=0 ? GPIOD_LINE_VALUE_ACTIVE : GPIOD_LINE_VALUE_INACTIVE);
275275
pinPos=pinPos<<1;
276276
}
277277

0 commit comments

Comments
 (0)