The following pull request was submitted through Github.
It can be accessed and reviewed at: https://github.com/lxc/distrobuilder/pull/268

This e-mail was sent by the LXC bot, direct replies will not reach the author
unless they happen to be subscribed to this list.

=== Description (from pull-request) ===
This adds support for CentOS Stream.

Signed-off-by: Thomas Hipp <thomas.h...@canonical.com>
From 2d74c936f0c6488d887272c5c6642545490b91e6 Mon Sep 17 00:00:00 2001
From: Thomas Hipp <thomas.h...@canonical.com>
Date: Tue, 14 Jan 2020 21:44:25 +0100
Subject: [PATCH] sources: Support CentOS Stream

This adds support for CentOS Stream.

Signed-off-by: Thomas Hipp <thomas.h...@canonical.com>
---
 sources/centos-http.go | 38 ++++++++++++++++++++++++++++----------
 1 file changed, 28 insertions(+), 10 deletions(-)

diff --git a/sources/centos-http.go b/sources/centos-http.go
index ea533b7..0e7cab9 100644
--- a/sources/centos-http.go
+++ b/sources/centos-http.go
@@ -34,7 +34,11 @@ func NewCentOSHTTP() *CentOSHTTP {
 
 // Run downloads the tarball and unpacks it.
 func (s *CentOSHTTP) Run(definition shared.Definition, rootfsDir string) error 
{
-       s.majorVersion = strings.Split(definition.Image.Release, ".")[0]
+       if strings.HasSuffix(definition.Image.Release, "-Stream") {
+               s.majorVersion = strings.ToLower(definition.Image.Release)
+       } else {
+               s.majorVersion = strings.Split(definition.Image.Release, ".")[0]
+       }
 
        baseURL := fmt.Sprintf("%s/%s/isos/%s/", definition.Source.URL,
                s.majorVersion,
@@ -76,7 +80,11 @@ func (s *CentOSHTTP) Run(definition shared.Definition, 
rootfsDir string) error {
                                checksumFile = "sha256sum.txt"
                        } else {
                                if strings.HasPrefix(definition.Image.Release, 
"8") {
-                                       checksumFile = "CHECKSUM.asc"
+                                       if 
strings.HasSuffix(definition.Image.Release, "-Stream") {
+                                               checksumFile = "CHECKSUM"
+                                       } else {
+                                               checksumFile = "CHECKSUM.asc"
+                                       }
                                } else {
                                        checksumFile = "sha256sum.txt.asc"
                                }
@@ -87,13 +95,16 @@ func (s *CentOSHTTP) Run(definition shared.Definition, 
rootfsDir string) error {
                                return err
                        }
 
-                       valid, err := shared.VerifyFile(filepath.Join(fpath, 
checksumFile), "",
-                               definition.Source.Keys, 
definition.Source.Keyserver)
-                       if err != nil {
-                               return err
-                       }
-                       if !valid {
-                               return errors.New("Failed to verify tarball")
+                       // Only verify file if possible.
+                       if strings.HasSuffix(checksumFile, ".asc") {
+                               valid, err := 
shared.VerifyFile(filepath.Join(fpath, checksumFile), "",
+                                       definition.Source.Keys, 
definition.Source.Keyserver)
+                               if err != nil {
+                                       return err
+                               }
+                               if !valid {
+                                       return errors.New("Failed to verify 
tarball")
+                               }
                        }
                }
        }
@@ -356,7 +367,8 @@ rm -rf /rootfs/var/cache/yum
 
 func (s CentOSHTTP) getRelease(URL, release, variant, arch string) string {
        releaseFields := strings.Split(release, ".")
-       resp, err := http.Get(URL + path.Join("/", releaseFields[0], "isos", 
arch))
+
+       resp, err := http.Get(URL + path.Join("/", 
strings.ToLower(releaseFields[0]), "isos", arch))
        if err != nil {
                fmt.Fprintln(os.Stderr, err)
                return ""
@@ -369,6 +381,12 @@ func (s CentOSHTTP) getRelease(URL, release, variant, arch 
string) string {
                return ""
        }
 
+       if strings.HasSuffix(releaseFields[0], "-Stream") {
+               fields := strings.Split(releaseFields[0], "-")
+               // Convert <version>-Stream to Stream-<version>
+               releaseFields[0] = fmt.Sprintf("%s-%s", fields[1], fields[0])
+       }
+
        var re []string
        if len(releaseFields) > 1 {
                if arch == "armhfp" {
_______________________________________________
lxc-devel mailing list
lxc-devel@lists.linuxcontainers.org
http://lists.linuxcontainers.org/listinfo/lxc-devel

Reply via email to