During development of a new distro, we need to test composer against nightly or beta repositories, but we cannot ship composer itself with the nightly repository information hardcoded in. At the same time, we want to distinguish between the system repositories of the host and the repositories we use to generate images (the host may not use the same distro/version/architecture as the target, and it may include custom repositories that the target should not). We therefore ship per distro repository information that can be overriden (typically in testing) by dropping files in /etc. For now use the latest nightlies for RHEL-8.2, we may want to replace these with the official mirrors for GA eventually. Signed-off-by: Tom Gundersen <teg@jklm.no>
71 lines
1.6 KiB
Go
71 lines
1.6 KiB
Go
package main
|
|
|
|
import (
|
|
"flag"
|
|
"log"
|
|
"os"
|
|
"runtime"
|
|
|
|
"github.com/osbuild/osbuild-composer/internal/distro"
|
|
"github.com/osbuild/osbuild-composer/internal/jobqueue"
|
|
"github.com/osbuild/osbuild-composer/internal/rpmmd"
|
|
"github.com/osbuild/osbuild-composer/internal/store"
|
|
"github.com/osbuild/osbuild-composer/internal/weldr"
|
|
|
|
"github.com/coreos/go-systemd/activation"
|
|
)
|
|
|
|
func currentArch() string {
|
|
if runtime.GOARCH == "amd64" {
|
|
return "x86_64"
|
|
} else if runtime.GOARCH == "arm64" {
|
|
return "aarch64"
|
|
} else if runtime.GOARCH == "ppc64le" {
|
|
return "ppc64le"
|
|
} else if runtime.GOARCH == "s390x" {
|
|
return "s390x"
|
|
} else {
|
|
panic("unsupported architecture")
|
|
}
|
|
}
|
|
|
|
func main() {
|
|
var verbose bool
|
|
flag.BoolVar(&verbose, "v", false, "Print access log")
|
|
flag.Parse()
|
|
|
|
stateDir := "/var/lib/osbuild-composer"
|
|
|
|
listeners, err := activation.Listeners()
|
|
if err != nil {
|
|
log.Fatalf("Could not get listening sockets: " + err.Error())
|
|
}
|
|
|
|
if len(listeners) != 2 {
|
|
log.Fatalf("Unexpected number of listening sockets (%d), expected 2", len(listeners))
|
|
}
|
|
|
|
weldrListener := listeners[0]
|
|
jobListener := listeners[1]
|
|
|
|
rpm := rpmmd.NewRPMMD()
|
|
distros := distro.NewRegistry([]string{"/etc/osbuild-composer", "/usr/share/osbuild-composer"})
|
|
|
|
distribution, err := distros.FromHost()
|
|
if err != nil {
|
|
log.Fatalf("Could not determine distro from host: " + err.Error())
|
|
}
|
|
|
|
var logger *log.Logger
|
|
if verbose {
|
|
logger = log.New(os.Stdout, "", 0)
|
|
}
|
|
|
|
store := store.New(&stateDir, distribution)
|
|
|
|
jobAPI := jobqueue.New(logger, store)
|
|
weldrAPI := weldr.New(rpm, currentArch(), distribution, logger, store)
|
|
|
|
go jobAPI.Serve(jobListener)
|
|
weldrAPI.Serve(weldrListener)
|
|
}
|