Browse Source

[3513] Added embedded config.report in binaries

Francis Dupont 10 years ago
parent
commit
255ce4ec2c

+ 7 - 2
configure.ac

@@ -1412,7 +1412,7 @@ AC_CONFIG_FILES([compatcheck/Makefile
                  doc/version.ent
                  ext/asio/asio/Makefile
                  ext/asio/Makefile
-		 ext/gtest/Makefile
+                 ext/gtest/Makefile
                  ext/Makefile
                  m4macros/Makefile
                  Makefile
@@ -1423,6 +1423,7 @@ AC_CONFIG_FILES([compatcheck/Makefile
                  src/bin/d2/tests/Makefile
                  src/bin/d2/tests/d2_process_tests.sh
                  src/bin/d2/tests/test_data_files_config.h
+                 src/bin/cfgrpt/Makefile
                  src/bin/dhcp4/Makefile
                  src/bin/dhcp4/spec_config.h.pre
                  src/bin/dhcp4/tests/Makefile
@@ -1455,7 +1456,7 @@ AC_CONFIG_FILES([compatcheck/Makefile
                  src/bin/admin/tests/mysql_tests.sh
                  src/bin/admin/scripts/mysql/Makefile
                  src/bin/admin/scripts/mysql/upgrade_1.0_to_2.0.sh
-		 src/bin/admin/scripts/mysql/upgrade_2.0_to_3.0.sh
+                 src/bin/admin/scripts/mysql/upgrade_2.0_to_3.0.sh
                  src/bin/admin/scripts/pgsql/Makefile
                  src/hooks/Makefile
                  src/hooks/dhcp/Makefile
@@ -1680,6 +1681,10 @@ Developer:
 
 END
 
+# Create config_report.cc with embedded config.report
+chmod +x ${srcdir}/tools/mk_cfgrpt.sh
+${srcdir}/tools/mk_cfgrpt.sh ${srcdir}/src/bin/cfgrpt/config_report.cc
+
 cat config.report
 cat <<EOF
 

+ 1 - 1
src/bin/Makefile.am

@@ -1,5 +1,5 @@
 # The following build order must be maintained.
-SUBDIRS = dhcp4 dhcp6 d2 perfdhcp admin lfc
+SUBDIRS = cfgrpt dhcp4 dhcp6 d2 perfdhcp admin lfc
 
 if CONFIG_BACKEND_JSON
 SUBDIRS += keactrl

+ 1 - 0
src/bin/cfgrpt/.gitignore

@@ -0,0 +1 @@
+/config_report.cc

+ 10 - 0
src/bin/cfgrpt/Makefile.am

@@ -0,0 +1,10 @@
+# Get rid of generated message files on a clean
+CLEANFILES = *.gcno *.gcda
+
+# config_report.cc was generated by configure
+DISTCLEANFILES = config_report.cc
+
+# convenience archive
+noinst_LTLIBRARIES = libcfgrpt.la
+
+libcfgrpt_la_SOURCES = config_report.h config_report.cc

+ 26 - 0
src/bin/cfgrpt/config_report.h

@@ -0,0 +1,26 @@
+// Copyright (C) 2015 Internet Systems Consortium, Inc. ("ISC")
+//
+// Permission to use, copy, modify, and/or distribute this software for any
+// purpose with or without fee is hereby granted, provided that the above
+// copyright notice and this permission notice appear in all copies.
+//
+// THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
+// REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+// AND FITNESS.  IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
+// INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
+// LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
+// OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+// PERFORMANCE OF THIS SOFTWARE.
+
+#ifndef CONFIG_REPORT_H
+#define CONFIG_REPORT_H
+
+namespace isc {
+namespace detail {
+
+extern const char* const config_report[];
+
+}
+}
+
+#endif // CONFIG_REPORT_H

+ 1 - 0
src/bin/d2/Makefile.am

@@ -98,6 +98,7 @@ kea_dhcp_ddns_LDADD += $(top_builddir)/src/lib/dns/libkea-dns++.la
 kea_dhcp_ddns_LDADD += $(top_builddir)/src/lib/util/libkea-util.la
 kea_dhcp_ddns_LDADD += $(top_builddir)/src/lib/hooks/libkea-hooks.la
 kea_dhcp_ddns_LDADD += $(top_builddir)/src/lib/cryptolink/libkea-cryptolink.la
+kea_dhcp_ddns_LDADD += $(top_builddir)/src/bin/cfgrpt/libcfgrpt.la
 
 kea_dhcp_ddnsdir = $(pkgdatadir)
 kea_dhcp_ddns_DATA = dhcp-ddns.spec

+ 4 - 0
src/bin/d2/d_controller.cc

@@ -21,6 +21,7 @@
 #include <dhcpsrv/cfgmgr.h>
 #include <cryptolink/cryptolink.h>
 #include <log/logger.h>
+#include <cfgrpt/config_report.h>
 
 #include <sstream>
 #include <unistd.h>
@@ -443,6 +444,9 @@ DControllerBase::usage(const std::string & text)
 DControllerBase::~DControllerBase() {
 }
 
+// Refer to config_report so it will be embedded in the binary
+const char* const* d2_config_report = isc::detail::config_report;
+
 }; // namespace isc::d2
 
 }; // namespace isc

+ 1 - 0
src/bin/dhcp4/Makefile.am

@@ -83,6 +83,7 @@ kea_dhcp4_LDADD += $(top_builddir)/src/lib/config/libkea-cfgclient.la
 kea_dhcp4_LDADD += $(top_builddir)/src/lib/cc/libkea-cc.la
 kea_dhcp4_LDADD += $(top_builddir)/src/lib/hooks/libkea-hooks.la
 kea_dhcp4_LDADD += $(top_builddir)/src/lib/cryptolink/libkea-cryptolink.la
+kea_dhcp4_LDADD += $(top_builddir)/src/bin/cfgrpt/libcfgrpt.la
 
 kea_dhcp4dir = $(pkgdatadir)
 kea_dhcp4_DATA = dhcp4.spec

+ 4 - 0
src/bin/dhcp4/dhcp4_srv.cc

@@ -43,6 +43,7 @@
 #include <util/strutil.h>
 #include <log/logger.h>
 #include <cryptolink/cryptolink.h>
+#include <cfgrpt/config_report.h>
 
 #include <asio.hpp>
 #include <boost/bind.hpp>
@@ -2210,6 +2211,9 @@ Dhcpv4Srv::d2ClientErrorHandler(const
     CfgMgr::instance().getD2ClientMgr().suspendUpdates();
 }
 
+// Refer to config_report so it will be embedded in the binary
+const char* const* dhcp4_config_report = isc::detail::config_report;
+
 std::string
 Daemon::getVersion(bool extended) {
     std::stringstream tmp;

+ 1 - 0
src/bin/dhcp6/Makefile.am

@@ -85,6 +85,7 @@ kea_dhcp6_LDADD += $(top_builddir)/src/lib/log/libkea-log.la
 kea_dhcp6_LDADD += $(top_builddir)/src/lib/util/libkea-util.la
 kea_dhcp6_LDADD += $(top_builddir)/src/lib/hooks/libkea-hooks.la
 kea_dhcp6_LDADD += $(top_builddir)/src/lib/cryptolink/libkea-cryptolink.la
+kea_dhcp6_LDADD += $(top_builddir)/src/bin/cfgrpt/libcfgrpt.la
 
 kea_dhcp6dir = $(pkgdatadir)
 kea_dhcp6_DATA = dhcp6.spec

+ 4 - 0
src/bin/dhcp6/dhcp6_srv.cc

@@ -48,6 +48,7 @@
 #include <util/range_utilities.h>
 #include <log/logger.h>
 #include <cryptolink/cryptolink.h>
+#include <cfgrpt/config_report.h>
 
 #include <asio.hpp>
 
@@ -2757,6 +2758,9 @@ Dhcpv6Srv::d2ClientErrorHandler(const
     CfgMgr::instance().getD2ClientMgr().suspendUpdates();
 }
 
+// Refer to config_report so it will be embedded in the binary
+const char* const* dhcp6_config_report = isc::detail::config_report;
+
 std::string
 Daemon::getVersion(bool extended) {
     std::stringstream tmp;

+ 1 - 0
src/bin/lfc/Makefile.am

@@ -64,5 +64,6 @@ kea_lfc_LDADD += $(top_builddir)/src/lib/asiolink/libkea-asiolink.la
 kea_lfc_LDADD += $(top_builddir)/src/lib/dhcp/libkea-dhcp++.la
 kea_lfc_LDADD += $(top_builddir)/src/lib/dhcpsrv/libkea-dhcpsrv.la
 kea_lfc_LDADD += $(top_builddir)/src/lib/util/libkea-util.la
+kea_lfc_LDADD += $(top_builddir)/src/bin/cfgrpt/libcfgrpt.la
 
 kea_lfcdir = $(pkgdatadir)

+ 4 - 0
src/bin/lfc/lfc_controller.cc

@@ -25,6 +25,7 @@
 #include <dhcpsrv/lease_file_loader.h>
 #include <log/logger_manager.h>
 #include <log/logger_name.h>
+#include <cfgrpt/config_report.h>
 
 #include <iostream>
 #include <sstream>
@@ -45,6 +46,9 @@ const uint32_t MAX_LEASE_ERRORS = 100;
 namespace isc {
 namespace lfc {
 
+// Refer to config_report so it will be embedded in the binary
+const char* const* lfc_config_report = isc::detail::config_report;
+
 /// @brief Defines the application name, it may be used to locate
 /// configuration data and appears in log statements.
 const char* LFCController::lfc_app_name_ = "DhcpLFC";

+ 2 - 1
src/bin/perfdhcp/Makefile.am

@@ -1,6 +1,7 @@
 SUBDIRS = . tests
 
 AM_CPPFLAGS = -I$(top_srcdir)/src/lib -I$(top_builddir)/src/lib
+AM_CPPFLAGS += -I$(top_srcdir)/src/bin -I$(top_builddir)/src/bin
 AM_CPPFLAGS += -I$(top_srcdir)/src/lib/log -I$(top_builddir)/src/lib/log
 AM_CPPFLAGS += $(BOOST_INCLUDES)
 
@@ -47,7 +48,7 @@ perfdhcp_LDADD = libperfdhcp.la
 perfdhcp_LDADD += $(top_builddir)/src/lib/exceptions/libkea-exceptions.la
 perfdhcp_LDADD += $(top_builddir)/src/lib/dhcp/libkea-dhcp++.la
 perfdhcp_LDADD += $(top_builddir)/src/lib/asiolink/libkea-asiolink.la
-
+perfdhcp_LDADD += $(top_builddir)/src/bin/cfgrpt/libcfgrpt.la
 
 # ... and the documentation
 EXTRA_DIST = perfdhcp_internals.dox

+ 4 - 0
src/bin/perfdhcp/command_options.cc

@@ -18,6 +18,7 @@
 #include <exceptions/exceptions.h>
 #include <dhcp/iface_mgr.h>
 #include <dhcp/duid.h>
+#include <cfgrpt/config_report.h>
 
 #include <boost/lexical_cast.hpp>
 #include <boost/date_time/posix_time/posix_time.hpp>
@@ -35,6 +36,9 @@ using namespace isc;
 namespace isc {
 namespace perfdhcp {
 
+// Refer to config_report so it will be embedded in the binary
+const char* const* perfdhcp_config_report = isc::detail::config_report;
+
 CommandOptions::LeaseType::LeaseType()
     : type_(ADDRESS) {
 }

+ 46 - 0
tools/mk_cfgrpt.sh

@@ -0,0 +1,46 @@
+#!/bin/sh
+# Copyright (C) 2015  Internet Systems Consortium, Inc. ("ISC")
+#
+# Permission to use, copy, modify, and/or distribute this software for any
+# purpose with or without fee is hereby granted, provided that the above
+# copyright notice and this permission notice appear in all copies.
+#
+# THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
+# REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+# AND FITNESS.  IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
+# INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
+# LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
+# OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+# PERFORMANCE OF THIS SOFTWARE.
+#
+# This script embeds config.report into src/bin/cfgrpt/config_report.cc
+# Called by configure
+#
+
+dest=$1
+
+# Initializes
+cat > $dest
+
+# Header
+cat >> $dest << END
+// config_report.cc. Generated from config.report by tools/mk_cfgrpt_header.sh
+
+namespace isc {
+namespace detail {
+
+extern const char* const config_report[] = {
+END
+
+# Body: escape '\'s and '"'s, preprend '    ";;;; ' and append '",'
+sed -e 's/\\/\\\\/g' -e 's/"/\\"/g' -e 's/^/    ";;;; /' -e 's/$/",/' \
+    < config.report >> $dest
+
+# Trailer
+cat >> $dest <<END
+    ""
+};
+
+}
+}
+END