summaryrefslogtreecommitdiffstats
path: root/vppversion
diff options
context:
space:
mode:
Diffstat (limited to 'vppversion')
-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
5 files changed, 4 insertions, 977 deletions
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);
-}
-