for dealing with the util-vserver module, specifically the scholz branch
authorThierry Parmentelat <thierry.parmentelat@sophia.inria.fr>
Thu, 3 Apr 2008 08:08:25 +0000 (08:08 +0000)
committerThierry Parmentelat <thierry.parmentelat@sophia.inria.fr>
Thu, 3 Apr 2008 08:08:25 +0000 (08:08 +0000)
+ for convenience, create a specfiles header as header.spec

Makefile
module-tag.py
modules.list
spec2make.c

index fd7f8d9..04f5c47 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -229,21 +229,26 @@ endef
 
 $(foreach package, $(ALL), $(eval $(call package_hasdate,$(package))))
 
+### the common header for generated specfiles
+# useful when trying new specfiles manually
+header.spec:
+       (echo -n "# Generated by planetlab build from $($(1)-SPEC) on " ; date) > $@
+       echo "%define distro $(DISTRO)" >> $@
+       echo "%define distrorelease $(RELEASE)" >> $@
+       echo "%define distroname $(DISTRONAME)" >> $@
+       echo "%define pldistro $(PLDISTRO)" >> $@
+       echo "%define plrelease $(PLANETLAB_RELEASE)" >> $@
+
 ### extract spec file from scm
 define target_spec
-$($(1).specpath):
+$($(1).specpath): header.spec
        mkdir -p SPECS
-       (echo -n "# Generated by planetlab build from $($(1)-SPEC) on " ; date) > $($(1).specpath)
-       echo "%define distro $(DISTRO)" >> $($(1).specpath)
-       echo "%define distrorelease $(RELEASE)" >> $($(1).specpath)
-       echo "%define distroname $(DISTRONAME)" >> $($(1).specpath)
-       echo "%define pldistro $(PLDISTRO)" >> $($(1).specpath)
-       echo "%define plrelease $(PLANETLAB_RELEASE)" >> $($(1).specpath)
+       cat header.spec > $($(1).specpath)
        $(if $($(1).has-date),echo "%define date $(shell date +%Y.%m.%d)" >> $($(1).specpath),)
        $(if $($(1)-SPECVARS), \
          $(foreach line,$($(1)-SPECVARS), \
            echo "%define" $(word 1,$(subst =, ,$(line))) "$(word 2,$(subst =, ,$(line)))" >> $($(1).specpath) ;))
-       echo "# included from codebase specfile" >> $($(1).specpath)
+       echo "# included from $($(1)-SPEC)" >> $($(1).specpath)
        $(if $($($(1).module)-SVNPATH),\
           svn cat $($($(1).module)-SVNPATH)/$($(1)-SPEC) >> $($(1).specpath) || rm $($(1).specpath),\
           cvs -d $($($(1).module)-CVSROOT) checkout \
index d23de97..7b1146c 100755 (executable)
@@ -124,8 +124,8 @@ class Module:
 
 
     # for parsing module spec name:branch
-    matcher_branch_spec=mbq=re.compile("\A(?P<name>\w+):(?P<branch>[\w\.]+)\Z")
-    matcher_rpm_define=re.compile("%define\s+(\S+)\s+(\S*)\s*")
+    matcher_branch_spec=re.compile("\A(?P<name>[\w-]+):(?P<branch>[\w\.]+)\Z")
+    matcher_rpm_define=re.compile("%(define|global)\s+(\S+)\s+(\S*)\s*")
 
     def __init__ (self,module_spec,options):
         # parse module spec
@@ -266,20 +266,22 @@ that for other purposes than tagging"""%topdir
         return glob("%s/*.spec"%self.edge_dir())
 
     def parse_spec (self, specfile, varnames):
-        if self.options.debug:
-            print 'parse_spec',specfile,
+        if self.options.verbose:
+            print 'Parsing',specfile,
+            for var in varnames:
+                print "[%s]"%var,
+            print ""
         result={}
         f=open(specfile)
         for line in f.readlines():
             attempt=Module.matcher_rpm_define.match(line)
             if attempt:
-                (var,value)=attempt.groups()
+                (define,var,value)=attempt.groups()
                 if var in varnames:
                     result[var]=value
         f.close()
-        if self.options.verbose:
-            print 'found',len(result),'keys'
         if self.options.debug:
+            print 'found',len(result),'keys'
             for (k,v) in result.iteritems():
                 print k,'=',v
         return result
@@ -317,9 +319,9 @@ that for other purposes than tagging"""%topdir
             for line in spec.readlines():
                 attempt=Module.matcher_rpm_define.match(line)
                 if attempt:
-                    (var,value)=attempt.groups()
+                    (define,var,value)=attempt.groups()
                     if var in patch_dict.keys():
-                        new.write('%%define %s %s\n'%(var,patch_dict[var]))
+                        new.write('%%%s %s %s\n'%(define,var,patch_dict[var]))
                         continue
                 new.write(line)
             spec.close()
index f66ad12..d315470 100644 (file)
@@ -4,8 +4,8 @@ BootstrapFS
 CoDemux
 # 4.2
 Mom:2.2
-Mom
 MyPLC
+# 4.2
 NodeManager:1.7
 NodeUpdate
 PLCAPI
@@ -30,7 +30,7 @@ pypcilib
 ulogd
 util-python
 # using branches/scholz for this module
-# util-vserver
+util-vserver:scholz
 util-vserver-pl
 vsys
 wireless-tools
index 77ddec9..a0144f1 100644 (file)
@@ -184,8 +184,9 @@ main(int argc, char *argv[])
   }
 
   /* export some macros to make */
+  /* note : this relies on pl-specific conventions and might be wrong */
   { 
-    char *macros[] = { "release" , "name" , "version" , "subversion" , NULL } ;
+    char *macros[] = { "release" , "name" , "version" , "taglevel" , NULL } ;
     char **nav;
     char *macro=malloc(32);
     for (nav=macros; *nav; nav++) {