From 28997ccd58d3a85eba38e0c57e325616f93cd577 Mon Sep 17 00:00:00 2001 From: Kelson Date: Sun, 25 Aug 2019 17:39:09 +0200 Subject: [PATCH 01/11] Bump-up version to 3.0.2 --- meson.build | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/meson.build b/meson.build index e280094..e5a7a37 100644 --- a/meson.build +++ b/meson.build @@ -1,5 +1,5 @@ project('kiwix-tools', 'cpp', - version : '3.0.1', + version : '3.0.2', license : 'GPL', default_options: ['c_std=c11', 'cpp_std=c++11', 'werror=true']) From 4b5eb482b5943e496bef7c9a66ebefcca05443b2 Mon Sep 17 00:00:00 2001 From: Kelson Date: Sun, 25 Aug 2019 17:43:41 +0200 Subject: [PATCH 02/11] New version() function --- include/version.h | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 include/version.h diff --git a/include/version.h b/include/version.h new file mode 100644 index 0000000..6555380 --- /dev/null +++ b/include/version.h @@ -0,0 +1,32 @@ +/* + * Copyright 2009-2016 Emmanuel Engelhart + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301, USA. + */ + +#ifndef _KIWIX_TOOL_VERSION_H_ +#define _KIWIX_TOOL_VERSION_H_ + +#ifndef VERSION + #define VERSION "undefined" +#endif + +void version() +{ + std::cout << VERSION << std::endl; +} + +#endif //_KIWIX_TOOL_VERSION_H_ From 612081ec51be83fb088974b3001a05757c5e8588 Mon Sep 17 00:00:00 2001 From: Kelson Date: Sun, 25 Aug 2019 17:46:00 +0200 Subject: [PATCH 03/11] Compile with Meson version #defined --- meson.build | 2 ++ 1 file changed, 2 insertions(+) diff --git a/meson.build b/meson.build index e5a7a37..54fcf18 100644 --- a/meson.build +++ b/meson.build @@ -5,6 +5,8 @@ project('kiwix-tools', 'cpp', compiler = meson.get_compiler('cpp') +add_global_arguments('-DVERSION="@0@"'.format(meson.project_version()), language : 'cpp') + static_linkage = get_option('static-linkage') if static_linkage add_global_link_arguments('-static-libstdc++', '--static', language:'cpp') From 48db92af0943f3a3133e61b642b4982727053ccb Mon Sep 17 00:00:00 2001 From: Kelson Date: Sun, 25 Aug 2019 17:48:16 +0200 Subject: [PATCH 04/11] Move version.h to src/ --- {include => src}/version.h | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {include => src}/version.h (100%) diff --git a/include/version.h b/src/version.h similarity index 100% rename from include/version.h rename to src/version.h From d17fd2af94e66fe191013009fa3c39e2e7e95dba Mon Sep 17 00:00:00 2001 From: Kelson Date: Sun, 25 Aug 2019 17:55:06 +0200 Subject: [PATCH 05/11] Add --version argument to kiwix-serve --- meson.build | 1 - src/server/kiwix-serve.cpp | 11 +++++++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/meson.build b/meson.build index 54fcf18..a706b72 100644 --- a/meson.build +++ b/meson.build @@ -26,5 +26,4 @@ if static_linkage endif endif -#subdir('include') subdir('src') diff --git a/src/server/kiwix-serve.cpp b/src/server/kiwix-serve.cpp index 267ad49..86c650e 100644 --- a/src/server/kiwix-serve.cpp +++ b/src/server/kiwix-serve.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2009-2016 Emmanuel Engelhart + * Copyright 2009-2019 Emmanuel Engelhart * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -33,6 +33,8 @@ # define MIBSIZE 4 #endif +#include "../version.h" + #define DEFAULT_THREADS 4 void usage() @@ -62,6 +64,7 @@ void usage() << "\t-r, --urlRootLocation\tURL prefix on which the content should be made available (default: /)" << std::endl << "\t-t, --threads\t\tnumber of threads to run in parallel (default: " << DEFAULT_THREADS << ")" << std::endl << "\t-v, --verbose\t\tprint debug log to STDOUT" << std::endl + << "\t-V, --version\t\tprint software version" << std::endl << "\t-z, --nodatealiases\tcreate URL aliases for each content by removing the date" << std::endl << std::endl @@ -93,6 +96,7 @@ int main(int argc, char** argv) static struct option long_options[] = {{"daemon", no_argument, 0, 'd'}, {"verbose", no_argument, 0, 'v'}, + {"version", no_argument, 0, 'V'}, {"library", no_argument, 0, 'l'}, {"nolibrarybutton", no_argument, 0, 'm'}, {"nodatealiases", no_argument, 0, 'z'}, @@ -108,7 +112,7 @@ int main(int argc, char** argv) while (true) { int option_index = 0; int c - = getopt_long(argc, argv, "mndvla:p:f:t:r:", long_options, &option_index); + = getopt_long(argc, argv, "mndvVla:p:f:t:r:", long_options, &option_index); if (c != -1) { switch (c) { @@ -118,6 +122,9 @@ int main(int argc, char** argv) case 'v': isVerboseFlag = true; break; + case 'V': + version(); + return 0; case 'l': libraryFlag = true; break; From 4eb38869c1074a8d61422f1b1777c32aa37dd755 Mon Sep 17 00:00:00 2001 From: Kelson Date: Sun, 25 Aug 2019 18:15:16 +0200 Subject: [PATCH 06/11] New --version argument to kiwix-manage --- src/manager/kiwix-manage.cpp | 31 +++++++++++++++++++++++++++---- 1 file changed, 27 insertions(+), 4 deletions(-) diff --git a/src/manager/kiwix-manage.cpp b/src/manager/kiwix-manage.cpp index e676151..5b0334b 100644 --- a/src/manager/kiwix-manage.cpp +++ b/src/manager/kiwix-manage.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2011 Emmanuel Engelhart + * Copyright 2011-2019 Emmanuel Engelhart * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -23,6 +23,8 @@ #include #include +#include "../version.h" + using namespace std; enum supportedAction { NONE, ADD, SHOW, REMOVE }; @@ -78,6 +80,9 @@ void usage() << "\t\t\t--zimPathToSave=CUSTOM_ZIM_PATH to replace the current ZIM file path" << std::endl << "\t\t\t--url=HTTP_ZIM_URL to create an \"url\" attribute for the online version of the ZIM file" << std::endl << std::endl + << "\t\t\tOther options:" << std::endl + << "\t\t\t-v, --version to print the software version" << std::endl + << std::endl << "Examples:" << std::endl << "\tAdd ZIM files to library: kiwix-manage my_library.xml add first.zim second.zim" << std::endl @@ -144,11 +149,9 @@ int handle_add(kiwix::Library* library, const std::string& libraryPath, case 'u': url = optarg; break; - case 'o': origID = optarg; break; - case 'z': zimPathToSave = optarg; break; @@ -217,7 +220,27 @@ int main(int argc, char** argv) supportedAction action = NONE; kiwix::Library library; - /* Argument parsing */ + /* General argument parsing */ + static struct option long_options[] = { + {"version", no_argument, 0, 'v'}, + {0, 0, 0, 0} + }; + + int option_index = 0; + int c; + while (true) { + c = getopt_long(argc, argv, "v", long_options, &option_index); + if (c == -1) + break; + + switch (c) { + case 'v': + version(); + return 0; + } + } + + /* Action related argument parsing */ if (argc > 2) { libraryPath = argv[1]; string actionString = argv[2]; From 4aca5ff551e61e05d3ee43ac762edd43abf0ad3e Mon Sep 17 00:00:00 2001 From: Kelson Date: Sun, 25 Aug 2019 18:17:34 +0200 Subject: [PATCH 07/11] Add --version option to kiwix-search --- src/searcher/kiwix-search.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/searcher/kiwix-search.cpp b/src/searcher/kiwix-search.cpp index 6f13136..99cc932 100644 --- a/src/searcher/kiwix-search.cpp +++ b/src/searcher/kiwix-search.cpp @@ -21,6 +21,7 @@ #include #include +#include "../version.h" void usage() { @@ -29,7 +30,8 @@ void usage() << " ZIM is the full path of the ZIM file." << endl << " PATTERN is/are word(s) - or part of - to search in the ZIM." << endl << endl << " -s, --suggestion\tSuggest article titles based on the few letters of the PATTERN instead of making a fulltext search. Work a bit like a completion solution." << endl - << " -v, --verbose\t\tGive details about the search process" << endl; + << " -v, --verbose\t\tGive details about the search process" << endl + << " -V, --version\t\tPrint software version" << endl; exit(1); } @@ -54,15 +56,19 @@ int main(int argc, char** argv) static struct option long_options[] = {{"verbose", no_argument, 0, 'v'}, {"suggestion", no_argument, 0, 's'}, + {"version", no_argument, 0, 'V'}, {0, 0, 0, 0}}; if (c != -1) { - c = getopt_long(argc, argv, "vsb:", long_options, &option_index); + c = getopt_long(argc, argv, "Vvsb:", long_options, &option_index); switch (c) { case 'v': verboseFlag = true; break; + case 'V': + version(); + return 0; case 's': suggestionFlag = true; break; From 93116c76b3e7c17b8d5cb7c7b79f3d06cb88afba Mon Sep 17 00:00:00 2001 From: Kelson Date: Sun, 25 Aug 2019 18:19:17 +0200 Subject: [PATCH 08/11] Add --version option to kiwix-read --- src/reader/kiwix-read.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/reader/kiwix-read.cpp b/src/reader/kiwix-read.cpp index af814f8..22822f5 100644 --- a/src/reader/kiwix-read.cpp +++ b/src/reader/kiwix-read.cpp @@ -22,9 +22,11 @@ #include #include +#include "../version.h" + void usage() { - cout << "Usage: kiwix-read --suggest= ZIM_FILE_PATH" << endl; + cout << "Usage: kiwix-read [--verbose] [--version] --suggest= ZIM_FILE_PATH" << endl; exit(1); } @@ -42,15 +44,19 @@ int main(int argc, char** argv) while (42) { static struct option long_options[] = {{"verbose", no_argument, 0, 'v'}, + {"version", no_argument, 0, 'V'}, {"suggest", required_argument, 0, 's'}, {0, 0, 0, 0}}; if (c != -1) { - c = getopt_long(argc, argv, "vs:", long_options, &option_index); + c = getopt_long(argc, argv, "Vvs:", long_options, &option_index); switch (c) { case 'v': break; + case 'V': + version(); + return 0; case 's': pattern = optarg; break; From 23b0ff3d01fe8b1375c1227c57efa2a8916baea2 Mon Sep 17 00:00:00 2001 From: Kelson Date: Sun, 25 Aug 2019 18:20:29 +0200 Subject: [PATCH 09/11] Update changelog --- Changelog | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Changelog b/Changelog index 53ec3a3..c560df5 100644 --- a/Changelog +++ b/Changelog @@ -1,3 +1,8 @@ +kiwix-tools 3.0.2 +================= + + * New option --version for all tools + kiwix-tools 3.0.1 ================= From c6757dd30924428fbe459899fb39c972a53c8c56 Mon Sep 17 00:00:00 2001 From: Kelson Date: Sun, 25 Aug 2019 18:27:22 +0200 Subject: [PATCH 10/11] Various README.md improvements --- README.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 25af853..ebcb481 100644 --- a/README.md +++ b/README.md @@ -121,7 +121,11 @@ If you want to uninstall the Kiwix tools: ninja -C build uninstall ``` +<<<<<<< HEAD Like for the installation, you might need to run the command as `root` +======= +Like for the installation, you might need to run the command as root +>>>>>>> Various README.md improvements (or using `sudo`). Docker @@ -161,4 +165,4 @@ License ------- [GPLv3](https://www.gnu.org/licenses/gpl-3.0) or later, see -[LICENSE](LICENSE) for more details. +[COPYING](COPYING) for more details. From ca943b9d0bf55380f990d193cd735b55b14f11f3 Mon Sep 17 00:00:00 2001 From: Kelson Date: Sun, 25 Aug 2019 18:30:11 +0200 Subject: [PATCH 11/11] Rename VERSION to KIWIX_TOOLS_VERSION to avoid collision --- README.md | 4 ---- meson.build | 2 +- src/version.h | 12 ++++++------ 3 files changed, 7 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index ebcb481..268ff35 100644 --- a/README.md +++ b/README.md @@ -121,11 +121,7 @@ If you want to uninstall the Kiwix tools: ninja -C build uninstall ``` -<<<<<<< HEAD Like for the installation, you might need to run the command as `root` -======= -Like for the installation, you might need to run the command as root ->>>>>>> Various README.md improvements (or using `sudo`). Docker diff --git a/meson.build b/meson.build index a706b72..0d2fe43 100644 --- a/meson.build +++ b/meson.build @@ -5,7 +5,7 @@ project('kiwix-tools', 'cpp', compiler = meson.get_compiler('cpp') -add_global_arguments('-DVERSION="@0@"'.format(meson.project_version()), language : 'cpp') +add_global_arguments('-DKIWIX_TOOLS_VERSION="@0@"'.format(meson.project_version()), language : 'cpp') static_linkage = get_option('static-linkage') if static_linkage diff --git a/src/version.h b/src/version.h index 6555380..0b556cf 100644 --- a/src/version.h +++ b/src/version.h @@ -17,16 +17,16 @@ * MA 02110-1301, USA. */ -#ifndef _KIWIX_TOOL_VERSION_H_ -#define _KIWIX_TOOL_VERSION_H_ +#ifndef _KIWIX_TOOLS_VERSION_H_ +#define _KIWIX_TOOLS_VERSION_H_ -#ifndef VERSION - #define VERSION "undefined" +#ifndef KIWIX_TOOLS_VERSION + #define KIWIX_TOOLS_VERSION "undefined" #endif void version() { - std::cout << VERSION << std::endl; + std::cout << KIWIX_TOOLS_VERSION << std::endl; } -#endif //_KIWIX_TOOL_VERSION_H_ +#endif //_KIWIX_TOOLs_VERSION_H_