Skip to content

Commit 19ef1a9

Browse files
committed
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.
1 parent c2012af commit 19ef1a9

File tree

1 file changed

+27
-2
lines changed

1 file changed

+27
-2
lines changed

Gentoo/scripts/mythtv-buildebuild.py

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,22 @@ def dst(self, dt): return datetime.timedelta(0)
5252
dt.append(tz)
5353
return datetime.datetime(*dt)
5454

55+
def multi_split(string, separators, merge=True):
56+
response = [string]
57+
for sep in separators:
58+
for index, group in enumerate(response):
59+
if sep in group:
60+
response.pop(index)
61+
for pos, chunk in enumerate(group.split(sep)):
62+
response.insert(index+pos, chunk)
63+
if merge:
64+
offs = 0
65+
for index, group in enumerate(list(response)):
66+
if group == "":
67+
response.pop(index+offs)
68+
offs -= 1
69+
return response
70+
5571
class Ebuild( object ):
5672
def __init__(self, package):
5773
self.package = package
@@ -82,9 +98,18 @@ def get_tarball(self):
8298
request = urllib2.Request(url)
8399
opener = urllib2.build_opener()
84100
f = opener.open(request)
85-
url = f.url
86101

87-
self.opts.gitver = url.split('/')[-1][14:-7]
102+
for line in f.headers.headers:
103+
if not line.startswith('Content-Disposition'):
104+
continue
105+
line = multi_split(line.strip(), ' =:;')
106+
line = dict([line[i:i+2] for i in range(0, len(line), 2)])
107+
if line['Content-Disposition'] != 'attachment':
108+
raise Exception("requested tarball is not of type 'attachment'")
109+
self.opts.gitver = line['filename'][14:-7]
110+
break
111+
else:
112+
raise Exception("could not extract version string from tarball")
88113

89114
if self.opts.tarball is not None:
90115
return

0 commit comments

Comments
 (0)