[cowdancer] 03/03: parameter.c: Allow commands to come later, but give deprecation warning

James Clarke jrtc27 at moszumanska.debian.org
Tue Jan 31 17:00:21 UTC 2017


This is an automated email from the git hooks/post-receive script.

jrtc27 pushed a commit to branch master
in repository cowdancer.

commit 86493b05640cc2dd1dde303f69805b293ae5b432
Author: James Clarke <jrtc27 at debian.org>
Date:   Tue Jan 31 16:50:48 2017 +0000

    parameter.c: Allow commands to come later, but give deprecation warning
    
    Closes: #852434
---
 parameter.c | 83 +++++++++++++++++++++++++++++++++++++++++++++++++++++--------
 1 file changed, 73 insertions(+), 10 deletions(-)

diff --git a/parameter.c b/parameter.c
index 8483bb7..c2b803a 100644
--- a/parameter.c
+++ b/parameter.c
@@ -401,6 +401,14 @@ int parse_parameter(int ac, char **av, const char *keyword) {
 		{"debootstrapopts", required_argument, 0, 0},
 		{"debootstrap", required_argument, 0, 0},
 
+		/* Deprecated command placement; should be given first */
+		{"build", no_argument, 0, 0},
+		{"create", no_argument, 0, 0},
+		{"update", no_argument, 0, 0},
+		{"login", no_argument, 0, 0},
+		{"execute", no_argument, 0, 0},
+		{"dumpconfig", no_argument, 0, 0},
+
 		/* cowbuilder specific options */
 		{"no-cowdancer-update", no_argument, 0, 0},
 		{"debian-etch-workaround", no_argument, 0, 0},
@@ -480,19 +488,13 @@ int parse_parameter(int ac, char **av, const char *keyword) {
 			}
 		}
 
-		if (pc.operation == pbuilder_do_nothing) {
-			log_printf(log_error, "Unknown operation: %s", av[1]);
-			return 1;
+		if (pc.operation != pbuilder_do_nothing) {
+			--ac;
+			av[1] = av[0];
+			++av;
 		}
-	} else {
-		log_printf(log_error, "No operation specified");
-		return 1;
 	}
 
-	--ac;
-	av[1] = av[0];
-	++av;
-
 #define PASS_TO_PBUILDER_WITH_PARAM \
 	PBUILDER_ADD_PARAM(cmdstr); \
 	PBUILDER_ADD_PARAM(strdup(optarg));
@@ -573,6 +575,63 @@ int parse_parameter(int ac, char **av, const char *keyword) {
 				 * behavior, so ignore it, for most of the time.
 				 */
 
+				/* Handle deprecated command placement */
+				if (!strcmp(long_options[index_point].name, "build")) {
+					pc.operation = pbuilder_build;
+					log_printf(
+						log_warn,
+						"Passing the command as an option is deprecated and will be removed in future.");
+					log_printf(
+						log_warn,
+						"Please give it as the first argument - cowbuilder build [options] .dsc-file");
+					break;
+				} else if (!strcmp(long_options[index_point].name, "create")) {
+					pc.operation = pbuilder_create;
+					log_printf(
+						log_warn,
+						"Passing the command as an option is deprecated and will be removed in future.");
+					log_printf(
+						log_warn,
+						"Please give it as the first argument - cowbuilder create [options]");
+					break;
+				} else if (!strcmp(long_options[index_point].name, "update")) {
+					pc.operation = pbuilder_update;
+					log_printf(
+						log_warn,
+						"Passing the command as an option is deprecated and will be removed in future.");
+					log_printf(
+						log_warn,
+						"Please give it as the first argument - cowbuilder update [options]");
+					break;
+				} else if (!strcmp(long_options[index_point].name, "login")) {
+					pc.operation = pbuilder_login;
+					log_printf(
+						log_warn,
+						"Passing the command as an option is deprecated and will be removed in future.");
+					log_printf(
+						log_warn,
+						"Please give it as the first argument - cowbuilder login [options]");
+					break;
+				} else if (!strcmp(long_options[index_point].name, "execute")) {
+					pc.operation = pbuilder_execute;
+					log_printf(
+						log_warn,
+						"Passing the command as an option is deprecated and will be removed in future.");
+					log_printf(
+						log_warn,
+						"Please give it as the first argument - cowbuilder execute [options] -- script [script options]");
+					break;
+				} else if (!strcmp(long_options[index_point].name, "dumpconfig")) {
+					pc.operation = pbuilder_dumpconfig;
+					log_printf(
+						log_warn,
+						"Passing the command as an option is deprecated and will be removed in future.");
+					log_printf(
+						log_warn,
+						"Please give it as the first argument - cowbuilder dumpconfig [options]");
+					break;
+				}
+
 				/* handle specific options which also give 0. */
 
 				/* first, generate 'cmdstr' which is useful anyway */
@@ -835,6 +894,10 @@ int parse_parameter(int ac, char **av, const char *keyword) {
 		case pbuilder_dumpconfig:
 			return cpbuilder_dumpconfig(&pc);
 
+		case pbuilder_do_nothing:
+			log_printf(log_error, "No operation specified");
+			return 1;
+
 		default:
 			log_printf(log_error,
 					   "Internal error: Unknown operation (%d)",

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pbuilder/cowdancer.git



More information about the Pbuilder-maint mailing list