gentoo: Tweak source image parsing

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
This commit is contained in:
Stéphane Graber 2019-02-11 20:22:25 -05:00
parent 117055b3ed
commit 73706bff65
No known key found for this signature in database
GPG Key ID: C638974D64792D67

View File

@ -109,23 +109,23 @@ func (s *GentooHTTP) getLatestBuild(baseURL, arch string) (string, error) {
}
// Look for .tar.xz
regex := regexp.MustCompile(fmt.Sprintf("stage3-%s-\\d{8}T\\d{6}Z.tar.xz", arch))
regex := regexp.MustCompile(fmt.Sprintf(">stage3-%s-.*.tar.xz<", arch))
// Find all stage3 related files
matches := regex.FindAllString(string(body), -1)
if len(matches) > 1 {
if len(matches) > 0 {
// Take the first match since they're all the same anyway
return matches[0], nil
return strings.Trim(matches[0], "<>"), nil
}
// Look for .tar.bz2
regex = regexp.MustCompile(fmt.Sprintf("stage3-%s-\\d{8}T\\d{6}Z.tar.bz2", arch))
regex = regexp.MustCompile(fmt.Sprintf(">stage3-%s-.*.tar.bz2<", arch))
// Find all stage3 related files
matches = regex.FindAllString(string(body), -1)
if len(matches) > 1 {
if len(matches) > 0 {
// Take the first match since they're all the same anyway
return matches[0], nil
return strings.Trim(matches[0], "<>"), nil
}
return "", nil