Package:qemubuilder
Version: 0.75
Severity: wishlist
Tags: patch

Dear Maintainer,

using qemubuilder for armel and armhf in an automated build environment
causes some extra work due to different qemu machine types. Using the
same kernel for both architectures like in all other cases is not
possible since a different qemu machine type is choosen. Add a
qemu machine type overwrite to be able to force the same machine type
for armel and armhf.

Tested in my build environment with machine type "virt" to build
armhf- and armel-Packages for wheezy, jessie, stretch and sid.

Regards
    Bene

-- System Information:
Debian Release: stretch/sid
  APT prefers unstable
  APT policy: (500, 'unstable')
Architecture: amd64 (x86_64)
Foreign Architectures: i386, armel, armhf

Kernel: Linux 4.2.0-1-amd64 (SMP w/8 CPU cores)
Locale: LANG=de_DE.UTF-8, LC_CTYPE=de_DE.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash
Init: sysvinit (via /sbin/init)

Versions of packages qemubuilder depends on:
ii  debootstrap     1.0.75
ii  libc6           2.19-22
ii  pbuilder        0.220
ii  qemu-kvm [kvm]  1:2.4+dfsg-4
ii  qemu-system     1:2.4+dfsg-4

qemubuilder recommends no packages.

qemubuilder suggests no packages.

-- no debconf information

>From 98f9ea42155f7711996b600edc8d8f7943bf86f5 Mon Sep 17 00:00:00 2001
From: Benedikt Spranger <b.spran...@linutronix.de>
Date: Thu, 12 Nov 2015 19:57:18 +0100
Subject: [PATCH] qemubuilder: Add qemu machine type overwrite.

qemubuilder determine the build architecture to select the qemu machine
type from a hardcoded list. This prohibits to build armel and armhf using
the same kernel. Add a qemu machine type overwrite.

Signed-off-by: Benedikt Spranger <b.spran...@linutronix.de>
---
 parameter.c   | 14 ++++++++++++++
 parameter.h   |  1 +
 qemuarch.c    |  7 ++++++-
 qemuarch.h    |  2 +-
 qemubuilder.c |  2 +-
 5 files changed, 23 insertions(+), 3 deletions(-)

diff --git a/parameter.c b/parameter.c
index 8c015a6..54abf4c 100644
--- a/parameter.c
+++ b/parameter.c
@@ -146,6 +146,14 @@ int load_config_file(const char* config, pbuilderconfig* pc)
 	    {
 	      pc->arch=strdup_strip_quote(delim);
 	    }
+	  else if (!strcmp(buf, "MACHINE"))
+	    {
+	      pc->mach=strdup_strip_quote(delim);
+	    }
+	  else if (!strcmp(buf, "MACH"))
+	    {
+	      pc->mach=strdup_strip_quote(delim);
+	    }
 	  else if (!strcmp(buf, "BASEPATH"))
 	    {
 	      pc->basepath=strdup_strip_quote(delim);
@@ -246,6 +254,7 @@ int cpbuilder_dumpconfig(pbuilderconfig* pc)
   DUMPSTR(initrd);
   DUMPINT(memory_megs);
   DUMPSTR(arch);
+  DUMPSTR(mach);
   return 0;
 }
 
@@ -291,6 +300,7 @@ int parse_parameter(int ac, char** av,
     {"inputfile", required_argument, 0, 0},
     {"outputfile", required_argument, 0, 0},
     {"architecture", required_argument, 0, 0},
+    {"machine", required_argument, 0, 0},
     {"http-proxy", required_argument, 0, 0},
 
     /* cowbuilder specific options */
@@ -448,6 +458,10 @@ int parse_parameter(int ac, char** av,
 	    {
 	      pc.arch=strdup(optarg);
 	    }
+	  else if (!strcmp(long_options[index_point].name,"machine"))
+	    {
+	      pc.mach=strdup(optarg);
+	    }
 	  else if (!strcmp(long_options[index_point].name,"arch-diskdevice"))
 	    {
 	      pc.arch_diskdevice=strdup(optarg);
diff --git a/parameter.h b/parameter.h
index 9ef23a7..d4eac52 100644
--- a/parameter.h
+++ b/parameter.h
@@ -57,6 +57,7 @@ typedef struct pbuilderconfig
   char* smp;
   int memory_megs;		/* megabytes of memory */
   char* arch;
+  char* mach;
   char* arch_diskdevice;
 
   enum {
diff --git a/qemuarch.c b/qemuarch.c
index 3fe7f11..5003144 100644
--- a/qemuarch.c
+++ b/qemuarch.c
@@ -160,8 +160,13 @@ const char* qemu_arch_qemu(const char* arch)
 /**
  * arch-specific routine; the machine spec for this arch
  */
-const char* qemu_arch_qemumachine(const char* arch)
+const char* qemu_arch_qemumachine(const struct pbuilderconfig* pc)
 {
+  const char *arch = pc->arch;
+
+  if (pc->mach)
+    return strdup(pc->mach);
+
   if (!strcmp(arch, "arm") ||
       !strcmp(arch, "armel"))
     return "versatilepb";
diff --git a/qemuarch.h b/qemuarch.h
index 12d989e..c374a6f 100644
--- a/qemuarch.h
+++ b/qemuarch.h
@@ -12,7 +12,7 @@ const int qemu_create_arch_serialdevice(const char* basedir, const char* arch);
 const int qemu_create_arch_devices(const char* basedir, const char* arch);
 char* get_host_dpkg_arch();
 const char* qemu_arch_qemu(const char* arch);
-const char* qemu_arch_qemumachine(const char* arch);
+const char* qemu_arch_qemumachine(const struct pbuilderconfig* pc);
 const char* qemu_arch_tty(const char* arch);
 
 #endif
diff --git a/qemubuilder.c b/qemubuilder.c
index 4436703..904ea4f 100755
--- a/qemubuilder.c
+++ b/qemubuilder.c
@@ -267,7 +267,7 @@ static int fork_qemu(const char* hda, const char* hdb, const struct pbuilderconf
     {
       /* this is the child process */
       const char* qemu = qemu_arch_qemu(pc->arch);
-      const char* machine = qemu_arch_qemumachine(pc->arch);
+      const char* machine = qemu_arch_qemumachine(pc);
       char* hda_command;
       char* hdb_command;
       char* append_command;
-- 
2.6.2

Reply via email to