Here is a fix to opkgc agains svn 9194.
It's a better than nothing patch. There are some cases that are still not 
handled.
cases not handled:
requires for distro version 4
followed by
requires for distro version 5
followed by
another requires for version 4

Also, not tested:
if there are only requires relative to specific version (no global requires)

This fix is a progress to a better rpm requirements processing. Though, to 
address the requirements fully, the code needs to be rewritten:
- 1st pass: create requirements strucuture in memory
- 2nd pass: loop on structures to write all requirements

Best regards.
-- 
        Olivier LAHAYE
        CEAEA Saclay
        DRT-LIST-DCSI-DIR
Index: Rpm.py
===================================================================
--- Rpm.py	(révision 9194)
+++ Rpm.py	(copie de travail)
@@ -65,39 +65,46 @@
                     nc['name'] = "OPKG::%s" % c['name']
                     deps.append(nc)
 
-            if len(deps) != 0:
+            if len(deps) != 0: # if there are some dependancies
                 archout = ""
-                if arch != None:
+                if arch != None: # if there is a specific arch, report it
                     archout += "%%if %%{_build_arch} == %s\n" % arch
-                archout += "%s: " % self.dependsName[relation]
-                pkg_d = {}
-                ver_d = {}
+                pkg_d = {} # memory for processed deps
+                ver_d = {} # flags for each filters. (if not in: create section)
+                version=-1 # no version for generic requirements.
                 for i, d in enumerate(deps):
-                    if len(d) != 0:
-                        xs = d['dist']
-                        for x in xs:
-                            if x['version'] != None: 
+                    if len(d) != 0: # non empty deps
+                        xs = d['dist'] # dependancy filter (os, version, ...)
+                        for x in xs:   # scann all filters for this "requires"
+                            if x['version'] != None:  # filter exists
                                 xx = x['version']
-                                if xx not in ver_d:
-                                    ver_d[xx] = 1
-                                    xx = self.replace_comp_sign(xx)
+                                if xx != version and version != -1:
+                                    archout += "\n%endif\n"
+                                    archout += "%endif\n"
+                                version = xx # keep version tracking so we can add endif when changing.
+                                if xx not in ver_d:   # 1st time we see this version => create section
+                                    ver_d[xx] = 1     # remember section created
+                                    xx = self.replace_comp_sign(xx) # convert comparison sign
                                     archout += "\n%%if %%{%s}" % distro_d[x['name']]
                                     archout += "\n%%define is_version %%(test %%{vtag} %s && echo 1 || echo 0)" % xx
                                     archout += "\n%if %{is_version}\n"
                                     archout += "%s: " % self.dependsName[relation]
+                                else:
+                                    archout += ', ' # section exists, jsut add a ","
+                        if len(pkg_d) == 0: # 1st relation:
+                            archout += "%s: " % self.dependsName[relation]
+                        elif version == -1: # still processing generic requirements
+                            archout += ', ' # section exists, jsut add a ","
+                        pkg_d[self.formatPkg(d)] = 1 # package processed
                     	archout += self.formatPkg(d)
-                    if ((len(deps) > 1) and (i < len(deps) - 1)):
-                        archout += ', '
-                    elif self.formatPkg(d) not in pkg_d and len(ver_d) != 0:
-                        pkg_d[self.formatPkg(d)] = 1
-                        archout += "\n%endif\n"
-                        archout += "%endif\n"
+                if version != -1:
+                    archout += "\n%endif\n"
+                    archout += "%endif\n"
                 archout += "\n"
-                if arch != None:
+                if arch != None: # OL: Still usefull?
                     archout += "%endif\n"
                 archout += "\n"
                 out += archout
-
         return out
 
     def formatPkg(self, p):
------------------------------------------------------------------------------
Download Intel&#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
_______________________________________________
Oscar-devel mailing list
Oscar-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/oscar-devel

Reply via email to