Skip to contentSkip to conversation

Allow to override sync source

PATCH In review Jan Kiszka 3 participants 3 messages May 14, 2009 – May 18, 2009

Subsystems (2)
lore
Share & tools
lore

Jan Kiszka

author
#0 lore raw

PATCH 1/1 Allow to override sync source

In order to allow sync'ing the kmod dir against arbitrary kernels trees, extend the sync script to accept alternative paths and adjust the Makefile accordingly.

---

 Makefile |    3 ++-
 sync     |   14 +++++++++++---
 2 files changed, 13 insertions(+), 4 deletions(-)
Makefile +2 -1
index 1e0420e..dad5f0b 100644
@@ -17,6 +17,7 @@ ORIGMODDIR = $(patsubst %/build,%/kernel,$(KERNELDIR))
 
 rpmrelease = devel
 
+KVM_VERSION = kvm-devel
 LINUX = ./linux-2.6
 
 ifeq ($(EXT_CONFIG_KVM_TRACE),y)
@@ -38,7 +39,7 @@ include $(MAKEFILE_PRE)
 .PHONY: sync
 
 sync:
-	./sync $(KVM_VERSION)
+	./sync -v $(KVM_VERSION) -l $(LINUX)
 
 install:
 	mkdir -p $(DESTDIR)/$(INSTALLDIR)
sync +11 -3
index 4a89296..2e53a31 100755
@@ -1,6 +1,7 @@
 #!/usr/bin/python
 
 import sys, os, glob, os.path, shutil, re
+from optparse import OptionParser
 
 glob = glob.glob
 
@@ -8,12 +9,19 @@ def cmd(c):
     if os.system(c) != 0:
         raise Exception('command execution failed: ' + c)
 
-version = 'kvm-devel'
-if len(sys.argv) >= 2:
-    version = sys.argv[1]
+parser = OptionParser(usage='usage: %prog [-v version][-l linuxkernel]')
+parser.add_option('-v', action='store', type='string', dest='version')
+parser.add_option('-l', action='store', type='string', dest='linux')
+(options, args) = parser.parse_args()
 
+version = 'kvm-devel'
 linux = 'linux-2.6'
 
+if options.version:
+    version = options.version
+if options.linux:
+    linux = options.linux
+
 _re_cache = {}
 
 def re_cache(regexp):
#1 lore raw

Makefile ORIGMODDIR = $(patsubst %/build,%/kernel,$(KERNELDIR)) · line 22

Quoted 11 lines · Jan Kiszka

In order to allow sync'ing the kmod dir against arbitrary kernels trees, extend the sync script to accept alternative paths and adjust the Makefile accordingly.

Makefile +1 -0
@@ -17,6 +17,7 @@ ORIGMODDIR = $(patsubst %/build,%/kernel,$(KERNELDIR))
 
 rpmrelease = devel
 
+KVM_VERSION = kvm-devel
 LINUX = ./linux-2.6
 

You're overriding ./configure here. What was the motivation?

sync def cmd(c): · line 14

Quoted 8 lines
sync +3 -3
-version = 'kvm-devel'
-if len(sys.argv) >= 2:
-    version = sys.argv[1]
+parser = OptionParser(usage='usage: %prog [-v version][-l linuxkernel]')
+parser.add_option('-v', action='store', type='string', dest='version')
+parser.add_option('-l', action='store', type='string', dest='linux')

Please add help, and spaces around '='.

sync def cmd(c): · line 24

Quoted 11 lines
sync +7 -0
+(options, args) = parser.parse_args()
 
+version = 'kvm-devel'
 linux = 'linux-2.6'
 
+if options.version:
+    version = options.version
+if options.linux:
+    linux = options.linux
+

Can replace this with set_defaults().

Signature · 2 lines
I have a truly marvellous patch that fixes the bug which this
signature is too narrow to contain.
#2 lore raw

PATCH v2 1/1 Allow to override sync source

Quoted 7 lines · Avi Kivity
Quoted 6 lines · Jan Kiszka

In order to allow sync'ing the kmod dir against arbitrary kernels trees, extend the sync script to accept alternative paths and adjust the Makefile accordingly.

(quoted diff) +0 -0
@@ -17,6 +17,7 @@ ORIGMODDIR = $(patsubst %/build,%/kernel,$(KERNELDIR))
 
Quoted 7 lines

Review ORIGMODDIR = $(patsubst %/build,%/kernel,$(KERNELDIR)) · line 22

Quoted 5 lines
(quoted diff) +1 -0
 rpmrelease = devel
 
+KVM_VERSION = kvm-devel
 LINUX = ./linux-2.6
 

You're overriding ./configure here. What was the motivation?

I missed that this is provided via configure - dropped again.

Quoted 11 lines

Review ORIGMODDIR = $(patsubst %/build,%/kernel,$(KERNELDIR))

Quoted 9 lines
(quoted diff) +3 -3
-version = 'kvm-devel'
-if len(sys.argv) >= 2:
-    version = sys.argv[1]
+parser = OptionParser(usage='usage: %prog [-v version][-l linuxkernel]')
+parser.add_option('-v', action='store', type='string', dest='version')
+parser.add_option('-l', action='store', type='string', dest='linux')

Please add help, and spaces around '='.

OK.

Quoted 6 lines
Quoted 6 lines
(quoted diff) +2 -0
+(options, args) = parser.parse_args()
 
+version = 'kvm-devel'
 linux = 'linux-2.6'
Quoted 9 lines

Review

Quoted 6 lines
(quoted diff) +5 -0
+if options.version:
+    version = options.version
+if options.linux:
+    linux = options.linux
+

Can replace this with set_defaults().

Nice. Done below.

---------->

In order to allow sync'ing the kmod dir against arbitrary kernels trees, extend the sync script to accept alternative paths and adjust the Makefile accordingly.

Changes in v2:
- drop KVM_VERSION override
- make use of set_defaults
- option help texts

---

 Makefile |    2 +-
 sync     |   16 +++++++++++-----
 2 files changed, 12 insertions(+), 6 deletions(-)
Makefile +1 -1
index a8e8e0b..8bd5b9b 100644
@@ -38,7 +38,7 @@ include $(MAKEFILE_PRE)
 .PHONY: sync
 
 sync:
-	./sync $(KVM_VERSION)
+	./sync -v $(KVM_VERSION) -l $(LINUX)
 
 install:
 	mkdir -p $(DESTDIR)/$(INSTALLDIR)
sync +11 -5
index 4a89296..f3f4d6a 100755
@@ -1,6 +1,7 @@
 #!/usr/bin/python
 
 import sys, os, glob, os.path, shutil, re
+from optparse import OptionParser
 
 glob = glob.glob
 
@@ -8,11 +9,16 @@ def cmd(c):
     if os.system(c) != 0:
         raise Exception('command execution failed: ' + c)
 
-version = 'kvm-devel'
-if len(sys.argv) >= 2:
-    version = sys.argv[1]
-
-linux = 'linux-2.6'
+parser = OptionParser(usage = 'usage: %prog [-v VERSION][-l LINUX]')
+parser.add_option('-v', action = 'store', type = 'string', dest = 'version', \
+                  help = 'kvm-kmod release version', default = 'kvm-devel')
+parser.add_option('-l', action = 'store', type = 'string', dest = 'linux', \
+                  help = 'Linux kernel tree to sync from', \
+                  default = 'linux-2.6')
+parser.set_defaults()
+(options, args) = parser.parse_args()
+version = options.version
+linux = options.linux
 
 _re_cache = {}