From 87a19cc5e9e587171bacb811fe6879ae624ce523 Mon Sep 17 00:00:00 2001 From: Tomas Mlcoch Date: Mon, 27 Jan 2014 15:00:20 +0100 Subject: [PATCH] Add new cmd option --ignore-lock. --- src/cmd_parser.c | 41 +++++++++++++++++++++++++++++++++-------- src/cmd_parser.h | 4 ++++ 2 files changed, 37 insertions(+), 8 deletions(-) diff --git a/src/cmd_parser.c b/src/cmd_parser.c index d08d83b..867fc3a 100644 --- a/src/cmd_parser.c +++ b/src/cmd_parser.c @@ -29,16 +29,17 @@ #define DEFAULT_CHECKSUM "sha256" #define DEFAULT_WORKERS 5 #define DEFAULT_UNIQUE_MD_FILENAMES TRUE - +#define DEFAULT_IGNORE_LOCK FALSE struct CmdOptions _cmd_options = { - .changelog_limit = DEFAULT_CHANGELOG_LIMIT, - .checksum = NULL, - .workers = DEFAULT_WORKERS, - .unique_md_filenames = DEFAULT_UNIQUE_MD_FILENAMES, - .checksum_type = CR_CHECKSUM_SHA256, - .retain_old = 0, - .compression_type = CR_CW_UNKNOWN_COMPRESSION + .changelog_limit = DEFAULT_CHANGELOG_LIMIT, + .checksum = NULL, + .workers = DEFAULT_WORKERS, + .unique_md_filenames = DEFAULT_UNIQUE_MD_FILENAMES, + .checksum_type = CR_CHECKSUM_SHA256, + .retain_old = 0, + .compression_type = CR_CW_UNKNOWN_COMPRESSION, + .ignore_lock = DEFAULT_IGNORE_LOCK }; @@ -127,11 +128,27 @@ static GOptionEntry cmd_entries[] = }; +static GOptionEntry expert_entries[] = +{ + { "ignore-lock", 0, 0, G_OPTION_ARG_NONE, &(_cmd_options.ignore_lock), + "Expert (risky) option: Ignore an existing .repodata/. " + "(Remove the existing .repodata/ and create an empty new one " + "to serve as a lock for other createrepo intances. For the repodata " + "generation, a different temporary dir with the name in format " + "\".repodata.time.microseconds.pid/\" will be used). " + "NOTE: Use this option on your " + "own risk! If two createrepos run simultaneously, then the state of the " + "generated metadata is not guaranted - it can be inconsistent and wrong.", + NULL }, + { NULL, 0, 0, G_OPTION_ARG_NONE, NULL, NULL, NULL }, +}; + struct CmdOptions *parse_arguments(int *argc, char ***argv, GError **err) { gboolean ret; GOptionContext *context; + GOptionGroup *group_expert; assert(!err || *err == NULL); @@ -140,6 +157,14 @@ struct CmdOptions *parse_arguments(int *argc, char ***argv, GError **err) " rpms."); g_option_context_add_main_entries(context, cmd_entries, NULL); + group_expert = g_option_group_new("expert", + "Expert (risky) options", + "Expert (risky) options", + NULL, + NULL); + g_option_group_add_entries(group_expert, expert_entries); + g_option_context_add_group(context, group_expert); + ret = g_option_context_parse(context, argc, argv, err); g_option_context_free(context); diff --git a/src/cmd_parser.h b/src/cmd_parser.h index e03f742..aeb0e3e 100644 --- a/src/cmd_parser.h +++ b/src/cmd_parser.h @@ -68,6 +68,10 @@ struct CmdOptions { gboolean xz_compression; /*!< use xz for repodata compression */ gboolean keep_all_metadata; /*!< keep groupfile and updateinfo from source repo during update */ + gboolean ignore_lock; /*!< Ignore existing .repodata/ - remove it, + create the new one (empty) to serve as + a lock and use a .repodata.date.pid for + data generation. */ /* Items filled by check_arguments() */ -- 2.7.4