diff --git a/cmd/osbuild-worker/main.go b/cmd/osbuild-worker/main.go index 9aaf4287e..993ffc0fe 100644 --- a/cmd/osbuild-worker/main.go +++ b/cmd/osbuild-worker/main.go @@ -19,6 +19,7 @@ import ( "github.com/google/uuid" "github.com/osbuild/osbuild-composer/internal/common" + "github.com/osbuild/osbuild-composer/internal/distro" "github.com/osbuild/osbuild-composer/internal/osbuild" "github.com/osbuild/osbuild-composer/internal/target" "github.com/osbuild/osbuild-composer/internal/upload/awsupload" @@ -236,6 +237,12 @@ func RunJob(job worker.Job, store string, kojiServers map[string]koji.GSSAPICred continue } + hostOS, err := distro.GetRedHatRelease() + if err != nil { + r = append(r, err) + continue + } + build := koji.ImageBuild{ BuildID: options.BuildID, TaskID: options.TaskID, @@ -249,7 +256,7 @@ func RunJob(job worker.Job, store string, kojiServers map[string]koji.GSSAPICred { ID: 1, Host: koji.Host{ - Os: "RHEL8", + Os: hostOS, Arch: "noarch", }, ContentGenerator: koji.ContentGenerator{ diff --git a/internal/distro/distro.go b/internal/distro/distro.go index d5ec11b13..81a185e34 100644 --- a/internal/distro/distro.go +++ b/internal/distro/distro.go @@ -6,6 +6,7 @@ import ( "errors" "fmt" "io" + "io/ioutil" "os" "sort" "strings" @@ -193,6 +194,20 @@ func GetHostDistroName() (string, bool, error) { return name, beta, nil } +// GetRedHatRelease returns the content of /etc/redhat-release +// without the trailing new-line. +func GetRedHatRelease() (string, error) { + raw, err := ioutil.ReadFile("/etc/redhat-release") + if err != nil { + return "", fmt.Errorf("cannot read /etc/redhat-release: %v", err) + } + + //Remove the trailing new-line. + redHatRelease := strings.TrimSpace(string(raw)) + + return redHatRelease, nil +} + func readOSRelease(r io.Reader) (map[string]string, error) { osrelease := make(map[string]string) scanner := bufio.NewScanner(r)