[cowdancer] 04/04: qemubuilder: Allow custom debootstrap and options

James Clarke jrtc27 at moszumanska.debian.org
Sat Jan 14 01:14:12 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 2231e96765cae5864e75c3d0ed755e95db63c708
Author: James Clarke <jrtc27 at jrtc27.com>
Date:   Sat Jan 14 01:06:53 2017 +0000

    qemubuilder: Allow custom debootstrap and options
    
    Closes: #851226
---
 parameter.c   | 39 +++++++++++++++++++++++++++++++++++++--
 parameter.h   | 32 ++++++++++++++++++++++++++++++++
 qemubuilder.c | 17 +++++++++--------
 3 files changed, 78 insertions(+), 10 deletions(-)

diff --git a/parameter.c b/parameter.c
index 368f69d..4b408d3 100644
--- a/parameter.c
+++ b/parameter.c
@@ -44,6 +44,23 @@ PBUILDER_ADD_PARAM(NULL);
 char* pbuildercommandline[MAXPBUILDERCOMMANDLINE];
 int offset=2;
 
+/*
+
+The debootstrap command-line to pass
+Only used by qemubuilder
+
+0: debootstrap
+1: --arch
+2: <architecture>
+3: --foreign
+debootstrap_param_offset: the next command
+
+The last-command will be
+DEBOOTSTRAP_ADD_PARAM(NULL);
+
+ */
+char* debootstrap_command_line[MAX_DEBOOTSTRAP_COMMAND_LINE];
+int debootstrap_param_offset = 4;
 
 /*
    get size of Null Terminated array of strings
@@ -404,6 +421,8 @@ int parse_parameter(int ac, char** av,
     {"architecture", required_argument, 0, 0},
     {"http-proxy", required_argument, 0, 0},
     {"allow-untrusted", no_argument, 0, 0},
+    {"debootstrapopts", required_argument, 0, 0},
+    {"debootstrap", required_argument, 0, 0},
 
     /* cowbuilder specific options */
     {"no-cowdancer-update", no_argument, 0, 0},
@@ -420,8 +439,6 @@ int parse_parameter(int ac, char** av,
     {"keyring", required_argument, 0, 'M'},
     {"timeout", required_argument, 0, 'M'},
     {"bindmounts", required_argument, 0, 'M'},
-    {"debootstrapopts", required_argument, 0, 'M'},
-    {"debootstrap", required_argument, 0, 'M'},
 
     /* verbatim options without argument, synced as of pbuilder 0.153 */
     {"removepackages", no_argument, 0, 'm'},
@@ -438,6 +455,7 @@ int parse_parameter(int ac, char** av,
   memset (&pc, 0, sizeof(pbuilderconfig));
   /* default command-line component */
   pbuildercommandline[0]="pbuilder";
+  debootstrap_command_line[0]=strdup("debootstrap");
 
   /**
    * Try to load all standard config files.
@@ -658,6 +676,23 @@ int parse_parameter(int ac, char** av,
 	      pc.allow_untrusted=1;
 	      PBUILDER_ADD_PARAM(cmdstr);
 	    }
+	  else if (!strcmp(long_options[index_point].name,"debootstrapopts"))
+	    {
+	      /* this is for qemubuilder */
+	      DEBOOTSTRAP_ADD_PARAM(strdup(optarg));
+
+	      /* pass it for cowbuilder */
+	      PASS_TO_PBUILDER_WITH_PARAM
+	    }
+	  else if (!strcmp(long_options[index_point].name,"debootstrap"))
+	    {
+	      /* this is for qemubuilder */
+	      free(debootstrap_command_line[0]);
+	      debootstrap_command_line[0]=strdup(optarg);
+
+	      /* pass it for cowbuilder */
+	      PASS_TO_PBUILDER_WITH_PARAM
+	    }
 	  break;
 	case 'h':		/* -h */
 	case 'v':		/* -v --version */
diff --git a/parameter.h b/parameter.h
index e36b2a1..fac1af0 100644
--- a/parameter.h
+++ b/parameter.h
@@ -115,5 +115,37 @@ PBUILDER_ADD_PARAM(NULL);
 extern char* pbuildercommandline[MAXPBUILDERCOMMANDLINE];
 extern int offset;
 
+/*
+
+The debootstrap command-line to pass
+Only used by qemubuilder
+
+0: debootstrap
+1: --arch
+2: <architecture>
+3: --foreign
+debootstrap_param_offset: the next command
+
+The last-command will be
+DEBOOTSTRAP_ADD_PARAM(NULL);
+
+ */
+#define MAX_DEBOOTSTRAP_COMMAND_LINE 256
+#define DEBOOTSTRAP_ADD_PARAM(a) \
+  do \
+    { \
+      if (debootstrap_param_offset < MAX_DEBOOTSTRAP_COMMAND_LINE-1) \
+	debootstrap_command_line[debootstrap_param_offset++] = a; \
+      else \
+	{ \
+	  debootstrap_command_line[debootstrap_param_offset] = NULL; \
+	  log_printf(log_error, "debootstrap_command_line: Max command-line length exceeded"); \
+	} \
+    } \
+  while (0)
+
+extern char* debootstrap_command_line[MAX_DEBOOTSTRAP_COMMAND_LINE];
+extern int debootstrap_param_offset;
+
 #endif
 
diff --git a/qemubuilder.c b/qemubuilder.c
index 54621f9..952f73e 100755
--- a/qemubuilder.c
+++ b/qemubuilder.c
@@ -1128,15 +1128,16 @@ int cpbuilder_create(const struct pbuilderconfig* pc)
       goto out;
     }
 
+  debootstrap_command_line[1] = "--arch";
+  debootstrap_command_line[2] = pc->arch;
+  debootstrap_command_line[3] = "--foreign";
+  DEBOOTSTRAP_ADD_PARAM(pc->distribution);
+  DEBOOTSTRAP_ADD_PARAM(pc->buildplace);
+  DEBOOTSTRAP_ADD_PARAM(pc->mirror);
+  DEBOOTSTRAP_ADD_PARAM(NULL);
+
   log_printf(log_info, "Invoking debootstrap");
-  ret=forkexeclp("debootstrap", "debootstrap",
-		 "--arch",
-		 pc->arch,
-		 "--foreign",
-		 pc->distribution,
-		 pc->buildplace,
-		 pc->mirror,
-		 NULL);
+  ret=forkexecvp(debootstrap_command_line);
   if (ret)
     {
       log_printf(log_error, "debootstrap failed with %i", ret);

-- 
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