summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Makefile.am10
-rw-r--r--wgtpkg-digsig.c2
-rw-r--r--wgtpkg-install.c4
-rw-r--r--wgtpkg-pack.c15
-rw-r--r--wgtpkg-sign.c6
-rw-r--r--wgtpkg-verbose.c36
-rw-r--r--wgtpkg.h9
7 files changed, 76 insertions, 6 deletions
diff --git a/Makefile.am b/Makefile.am
index a0fe372..02a724c 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -1,6 +1,14 @@
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
diff --git a/wgtpkg-digsig.c b/wgtpkg-digsig.c
index 26ee824..273c902 100644
--- a/wgtpkg-digsig.c
+++ b/wgtpkg-digsig.c
@@ -271,7 +271,7 @@ int verify_digsig(struct filedesc *fdesc)
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();
diff --git a/wgtpkg-install.c b/wgtpkg-install.c
index 7781c62..7a88ebf 100644
--- a/wgtpkg-install.c
+++ b/wgtpkg-install.c
@@ -29,7 +29,7 @@
/* 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;
@@ -56,6 +56,8 @@ int main(int ac, char **av)
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) {
diff --git a/wgtpkg-pack.c b/wgtpkg-pack.c
index 9164447..a8aaa05 100644
--- a/wgtpkg-pack.c
+++ b/wgtpkg-pack.c
@@ -47,6 +47,8 @@ static void usage()
"\n"
" -o wgtfile the output widget file\n"
" -f force overwriting\n"
+ " -q quiet\n"
+ " -v verbose\n"
"\n",
appname
);
@@ -56,6 +58,8 @@ static struct option options[] = {
{ "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 }
};
@@ -71,13 +75,20 @@ int main(int ac, char **av)
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;
@@ -124,7 +135,7 @@ int main(int ac, char **av)
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);
diff --git a/wgtpkg-sign.c b/wgtpkg-sign.c
index 6a6a72a..cd506fc 100644
--- a/wgtpkg-sign.c
+++ b/wgtpkg-sign.c
@@ -63,6 +63,8 @@ static void usage()
" -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
);
@@ -75,6 +77,8 @@ static struct option options[] = {
{ "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 }
};
@@ -187,7 +191,7 @@ int main(int ac, char **av)
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);
diff --git a/wgtpkg-verbose.c b/wgtpkg-verbose.c
new file mode 100644
index 0000000..1472a90
--- /dev/null
+++ b/wgtpkg-verbose.c
@@ -0,0 +1,36 @@
+/*
+ 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;
+}
+
+
diff --git a/wgtpkg.h b/wgtpkg.h
index 5a2fcbf..d35b7f4 100644
--- a/wgtpkg.h
+++ b/wgtpkg.h
@@ -89,6 +89,15 @@ extern int file_set_prop(struct filedesc *file, const char *name, const char *va
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 */
extern int enter_workdir(int clean);