From ad9428741b9a8f91e68829433bd643eee101a665 Mon Sep 17 00:00:00 2001 From: José Bollo Date: Mon, 9 Nov 2015 21:58:30 +0100 Subject: initial commit MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: Ib882fe057690e03e2f5d32ee7e0c594697dd46c8 Signed-off-by: José Bollo --- wgtpkg-install.c | 82 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 82 insertions(+) create mode 100644 wgtpkg-install.c (limited to 'wgtpkg-install.c') diff --git a/wgtpkg-install.c b/wgtpkg-install.c new file mode 100644 index 0000000..7781c62 --- /dev/null +++ b/wgtpkg-install.c @@ -0,0 +1,82 @@ +/* + 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. +*/ + +#define _BSD_SOURCE /* see readdir */ + +#include +#include +#include +#include +#include +#include +#include + +#include "wgtpkg.h" + +/* install the widget of the file */ +static void install(const char *wgtfile) +{ +printf("\n\nINSTALLING widget %s\n", wgtfile); + + if (enter_workdir(1)) + goto error; + + if (zread(wgtfile, 0)) + goto error; + + if (check_all_signatures()) + goto error; + + return; + +error: + return; + exit(1); +} + +/* install the widgets of the list */ +int main(int ac, char **av) +{ + int i, kwd; + + openlog("wgtpkg-install", LOG_PERROR, LOG_AUTH); + + xmlsec_init(); + + /* canonic names for files */ + for (i = 1 ; av[i] != NULL ; i++) + if ((av[i] = realpath(av[i], NULL)) == NULL) { + syslog(LOG_ERR, "error while getting realpath of %dth argument", i); + return 1; + } + + /* workdir */ + kwd = 1; + if (make_workdir(kwd)) { + syslog(LOG_ERR, "failed to create a working directory"); + return 1; + } + if (!kwd) + atexit(remove_workdir); + + /* install widgets */ + for (av++ ; *av ; av++) + install(*av); + + exit(0); + return 0; +} + -- cgit 1.2.3-korg