aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDamjan Marion <damarion@cisco.com>2015-12-12 14:40:59 +0100
committerDamjan Marion <damarion@cisco.com>2015-12-13 18:18:27 +0100
commita0d4a1a6d1b81b132787e382ac3f8487b71cf52c (patch)
treeaabeaa39e8b0e6db087e993c9acecadbf84811b7
parent29726ab117a1fc5b3d92d1afaaaaa08ef7f138eb (diff)
new version handling
Change-Id: I90983f3df94a3b28199908b29ffd8f827ab0c379 Signed-off-by: Damjan Marion <damarion@cisco.com>
-rw-r--r--vpp-api-test/vat/api_format.c4
-rw-r--r--vpp-japi/japi/vppjni.c10
-rw-r--r--vpp-japi/japi/vppjni.h4
-rw-r--r--vpp/Makefile.am22
-rw-r--r--vpp/Makefile.in20
-rw-r--r--vpp/api/api.c6
-rw-r--r--vpp/api/vpe.api4
-rw-r--r--vpp/app/version.c52
-rw-r--r--vppversion/Makefile.am5
-rw-r--r--vppversion/Makefile.in15
-rw-r--r--vppversion/lt.c577
-rw-r--r--vppversion/sign.c178
-rw-r--r--vppversion/vlib_version.c206
13 files changed, 90 insertions, 1013 deletions
diff --git a/vpp-api-test/vat/api_format.c b/vpp-api-test/vat/api_format.c
index 5ee4b929ce8..02c3ad5fe06 100644
--- a/vpp-api-test/vat/api_format.c
+++ b/vpp-api-test/vat/api_format.c
@@ -861,7 +861,7 @@ static void vl_api_show_version_reply_t_handler
if (retval >= 0) {
errmsg (" program: %s\n", mp->program);
- errmsg (" git branch: %s\n", mp->git_branch);
+ errmsg (" version: %s\n", mp->version);
errmsg (" build date: %s\n", mp->build_date);
errmsg ("build directory: %s\n", mp->build_directory);
}
@@ -878,7 +878,7 @@ static void vl_api_show_version_reply_t_handler_json
vat_json_init_object(&node);
vat_json_object_add_int(&node, "retval", ntohl(mp->retval));
vat_json_object_add_string_copy(&node, "program", mp->program);
- vat_json_object_add_string_copy(&node, "git_branch", mp->git_branch);
+ vat_json_object_add_string_copy(&node, "version", mp->version);
vat_json_object_add_string_copy(&node, "build_date", mp->build_date);
vat_json_object_add_string_copy(&node, "build_directory", mp->build_directory);
diff --git a/vpp-japi/japi/vppjni.c b/vpp-japi/japi/vppjni.c
index 65c26403a1d..740a3425d90 100644
--- a/vpp-japi/japi/vppjni.c
+++ b/vpp-japi/japi/vppjni.c
@@ -153,11 +153,11 @@ JNIEXPORT jobject JNICALL Java_org_openvpp_vppjapi_vppConn_getVppVersion
vppjni_lock (jm, 11);
jstring progName = (*env)->NewStringUTF(env, (char *)jm->program_name);
jstring buildDir = (*env)->NewStringUTF(env, (char *)jm->build_directory);
- jstring gitBranch = (*env)->NewStringUTF(env, (char *)jm->git_branch);
+ jstring version = (*env)->NewStringUTF(env, (char *)jm->version);
jstring buildDate = (*env)->NewStringUTF(env, (char *)jm->build_date);
vppjni_unlock (jm);
- return (*env)->NewObject(env, cls, constr, progName, buildDir, gitBranch, buildDate);
+ return (*env)->NewObject(env, cls, constr, progName, buildDir, version, buildDate);
}
static int jm_show_version (vppjni_main_t *jm)
@@ -1349,9 +1349,9 @@ vl_api_show_version_reply_t_handler (vl_api_show_version_reply_t * mp)
sizeof(jm->build_directory)-1);
jm->build_directory[sizeof(jm->build_directory)-1] = 0;
- strncpy((char*)jm->git_branch, (const char*)mp->git_branch,
- sizeof(jm->git_branch)-1);
- jm->git_branch[sizeof(jm->git_branch)-1] = 0;
+ strncpy((char*)jm->version, (const char*)mp->version,
+ sizeof(jm->version)-1);
+ jm->version[sizeof(jm->version)-1] = 0;
strncpy((char*)jm->build_date, (const char*)mp->build_date,
sizeof(jm->build_date)-1);
diff --git a/vpp-japi/japi/vppjni.h b/vpp-japi/japi/vppjni.h
index d2054b77a26..c065016c346 100644
--- a/vpp-japi/japi/vppjni.h
+++ b/vpp-japi/japi/vppjni.h
@@ -156,10 +156,10 @@ typedef struct {
u8 collect_indices;
u32 * sw_if_dump_if_indices;
- /* program name, build_dir, git_version */
+ /* program name, build_dir, version */
u8 program_name[32];
u8 build_directory[256];
- u8 git_branch[32];
+ u8 version[32];
u8 build_date[32];
/* subinterface table */
diff --git a/vpp/Makefile.am b/vpp/Makefile.am
index eef0ff6fedc..1e3bbf08ebd 100644
--- a/vpp/Makefile.am
+++ b/vpp/Makefile.am
@@ -49,18 +49,16 @@ nobase_include_HEADERS = \
apidir = $(prefix)/api
api_DATA = api/vpe.api
-BUILT_SOURCES += api/vpe.api.h app/version.c
-
-.PHONY: app/version.c
-
-app/version.c:
- @pushd ../../../vpp ; \
- branch=`git rev-parse --abbrev-ref HEAD` ; \
- popd ; \
- if [ x$$GITTAG = "x" ] ; then \
- GITTAG=$$USER-private ; \
- fi ; \
- vppversion -p vpe -b $${branch}@$${GITTAG} -o $@
+BUILT_SOURCES += api/vpe.api.h app/version.h
+
+.PHONY: app/version.h
+
+app/version.h: ../build-root/scripts/version
+ @echo "#define VPP_BUILD_DATE \"$$(date)\"" > $@
+ @echo "#define VPP_BUILD_USER \"$$(whoami)\"" >> $@
+ @echo "#define VPP_BUILD_HOST \"$$(hostname)\"" >> $@
+ @echo "#define VPP_BUILD_TOPDIR \"$$(git rev-parse --show-toplevel)\"" >> $@
+ @echo "#define VPP_BUILD_VER \"$$(../../scripts/version)\"" >> $@
vpe_LDADD = -lvlibapi -lvlibmemory -lvlib_unix -lvlib
diff --git a/vpp/Makefile.in b/vpp/Makefile.in
index 643f41e9158..17f3a8cddf1 100644
--- a/vpp/Makefile.in
+++ b/vpp/Makefile.in
@@ -368,7 +368,7 @@ top_builddir = @top_builddir@
top_srcdir = @top_srcdir@
AUTOMAKE_OPTIONS = foreign subdir-objects
AM_CFLAGS = -Wall @Q_PLATFORM_DEFINE@ @Q_PLATFORM_PLUGPATH@ @DPDK@
-BUILT_SOURCES = api/vpe.api.h app/version.c
+BUILT_SOURCES = api/vpe.api.h app/version.h
CLEANFILES =
lib_LTLIBRARIES =
@@ -1074,17 +1074,17 @@ uninstall-am: uninstall-apiDATA uninstall-binPROGRAMS \
uninstall-binPROGRAMS uninstall-libLTLIBRARIES \
uninstall-nobase_includeHEADERS
+.PRECIOUS: Makefile
+
-.PHONY: app/version.c
+.PHONY: app/version.h
-app/version.c:
- @pushd ../../../vpp ; \
- branch=`git rev-parse --abbrev-ref HEAD` ; \
- popd ; \
- if [ x$$GITTAG = "x" ] ; then \
- GITTAG=$$USER-private ; \
- fi ; \
- vppversion -p vpe -b $${branch}@$${GITTAG} -o $@
+app/version.h: ../build-root/scripts/version
+ @echo "#define VPP_BUILD_DATE \"$$(date)\"" > $@
+ @echo "#define VPP_BUILD_USER \"$$(whoami)\"" >> $@
+ @echo "#define VPP_BUILD_HOST \"$$(hostname)\"" >> $@
+ @echo "#define VPP_BUILD_TOPDIR \"$$(git rev-parse --show-toplevel)\"" >> $@
+ @echo "#define VPP_BUILD_VER \"$$(../../scripts/version)\"" >> $@
%.api.h: %.api
@echo " APIGEN " $@ ; \
diff --git a/vpp/api/api.c b/vpp/api/api.c
index 57eaa7237f6..a1e7f020e6c 100644
--- a/vpp/api/api.c
+++ b/vpp/api/api.c
@@ -3915,7 +3915,7 @@ vl_api_show_version_t_handler (vl_api_show_version_t *mp)
vl_api_show_version_reply_t *rmp;
int rv = 0;
char * vpe_api_get_build_directory(void);
- char * vpe_api_get_branch(void);
+ char * vpe_api_get_version(void);
char * vpe_api_get_build_date(void);
unix_shared_memory_queue_t * q =
@@ -3929,8 +3929,8 @@ vl_api_show_version_t_handler (vl_api_show_version_t *mp)
strncpy ((char *) rmp->program, "vpe", ARRAY_LEN(rmp->program)-1);
strncpy ((char *) rmp->build_directory, vpe_api_get_build_directory(),
ARRAY_LEN(rmp->build_directory)-1);
- strncpy ((char *) rmp->git_branch, vpe_api_get_branch(),
- ARRAY_LEN(rmp->git_branch)-1);
+ strncpy ((char *) rmp->version, vpe_api_get_version(),
+ ARRAY_LEN(rmp->version)-1);
strncpy ((char *) rmp->build_date, vpe_api_get_build_date(),
ARRAY_LEN(rmp->build_date)-1);
}));
diff --git a/vpp/api/vpe.api b/vpp/api/vpe.api
index 4301f549b4c..480558aa4c2 100644
--- a/vpp/api/vpe.api
+++ b/vpp/api/vpe.api
@@ -1988,14 +1988,14 @@ define show_version {
@param context - sender context, to match reply w/ request
@param retval - return code for the request
@param program - name of the program (vpe)
+ @param version - version of the program
@param build_directory - root of the workspace where the program was built
- @param git_branch - the git branch for the workspace
*/
manual_java define show_version_reply {
u32 context;
i32 retval;
u8 program[32];
- u8 git_branch[32];
+ u8 version[32];
u8 build_date[32];
u8 build_directory[256];
};
diff --git a/vpp/app/version.c b/vpp/app/version.c
new file mode 100644
index 00000000000..354c0296306
--- /dev/null
+++ b/vpp/app/version.c
@@ -0,0 +1,52 @@
+/*
+ * Copyright (c) 2015 Cisco and/or its affiliates.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#include <vlib/vlib.h>
+#include <app/version.h>
+
+static char * vpe_version_string =
+"vpp v" VPP_BUILD_VER " built by " VPP_BUILD_USER " on " VPP_BUILD_HOST " at " VPP_BUILD_DATE;
+static char * vpe_dir_string = "workspace is " VPP_BUILD_TOPDIR;
+
+static clib_error_t *
+show_vpe_version_command_fn (vlib_main_t * vm,
+ unformat_input_t * input,
+ vlib_cli_command_t * cmd)
+{
+ vlib_cli_output (vm, "%s", vpe_version_string);
+ if (unformat (input, "verbose")){
+ vlib_cli_output (vm, "%s", vpe_dir_string);
+ }
+ return 0;
+}
+
+VLIB_CLI_COMMAND (show_vpe_version_command, static) = {
+ .path = "show version",
+ .short_help = "show version information",
+ .function = show_vpe_version_command_fn,
+};
+
+char * vpe_api_get_build_directory (void)
+{
+ return VPP_BUILD_TOPDIR;
+}
+
+char * vpe_api_get_version (void)
+{
+ return VPP_BUILD_VER;
+}
+char * vpe_api_get_build_date (void)
+{
+ return VPP_BUILD_DATE;
+}
diff --git a/vppversion/Makefile.am b/vppversion/Makefile.am
index d5b6af255a9..0296cdffcdb 100644
--- a/vppversion/Makefile.am
+++ b/vppversion/Makefile.am
@@ -13,11 +13,8 @@
AUTOMAKE_OPTIONS = foreign
-bin_PROGRAMS = elftool vppversion
+bin_PROGRAMS = elftool
elftool_SOURCES = elftool.c
elftool_CPPFLAGS = -Wall
elftool_LDADD = -lvppinfra -lpthread -lrt -lm
-
-vppversion_SOURCES = vlib_version.c
-vppversion_LDADD = -lvppinfra -lpthread -lm
diff --git a/vppversion/Makefile.in b/vppversion/Makefile.in
index e79d07b0736..88857ba4891 100644
--- a/vppversion/Makefile.in
+++ b/vppversion/Makefile.in
@@ -91,7 +91,7 @@ PRE_UNINSTALL = :
POST_UNINSTALL = :
build_triplet = @build@
host_triplet = @host@
-bin_PROGRAMS = elftool$(EXEEXT) vppversion$(EXEEXT)
+bin_PROGRAMS = elftool$(EXEEXT)
subdir = .
DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \
$(top_srcdir)/configure $(am__configure_deps) depcomp compile \
@@ -114,9 +114,6 @@ AM_V_lt = $(am__v_lt_@AM_V@)
am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@)
am__v_lt_0 = --silent
am__v_lt_1 =
-am_vppversion_OBJECTS = vlib_version.$(OBJEXT)
-vppversion_OBJECTS = $(am_vppversion_OBJECTS)
-vppversion_DEPENDENCIES =
AM_V_P = $(am__v_P_@AM_V@)
am__v_P_ = $(am__v_P_@AM_DEFAULT_V@)
am__v_P_0 = false
@@ -151,8 +148,8 @@ AM_V_CCLD = $(am__v_CCLD_@AM_V@)
am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@)
am__v_CCLD_0 = @echo " CCLD " $@;
am__v_CCLD_1 =
-SOURCES = $(elftool_SOURCES) $(vppversion_SOURCES)
-DIST_SOURCES = $(elftool_SOURCES) $(vppversion_SOURCES)
+SOURCES = $(elftool_SOURCES)
+DIST_SOURCES = $(elftool_SOURCES)
am__can_run_installinfo = \
case $$AM_UPDATE_INFO_DIR in \
n|no|NO) false;; \
@@ -317,8 +314,6 @@ AUTOMAKE_OPTIONS = foreign
elftool_SOURCES = elftool.c
elftool_CPPFLAGS = -Wall
elftool_LDADD = -lvppinfra -lpthread -lrt -lm
-vppversion_SOURCES = vlib_version.c
-vppversion_LDADD = -lvppinfra -lpthread -lm
all: all-am
.SUFFIXES:
@@ -411,10 +406,6 @@ elftool$(EXEEXT): $(elftool_OBJECTS) $(elftool_DEPENDENCIES) $(EXTRA_elftool_DEP
@rm -f elftool$(EXEEXT)
$(AM_V_CCLD)$(LINK) $(elftool_OBJECTS) $(elftool_LDADD) $(LIBS)
-vppversion$(EXEEXT): $(vppversion_OBJECTS) $(vppversion_DEPENDENCIES) $(EXTRA_vppversion_DEPENDENCIES)
- @rm -f vppversion$(EXEEXT)
- $(AM_V_CCLD)$(LINK) $(vppversion_OBJECTS) $(vppversion_LDADD) $(LIBS)
-
mostlyclean-compile:
-rm -f *.$(OBJEXT)
diff --git a/vppversion/lt.c b/vppversion/lt.c
deleted file mode 100644
index 0de2b06114e..00000000000
--- a/vppversion/lt.c
+++ /dev/null
@@ -1,577 +0,0 @@
-/*
- * Copyright (c) 2015 Cisco and/or its affiliates.
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at:
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-#include <string.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <sys/wait.h>
-#include <vppinfra/bitmap.h>
-#include <vppinfra/format.h>
-#include <vppinfra/hash.h>
-
-#define foreach_libtool_mode _ (compile) _ (link) _ (install)
-
-typedef enum {
-#define _(m) MODE_##m,
- foreach_libtool_mode
-#undef _
-} lt_mode_t;
-
-typedef enum {
- LITERAL,
- OUTPUT_EXE,
- OUTPUT_LO,
- OUTPUT_LA,
- LT_LIB,
- NON_LT_LIB,
- IGNORE,
-} lt_edit_type_t;
-
-typedef struct {
- lt_edit_type_t type;
- u8 * data;
-} lt_edit_t;
-
-typedef struct {
- u8 * path;
-} lt_lib_path_t;
-
-typedef struct {
- lt_mode_t mode;
- int link_static;
- int silent;
- lt_edit_type_t output_edit_type;
- u8 * output_file;
- lt_edit_t * edits;
- lt_lib_path_t * lib_path;
- uword * rpath_hash;
- u8 * tag;
-} lt_main_t;
-
-static lt_lib_path_t *
-search_lib_path (lt_main_t * lm, char * fmt, ...)
-{
- va_list va;
- static u8 * file_name, * path_name;
- lt_lib_path_t * p = 0;
-
- if (file_name)
- _vec_len (file_name) = 0;
-
- va_start (va, fmt);
- file_name = va_format (file_name, fmt, &va);
- va_end (va);
-
- path_name = 0;
- vec_foreach (p, lm->lib_path)
- {
- struct stat st;
-
- if (path_name)
- _vec_len (path_name) = 0;
-
- path_name = format (path_name, "%s/%v%c", p->path, file_name, 0);
- if (stat ((char *) path_name, &st) >= 0)
- return p;
- }
- return 0;
-}
-
-static u8 * format_libtool_mode (u8 * s, va_list * args)
-{
- int m = va_arg (*args, int);
- char * t;
- switch (m)
- {
-#define _(f) case MODE_##f: t = #f; break;
- foreach_libtool_mode;
-#undef _
- default:
- t = 0;
- }
- if (t)
- vec_add (s, t, strlen (t));
- else
- s = format (s, "unknown 0x%x", m);
- return s;
-}
-
-static uword unformat_libtool_mode (unformat_input_t * input, va_list * args)
-{
- int * result = va_arg (*args, int *);
-#define _(m) if (unformat (input, #m)) { *result = MODE_##m; return 1; }
- foreach_libtool_mode;
-#undef _
- return 0;
-}
-
-static uword unformat_basename (unformat_input_t * input, va_list * args)
-{
- u8 ** result = va_arg (*args, u8 **);
- u8 * suffix = va_arg (*args, u8 *);
- u8 * current_suffix = suffix;
- uword c;
-
- while ((c = unformat_get_input (input)) != UNFORMAT_END_OF_INPUT)
- {
- switch (c)
- {
- case 0:
- case ' ':
- case '\t':
- case '\n':
- case '\r':
- goto fail;
- }
-
- vec_add1 (*result, c);
- if (c == *current_suffix)
- current_suffix++;
- else
- current_suffix = suffix;
-
- if (*current_suffix == 0)
- {
- _vec_len (*result) -= current_suffix - suffix;
- return 1;
- }
- }
- fail:
- vec_free (*result);
- return 0;
-}
-
-static void edit (lt_main_t * lm, lt_edit_type_t type, char * fmt, ...)
-{
- va_list va;
- lt_edit_t * e;
- u8 * s;
-
- va_start (va, fmt);
- s = va_format (0, fmt, &va);
- va_end (va);
-
- vec_add2 (lm->edits, e, 1);
- e->type = type;
- e->data = s;
-}
-
-static u8 * format_argv (u8 * s, va_list * args)
-{
- u8 ** a = va_arg (*args, u8 **);
- uword i;
- for (i = 0; i < vec_len (a) - 1; i++)
- {
- if (i > 0)
- vec_add1 (s, ' ');
- vec_add (s, a[i], vec_len (a[i]) - 1);
- }
- return s;
-}
-
-static u8 * format_dirname (u8 * s, va_list * args)
-{
- u8 * f = va_arg (*args, u8 *);
- u8 * t;
-
- for (t = vec_end (f) - 1; t >= f; t--)
- {
- if (t[0] == '/')
- break;
- }
- if (t[0] == '/')
- vec_add (s, f, t - f);
- else
- vec_add1 (s, '.');
- return s;
-}
-
-static u8 * format_basename (u8 * s, va_list * args)
-{
- u8 * f = va_arg (*args, u8 *);
- u8 * t;
-
- for (t = vec_end (f) - 1; t >= f; t--)
- {
- if (t[0] == '/')
- break;
- }
- if (t[0] == '/')
- vec_add (s, t + 1, vec_end (f) - (t + 1));
- else
- vec_add (s, f, vec_len (f));
- return s;
-}
-
-static void my_system (char * fmt, ...)
-{
- va_list va;
- u8 * s;
-
- va_start (va, fmt);
- s = va_format (0, fmt, &va);
- va_end (va);
-
- vec_add1 (s, 0); /* null terminate */
- if (system ((char *) s) != 0)
- clib_error ("%s", s);
- vec_free (s);
-}
-
-static u8 * my_cmd (char * fmt, ...)
-{
- va_list va;
- u8 * s;
- FILE * result;
- int c;
-
- va_start (va, fmt);
- s = va_format (0, fmt, &va);
- va_end (va);
-
- vec_add1 (s, 0); /* null terminate */
- result = popen ((char *) s, "r");
- if (! result)
- clib_error ("%s", s);
- _vec_len (s) = 0;
- while ((c = fgetc (result)) != EOF)
- vec_add1 (s, c);
- pclose (result);
- return s;
-}
-
-static void make_file_with_contents (lt_main_t * lm, u8 * contents, char * fmt, ...)
-{
- va_list va;
- u8 * s;
- FILE * f;
-
- va_start (va, fmt);
- s = va_format (0, fmt, &va);
- va_end (va);
-
- vec_add1 (s, 0); /* null terminate */
- f = fopen ((char *) s, "w");
-
- if (! f)
- clib_error ("fopen %s", s);
-
- if (1 != fwrite (contents, vec_len (contents), 1, f))
- clib_error ("fwrite");
-
- fclose (f);
-}
-
-static u8 ** add_argv (u8 ** argv, char * fmt, ...)
-{
- va_list va;
- u8 * s;
-
- va_start (va, fmt);
- s = va_format (0, fmt, &va);
- va_end (va);
- vec_add1 (s, 0); /* null terminate */
- vec_add1 (argv, s);
- return argv;
-}
-
-#define GEN_ARGV_PIC (1 << 0)
-#define GEN_ARGV_PUNT (1 << 1)
-
-static u8 ** gen_argv (lt_main_t * lm, uword flags)
-{
- u8 ** r = 0;
- uword * path_used_bitmap = 0;
- lt_edit_t * e;
- int is_punt;
-
- is_punt = (flags & GEN_ARGV_PUNT) != 0;
- if (is_punt)
- {
- /* No supported so punt back to shell based libtool. */
- r = add_argv (r, "/bin/sh");
- r = add_argv (r, "./libtool");
- r = add_argv (r, "--mode=%U", format_libtool_mode, lm->mode);
- }
-
- if (lm->mode == MODE_compile)
- ASSERT (lm->output_edit_type != OUTPUT_LA);
-
- vec_foreach (e, lm->edits)
- {
- switch (e->type)
- {
- case LITERAL:
- r = add_argv (r, "%v", e->data);
- break;
-
- case OUTPUT_EXE:
- if (! is_punt)
- my_system ("mkdir -p %U/.libs", format_dirname, e->data);
- r = add_argv (r, "-o");
- r = add_argv (r, "%s%v", is_punt ? "" : ".libs/", e->data);
- break;
-
- case OUTPUT_LO:
- if (flags & GEN_ARGV_PIC)
- {
- r = add_argv (r, "-fPIC");
- r = add_argv (r, "-DPIC");
- }
- r = add_argv (r, "-o");
-
- if (is_punt)
- r = add_argv (r, "-o %v.lo", e->data);
-
- else if (flags & GEN_ARGV_PIC)
- {
- my_system ("mkdir -p %U/.libs", format_dirname, e->data);
- r = add_argv (r, "%U/.libs/%U.o",
- format_dirname, e->data,
- format_basename, e->data);
- }
- else
- {
- my_system ("mkdir -p %U", format_dirname, e->data);
- r = add_argv (r, "%v.o", e->data);
- }
- break;
-
- case OUTPUT_LA:
- if (is_punt)
- r = add_argv (r, "-o %v.la", e->data);
- else
- abort ();
- break;
-
- case LT_LIB:
- if (is_punt)
- r = add_argv (r, "%v.la", e->data);
-
- else if (lm->mode == MODE_link)
- {
- u8 * pwd = get_current_dir_name ();
- u8 * libdir = my_cmd (". %s/%v.la && echo -n ${libdir}", pwd, e->data);
-
- if (! hash_get_mem (lm->rpath_hash, libdir))
- {
- r = add_argv (r, "-Wl,-rpath");
- r = add_argv (r, "-Wl,%v", libdir);
- hash_set_mem (lm->rpath_hash, libdir, 0);
- }
-
- r = add_argv (r, "%U/.libs/%U.so",
- format_dirname, e->data,
- format_basename, e->data);
- }
- else
- r = add_argv (r, "%v.la", e->data);
- break;
-
- case NON_LT_LIB:
- if (lm->mode == MODE_link && ! is_punt)
- {
- lt_lib_path_t * p = search_lib_path (lm, "lib%v.so", e->data);
- if (p)
- {
- path_used_bitmap = clib_bitmap_ori (path_used_bitmap, p - lm->lib_path);
- r = add_argv (r, "%s/lib%v.so", p->path, e->data);
- }
- else
- r = add_argv (r, "-l%v", e->data);
- }
-
- else
- r = add_argv (r, "-l%v", e->data);
- break;
-
- default:
- ASSERT (0);
- }
- }
-
- {
- uword i;
- clib_bitmap_foreach (i, path_used_bitmap, ({
- lt_lib_path_t * p = vec_elt_at_index (lm->lib_path, i);
- r = add_argv (r, "-Wl,-rpath");
- r = add_argv (r, "-Wl,%s", p->path);
- }));
- clib_bitmap_free (path_used_bitmap);
- }
-
- vec_add1 (r, 0);
-
- return r;
-}
-
-static void do_command (lt_main_t * lm, u8 ** argv)
-{
- u8 * cmd = format (0, "%U%c", format_argv, argv, 0);
-
- if (! lm->silent)
- fformat (stderr, "lt: %s\n", cmd);
-
- if (system ((char *) cmd))
- exit (1);
-
- vec_free (cmd);
-}
-
-static int lt_main (unformat_input_t * input)
-{
- lt_main_t _lm = {0}, * lm = &_lm;
- clib_error_t * error = 0;
- u8 * s;
-
- lm->rpath_hash = hash_create_vec (0, sizeof (u8), sizeof (uword));
- while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
- {
- s = 0;
-
- if (s)
- _vec_len (s) = 0;
-
- if (unformat (input, "-o %s", &s))
- {
- u8 * dot = vec_end (s) - 4;
- int is_la = 0, is_lo = 0;
-
- is_lo = vec_len (s) >= 4 && ! strcmp ((char *) dot, ".lo");
- is_la = vec_len (s) >= 4 && ! strcmp ((char *) dot, ".la");
- if (is_lo || is_la)
- {
- dot[0] = 0;
- lm->output_edit_type = is_lo ? OUTPUT_LO : OUTPUT_LA;
- }
- else
- lm->output_edit_type = OUTPUT_EXE;
- edit (lm, lm->output_edit_type, "%s", s);
- lm->output_file = format (0, "%s", s);
- }
-
- else if (unformat (input, "-L%s", &s))
- {
- lt_lib_path_t * p;
- vec_add2 (lm->lib_path, p, 1);
- p->path = s;
- edit (lm, LITERAL, "-L%s", s);
- }
-
- else if (unformat (input, "%U", unformat_basename, &s, ".la"))
- edit (lm, LT_LIB, "%v", s);
-
- else if (unformat (input, "-l%s", &s))
- edit (lm, NON_LT_LIB, "%s", s);
-
- else if (unformat (input, "--mode=%U", unformat_libtool_mode, &lm->mode))
- ;
-
- else if (unformat (input, "--tag=%s", &lm->tag))
- ;
-
- else if (unformat (input, "-static"))
- {
- lm->link_static = 1;
- edit (lm, LITERAL, "%s", "-static");
- }
-
- else if (unformat (input, "%s", &s))
- edit (lm, LITERAL, "%s", s);
-
- else
- {
- error = clib_error_create ("parse error `%U'",
- format_unformat_error, input);
- goto done;
- }
- }
-
- {
- u8 ** argv;
-
- if (! (lm->mode == MODE_compile
- || (lm->mode == MODE_link && lm->output_edit_type == OUTPUT_EXE && ! lm->link_static)))
- {
- argv = gen_argv (lm, GEN_ARGV_PUNT);
- do_command (lm, argv);
- }
- else if (lm->mode == MODE_compile)
- {
- argv = gen_argv (lm, GEN_ARGV_PIC);
- do_command (lm, argv);
- argv = gen_argv (lm, 0);
- do_command (lm, argv);
- }
- else
- {
- argv = gen_argv (lm, 0);
- do_command (lm, argv);
- }
-
- if (lm->mode == MODE_compile)
- {
- u8 * s = 0;
- u8 * f = lm->output_file;
-
- /* Need this or .lo files are rejected. */
- s = format (s, "# Generated by libtool (Eliot lt 0.0)\n");
-
- s = format (s, "pic_object='.libs/%U.o'\n", format_basename, f);
- s = format (s, "non_pic_object='%U.o'\n", format_basename, f);
- make_file_with_contents (lm, s, "%v.lo", f);
- vec_free (s);
- }
- else if (lm->mode == MODE_link)
- {
- u8 * s = 0;
- u8 * f = lm->output_file;
- s = format (s, "%s",
- "# Generated by libtool (Eliot lt) 2.4\n"
- "# %%%MAGIC variable%%%\n"
- "generated_by_libtool_version=2.4\n");
- make_file_with_contents (lm, s, "%v", f);
- vec_free (s);
- }
-
- {
- int status;
- while (1)
- {
- if (waitpid (-1, &status, 0) < 0 && errno == ECHILD)
- break;
- }
- exit (0);
- }
- }
-
- done:
- if (s)
- vec_free (s);
- if (error)
- {
- clib_error_report (error);
- return 1;
- }
- return 0;
-}
-
-int main (int argc, char * argv[])
-{
- unformat_input_t i;
-
- unformat_init_command_line (&i, argv);
- exit (lt_main (&i));
- return 0;
-}
diff --git a/vppversion/sign.c b/vppversion/sign.c
deleted file mode 100644
index ed97894b5f5..00000000000
--- a/vppversion/sign.c
+++ /dev/null
@@ -1,178 +0,0 @@
-/*
- *------------------------------------------------------------------
- * sign.c - sign a binary
- *
- * Jan 2010, George Spelvin
- *
- * Copyright (c) 2010 Cisco and/or its affiliates.
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at:
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *------------------------------------------------------------------
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <sys/types.h>
-#include <sys/mman.h>
-#include <sys/stat.h>
-#include <netinet/in.h>
-#include <signal.h>
-#include <pthread.h>
-#include <unistd.h>
-#include <time.h>
-#include <fcntl.h>
-#include <string.h>
-#include <vppinfra/clib.h>
-#include <vppinfra/vec.h>
-#include <vppinfra/hash.h>
-#include <vppinfra/bitmap.h>
-#include <vppinfra/fifo.h>
-#include <vppinfra/time.h>
-#include <vppinfra/mheap.h>
-#include <vppinfra/heap.h>
-#include <vppinfra/pool.h>
-#include <vppinfra/format.h>
-#include <vppinfra/error.h>
-#include <vppinfra/unix.h>
-
-/* Elf-file magic number */
-static unsigned char elfmag[4] = {0x7F, 'E', 'L', 'F'};
-
-int add_signature (char *file, u8 *sigfile)
-{
- clib_error_t *e;
- u8 *sigcontents;
- uword siglen;
- struct stat statb;
- int fd;
- char magic[4];
- int i;
-
- if ((e = unix_file_contents ((char *)sigfile, &sigcontents))) {
- fformat(stderr, "%v", e->what);
- clib_error_free (e);
- return 1;
- }
-
- siglen = vec_len (sigcontents);
-
- vec_add1(sigcontents, (siglen>>24)&0xff);
- vec_add1(sigcontents, (siglen>>16)&0xff);
- vec_add1(sigcontents, (siglen>> 8)&0xff);
- vec_add1(sigcontents, (siglen>> 0)&0xff);
-
- /* remember the desired file mode */
- if (stat(file, &statb) < 0) {
- fformat(stderr, "Couldn't stat %s\n", file);
- return 1;
- }
- /* Skip empty / short trout. Don't complain */
- if (statb.st_size < 4) {
- return 0;
- }
-
- /* make it writeable */
- chmod (file, 0777);
-
- fd = open (file, O_RDWR | O_APPEND, 0755);
-
- if (fd < 0) {
- fformat (stderr, "Couldn't append to %s\n", file);
- return 1;
- }
-
- /*
- * We feed this program a list of files with execute permission.
- * Signing a shell script makes it taste bad, etc. etc.
- */
- if (read(fd, magic, 4) != 4) {
- fformat (stderr, "Couldn't read magic number from %s\n", file);
- }
-
- for (i = 0; i < 4; i++) {
- if (magic[i] != elfmag[i]) {
- goto skip_write;
- }
- }
-
- if (write (fd, sigcontents, vec_len(sigcontents))
- != vec_len (sigcontents)) {
- fformat (stderr, "Write error on %s\n", file);
- return 1;
- }
-
- skip_write:
- close(fd);
-
- /* restore the file mode */
- chmod (file, statb.st_mode);
-
- return 0;
-}
-
-int mypid;
-
-int sign_one_file (char *pemfile, char *password, char *file)
-{
- u8 *cmd;
- u8 *t1, *t2;
-
- t1 = format (0, "/tmp/sha256-%d%c", mypid, 0);
- t2 = format (0, "/tmp/sig-%d%c", mypid, 0);
-
- cmd = format (0, "openssl dgst -sha256 < %s > %s%c", file, t1, 0);
- if (system((char *)cmd)) {
- barf:
- clib_warning("'%s' failed", cmd);
- return 1;
- }
- vec_free(cmd);
-
- cmd = format (0, "openssl rsautl -inkey %s -in %s -out %s ",
- pemfile, t1, t2);
- cmd = format (cmd, "-passin pass:%s -sign%c", password, 0);
-
- if (system((char *)cmd))
- goto barf;
-
- vec_free(cmd);
-
- if (add_signature (file, t2))
- return 1;
-
- unlink ((char *)t1);
- unlink ((char *)t2);
-
- return (0);
-}
-
-/* usage: sign <foo.pem> <password> <list-of-files> */
-
-int main (int argc, char **argv)
-{
- int i;
- mypid = getpid();
-
- if (argc < 4) {
- fformat(stderr, "usage: %s <xxx.pem> <password> <list-of-files>\n",
- argv[0]);
- exit (1);
- }
-
- for (i = 3; i < argc; i++) {
- if (sign_one_file (argv[1], argv[2], argv[i])) {
- fformat(stderr, "Left unsigned: %s\n", argv[i]);
- }
- }
-
- exit (0);
-}
diff --git a/vppversion/vlib_version.c b/vppversion/vlib_version.c
deleted file mode 100644
index 53e65038d9a..00000000000
--- a/vppversion/vlib_version.c
+++ /dev/null
@@ -1,206 +0,0 @@
-/*
- *------------------------------------------------------------------
- * vlib_version.c - generate a vlib version stamp
- *
- * Copyright (c) 2013 Cisco and/or its affiliates.
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at:
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *------------------------------------------------------------------
- */
-
-#include <stdlib.h>
-#include <stdio.h>
-#include <time.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <pwd.h>
-#include <vppinfra/clib.h>
-#include <vppinfra/vec.h>
-#include <vppinfra/hash.h>
-#include <vppinfra/bitmap.h>
-#include <vppinfra/fifo.h>
-#include <vppinfra/time.h>
-#include <vppinfra/mheap.h>
-#include <vppinfra/heap.h>
-#include <vppinfra/pool.h>
-#include <vppinfra/format.h>
-#include <vppinfra/error.h>
-#include <vppinfra/unix.h>
-
-typedef struct {
- u8 * program;
- u8 * output_filename;
- u8 * git_branch;
- int ofd;
-} version_main_t;
-
-version_main_t version_main;
-
-static char * fmt =
-"#include <vlib/vlib.h>"
-"\n"
-"static char * %s_version_string = \n\"%s\";\n"
-"static char * %s_dir_string = \n\"%s\";\n"
-"static char * %s_git_branch = \n\"%s\";\n"
-"\n"
-"static clib_error_t *\n"
-"show_%s_version_command_fn (vlib_main_t * vm,\n"
-" unformat_input_t * input,\n"
-" vlib_cli_command_t * cmd)\n"
-"{\n"
-" vlib_cli_output (vm, \"%%s\", %s_version_string);\n"
-" if (unformat (input, \"verbose\")){\n"
-" vlib_cli_output (vm, \"%%s\", %s_dir_string);\n"
-" vlib_cli_output (vm, \"%%s\", %s_git_branch);\n"
-" }\n"
-" return 0;\n"
-"}\n"
-"\n"
-"VLIB_CLI_COMMAND (show_%s_version_command, static) = {\n"
-" .path = \"show version %s\",\n"
-" .short_help = \"show version information for %s\",\n"
-" .function = show_%s_version_command_fn,\n"
-"};\n\n";
-
-static char *api_fmt =
-"char * %s_api_get_build_directory (void) \n{\n return \"%s\";\n}\n\n"
-"char * %s_api_get_branch (void) \n{\n return \"%s\";\n}\n"
-"char * %s_api_get_build_date (void) \n{\n return \"%s\";\n}";
-
-clib_error_t *
-write_version_file (version_main_t *vm)
-{
- u8 * pgm, * api_fns;
- u8 * vs;
- u8 * ts;
- u8 * ds;
- u8 * gb;
- u8 * hostname = 0;
- u8 * pathname = 0;
- struct passwd *passwd_file_entry;
- time_t now = time (0);
- clib_error_t * error = 0;
-
- /* kill the newline */
- ts = format (0, "%s", ctime (&now));
- ts[vec_len(ts)-1] = 0;
-
- vec_validate (hostname, 128);
-
- gethostname (hostname, vec_len (hostname)-1);
- hostname[128] = 0; /* jic */
-
- vec_validate (pathname, 256);
- { char *rv __attribute__((unused)) =
- getcwd ((char *)pathname, vec_len(pathname) - 1);
- }
-
- passwd_file_entry = getpwuid(geteuid());
-
- vs = format (0, "%s built by %s on %s at %s%c",
- vm->program, passwd_file_entry->pw_name, hostname, ts, 0);
-
- ds = format (0, "in %s%c", pathname, 0);
-
- gb = format (0, "from git uber-branch %s%c", vm->git_branch, 0);
-
- pgm = format (0, fmt,
- vm->program, vs,
- vm->program, ds,
- vm->program, gb,
- vm->program,
- vm->program,
- vm->program,
- vm->program,
- vm->program,
- vm->program,
- vm->program,
- vm->program);
-
- if (write (vm->ofd, pgm, vec_len (pgm)) != vec_len (pgm))
- error = clib_error_return_unix (0, "write error on %s",
- vm->output_filename);
-
- api_fns = format (0, api_fmt,
- vm->program, pathname,
- vm->program, vm->git_branch,
- vm->program, ts);
-
- if (write (vm->ofd, api_fns, vec_len (api_fns)) != vec_len (api_fns))
- error = clib_error_return_unix (0, "write error on %s",
- vm->output_filename);
-
- return error;
-
-}
-
-clib_error_t * version_main_fn (unformat_input_t * input)
-{
- version_main_t * vm = &version_main;
- u8 * fn, * pn, * bn;
- clib_error_t * error;
-
- vm->output_filename = format (0, "version.c");
- vm->program = "unknown";
- vm->git_branch = "unknown";
- while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
- {
- if (unformat (input, "output-filename %s", &fn)
- || unformat (input, "-o %s", &fn))
- vm->output_filename = fn;
- else if (unformat (input, "program-name %s", &pn)
- || unformat (input, "-p %s", &pn))
- {
- vm->program = pn;
- vec_add1 (vm->program, 0);
- }
- else if (unformat (input, "git-branch %s", &bn)
- || unformat (input, "-b %s", &bn))
- {
- vm->git_branch = bn;
- vec_add1 (vm->git_branch, 0);
- }
- else
- return clib_error_return (0, "unknown args '%U'",
- format_unformat_error, input);
- }
- vec_add1 (vm->output_filename, 0);
-
- vm->ofd = creat (vm->output_filename, 0666);
- if (vm->ofd < 0)
- return clib_error_return_unix (0, "couldn't create '%s'",
- vm->output_filename);
-
- error = write_version_file (vm);
- close (vm->ofd);
- return error;
-}
-
-
-int main (int argc, char **argv)
-{
- unformat_input_t _input, *input = &_input;
- clib_error_t * error;
-
- unformat_init_command_line (input, argv);
- error = version_main_fn (input);
- unformat_free (input);
-
- if (error)
- {
- clib_error_report (error);
- exit (1);
- }
- exit (0);
-}
-