X-Git-Url: https://gerrit.automotivelinux.org/gerrit/gitweb?a=blobdiff_plain;f=src%2Fwgtpkg-pack.c;h=53ab9dc73257d5d0fa1b4bdcabcfe4ae241b1ad6;hb=2a319cf90daa6e3b01e8139923f7073e1c9bcf28;hp=e7fa7526d71cec6c3ca444df0f90d4bd132f8a95;hpb=c0fc18e47e49dd4e3cc2f09452a19297dad63f9c;p=src%2Fapp-framework-main.git diff --git a/src/wgtpkg-pack.c b/src/wgtpkg-pack.c index e7fa752..53ab9dc 100644 --- a/src/wgtpkg-pack.c +++ b/src/wgtpkg-pack.c @@ -1,5 +1,5 @@ /* - Copyright 2015 IoT.bzh + Copyright (C) 2015-2019 IoT.bzh author: José Bollo @@ -28,20 +28,26 @@ #include #include "verbose.h" -#include "wgtpkg.h" - -#if !defined(MAXCERT) -#define MAXCERT 20 -#endif -#if !defined(DEFAULT_KEY_FILE) -#define DEFAULT_KEY_FILE "key.pem" -#endif -#if !defined(DEFAULT_CERT_FILE) -#define DEFAULT_CERT_FILE "cert.pem" -#endif +#include "wgtpkg-files.h" +#include "wgtpkg-workdir.h" +#include "wgtpkg-zip.h" const char appname[] = "wgtpkg-pack"; +static void version() +{ + printf( + "\n" + " %s version="AFM_VERSION"\n" + "\n" + " Copyright (C) 2015-2019 \"IoT.bzh\"\n" + " AFB comes with ABSOLUTELY NO WARRANTY.\n" + " Licence Apache 2\n" + "\n", + appname + ); +} + static void usage() { printf( @@ -51,6 +57,7 @@ static void usage() " -f force overwriting\n" " -q quiet\n" " -v verbose\n" + " -V version\n" "\n", appname ); @@ -62,6 +69,7 @@ static struct option options[] = { { "help", no_argument, NULL, 'h' }, { "quiet", no_argument, NULL, 'q' }, { "verbose", no_argument, NULL, 'v' }, + { "version", no_argument, NULL, 'V' }, { NULL, 0, NULL, 0 } }; @@ -77,7 +85,7 @@ int main(int ac, char **av) force = 0; wgtfile = directory = NULL; for (;;) { - i = getopt_long(ac, av, "qvhfo:", options, NULL); + i = getopt_long(ac, av, "qvVhfo:", options, NULL); if (i < 0) break; switch (i) { @@ -97,6 +105,9 @@ int main(int ac, char **av) case 'h': usage(); return 0; + case 'V': + version(); + return 0; case ':': ERROR("missing argument"); return 1; @@ -150,13 +161,17 @@ int main(int ac, char **av) /* compute absolutes paths */ x = realpath(wgtfile, NULL); if (x == NULL) { - ERROR("realpath failed for %s",wgtfile); + ERROR("realpath failed for %s", wgtfile); return 1; } wgtfile = x; /* set and enter the workdir */ - if (set_workdir(directory, 0)) + if (chdir(directory)) { + ERROR("failed to enter directory %s", directory); + return 1; + } + if (set_workdir(".", 0)) return 1;