bin_PROGRAMS = wgtpkg-install wgtpkg-pack wgtpkg-sign
-COMMONSRCS = wgtpkg-base64.c wgtpkg-certs.c wgtpkg-digsig.c wgtpkg-files.c wgtpkg-workdir.c wgtpkg-xmlsec.c wgtpkg-zip.c
+COMMONSRCS = \
+ wgtpkg-base64.c \
+ wgtpkg-certs.c \
+ wgtpkg-digsig.c \
+ wgtpkg-files.c \
+ wgtpkg-verbose.c \
+ wgtpkg-workdir.c \
+ wgtpkg-xmlsec.c \
+ wgtpkg-zip.c
AM_CFLAGS = -Wall -Wno-pointer-sign
AM_CFLAGS += -ffunction-sections -fdata-sections
int res;
assert ((fdesc->flags & flag_signature) != 0);
-printf("\n\nchecking file %s\n\n",fdesc->name);
+ notice("-- checking file %s",fdesc->name);
/* reset the flags */
file_clear_flags();
/* install the widget of the file */
static void install(const char *wgtfile)
{
-printf("\n\nINSTALLING widget %s\n", wgtfile);
+ notice("-- INSTALLING widget %s", wgtfile);
if (enter_workdir(1))
goto error;
xmlsec_init();
+ ac = verbose_scan_args(ac, av);
+
/* canonic names for files */
for (i = 1 ; av[i] != NULL ; i++)
if ((av[i] = realpath(av[i], NULL)) == NULL) {
"\n"
" -o wgtfile the output widget file\n"
" -f force overwriting\n"
+ " -q quiet\n"
+ " -v verbose\n"
"\n",
appname
);
{ "output", required_argument, NULL, 'o' },
{ "force", no_argument, NULL, 'f' },
{ "help", no_argument, NULL, 'h' },
+ { "quiet", no_argument, NULL, 'q' },
+ { "verbose", no_argument, NULL, 'v' },
{ NULL, 0, NULL, 0 }
};
force = 0;
wgtfile = directory = NULL;
for (;;) {
- i = getopt_long(ac, av, "hfo:", options, NULL);
+ i = getopt_long(ac, av, "qvhfo:", options, NULL);
if (i < 0)
break;
switch (i) {
case 'o':
wgtfile = optarg;
break;
+ case 'q':
+ if (verbosity)
+ verbosity--;
+ break;
+ case 'v':
+ verbosity++;
+ break;
case 'f':
force = 1;
break;
return 1;
}
-printf("\n\nPACKING widget %s from directory %s\n", wgtfile, directory);
+ notice("-- PACKING widget %s from directory %s", wgtfile, directory);
/* creates an existing widget (for realpath it must exist) */
i = open(wgtfile, O_WRONLY|O_CREAT|O_NOCTTY|O_NONBLOCK, 0666);
" -d number the number of the distributor signature (zero for automatic)\n"
" -a the author signature\n"
" -f force overwriting\n"
+ " -q quiet\n"
+ " -v verbose\n"
"\n",
appname
);
{ "author", no_argument, NULL, 'a' },
{ "force", no_argument, NULL, 'f' },
{ "help", no_argument, NULL, 'h' },
+ { "quiet", no_argument, NULL, 'q' },
+ { "verbose", no_argument, NULL, 'v' },
{ NULL, 0, NULL, 0 }
};
return 1;
}
-printf("\n\nSIGNING content of directory %s for number %u\n", directory, number);
+ notice("-- SIGNING content of directory %s for number %u", directory, number);
certfiles[ncert] = NULL;
return !!create_digsig(number, keyfile, (const char**)certfiles);
--- /dev/null
+/*
+ Copyright 2015 IoT.bzh
+
+ 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>
+
+int verbosity = 1;
+
+int verbose_scan_args(int argc, char **argv)
+{
+ int i, r;
+ for (i=r=0 ; i < argc ; i++) {
+ if (!strcmp(argv[i], "-q"))
+ verbosity = verbosity ? verbosity-1 : 0;
+ else if (!strcmp(argv[i], "-v"))
+ verbosity++;
+ else
+ argv[r++] = argv[i];
+ }
+ argv[r] = NULL;
+ return r;
+}
+
+
extern int file_set_prop(struct filedesc *file, const char *name, const char *value);
extern const char *file_get_prop(struct filedesc *file, const char *name);
+/**************************************************************/
+/* from wgtpkg-verbose */
+extern int verbosity;
+#define warning(...) do{if(verbosity)syslog(LOG_WARNING,__VA_ARGS__);}while(0)
+#define notice(...) do{if(verbosity)syslog(LOG_NOTICE,__VA_ARGS__);}while(0)
+#define info(...) do{if(verbosity)syslog(LOG_INFO,__VA_ARGS__);}while(0)
+#define debug(...) do{if(verbosity>1)syslog(LOG_DEBUG,__VA_ARGS__);}while(0)
+extern int verbose_scan_args(int argc, char **argv);
+
/**************************************************************/
/* from wgtpkg-workdir */