summaryrefslogtreecommitdiffstats
path: root/src/syrep.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/syrep.c')
-rw-r--r--src/syrep.c100
1 files changed, 95 insertions, 5 deletions
diff --git a/src/syrep.c b/src/syrep.c
index 534c62b..446c2c9 100644
--- a/src/syrep.c
+++ b/src/syrep.c
@@ -20,7 +20,6 @@
#include <stdint.h>
#include <limits.h>
-#include <db.h>
#include <assert.h>
#include <malloc.h>
#include <string.h>
@@ -33,6 +32,9 @@
#include <errno.h>
#include <signal.h>
+#include <db.h>
+#include <zlib.h>
+
#include "md5util.h"
#include "md5.h"
#include "context.h"
@@ -461,10 +463,94 @@ static void free_args(void) {
free(args.inputs);
}
-#include "package.h"
+
+static int help(const char *argv0) {
+
+ fprintf(stderr,
+ "%s -- Synchronize Repositories\n\n"
+
+ "Usage: %s [options] <command> [argument...]\n\n"
+
+ "General options:\n"
+ " -v --verbose Enable verbose operation\n"
+ " -T --local-temp Use temporary directory inside repository\n"
+ " --ignore-origin Don't warn if snapshot not local in update, merge, makepatch\n"
+ " -z --compress Compress snapshots or patches\n"
+ " -p --progress Show progress\n\n"
+
+ "General commands:\n"
+ " -h --help Print help and exit\n"
+ " -V --version Print version and exit\n\n"
+
+ "Specific commands:\n"
+ " --list List a repository snapshot\n"
+ " --show-deleted Show deleted entries of repository snapshot\n"
+ " --show-by-md Show files by message digests\n"
+ " --show-times Show first and last seen times\n\n"
+
+ " --info Show information about a repository or snapshot\n\n"
+
+ " --history Show history of a repository or snapshot\n\n"
+
+ " --dump Show a structure dump of a repository or snapshot\n\n"
+
+ " --update Update a repository snapshot\n"
+ " -SSTRING --snapshot=STRING Use the specified snapshot file instead of the one contained in the repository\n"
+ " -CSTRING --cache=STRING Use the specified cache file instead of the one contained in the repository\n"
+ " --no-cache Don't use a message digest cache\n"
+ " --no-purge Don't purge obsolete entries from cache after update run\n"
+ " --ro-cache Use read only cache\n\n"
+
+ " --diff Show difference between two repositories or snapshots\n\n"
+
+ " --merge Merge a snapshot or a patch into a repository\n"
+ " -q --question Ask a question before each action\n"
+ " --prune-empty Prune empty directories\n"
+ " --keep-trash Don't empty trash\n\n"
+
+ " --makepatch Make a patch against the specified repository\n"
+ " -oSTRING --output-file=STRING Write output to specified file instead of STDOUT\n"
+ " --include-all Include files in patch which do exist on the other side under a different name\n\n"
+
+ " --extract Extract the contents of a snapshot or patch\n"
+ " -DSTRING --output-directory=STRING Write output to specified directory\n\n"
+
+ " --cleanup Remove syrep info from repository\n"
+ " -lINT --cleanup-level=INT 1 - just remove temporary data and trash (default)\n"
+ " 2 - remove MD cache as well\n"
+ " 3 - remove all syrep data\n",
+ argv0, argv0);
+
+ return 0;
+}
+
+static int version(const char *argv0) {
+ int major, minor, patch;
+
+ db_version(&major, &minor, &patch);
+
+ fprintf(stderr,
+ "%s "PACKAGE_VERSION"\n"
+ "Compiled with %i Bit off_t.\n"
+ "Compiled with zlib %s, linked to zlib %s.\n"
+ "Compiled with libdb %i.%i.%i, linked to libdb %i.%i.%i\n",
+ argv0,
+ sizeof(off_t)*8,
+ ZLIB_VERSION, zlibVersion(),
+ DB_VERSION_MAJOR, DB_VERSION_MINOR, DB_VERSION_PATCH,
+ major, minor, patch);
+
+ return 0;
+}
int main(int argc, char *argv[]) {
struct sigaction sa;
+ char *bn;
+
+ if ((bn = strrchr(argv[0], '/')))
+ bn++;
+ else
+ bn = argv[0];
memset(&sa, 0, sizeof(sa));
sa.sa_handler = sigint;
@@ -472,8 +558,12 @@ int main(int argc, char *argv[]) {
cmdline_parser(argc, argv, &args);
atexit(free_args);
-
- if (args.list_flag)
+
+ if (args.help_given)
+ return help(bn);
+ else if (args.version_given)
+ return version(bn);
+ else if (args.list_flag)
return do_foreach(list, 0);
else if (args.info_flag)
return do_foreach(info, 0);
@@ -494,7 +584,7 @@ int main(int argc, char *argv[]) {
else if (args.cleanup_flag)
return do_cleanup();
- cmdline_parser_print_help();
+ help(bn);
return 1;
}