Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion clients/upsclient.c
Original file line number Diff line number Diff line change
Expand Up @@ -501,7 +501,7 @@ int upscli_init(int certverify, const char *certpath,
void upscli_add_host_cert(const char* hostname, const char* certname, int certverify, int forcessl)
{
#ifdef WITH_NSS
HOST_CERT_t* cert = xmalloc(sizeof(HOST_CERT_t));
HOST_CERT_t* cert = (HOST_CERT_t *)xmalloc(sizeof(HOST_CERT_t));
cert->next = first_host_cert;
cert->host = xstrdup(hostname);
cert->certname = xstrdup(certname);
Expand Down
60 changes: 51 additions & 9 deletions docs/config-prereqs.txt
Original file line number Diff line number Diff line change
Expand Up @@ -313,16 +313,21 @@ NOTE: For Jenkins agents, also need to `apt-get install openjdk-21-jdk-headless`
You may have to ensure that `/proc` is mounted in the target chroot
(or do this from the running container).

CentOS 6 and 7
~~~~~~~~~~~~~~
CentOS 6 and 7, Fedora 43
~~~~~~~~~~~~~~~~~~~~~~~~~

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

In fact, most of the instructions directly apply to much newer distributions
like Fedora 43.

For CI farm container setup, prepared root filesystem archives from
http://download.proxmox.com/images/system/ worked sufficiently well.
For Fedora, https://images.linuxcontainers.org/images/fedora/43/amd64/default
nightly image was used.

Prepare CentOS repository mirrors
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Expand Down Expand Up @@ -388,6 +393,7 @@ enable it:
:; yum install \
openssh-server openssh-clients

# On CentOS 6/7:
:; chkconfig sshd on
:; service sshd start

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

NOTE: On CentOS, `libusb` means 0.1.x and `libusbx` means 1.x.x API version
(latter is not available for CentOS 6).
NOTE: On CentOS, `libusb` means 0.1.x (not available on modern Fedora),
and `libusbx` means 1.x.x API version (latter is not available for CentOS 6).

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

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

# For PDF generation, you may need explicitly (at least on Fedora 43):
:; yum install \
texlive 'tex(upquote.sty)'

# For CGI graph generation - massive packages (X11):
:; yum install \
gd-devel
Expand All @@ -454,34 +466,57 @@ drivers in distro packaging of NUT. Resolution and doc PRs are welcome.
systemd-devel

# NOTE: "libusbx" is the CentOS way of naming "libusb-1.0" (not in CentOS 6)
# vs. the older "libusb" as the package with "libusb-0.1"
# vs. the older "libusb" as the package with "libusb-0.1" (not in recent Fedora)
:; yum install \
libusb-devel

:; yum install \
libusbx-devel

:; yum install \
cppunit-devel \
openssl-devel nss-devel \
augeas augeas-devel \
libusb-devel libusbx-devel \
glib2-devel \
i2c-tools \
libmodbus-devel \
net-snmp-devel \
powerman-devel \
freeipmi-devel \
avahi-devel \
neon-devel

# Not in recent Fedora releases:
:; yum install \
powerman-devel

# Not in CentOS, some present in Fedora:
#?# is python-augeas needed? exists at least...
#?# no (lib)i2c-devel ...
#?# no (lib)ipmimonitoring-devel ... would "freeipmi-ipmidetectd"
#?# cut it at least for run-time?
#?# no (lib)gpio(d)-devel - starts with CentOS 8 (or extra repositories
#?# for later minor releases of CentOS 7)

# In Fedora:
:; yum install \
libi2c-devel \
libgpiod-devel

# Some NUT code related to lua may be currently limited to lua-5.1
# or possibly 5.2; the former is default in CentOS 7 releases...
:; yum install \
lua-devel

:; yum install \
bash dash ksh

# If available:
:; yum install \
bash-completion

# In Fedora:
:; yum install \
busybox
------

NOTE: `busybox` is not packaged for CentOS 7 release; a static binary can
Expand All @@ -499,8 +534,15 @@ other described environments by adding a symlink `/usr/lib/ccache`:
======
For Jenkins agents, also need to install JDK 17 or newer, which is not
available for CentOS 6 nor 7 directly (in distribution packaging).
Alternative packaging, such as Temurin from the Adoptium project, is possible
(checked for at least CentOS 7), see

In Fedora e.g.:
------
:; yum install \
java-21-openjdk-headless
------

Alternative packaging for older distros, such as Temurin from the Adoptium
project, is possible (checked for at least CentOS 7), see
link:https://adoptium.net/installation/linux/#_centosrhelfedora_instructions[their
instructions] for specific details. This may require updated library package
versions as dependencies from the OS distribution, so you may also have to make
Expand Down
10 changes: 7 additions & 3 deletions docs/download.txt
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,13 @@ workspace to try subsequent iterations), although the latter are now also
available for development iterations.

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

