This is merely a historical archive of years 2008-2021, before the migration to mailman3.
A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.
laforge gerrit-no-reply at lists.osmocom.orglaforge has submitted this change. ( https://gerrit.osmocom.org/c/osmo-pcap/+/23691 )
Change subject: manuals: generate VTY reference for osmo-pcap-{client,server}
......................................................................
manuals: generate VTY reference for osmo-pcap-{client,server}
Change-Id: I28353f51de798535a3bb6efdc6c2da443d96ddfb
Tweaked-By: Vadim Yanitskiy <vyanitskiy at sysmocom.de>
---
M .gitignore
M configure.ac
M contrib/jenkins.sh
M doc/Makefile.am
A doc/manuals/Makefile.am
A doc/manuals/vty/Makefile.vty-reference.inc
A doc/manuals/vty/osmo-pcap-vty-reference.xml
A doc/manuals/vty/vty_additions.xml
M src/osmo_client_main.c
M src/osmo_server_main.c
10 files changed, 214 insertions(+), 3 deletions(-)
Approvals:
Jenkins Builder: Verified
pespin: Looks good to me, but someone else must approve
laforge: Looks good to me, approved
diff --git a/.gitignore b/.gitignore
index dd48c7d..cd976d9 100644
--- a/.gitignore
+++ b/.gitignore
@@ -37,3 +37,12 @@
tests/testsuite.log
contrib/osmo-pcap.spec
+
+# manuals
+doc/manuals/generated/
+doc/manuals/vty/osmo-pcap-*-vty-reference.pdf
+doc/manuals/vty/osmo-pcap-*-vty-reference.xml
+doc/manuals/vty/osmo-pcap-*-vty-reference.xml.inc.gen
+doc/manuals/vty/osmo-pcap-*-vty-reference.xml.inc.merged
+doc/manuals/common
+doc/manuals/build
diff --git a/configure.ac b/configure.ac
index 8ec9c88..f4c004a 100644
--- a/configure.ac
+++ b/configure.ac
@@ -5,6 +5,46 @@
AM_INIT_AUTOMAKE([dist-bzip2])
AC_CONFIG_TESTDIR(tests)
+AC_ARG_ENABLE(manuals,
+ [AS_HELP_STRING(
+ [--enable-manuals],
+ [Generate manual PDFs [default=no]],
+ )],
+ [osmo_ac_build_manuals=$enableval], [osmo_ac_build_manuals="no"])
+AM_CONDITIONAL([BUILD_MANUALS], [test x"$osmo_ac_build_manuals" = x"yes"])
+AC_ARG_VAR(OSMO_GSM_MANUALS_DIR, [path to common osmo-gsm-manuals files, overriding pkg-config and "../osmo-gsm-manuals"
+ fallback])
+if test x"$osmo_ac_build_manuals" = x"yes"
+then
+ # Find OSMO_GSM_MANUALS_DIR (env, pkg-conf, fallback)
+ if test -n "$OSMO_GSM_MANUALS_DIR"; then
+ echo "checking for OSMO_GSM_MANUALS_DIR... $OSMO_GSM_MANUALS_DIR (from env)"
+ else
+ OSMO_GSM_MANUALS_DIR="$($PKG_CONFIG osmo-gsm-manuals --variable=osmogsmmanualsdir 2>/dev/null)"
+ if test -n "$OSMO_GSM_MANUALS_DIR"; then
+ echo "checking for OSMO_GSM_MANUALS_DIR... $OSMO_GSM_MANUALS_DIR (from pkg-conf)"
+ else
+ OSMO_GSM_MANUALS_DIR="../osmo-gsm-manuals"
+ echo "checking for OSMO_GSM_MANUALS_DIR... $OSMO_GSM_MANUALS_DIR (fallback)"
+ fi
+ fi
+ if ! test -d "$OSMO_GSM_MANUALS_DIR"; then
+ AC_MSG_ERROR("OSMO_GSM_MANUALS_DIR does not exist! Install osmo-gsm-manuals or set OSMO_GSM_MANUALS_DIR.")
+ fi
+
+ # Find and run check-depends
+ CHECK_DEPENDS="$OSMO_GSM_MANUALS_DIR/check-depends.sh"
+ if ! test -x "$CHECK_DEPENDS"; then
+ CHECK_DEPENDS="osmo-gsm-manuals-check-depends"
+ fi
+ if ! $CHECK_DEPENDS; then
+ AC_MSG_ERROR("missing dependencies for --enable-manuals")
+ fi
+
+ # Put in Makefile with absolute path
+ OSMO_GSM_MANUALS_DIR="$(realpath "$OSMO_GSM_MANUALS_DIR")"
+ AC_SUBST([OSMO_GSM_MANUALS_DIR])
+fi
CFLAGS="$CFLAGS -std=gnu11"
@@ -150,5 +190,6 @@
contrib/osmo-pcap.spec
doc/Makefile
doc/examples/Makefile
+ doc/manuals/Makefile
tests/Makefile
Makefile)
diff --git a/contrib/jenkins.sh b/contrib/jenkins.sh
index f1779dc..ae5177f 100755
--- a/contrib/jenkins.sh
+++ b/contrib/jenkins.sh
@@ -41,6 +41,11 @@
DISTCHECK_CONFIGURE_FLAGS="--with-pcap-config=/bin/true" \
PCAP_LIBS="-lpcap" PCAP_CFLAGS="" \
$MAKE distcheck || cat-testlogs.sh
+
+if [ "$WITH_MANUALS" = "1" ] && [ "$PUBLISH" = "1" ]; then
+ make -C "$base/doc/manuals" publish
+fi
+
$MAKE maintainer-clean
osmo-clean-workspace.sh
diff --git a/doc/Makefile.am b/doc/Makefile.am
index aee2d7b..f04764f 100644
--- a/doc/Makefile.am
+++ b/doc/Makefile.am
@@ -1 +1,4 @@
-SUBDIRS = examples
+SUBDIRS = \
+ examples \
+ manuals \
+ $(NULL)
diff --git a/doc/manuals/Makefile.am b/doc/manuals/Makefile.am
new file mode 100644
index 0000000..2e24c6c
--- /dev/null
+++ b/doc/manuals/Makefile.am
@@ -0,0 +1,11 @@
+EXTRA_DIST = vty
+
+if BUILD_MANUALS
+ # This is a significantly modified, multi-target adopted copy of
+ # $(OSMO_GSM_MANUALS_DIR)/build/Makefile.vty-reference.inc
+ VARIANTS = client server
+ include $(srcdir)/vty/Makefile.vty-reference.inc
+
+ OSMO_REPOSITORY = osmo-pcap
+ include $(OSMO_GSM_MANUALS_DIR)/build/Makefile.common.inc
+endif
diff --git a/doc/manuals/vty/Makefile.vty-reference.inc b/doc/manuals/vty/Makefile.vty-reference.inc
new file mode 100644
index 0000000..ea8c68e
--- /dev/null
+++ b/doc/manuals/vty/Makefile.vty-reference.inc
@@ -0,0 +1,37 @@
+DOCBOOKS = $(foreach v,$(VARIANTS),vty/osmo-pcap-$(v)-vty-reference.xml)
+DOCBOOKS_DEPS = $(DOCBOOKS) $(addsuffix .inc,$(DOCBOOKS))
+INC_DIR = $(abspath $(builddir)/vty)
+
+include $(OSMO_GSM_MANUALS_DIR)/build/Makefile.docbook.inc
+
+CLEAN_FILES += $(DOCBOOKS_DEPS)
+CLEAN_FILES += $(addsuffix .inc.gen,$(DOCBOOKS))
+CLEAN_FILES += $(addsuffix .inc.merged,$(DOCBOOKS))
+
+$(INC_DIR):
+ mkdir -p $@
+
+vty/osmo-pcap-%-vty-reference.xml: $(top_builddir)/src/osmo-pcap-% $(INC_DIR)
+ sed -e "s|@@GENERATED@@|$@.inc|" \
+ -e "s|@@VARIANT@@|$(notdir $<)|" \
+ -e "s|@@REV_NUMBER@@|$(VERSION)|" \
+ -e "s|@@REV_DATE@@|$(shell date +"%dth %B %Y")|" \
+ -e "s|@@CR_YEAR@@|$(shell date +"%Y")|" \
+ $(srcdir)/vty/osmo-pcap-vty-reference.xml > $@
+
+vty/osmo-pcap-%-vty-reference.xml.inc: $(top_builddir)/src/osmo-pcap-% \
+ $(OSMO_GSM_MANUALS_DIR)/common/vty_additions.xml \
+ $(OSMO_GSM_MANUALS_DIR)/common/chapters/vty.xml \
+ $(OSMO_GSM_MANUALS_DIR)/vty_reference.xsl \
+ $(srcdir)/vty/*.xml $(INC_DIR)
+ # a) Invoke osmo-pcap-% to generate the list of commands first
+ $< --vty-ref-mode default --vty-ref-xml > "$@.gen"
+ # ... filter garbage potentially printed by libraries to stdout
+ sed -i '/^<vtydoc/,$$!d' "$@.gen"
+ # b) Merge the result of a) with global and local additions
+ $(OSMO_GSM_MANUALS_DIR)/build/vty_reference_combine.sh \
+ $(realpath $(OSMO_GSM_MANUALS_DIR)/merge_doc.xsl) "$@.gen" \
+ $(OSMO_GSM_MANUALS_DIR)/common/vty_additions.xml \
+ $(srcdir)/vty/vty_additions.xml > "$@.merged"
+ # c) Convert the result of b) into a valid docbook
+ xsltproc $(OSMO_GSM_MANUALS_DIR)/vty_reference.xsl "$@.merged" > $@
diff --git a/doc/manuals/vty/osmo-pcap-vty-reference.xml b/doc/manuals/vty/osmo-pcap-vty-reference.xml
new file mode 100644
index 0000000..f4955dc
--- /dev/null
+++ b/doc/manuals/vty/osmo-pcap-vty-reference.xml
@@ -0,0 +1,35 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML 5.0//EN"
+"http://docbook.org/xml/5.0/dtd/docbook.dtd" [
+<!ENTITY chapter-vty SYSTEM "./common/chapters/vty.xml" >
+<!ENTITY sections-vty SYSTEM "@@GENERATED@@" >
+]>
+
+<book>
+ <info>
+ <revhistory>
+ <revision>
+ <revnumber>v1</revnumber>
+ <date>@@REV_DATE@@</date>
+ <authorinitials>s.f.m.c.</authorinitials>
+ <revremark>Automatic build (@@REV_NUMBER@@)</revremark>
+ </revision>
+ </revhistory>
+
+ <title>OsmoPCAP VTY Reference</title>
+ <subtitle>@@VARIANT@@</subtitle>
+
+ <copyright>
+ <year>@@CR_YEAR@@</year>
+ </copyright>
+
+ <legalnotice>
+ <para>This work is copyright by <orgname>sysmocom - s.f.m.c. GmbH</orgname>. All rights reserved.
+ </para>
+ </legalnotice>
+ </info>
+
+ <!-- Main chapters-->
+ &chapter-vty;
+</book>
diff --git a/doc/manuals/vty/vty_additions.xml b/doc/manuals/vty/vty_additions.xml
new file mode 100644
index 0000000..a4c675e
--- /dev/null
+++ b/doc/manuals/vty/vty_additions.xml
@@ -0,0 +1,2 @@
+<vtydoc xmlns='urn:osmocom:xml:libosmocore:vty:doc:1.0'>
+</vtydoc>
diff --git a/src/osmo_client_main.c b/src/osmo_client_main.c
index c7d68d4..4ef46cc 100644
--- a/src/osmo_client_main.c
+++ b/src/osmo_client_main.c
@@ -98,12 +98,41 @@
printf(" -T --timestamp. Print a timestamp in the debug output.\n");
printf(" -e --log-level number. Set a global loglevel.\n");
printf(" -c --config-file filename The config file to use.\n");
+
+ printf("\nVTY reference generation:\n");
+ printf(" --vty-ref-mode MODE VTY reference generation mode (e.g. 'expert').\n");
+ printf(" --vty-ref-xml Generate the VTY reference XML output and exit.\n");
+}
+
+static void handle_long_options(const char *prog_name, const int long_option)
+{
+ static int vty_ref_mode = VTY_REF_GEN_MODE_DEFAULT;
+ switch (long_option) {
+ case 1:
+ vty_ref_mode = get_string_value(vty_ref_gen_mode_names, optarg);
+ if (vty_ref_mode < 0) {
+ fprintf(stderr, "%s: Unknown VTY reference generation "
+ "mode '%s'\n", prog_name, optarg);
+ exit(2);
+ }
+ break;
+ case 2:
+ fprintf(stderr, "Generating the VTY reference in mode '%s' (%s)\n",
+ get_value_string(vty_ref_gen_mode_names, vty_ref_mode),
+ get_value_string(vty_ref_gen_mode_desc, vty_ref_mode));
+ vty_dump_xml_ref_mode(stdout, (enum vty_ref_gen_mode) vty_ref_mode);
+ exit(0);
+ default:
+ fprintf(stderr, "%s: error parsing cmdline options\n", prog_name);
+ exit(2);
+ }
}
static void handle_options(int argc, char **argv)
{
while (1) {
int option_index = 0, c;
+ static int long_option = 0;
static struct option long_options[] = {
{"help", 0, 0, 'h'},
{"daemonize", 0, 0, 'D'},
@@ -112,6 +141,8 @@
{"timestamp", 0, 0, 'T'},
{"log-level", 1, 0, 'e'},
{"config-file", 1, 0, 'c'},
+ {"vty-ref-mode", 1, &long_option, 1},
+ {"vty-ref-xml", 0, &long_option, 2},
{0, 0, 0, 0}
};
@@ -125,6 +156,9 @@
print_usage();
print_help();
exit(0);
+ case 0:
+ handle_long_options(argv[0], long_option);
+ break;
case 'D':
daemonize = 1;
break;
@@ -197,6 +231,7 @@
vty_init(&vty_info);
logging_vty_add_cmds();
osmo_stats_vty_add_cmds();
+ vty_client_init(tall_cli_ctx);
/* parse options */
handle_options(argc, argv);
@@ -226,7 +261,6 @@
LOGP(DCLIENT, LOGL_ERROR, "Failed to allocate osmo_pcap_client.\n");
exit(1);
}
- vty_client_init(pcap_client);
/* initialize the queue */
INIT_LLIST_HEAD(&pcap_client->conns);
diff --git a/src/osmo_server_main.c b/src/osmo_server_main.c
index 51441a7..9fa00e1 100644
--- a/src/osmo_server_main.c
+++ b/src/osmo_server_main.c
@@ -108,12 +108,41 @@
printf(" -T --timestamp. Print a timestamp in the debug output.\n");
printf(" -e --log-level number. Set a global loglevel.\n");
printf(" -c --config-file filename The config file to use.\n");
+
+ printf("\nVTY reference generation:\n");
+ printf(" --vty-ref-mode MODE VTY reference generation mode (e.g. 'expert').\n");
+ printf(" --vty-ref-xml Generate the VTY reference XML output and exit.\n");
+}
+
+static void handle_long_options(const char *prog_name, const int long_option)
+{
+ static int vty_ref_mode = VTY_REF_GEN_MODE_DEFAULT;
+ switch (long_option) {
+ case 1:
+ vty_ref_mode = get_string_value(vty_ref_gen_mode_names, optarg);
+ if (vty_ref_mode < 0) {
+ fprintf(stderr, "%s: Unknown VTY reference generation "
+ "mode '%s'\n", prog_name, optarg);
+ exit(2);
+ }
+ break;
+ case 2:
+ fprintf(stderr, "Generating the VTY reference in mode '%s' (%s)\n",
+ get_value_string(vty_ref_gen_mode_names, vty_ref_mode),
+ get_value_string(vty_ref_gen_mode_desc, vty_ref_mode));
+ vty_dump_xml_ref_mode(stdout, (enum vty_ref_gen_mode) vty_ref_mode);
+ exit(0);
+ default:
+ fprintf(stderr, "%s: error parsing cmdline options\n", prog_name);
+ exit(2);
+ }
}
static void handle_options(int argc, char **argv)
{
while (1) {
int option_index = 0, c;
+ static int long_option = 0;
static struct option long_options[] = {
{"help", 0, 0, 'h'},
{"daemonize", 0, 0, 'D'},
@@ -122,6 +151,8 @@
{"timestamp", 0, 0, 'T'},
{"log-level", 1, 0, 'e'},
{"config-file", 1, 0, 'c'},
+ {"vty-ref-mode", 1, &long_option, 1},
+ {"vty-ref-xml", 0, &long_option, 2},
{0, 0, 0, 0}
};
@@ -135,6 +166,9 @@
print_usage();
print_help();
exit(0);
+ case 0:
+ handle_long_options(argv[0], long_option);
+ break;
case 'D':
daemonize = 1;
break;
@@ -210,6 +244,7 @@
vty_init(&vty_info);
logging_vty_add_cmds();
osmo_stats_vty_add_cmds();
+ vty_server_init(tall_srv_ctx);
/* parse options */
handle_options(argc, argv);
@@ -249,7 +284,6 @@
pcap_server->base_path = talloc_strdup(pcap_server, "./");
pcap_server->max_size = 1073741824;
pcap_server->max_snaplen = DEFAULT_SNAPLEN;
- vty_server_init(pcap_server);
if (vty_read_config_file(config_file, NULL) < 0) {
LOGP(DSERVER, LOGL_ERROR,
--
To view, visit https://gerrit.osmocom.org/c/osmo-pcap/+/23691
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings
Gerrit-Project: osmo-pcap
Gerrit-Branch: master
Gerrit-Change-Id: I28353f51de798535a3bb6efdc6c2da443d96ddfb
Gerrit-Change-Number: 23691
Gerrit-PatchSet: 4
Gerrit-Owner: roh <jsteiger at sysmocom.de>
Gerrit-Assignee: laforge <laforge at osmocom.org>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: fixeria <vyanitskiy at sysmocom.de>
Gerrit-Reviewer: laforge <laforge at osmocom.org>
Gerrit-Reviewer: osmith <osmith at sysmocom.de>
Gerrit-Reviewer: pespin <pespin at sysmocom.de>
Gerrit-MessageType: merged
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20210418/b7490948/attachment.htm>