/[soft]/mga-gnome/trunk/mga-gnome
ViewVC logotype

Diff of /mga-gnome/trunk/mga-gnome

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 3087 by ovitters, Mon Feb 27 09:43:14 2012 UTC revision 3088 by ovitters, Mon Feb 27 10:42:33 2012 UTC
# Line 62  def get_latest_version(versions, max_ver Line 62  def get_latest_version(versions, max_ver
62              latest = version              latest = version
63      return latest      return latest
64    
65    def judge_version_increase(version_old, version_new):
66            """Judge quality of version increase:
67    
68            Returns a tuple containing judgement and message
69    
70            Judgement:
71            Less than 0: Error
72            0 to 4: Better not
73            5+: Ok"""
74            versions = (version_old, version_new)
75    
76            print " => ".join(versions)
77    
78            # First do a basic version comparison to ensure version_new is actually newer
79            compare = version_cmp(version_new, version_old)
80    
81            if compare == 0:
82                return (-2, "Already at version %s!" % (version_old))
83    
84            if compare != 1:
85                return (-3, "Version %s is older than current version %s!" % (version_new, version_old))
86    
87            # Version is newer, but we don't want to see if it follows the GNOME versioning scheme
88            majmins = [re_majmin.sub(r'\1', ver) for ver in versions if re_majmin.match(ver) is not None]
89    
90            if len(majmins) == 1:
91                return (-1, "Version number scheme changes: %s" % (", ".join(versions)))
92    
93            if len(majmins) == 0:
94                return (0, "Unsupported version numbers: %s" % (", ".join(versions)))
95    
96            # Follows GNOME versioning scheme
97            # Meaning: x.y.z
98            #          x = major
99            #          y = minor  : even if stable
100            #          z = micro
101    
102            # Major+minor the same? Then go ahead and upgrade!
103            if majmins[0] == majmins[1]:
104                # Majmin of both versions are the same, looks good!
105                return (10, None)
106    
107            # More detailed analysis needed, so figure out the numbers
108            majmin_nrs = [map(long, ver.split('.')) for ver in majmins]
109    
110            # Check/ensure major version number is the same
111            if majmin_nrs[0][0] != majmin_nrs[1][0]:
112                return (1, "Major version number increase")
113    
114            # Minor indicates stable/unstable
115            devstate = (majmin_nrs[0][1] % 2 == 0, majmin_nrs[1][1] % 2 == 0)
116    
117            # Upgrading to unstable is weird
118            if not devstate[1]:
119                if devstate[0]:
120                    return (1, "Stable to unstable increase")
121    
122                return (4, "Unstable to unstable version increase")
123    
124            # Unstable => stable is always ok
125            if not devstate[0]:
126                return (5, "Unstable to stable")
127    
128            # Can only be increase of minors from one stable to the next
129            return (6, "Stable version increase")
130    
131  def line_input (file):  def line_input (file):
132      for line in file:      for line in file:
133          if line[-1] == '\n':          if line[-1] == '\n':
# Line 153  class SpecFile(object): Line 219  class SpecFile(object):
219          """Update specfile (increase version)"""          """Update specfile (increase version)"""
220          cur_version = self.version          cur_version = self.version
221    
222          compare = version_cmp(version, cur_version)          (judgement, msg) = judge_version_increase(cur_version, version)
223    
224          if compare == 0:          if judgement < 0:
225              print >>sys.stderr, "ERROR: Already at version %s!" % (cur_version)              print >>sys.stderr, "ERROR: %s!" % (msg)
226              return False              return False
227    
228          if compare != 1:          if judgement < 5:
229              print >>sys.stderr, "ERROR: Version %s is older than current version %s!" % (version, cur_version)              print >>sys.stderr, "WARNING: %s!" % (msg)
230              return False              return False
231    
232          # XXX - os.path.join is hackish          # XXX - os.path.join is hackish

Legend:
Removed from v.3087  
changed lines
  Added in v.3088

  ViewVC Help
Powered by ViewVC 1.1.30