Code repository
^^^^^^^^^^^^^^^
Expand Down
6 changes: 5 additions & 1 deletion docs/nut.dict
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
personal_ws-1.1 en 3655 utf-8
personal_ws-1.1 en 3659 utf-8
AAC
AAS
ABI
Expand Down Expand Up @@ -3137,6 +3137,7 @@ setproctag
setq
setuid
setupCommands
setuptools
setvar
setvar's
sfr
Expand Down Expand Up @@ -3335,6 +3336,8 @@ testime
testtime
testuser
testvar
tex
texlive
textproc
tgcware
tgt
Expand Down Expand Up @@ -3436,6 +3439,7 @@ unstash
updateinfo
upexia
upower
upquote
upsBypassCurrent
upsBypassPower
upsBypassVoltage
Expand Down
12 changes: 6 additions & 6 deletions drivers/generic_gpio_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -75,13 +75,13 @@ struct gpioups_t *generic_gpio_open(const char *chipName) {
if (!rules) /* rules is required configuration parameter */
fatalx(EXIT_FAILURE, "UPS status calculation rules not specified");

upsfdlocal = xcalloc(1, sizeof(*upsfdlocal));
upsfdlocal = (struct gpioups_t *)xcalloc(1, sizeof(*upsfdlocal));

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

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

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

upsfdlocal->rules[upsfdlocal->rulesCount - 1] = xrealloc(upsfdlocal->rules[upsfdlocal->rulesCount - 1], itemSize);
upsfdlocal->rules[upsfdlocal->rulesCount - 1] = (struct rulesint_t *)xrealloc(upsfdlocal->rules[upsfdlocal->rulesCount - 1], itemSize);
upsfdlocal->rules[upsfdlocal->rulesCount - 1]->subCount = subCount;
upsfdlocal->rules[upsfdlocal->rulesCount - 1]->cRules[subCount - 1] = newValue;
}
Expand Down Expand Up @@ -197,8 +197,8 @@ void get_ups_rules(struct gpioups_t *upsfdlocal, unsigned char *rulesString) {
} else {
lexStatus = 1;
upsfdlocal->rulesCount++;
upsfdlocal->rules = xrealloc(upsfdlocal->rules, (size_t)(sizeof(upsfdlocal->rules[0])*upsfdlocal->rulesCount));
upsfdlocal->rules[upsfdlocal->rulesCount -1 ] = xcalloc(1, sizeof(rulesint));
upsfdlocal->rules = (struct rulesint_t **)xrealloc(upsfdlocal->rules, (size_t)(sizeof(upsfdlocal->rules[0])*upsfdlocal->rulesCount));
upsfdlocal->rules[upsfdlocal->rulesCount -1 ] = (struct rulesint_t *)xcalloc(1, sizeof(rulesint));
strncpy(upsfdlocal->rules[upsfdlocal->rulesCount - 1]->stateName, (char *)(rulesString + startPos), endPos - startPos);
upsfdlocal->rules[upsfdlocal->rulesCount - 1]->stateName[endPos - startPos] = 0;
}
Expand Down Expand Up @@ -291,7 +291,7 @@ void get_ups_rules(struct gpioups_t *upsfdlocal, unsigned char *rulesString) {
if (!pinOnList) {
if (upsfdlocal->rules[i]->cRules[j] >= 0) {
upsfdlocal->upsLinesCount++;
upsfdlocal->upsLines = xrealloc(upsfdlocal->upsLines, sizeof(upsfdlocal->upsLines[0])*upsfdlocal->upsLinesCount);
upsfdlocal->upsLines = (int *)xrealloc(upsfdlocal->upsLines, sizeof(upsfdlocal->upsLines[0])*upsfdlocal->upsLinesCount);
upsfdlocal->upsLines[upsfdlocal->upsLinesCount - 1] = upsfdlocal->rules[i]->cRules[j];
if (upsfdlocal->upsLines[upsfdlocal->upsLinesCount - 1] > upsfdlocal->upsMaxLine) {
upsfdlocal->upsMaxLine = upsfdlocal->upsLines[upsfdlocal->upsLinesCount - 1];
Expand Down
6 changes: 3 additions & 3 deletions drivers/generic_gpio_libgpiod.c
Original file line number Diff line number Diff line change
Expand Up @@ -121,15 +121,15 @@ static void reserve_lines_libgpiod(struct gpioups_t *gpioupsfdlocal, int inner)
* and check lines numbers validity - consistency with h/w chip
*/
void gpio_open(struct gpioups_t *gpioupsfdlocal) {
struct libgpiod_data_t *libgpiod_data = xcalloc(1, sizeof(struct libgpiod_data_t));
struct libgpiod_data_t *libgpiod_data = (struct libgpiod_data_t *)xcalloc(1, sizeof(struct libgpiod_data_t));
gpioupsfdlocal->lib_data = libgpiod_data;

#if WITH_LIBGPIO_VERSION < 0x00020000
libgpiod_data->gpioChipHandle = gpiod_chip_open_by_name(gpioupsfdlocal->chipName);
#else /* #if WITH_LIBGPIO_VERSION >= 0x00020000 */
if(!strchr(gpioupsfdlocal->chipName, '/')) {
size_t pathNameLen = strlen(gpioupsfdlocal->chipName)+6;
char *pathName = xcalloc(pathNameLen, sizeof(char));
char *pathName = (char *)xcalloc(pathNameLen, sizeof(char));
strncpy(pathName, "/dev/", pathNameLen);
strncat(pathName, gpioupsfdlocal->chipName, pathNameLen);
libgpiod_data->gpioChipHandle = gpiod_chip_open(pathName);
Expand Down Expand Up @@ -182,7 +182,7 @@ void gpio_open(struct gpioups_t *gpioupsfdlocal) {
&libgpiod_data->gpioLines
);
#else /* #if WITH_LIBGPIO_VERSION >= 0x00020000 */
libgpiod_data->values = xcalloc(gpioupsfdlocal->upsLinesCount, sizeof(*libgpiod_data->values));
libgpiod_data->values = (enum gpiod_line_value *)xcalloc(gpioupsfdlocal->upsLinesCount, sizeof(*libgpiod_data->values));
lineSettings = gpiod_line_settings_new();
libgpiod_data->lineConfig = gpiod_line_config_new();
libgpiod_data->config = gpiod_request_config_new();
Expand Down
8 changes: 4 additions & 4 deletions drivers/nutdrv_qx_voltronic-axpert.c
Original file line number Diff line number Diff line change
Expand Up @@ -2419,7 +2419,7 @@ static int voltronic_sunny_energy_hour(item_t *item, char *command, const size_t
return -1;
}

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

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

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

buf = xcalloc(commandlen, sizeof(char));
buf = (char *)xcalloc(commandlen, sizeof(char));
if (!buf) {
upsdebugx(2, "%s: cannot allocate buffer", __func__);
return -1;
Expand Down
16 changes: 16 additions & 0 deletions scripts/augeas/gen-nutupsconf-aug.py.in
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,15 @@ import os
import re
import glob

HAVE_WARNINGS = False
try:
import warnings
warnings.filterwarnings("error")
HAVE_WARNINGS = True
except Exception as x:
# sys.stderr.write("WARNING: failed to import warnings or configure them: %s" % str(x))
pass

try:
# NOTE: Deprecated as of python3.14
import codecs
Expand All @@ -47,6 +56,9 @@ except Exception as x:
HAVE_CODECS = False
USE_CODECS = False

if HAVE_WARNINGS:
warnings.resetwarnings()

# Return a sorted list of unique entries, based on the input 'list'
def sortUnique(list):
newVarList = []
Expand Down Expand Up @@ -129,9 +141,11 @@ if __name__ == '__main__':
defRow = re.findall(r'"([^"]*)",?', varDefine)
if (len(defRow) == 1):
variableNames.append(defRow[0])
defFd.close()
else:
# Remove quotes
variableNames.append(row[1].replace('"', '').lstrip())
fd.close()

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

# 2.1/ Search for the pattern to replace
outputText = tplFd.read()
tplFd.close()
outputText = outputText.replace('@SPECIFIC_DRV_VARS@', specificVars)

# 3/ Output final lens
Expand All @@ -156,3 +171,4 @@ if __name__ == '__main__':
else:
outFd = open(outputFilename, mode='w', encoding='utf-8')
outFd.write(outputText)
outFd.close()
12 changes: 12 additions & 0 deletions scripts/python/module/setup.py.in
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,15 @@ import sys

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

HAVE_WARNINGS = False
try:
import warnings
warnings.filterwarnings("error")
HAVE_WARNINGS = True
except Exception as x:
# sys.stderr.write("WARNING: failed to import warnings or configure them: %s" % str(x))
pass

try:
# NOTE: Deprecated as of python3.14
import codecs
Expand All @@ -30,6 +39,9 @@ except Exception as x:
HAVE_CODECS = False
USE_CODECS = False

if HAVE_WARNINGS:
warnings.resetwarnings()

# README.txt appears from README.adoc during package or CI build
if USE_CODECS:
with codecs.open(os.path.join(here, "README.txt"), encoding="utf-8") as fh:
Expand Down
2 changes: 1 addition & 1 deletion tests/generic_gpio_liblocal.c
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ int gpiod_line_request_get_values(
return -1;
}
for(i=0; i<num_lines; i++) {
values[i]=(gStatus&pinPos)!=0;
values[i]= ( (gStatus&pinPos)!=0 ? GPIOD_LINE_VALUE_ACTIVE : GPIOD_LINE_VALUE_INACTIVE);
pinPos=pinPos<<1;
}

Expand Down
Loading
Loading