netcf: Fix build with newer autotools and gnulib

Newer gnulib use python implementation by default if it
finds py3 on the system. However, netcf is old package
and its not expecting python implementation, therefore
make the shell implementation be used.

REALLOC_N is gone in latest gnulib so house a local
macro

Signed-off-by: Khem Raj <khem.raj@oss.qualcomm.com>
This commit is contained in:
Khem Raj 2026-03-22 10:54:25 -07:00
parent a47c3a26f3
commit 752aad0e32
No known key found for this signature in database
GPG Key ID: BB053355919D3314
3 changed files with 90 additions and 17 deletions

View File

@ -17,11 +17,9 @@ Signed-off-by: Khem Raj <raj.khem@gmail.com>
src/ncftransform.c | 2 +-
4 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/src/dutil_linux.c b/src/dutil_linux.c
index 742153a..eb72eb2 100644
--- a/src/dutil_linux.c
+++ b/src/dutil_linux.c
@@ -1113,7 +1113,7 @@ static void add_link_info(struct netcf *ncf,
@@ -1113,7 +1113,7 @@ static void add_link_info(struct netcf *
xasprintf(&path, "/sys/class/net/%s/operstate", ifname);
ERR_NOMEM(!path, ncf);
@ -30,7 +28,7 @@ index 742153a..eb72eb2 100644
if (!state) {
/* missing operstate is *not* an error. It could be due to an
* alias interface, which has no entry in /sys/class/net at
@@ -1132,7 +1132,7 @@ static void add_link_info(struct netcf *ncf,
@@ -1132,7 +1132,7 @@ static void add_link_info(struct netcf *
FREE(path);
xasprintf(&path, "/sys/class/net/%s/speed", ifname);
ERR_NOMEM(path == NULL, ncf);
@ -39,11 +37,9 @@ index 742153a..eb72eb2 100644
if (!speed && errno == EINVAL) {
/* attempts to read $ifname/speed result in EINVAL if the
* interface is ifconfiged down (which isn't exactly the
diff --git a/src/dutil_posix.c b/src/dutil_posix.c
index 1313514..b9884f0 100644
--- a/src/dutil_posix.c
+++ b/src/dutil_posix.c
@@ -211,7 +211,7 @@ int run_program(struct netcf *ncf, const char *const *argv, char **output)
@@ -211,7 +211,7 @@ int run_program(struct netcf *ncf, const
"Failed to create file stream for output while executing '%s': %s",
argv_str, errbuf);
@ -52,11 +48,9 @@ index 1313514..b9884f0 100644
ERR_THROW_STRERROR(*output == NULL, ncf, EEXEC,
"Error while reading output from execution of '%s': %s",
argv_str, errbuf);
diff --git a/src/ncftool.c b/src/ncftool.c
index f1b5642..c878cb0 100644
--- a/src/ncftool.c
+++ b/src/ncftool.c
@@ -351,7 +351,7 @@ static int cmd_define(const struct command *cmd) {
@@ -351,7 +351,7 @@ static int cmd_define(const struct comma
struct netcf_if *nif = NULL;
int result = CMD_RES_ERR;
@ -65,8 +59,6 @@ index f1b5642..c878cb0 100644
if (xml == NULL) {
fprintf(stderr, "Failed to read %s\n", fname);
goto done;
diff --git a/src/ncftransform.c b/src/ncftransform.c
index fbabfc3..4c9a56d 100644
--- a/src/ncftransform.c
+++ b/src/ncftransform.c
@@ -54,7 +54,7 @@ int main(int argc, char **argv) {
@ -78,6 +70,25 @@ index fbabfc3..4c9a56d 100644
if (in_xml == NULL)
die("Failed to read %s\n", argv[2]);
--
2.44.0
--- a/src/internal.h
+++ b/src/internal.h
@@ -30,6 +30,7 @@
#include <string.h>
#include <stdarg.h>
+#include <stdlib.h>
#include <libxslt/transform.h>
#include <libxml/relaxng.h>
@@ -85,6 +86,11 @@
#define ATTRIBUTE_NOINLINE
#endif /* __GNUC__ */
+#ifndef REALLOC_N
+# define REALLOC_N(ptr, count) \
+ (((ptr) = realloc((ptr), sizeof(*(ptr)) * (count))) == NULL ? -1 : 0)
+#endif
+
/* This needs ATTRIBUTE_RETURN_CHECK */
#include "ref.h"

View File

@ -0,0 +1,61 @@
From dded6e3321e304f50922e61c553d4e4eb0f80fd0 Mon Sep 17 00:00:00 2001
From: Khem Raj <khem.raj@oss.qualcomm.com>
Date: Sun, 22 Mar 2026 11:05:34 -0700
Subject: [PATCH] netcf: fix bootstrap with newer gnulib/automake
Upstream netcf is old enough that bootstrap/autoreconf now trips over:
- gnulib-tool.py wrapper expectations in newer gnulib
- stricter automake handling of AM_CFLAGS += from generated gnulib.mk
- subdir source warnings
- deprecated INCLUDES usage
Upstream-Status: Pending
Signed-off-by: Khem Raj <khem.raj@oss.qualcomm.com>
---
configure.ac | 2 +-
gnulib/lib/Makefile.am | 2 +-
gnulib/tests/Makefile.am | 2 ++
tests/Makefile.am | 2 +-
4 files changed, 5 insertions(+), 3 deletions(-)
--- a/configure.ac
+++ b/configure.ac
@@ -3,7 +3,7 @@ AC_CONFIG_SRCDIR([src/netcf.c])
AC_CONFIG_AUX_DIR([build-aux])
AC_CONFIG_MACRO_DIR([gnulib/m4])
AC_CONFIG_HEADERS([config.h])
-AM_INIT_AUTOMAKE([-Wno-portability 1.11 color-tests parallel-tests])
+AM_INIT_AUTOMAKE([-Wno-portability 1.11 subdir-objects color-tests parallel-tests])
AM_SILENT_RULES([yes]) # make --enable-silent-rules the default.
AC_CANONICAL_HOST
--- a/gnulib/lib/Makefile.am
+++ b/gnulib/lib/Makefile.am
@@ -13,4 +13,4 @@ CLEANFILES=
include gnulib.mk
-INCLUDES = $(GETTEXT_CPPFLAGS)
+AM_CPPFLAGS = $(GETTEXT_CPPFLAGS)
--- a/gnulib/tests/Makefile.am
+++ b/gnulib/tests/Makefile.am
@@ -3,6 +3,6 @@
## Copyright (C) 2011 Red Hat, Inc.
## See COPYING.LIB for the License of this software
-include gnulib.mk
+AM_CFLAGS =
-INCLUDES = $(GETTEXT_CPPFLAGS)
+include gnulib.mk
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -14,7 +14,7 @@ TESTS_ENVIRONMENT = \
abs_top_builddir='$(abs_top_builddir)' \
abs_top_srcdir='$(abs_top_srcdir)'
-INCLUDES = -I$(top_srcdir)/src
+AM_CPPFLAGS = -I$(top_srcdir)/src
TESTS=
check_PROGRAMS=

View File

@ -10,6 +10,7 @@ SRCREV = "2c5d4255857531bc09d91dcd02e86545f29004d4"
PV .= "+git"
SRC_URI = "git://pagure.io/netcf.git;protocol=https;branch=master \
file://0001-netcf-fix-bootstrap-with-newer-gnulib-automake.patch \
file://0001-Adopt-to-new-gnulib-read_file-fread_file-signature.patch"
UPSTREAM_CHECK_GITTAGREGEX = "release-(?P<pver>(\d+(\.\d+)+))"
@ -50,11 +51,11 @@ do_install:append() {
if ${@bb.utils.contains('DISTRO_FEATURES', 'systemd', 'true', 'false', d)}; then
install -d ${D}${systemd_unitdir}/system
if [ -d "${D}${libdir}/systemd/system" ]; then
if [ "${systemd_unitdir}" != "${libdir}/systemd" ] ; then
if [ "${systemd_unitdir}" != "${libdir}/systemd" ] ; then
mv ${D}${libdir}/systemd/system/* ${D}${systemd_unitdir}/system/
rm -rf ${D}${libdir}/systemd/
fi
elif [ "${systemd_unitdir}" != "${nonarch_libdir}/systemd" ] ; then
elif [ "${systemd_unitdir}" != "${nonarch_libdir}/systemd" ] ; then
mv ${D}${nonarch_libdir}/systemd/system/* ${D}${systemd_unitdir}/system/
rm -rf ${D}${nonarch_libdir}/systemd/
fi