/[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 3034 by ovitters, Wed Feb 22 20:47:36 2012 UTC revision 3037 by ovitters, Thu Feb 23 19:43:09 2012 UTC
# Line 120  class SpecFile(object): Line 120  class SpecFile(object):
120      @property      @property
121      def version(self):      def version(self):
122          return subprocess.check_output(["rpm", "--specfile", self.path, "--queryformat", "%{VERSION}\n"]).splitlines()[0]          return subprocess.check_output(["rpm", "--specfile", self.path, "--queryformat", "%{VERSION}\n"]).splitlines()[0]
123    
124      def update(self, version):      def update(self, version):
125          """Update specfile (increase version)"""          """Update specfile (increase version)"""
126          cur_version = self.version          cur_version = self.version
127    
128          if version_cmp(version, cur_version) != 1:          compare = version_cmp(version, cur_version)
129    
130            if compare == 0:
131                print >>sys.stderr, "ERROR: Already at version %s!" % (cur_version)
132                return False
133    
134            if compare != 1:
135              print >>sys.stderr, "ERROR: Version %s is older than current version %s!" % (version, cur_version)              print >>sys.stderr, "ERROR: Version %s is older than current version %s!" % (version, cur_version)
136              return False              return False
137    
# Line 132  class SpecFile(object): Line 139  class SpecFile(object):
139              data = f.read()              data = f.read()
140    
141              if data.count("%mkrel") != 1:              if data.count("%mkrel") != 1:
142                  print "WARNING: Multiple %mkrel found; don't know what to do!"                  print >>sys.stderr, "ERROR: Multiple %mkrel found; don't know what to do!"
143                  return False                  return False
144    
145              data, nr = self.re_update_version.subn(r'\g<pre>%s\g<post>' % version, data, 1)              data, nr = self.re_update_version.subn(r'\g<pre>%s\g<post>' % version, data, 1)
146              if nr != 1:              if nr != 1:
147                  print "WARNING: Could not increase version!"                  print >>sys.stderr, "ERROR: Could not increase version!"
148                  return False                  return False
149    
150              data, nr = self.re_update_release.subn(r'\g<pre>%mkrel 1\g<post>', data, 1)              data, nr = self.re_update_release.subn(r'\g<pre>%mkrel 1\g<post>', data, 1)
151              if nr != 1:              if nr != 1:
152                  print "WARNING: Could not reset release!"                  print >>sys.stderr, "ERROR: Could not reset release!"
153                  return False                  return False
154    
155              # Overwrite file with new version number              # Overwrite file with new version number
# Line 415  def cmd_package_new_version(options, par Line 422  def cmd_package_new_version(options, par
422    
423      subprocess.call(['mgarepo', 'co', package], cwd=cwd)      subprocess.call(['mgarepo', 'co', package], cwd=cwd)
424      s = SpecFile(os.path.join(cwd, package, "SPECS", "%s.spec" % package))      s = SpecFile(os.path.join(cwd, package, "SPECS", "%s.spec" % package))
425      print s.version      print "%s => %s" % (s.version, options.version)
426      if not s.update(options.version):      if not s.update(options.version):
427          sys.exit(1)          sys.exit(1)
428    

Legend:
Removed from v.3034  
changed lines
  Added in v.3037

  ViewVC Help
Powered by ViewVC 1.1.30