Skip to content
Browse files

Correct version version string generation

Github changed their tarball download mechanism from providing the name
of the file directly in the URL, to providing the name in the headers.
This filename is used to specify the version string that the build
scripts otherwise expect to pull out of git, and the change resulted in
an invalid, chunk of SHA1 to be used instead. This corrects the
extraction of the version string by pulling it out of the new location
in the headers.
  • Loading branch information...
1 parent c2012af commit 19ef1a9375ea03f7ce4a27985038bd1cb99eed00 @wagnerrp wagnerrp committed
Showing with 27 additions and 2 deletions.
  1. +27 −2 Gentoo/scripts/mythtv-buildebuild.py
View
29 Gentoo/scripts/mythtv-buildebuild.py
@@ -52,6 +52,22 @@ def dst(self, dt): return datetime.timedelta(0)
dt.append(tz)
return datetime.datetime(*dt)
+def multi_split(string, separators, merge=True):
+ response = [string]
+ for sep in separators:
+ for index, group in enumerate(response):
+ if sep in group:
+ response.pop(index)
+ for pos, chunk in enumerate(group.split(sep)):
+ response.insert(index+pos, chunk)
+ if merge:
+ offs = 0
+ for index, group in enumerate(list(response)):
+ if group == "":
+ response.pop(index+offs)
+ offs -= 1
+ return response
+
class Ebuild( object ):
def __init__(self, package):
self.package = package
@@ -82,9 +98,18 @@ def get_tarball(self):
request = urllib2.Request(url)
opener = urllib2.build_opener()
f = opener.open(request)
- url = f.url
- self.opts.gitver = url.split('/')[-1][14:-7]
+ for line in f.headers.headers:
+ if not line.startswith('Content-Disposition'):
+ continue
+ line = multi_split(line.strip(), ' =:;')
+ line = dict([line[i:i+2] for i in range(0, len(line), 2)])
+ if line['Content-Disposition'] != 'attachment':
+ raise Exception("requested tarball is not of type 'attachment'")
+ self.opts.gitver = line['filename'][14:-7]
+ break
+ else:
+ raise Exception("could not extract version string from tarball")
if self.opts.tarball is not None:
return

0 comments on commit 19ef1a9

Please sign in to comment.
Something went wrong with that request. Please try again.