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 |
|
|
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 |
161 |
print "ERROR: Increased version to %s, but RPM doesn't agree!?!" % version |
print "ERROR: Increased version to %s, but RPM doesn't agree!?!" % version |
162 |
return False |
return False |
163 |
|
|
164 |
# Download new tarball |
try: |
165 |
subprocess.check_call(['mgarepo', 'sync', '-d'], cwd=self.cwd) |
# Download new tarball |
166 |
# Check patches still apply |
subprocess.check_call(['mgarepo', 'sync', '-d'], cwd=self.cwd) |
167 |
subprocess.check_call(['bm', '-p', '--nodeps'], cwd=self.cwd) |
# Check patches still apply |
168 |
|
subprocess.check_call(['bm', '-p', '--nodeps'], cwd=self.cwd) |
169 |
|
except subprocess.CalledProcessError: |
170 |
|
return False |
171 |
|
|
172 |
return True |
return True |
173 |
|
|
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 |
|
|