From a38e5582ac026c7461514fd728d225262ffdb442 Mon Sep 17 00:00:00 2001 From: Joachim Wiberg Date: Tue, 22 Aug 2023 15:22:58 +0200 Subject: [PATCH] Refactor, break out a libsrx from confd, shared with statd Everything (!) potentially shared with other sysrepo plugins/daemons and helper functions (not yet in libite) that can be used by other daemons have been relocated to libsrx. Fix #116 Signed-off-by: Joachim Wiberg --- package/Config.in | 1 + package/confd/Config.in | 1 + package/confd/confd.mk | 2 +- package/libsrx/Config.in | 7 +++ package/libsrx/libsrx.mk | 16 +++++ package/statd/Config.in | 1 + package/statd/statd.mk | 3 +- src/confd/LICENSE | 1 - src/confd/configure.ac | 7 +-- src/confd/src/confd/Makefile.am | 60 +++++++++---------- src/confd/src/confd/core.c | 5 +- src/confd/src/confd/core.h | 7 ++- src/confd/src/confd/dagger.c | 4 +- src/confd/src/confd/dagger.h | 8 ++- src/confd/src/confd/ietf-interfaces.c | 9 +-- src/confd/src/confd/ietf-system.c | 9 +-- src/confd/src/confd/infix-dhcp.c | 10 ++-- src/confd/src/confd/infix-factory.c | 9 +-- src/confd/src/confd/infix-system-software.c | 8 +-- src/libsrx/LICENSE | 27 +++++++++ src/libsrx/Makefile.am | 3 + src/libsrx/README.md | 6 ++ src/libsrx/autogen.sh | 3 + src/libsrx/configure.ac | 16 +++++ src/libsrx/src/Makefile.am | 17 ++++++ src/libsrx/src/common.c | 0 src/{confd/src/lib => libsrx/src}/common.h | 0 src/{confd/src/lib => libsrx/src}/helpers.c | 0 src/{confd/src/lib => libsrx/src}/helpers.h | 0 src/libsrx/src/libsrx.pc.in | 12 ++++ src/{confd/src/lib => libsrx/src}/lyx.c | 0 src/{confd/src/lib => libsrx/src}/lyx.h | 0 .../src/lib => libsrx/src}/srx_module.c | 0 .../src/lib => libsrx/src}/srx_module.h | 0 src/{confd/src/confd => libsrx/src}/srx_val.c | 7 ++- src/{confd/src/confd => libsrx/src}/srx_val.h | 0 src/{confd/src/confd => libsrx/src}/systemv.c | 0 src/{confd/src/confd => libsrx/src}/systemv.h | 0 src/statd/Makefile | 20 ++----- src/statd/core.c | 6 +- src/statd/statd.c | 6 +- 41 files changed, 199 insertions(+), 92 deletions(-) create mode 100644 package/libsrx/Config.in create mode 100644 package/libsrx/libsrx.mk create mode 100644 src/libsrx/LICENSE create mode 100644 src/libsrx/Makefile.am create mode 100644 src/libsrx/README.md create mode 100644 src/libsrx/autogen.sh create mode 100644 src/libsrx/configure.ac create mode 100644 src/libsrx/src/Makefile.am create mode 100644 src/libsrx/src/common.c rename src/{confd/src/lib => libsrx/src}/common.h (100%) rename src/{confd/src/lib => libsrx/src}/helpers.c (100%) rename src/{confd/src/lib => libsrx/src}/helpers.h (100%) create mode 100644 src/libsrx/src/libsrx.pc.in rename src/{confd/src/lib => libsrx/src}/lyx.c (100%) rename src/{confd/src/lib => libsrx/src}/lyx.h (100%) rename src/{confd/src/lib => libsrx/src}/srx_module.c (100%) rename src/{confd/src/lib => libsrx/src}/srx_module.h (100%) rename src/{confd/src/confd => libsrx/src}/srx_val.c (98%) rename src/{confd/src/confd => libsrx/src}/srx_val.h (100%) rename src/{confd/src/confd => libsrx/src}/systemv.c (100%) rename src/{confd/src/confd => libsrx/src}/systemv.h (100%) diff --git a/package/Config.in b/package/Config.in index b9d5022a..bb5275aa 100644 --- a/package/Config.in +++ b/package/Config.in @@ -8,6 +8,7 @@ source "$BR2_EXTERNAL_INFIX_PATH/package/ifupdown-ng/Config.in" source "$BR2_EXTERNAL_INFIX_PATH/package/klish-plugin-infix/Config.in" source "$BR2_EXTERNAL_INFIX_PATH/package/klish/Config.in" source "$BR2_EXTERNAL_INFIX_PATH/package/klish-plugin-sysrepo/Config.in" +source "$BR2_EXTERNAL_INFIX_PATH/package/libsrx/Config.in" source "$BR2_EXTERNAL_INFIX_PATH/package/lowdown/Config.in" source "$BR2_EXTERNAL_INFIX_PATH/package/mdnsd/Config.in" source "$BR2_EXTERNAL_INFIX_PATH/package/net/Config.in" diff --git a/package/confd/Config.in b/package/confd/Config.in index 170aeecc..a5c9112c 100644 --- a/package/confd/Config.in +++ b/package/confd/Config.in @@ -5,6 +5,7 @@ config BR2_PACKAGE_CONFD select BR2_PACKAGE_LIBITE select BR2_PACKAGE_NETOPEER2 select BR2_PACKAGE_SYSREPO + select BR2_PACKAGE_LIBSRX help A plugin to sysrepo that provides the core YANG models used to manage an Infix based system. Configuration can be done using diff --git a/package/confd/confd.mk b/package/confd/confd.mk index 09bc306c..f8733d2a 100644 --- a/package/confd/confd.mk +++ b/package/confd/confd.mk @@ -10,7 +10,7 @@ CONFD_SITE_METHOD = local CONFD_SITE = $(BR2_EXTERNAL_INFIX_PATH)/src/confd CONFD_LICENSE = BSD-3 CONFD_LICENSE_FILES = LICENSE -CONFD_DEPENDENCIES = augeas jansson libite sysrepo +CONFD_DEPENDENCIES = augeas jansson libite sysrepo libsrx CONFD_AUTORECONF = YES define CONFD_INSTALL_EXTRA diff --git a/package/libsrx/Config.in b/package/libsrx/Config.in new file mode 100644 index 00000000..c84529f8 --- /dev/null +++ b/package/libsrx/Config.in @@ -0,0 +1,7 @@ +config BR2_PACKAGE_LIBSRX + bool "libsrx" + select BR2_PACKAGE_SYSREPO + help + Extensions and helper APIs for sysrepo plugins. + + https://github.com/kernelkit/infix diff --git a/package/libsrx/libsrx.mk b/package/libsrx/libsrx.mk new file mode 100644 index 00000000..b42b078a --- /dev/null +++ b/package/libsrx/libsrx.mk @@ -0,0 +1,16 @@ +################################################################################ +# +# libsrx +# +################################################################################ + +LIBSRX_VERSION = 1.0.0 +LIBSRX_SITE_METHOD = local +LIBSRX_SITE = $(BR2_EXTERNAL_INFIX_PATH)/src/libsrx +LIBSRX_LICENSE = BSD-3-Clause +LIBSRX_LICENSE_FILES = LICENSE +LIBSRX_INSTALL_STAGING = YES +LIBSRX_DEPENDENCIES = sysrepo +LIBSRX_AUTORECONF = YES + +$(eval $(autotools-package)) diff --git a/package/statd/Config.in b/package/statd/Config.in index 4eeb059f..a3d4d4d2 100644 --- a/package/statd/Config.in +++ b/package/statd/Config.in @@ -3,6 +3,7 @@ config BR2_PACKAGE_STATD select BR2_PACKAGE_JANSSON select BR2_PACKAGE_LIBEV select BR2_PACKAGE_SYSREPO + select BR2_PACKAGE_LIBSRX help Operational Status Daemon. Responsible for handling sysrepo operational run-time info. Such as interface state and address. diff --git a/package/statd/statd.mk b/package/statd/statd.mk index c95f4faa..781b20ff 100644 --- a/package/statd/statd.mk +++ b/package/statd/statd.mk @@ -3,11 +3,12 @@ # statd # ################################################################################ + STATD_VERSION = 1.0 STATD_LICENSE = MIT STATD_SITE_METHOD = local STATD_SITE = $(BR2_EXTERNAL_INFIX_PATH)/src/statd -STATD_DEPENDENCIES = sysrepo libev jansson +STATD_DEPENDENCIES = sysrepo libev libsrx jansson define STATD_BUILD_CMDS $(TARGET_MAKE_ENV) $(TARGET_CONFIGURE_OPTS) $(MAKE) -C $(@D) \ diff --git a/src/confd/LICENSE b/src/confd/LICENSE index 0423839d..2554e913 100644 --- a/src/confd/LICENSE +++ b/src/confd/LICENSE @@ -26,4 +26,3 @@ SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - diff --git a/src/confd/configure.ac b/src/confd/configure.ac index dbed2834..3dd88cc8 100644 --- a/src/confd/configure.ac +++ b/src/confd/configure.ac @@ -1,11 +1,8 @@ AC_PREREQ(2.61) -AC_INIT([confd], [1.0.0], - [https://github.com/kernelkit/infix/issues]) +AC_INIT([confd], [1.0.0], [https://github.com/kernelkit/infix/issues]) AM_INIT_AUTOMAKE(1.11 foreign subdir-objects) AM_SILENT_RULES(yes) -LT_INIT - AC_CONFIG_FILES([ Makefile src/Makefile @@ -15,6 +12,7 @@ AC_CONFIG_FILES([ AC_PROG_CC AC_PROG_INSTALL +LT_INIT AC_CONFIG_LIBOBJ_DIR(lib) AC_REPLACE_FUNCS(vasprintf) @@ -38,6 +36,7 @@ PKG_CHECK_MODULES([glib], [glib-2.0 >= 2.50 gio-2.0 gio-unix-2.0]) PKG_CHECK_MODULES([jansson], [jansson >= 2.0.0]) PKG_CHECK_MODULES([libite], [libite >= 2.5.0]) PKG_CHECK_MODULES([sysrepo], [sysrepo >= 2.2.36]) +PKG_CHECK_MODULES([libsrx], [libsrx >= 1.0.0]) # Plugin installation path for sysrepo-plugind PKG_CHECK_VAR([srpdplugindir], [sysrepo], [SRPD_PLUGINS_PATH]) diff --git a/src/confd/src/confd/Makefile.am b/src/confd/src/confd/Makefile.am index 30535dbe..2e409b4e 100644 --- a/src/confd/src/confd/Makefile.am +++ b/src/confd/src/confd/Makefile.am @@ -6,20 +6,22 @@ plugin_LTLIBRARIES = confd-plugin.la confd_plugin_la_LDFLAGS = -module -avoid-version -shared -confd_plugin_la_CFLAGS = \ - $(augeas_CFLAGS) \ - $(glib_CFLAGS) \ - $(jansson_CFLAGS) \ - $(libite_CFLAGS) \ - $(sysrepo_CFLAGS) \ +confd_plugin_la_CFLAGS = \ + $(augeas_CFLAGS) \ + $(glib_CFLAGS) \ + $(jansson_CFLAGS) \ + $(libite_CFLAGS) \ + $(sysrepo_CFLAGS) \ + $(libsrx_CFLAGS) \ $(CFLAGS) -confd_plugin_la_LIBADD = \ - $(augeas_LIBS) \ - $(glib_LIBS) \ - $(jansson_LIBS) \ - $(libite_LIBS) \ - $(sysrepo_LIBS) +confd_plugin_la_LIBADD = \ + $(augeas_LIBS) \ + $(glib_LIBS) \ + $(jansson_LIBS) \ + $(libite_LIBS) \ + $(sysrepo_LIBS) \ + $(libsrx_LIBS) rauc_installer_sources = \ rauc-installer.c \ @@ -29,29 +31,21 @@ BUILT_SOURCES = $(rauc_installer_sources) EXTRA_DIST = ../lib/de.pengutronix.rauc.Installer.xml $(rauc_installer_sources): ../lib/de.pengutronix.rauc.Installer.xml - $(AM_V_GEN) gdbus-codegen \ - --generate-c-code rauc-installer \ - --c-generate-autocleanup all \ - --c-namespace Rauc \ - --interface-prefix de.pengutronix.rauc. \ + $(AM_V_GEN) gdbus-codegen \ + --generate-c-code rauc-installer \ + --c-generate-autocleanup all \ + --c-namespace Rauc \ + --interface-prefix de.pengutronix.rauc. \ $< nodist_confd_plugin_la_SOURCES = \ $(rauc_installer_sources) -confd_plugin_la_SOURCES = \ - ietf-interfaces.c \ - ietf-system.c \ - infix-dhcp.c \ - infix-factory.c \ - infix-system-software.c \ - \ - ../lib/common.h \ - ../lib/helpers.c ../lib/helpers.h \ - ../lib/lyx.c ../lib/lyx.h \ - ../lib/srx_module.c ../lib/srx_module.h \ - \ - core.c core.h \ - dagger.c dagger.h \ - srx_val.c srx_val.h \ - systemv.c systemv.h +confd_plugin_la_SOURCES = \ + ietf-interfaces.c \ + ietf-system.c \ + infix-dhcp.c \ + infix-factory.c \ + infix-system-software.c \ + core.c core.h \ + dagger.c dagger.h diff --git a/src/confd/src/confd/core.c b/src/confd/src/confd/core.c index 768af713..de71745b 100644 --- a/src/confd/src/confd/core.c +++ b/src/confd/src/confd/core.c @@ -1,8 +1,9 @@ /* SPDX-License-Identifier: BSD-3-Clause */ +#include +#include + #include "core.h" -#include "../lib/srx_module.h" -#include "../lib/common.h" static struct confd confd; diff --git a/src/confd/src/confd/core.h b/src/confd/src/confd/core.h index b5ccac9b..ee4548c3 100644 --- a/src/confd/src/confd/core.h +++ b/src/confd/src/confd/core.h @@ -21,10 +21,11 @@ #include #include -#include "../lib/common.h" +#include +#include +#include + #include "dagger.h" -#include "../lib/helpers.h" -#include "systemv.h" #define CB_PRIO_PRIMARY 65535 #define CB_PRIO_PASSIVE 65000 diff --git a/src/confd/src/confd/dagger.c b/src/confd/src/confd/dagger.c index 1b40fbd7..634f6757 100644 --- a/src/confd/src/confd/dagger.c +++ b/src/confd/src/confd/dagger.c @@ -1,8 +1,10 @@ +/* SPDX-License-Identifier: BSD-3-Clause */ + #include +#include #include "core.h" #include "dagger.h" -#include "../lib/common.h" #define PATH_ACTION_ "%s/%d/action/%s/%s" diff --git a/src/confd/src/confd/dagger.h b/src/confd/src/confd/dagger.h index a834e876..fa4ae7a6 100644 --- a/src/confd/src/confd/dagger.h +++ b/src/confd/src/confd/dagger.h @@ -1,5 +1,7 @@ -#ifndef _CONFD_DAGGER_H -#define _CONFD_DAGGER_H +/* SPDX-License-Identifier: BSD-3-Clause */ + +#ifndef CONFD_DAGGER_H_ +#define CONFD_DAGGER_H_ #include #include @@ -31,4 +33,4 @@ int dagger_should_skip_current(struct dagger *d, const char *ifname); int dagger_claim(struct dagger *d, const char *path); -#endif /* _CONFD_DAGGER_H */ +#endif /* CONFD_DAGGER_H_ */ diff --git a/src/confd/src/confd/ietf-interfaces.c b/src/confd/src/confd/ietf-interfaces.c index a142cbd9..416c8236 100644 --- a/src/confd/src/confd/ietf-interfaces.c +++ b/src/confd/src/confd/ietf-interfaces.c @@ -6,12 +6,13 @@ #include #include +#include +#include +#include +#include + #include "core.h" #include "dagger.h" -#include "../lib/common.h" -#include "../lib/lyx.h" -#include "../lib/srx_module.h" -#include "srx_val.h" #define ERR_IFACE(_iface, _err, _fmt, ...) \ ({ \ diff --git a/src/confd/src/confd/ietf-system.c b/src/confd/src/confd/ietf-system.c index 3153f9af..72a7ca47 100644 --- a/src/confd/src/confd/ietf-system.c +++ b/src/confd/src/confd/ietf-system.c @@ -8,11 +8,12 @@ #include #include +#include +#include +#include +#include + #include "core.h" -#include "../lib/common.h" -#include "../lib/lyx.h" -#include "../lib/srx_module.h" -#include "srx_val.h" #define XPATH_BASE_ "/ietf-system:system" #define XPATH_AUTH_ XPATH_BASE_"/authentication" diff --git a/src/confd/src/confd/infix-dhcp.c b/src/confd/src/confd/infix-dhcp.c index 25a9ad0c..229fda45 100644 --- a/src/confd/src/confd/infix-dhcp.c +++ b/src/confd/src/confd/infix-dhcp.c @@ -7,11 +7,13 @@ #include #include +#include +#include +#include +#include + #include "core.h" -#include "../lib/common.h" -#include "../lib/lyx.h" -#include "../lib/srx_module.h" -#include "srx_val.h" + static const struct srx_module_requirement infix_dhcp_reqs[] = { { .dir = YANG_PATH_, .name = "infix-dhcp-client", .rev = "2023-05-22" }, diff --git a/src/confd/src/confd/infix-factory.c b/src/confd/src/confd/infix-factory.c index 718cd1db..be239602 100644 --- a/src/confd/src/confd/infix-factory.c +++ b/src/confd/src/confd/infix-factory.c @@ -8,11 +8,12 @@ #include #include +#include +#include +#include +#include + #include "core.h" -#include "../lib/common.h" -#include "../lib/lyx.h" -#include "../lib/srx_module.h" -#include "srx_val.h" static const struct srx_module_requirement reqs[] = { { .dir = YANG_PATH_, .name = "infix-factory-default", .rev = "2023-06-28" }, diff --git a/src/confd/src/confd/infix-system-software.c b/src/confd/src/confd/infix-system-software.c index ac308543..1fece7cb 100644 --- a/src/confd/src/confd/infix-system-software.c +++ b/src/confd/src/confd/infix-system-software.c @@ -1,12 +1,12 @@ /* SPDX-License-Identifier: BSD-3-Clause */ +#include + +#include +#include #include "core.h" -#include "../lib/common.h" -#include "../lib/lyx.h" #include "rauc-installer.h" -#include - #define SW_STATE_PATH_ "/ietf-system:system-state/infix-system:software" static const struct lys_module *infix_system; diff --git a/src/libsrx/LICENSE b/src/libsrx/LICENSE new file mode 100644 index 00000000..7a17cba1 --- /dev/null +++ b/src/libsrx/LICENSE @@ -0,0 +1,27 @@ +Copyright (c) 2023 The KernelKit Authors +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + +* Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + +* Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + +* Neither the name of copyright holders nor the names of + contributors may be used to endorse or promote products derived from + this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/src/libsrx/Makefile.am b/src/libsrx/Makefile.am new file mode 100644 index 00000000..ae0cb05f --- /dev/null +++ b/src/libsrx/Makefile.am @@ -0,0 +1,3 @@ +SUBDIRS = src +dist_doc_DATA = README.md LICENSE +ACLOCAL_AMFLAGS = -I m4 diff --git a/src/libsrx/README.md b/src/libsrx/README.md new file mode 100644 index 00000000..9a6f2642 --- /dev/null +++ b/src/libsrx/README.md @@ -0,0 +1,6 @@ +sysepo extensions +================= + +This library contains extensions and helper APIs for sysrepo plugins. +It is currently used by confd and statd in Infix. + diff --git a/src/libsrx/autogen.sh b/src/libsrx/autogen.sh new file mode 100644 index 00000000..dbbcad3b --- /dev/null +++ b/src/libsrx/autogen.sh @@ -0,0 +1,3 @@ +#!/bin/sh + +autoreconf -W portability -visfm diff --git a/src/libsrx/configure.ac b/src/libsrx/configure.ac new file mode 100644 index 00000000..74283699 --- /dev/null +++ b/src/libsrx/configure.ac @@ -0,0 +1,16 @@ +AC_INIT(libsrx, 1.0.0, https://github.com/kernelkit/infix/issues) +AC_CONFIG_AUX_DIR(aux) +AM_INIT_AUTOMAKE([1.11 foreign]) +AM_SILENT_RULES([yes]) + +AC_CONFIG_SRCDIR(src/lyx.h) +AC_CONFIG_HEADERS(config.h) +AC_CONFIG_FILES([Makefile src/Makefile src/libsrx.pc]) +AC_CONFIG_MACRO_DIR([m4]) + +AC_PROG_CC +AC_PROG_INSTALL +AM_PROG_AR +LT_INIT + +AC_OUTPUT diff --git a/src/libsrx/src/Makefile.am b/src/libsrx/src/Makefile.am new file mode 100644 index 00000000..1b9b1cc3 --- /dev/null +++ b/src/libsrx/src/Makefile.am @@ -0,0 +1,17 @@ +lib_LTLIBRARIES = libsrx.la + +libsrx_la_CPPFLAGS = -D_DEFAULT_SOURCE -D_XOPEN_SOURCE -D_GNU_SOURCE +libsrx_la_CFLAGS = -W -Wall -Wextra -std=gnu11 +libsrx_la_LDFLAGS = $(AM_LDFLAGS) -version-info 0:0:0 +libsrx_la_SOURCES = common.c common.h \ + helpers.c helpers.h \ + lyx.c lyx.h \ + srx_module.c srx_module.h \ + srx_val.c srx_val.h \ + systemv.c systemv.h + +pkgincludedir = $(includedir)/srx +pkginclude_HEADERS = common.h helpers.h lyx.h srx_module.h srx_val.h systemv.h + +pkgconfigdir = $(libdir)/pkgconfig +pkgconfig_DATA = libsrx.pc diff --git a/src/libsrx/src/common.c b/src/libsrx/src/common.c new file mode 100644 index 00000000..e69de29b diff --git a/src/confd/src/lib/common.h b/src/libsrx/src/common.h similarity index 100% rename from src/confd/src/lib/common.h rename to src/libsrx/src/common.h diff --git a/src/confd/src/lib/helpers.c b/src/libsrx/src/helpers.c similarity index 100% rename from src/confd/src/lib/helpers.c rename to src/libsrx/src/helpers.c diff --git a/src/confd/src/lib/helpers.h b/src/libsrx/src/helpers.h similarity index 100% rename from src/confd/src/lib/helpers.h rename to src/libsrx/src/helpers.h diff --git a/src/libsrx/src/libsrx.pc.in b/src/libsrx/src/libsrx.pc.in new file mode 100644 index 00000000..ef15b2df --- /dev/null +++ b/src/libsrx/src/libsrx.pc.in @@ -0,0 +1,12 @@ +prefix=@prefix@ +exec_prefix=@exec_prefix@ +libdir=@libdir@ +includedir=@includedir@ + +Name: @PACKAGE@ +Description: Extensions and helper APIs for sysrepo plugins +Version: @VERSION@ +Requires: +Libs: -L${libdir} -lsrx +Cflags: -I${includedir} + diff --git a/src/confd/src/lib/lyx.c b/src/libsrx/src/lyx.c similarity index 100% rename from src/confd/src/lib/lyx.c rename to src/libsrx/src/lyx.c diff --git a/src/confd/src/lib/lyx.h b/src/libsrx/src/lyx.h similarity index 100% rename from src/confd/src/lib/lyx.h rename to src/libsrx/src/lyx.h diff --git a/src/confd/src/lib/srx_module.c b/src/libsrx/src/srx_module.c similarity index 100% rename from src/confd/src/lib/srx_module.c rename to src/libsrx/src/srx_module.c diff --git a/src/confd/src/lib/srx_module.h b/src/libsrx/src/srx_module.h similarity index 100% rename from src/confd/src/lib/srx_module.h rename to src/libsrx/src/srx_module.h diff --git a/src/confd/src/confd/srx_val.c b/src/libsrx/src/srx_val.c similarity index 98% rename from src/confd/src/confd/srx_val.c rename to src/libsrx/src/srx_val.c index 47d1107d..0417a4fa 100644 --- a/src/confd/src/confd/srx_val.c +++ b/src/libsrx/src/srx_val.c @@ -1,8 +1,9 @@ /* SPDX-License-Identifier: BSD-3-Clause */ - +#include #include -#include "core.h" -#include "../lib/common.h" +#include + +#include "common.h" sr_error_t srx_get_diff(sr_session_ctx_t *session, struct lyd_node **treep) { diff --git a/src/confd/src/confd/srx_val.h b/src/libsrx/src/srx_val.h similarity index 100% rename from src/confd/src/confd/srx_val.h rename to src/libsrx/src/srx_val.h diff --git a/src/confd/src/confd/systemv.c b/src/libsrx/src/systemv.c similarity index 100% rename from src/confd/src/confd/systemv.c rename to src/libsrx/src/systemv.c diff --git a/src/confd/src/confd/systemv.h b/src/libsrx/src/systemv.h similarity index 100% rename from src/confd/src/confd/systemv.h rename to src/libsrx/src/systemv.h diff --git a/src/statd/Makefile b/src/statd/Makefile index 87fa589f..01c6bfa1 100644 --- a/src/statd/Makefile +++ b/src/statd/Makefile @@ -1,21 +1,13 @@ -# TODO: Libs are included fron confd. They should be broken out of confd and -# shared between statd and confd in some nice way. -CONFD_LIB = $(BASE_DIR)/../src/confd/lib/ -CONFD_SRC_LIB = $(BASE_DIR)/../src/confd/src/lib +CFLAGS += -Wall -Wextra -Werror +LDLIBS += -lsysrepo -lev -lyang -ljansson -lite -lsrx -CFLAGS += -Wall -Wextra -Werror -LDLIBS += -lsysrepo -lev -lyang -ljansson -lite -CPPFLAGS := -I$(CONFD_SRC_LIB) - -TARGET = statd -SRC = statd.c -LIB_SRC = $(CONFD_SRC_LIB)/helpers.c $(CONFD_SRC_LIB)/lyx.c $(CONFD_LIB)/vasprintf.c -LIB_HDR = $(CONFD_SRC_LIB)/helpers.h $(CONFD_SRC_LIB)/lyx.h $(CONFD_SRC_LIB)/common.h +TARGET = statd +SRC = statd.c all: $(TARGET) -$(TARGET): $(SRC) $(LIB_SRC) $(LIB_HDR) - $(CC) $(CPPFLAGS) $(LDLIBS) $(CFLAGS) -o $(TARGET) $(SRC) $(LIB_SRC) +$(TARGET): $(SRC) + $(CC) $(CPPFLAGS) $(LDLIBS) $(CFLAGS) -o $(TARGET) $(SRC) clean: -rm statd diff --git a/src/statd/core.c b/src/statd/core.c index 7c9266ea..e646cb73 100644 --- a/src/statd/core.c +++ b/src/statd/core.c @@ -3,9 +3,9 @@ #include #include #include -#include "../lib/common.h" -#include "../lib/helpers.h" -#include "../lib/lyx.h" +#include +#include +#include /* TODO: break out and find a reasonable value */ #define XPATH_MAX PATH_MAX diff --git a/src/statd/statd.c b/src/statd/statd.c index ecdd11b5..99355217 100644 --- a/src/statd/statd.c +++ b/src/statd/statd.c @@ -16,9 +16,9 @@ #include #include -#include "common.h" -#include "helpers.h" -#include "lyx.h" +#include +#include +#include #define XPATH_MAX PATH_MAX #define XPATH_IFACE_BASE "/ietf-interfaces:interfaces"