X-Git-Url: https://gerrit.automotivelinux.org/gerrit/gitweb?a=blobdiff_plain;f=src%2Fwgtpkg-pack.c;h=5a81d7e224fcf0814a4a60c68a6ac30dc58a7101;hb=d0cb2a7a1e068a38b4a0c3216ccdbce0e33ecffb;hp=d49680d4f8616d7a963cc0f9a99c32879352fc83;hpb=3a6e947bef1b2942e24d2fdee1a76dbf3305b508;p=src%2Fapp-framework-main.git diff --git a/src/wgtpkg-pack.c b/src/wgtpkg-pack.c index d49680d..5a81d7e 100644 --- a/src/wgtpkg-pack.c +++ b/src/wgtpkg-pack.c @@ -1,5 +1,5 @@ /* - Copyright 2015, 2016, 2017 IoT.bzh + Copyright (C) 2015-2018 IoT.bzh author: José Bollo @@ -34,6 +34,20 @@ const char appname[] = "wgtpkg-pack"; +static void version() +{ + printf( + "\n" + " %s version="AFM_VERSION"\n" + "\n" + " Copyright (C) 2015, 2016, 2017 \"IoT.bzh\"\n" + " AFB comes with ABSOLUTELY NO WARRANTY.\n" + " Licence Apache 2\n" + "\n", + appname + ); +} + static void usage() { printf( @@ -43,6 +57,7 @@ static void usage() " -f force overwriting\n" " -q quiet\n" " -v verbose\n" + " -V version\n" "\n", appname ); @@ -54,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 } }; @@ -69,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) { @@ -89,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; @@ -142,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;