distro: add DetectHost

lorax-composer uses the host's repositories for building images. This is
prone to accidental configuration errors and duplicates functionality
(adding custom repositories via the source API is much more explicit).

However, blueprints don't specify the distribution they're based on.
This is something they should do in the future to enable cross-distro
image builds. Until then, read `/etc/os-release` to detect the host OS
and use that as the base distro for a blueprint.

Detection works by concatenating the ID field with a `-` and the
VERSION_ID field. This mandates how additional distributions should
register themselves to the `distro` package.

If composer cannot build the detected distro, fall back to fedora-30.

Use this detection everywhere that fedora-30 was hard-coded before.
This commit is contained in:
Lars Karlitski 2019-11-09 10:59:28 +00:00 committed by Tom Gundersen
parent 4d4da93240
commit f9cbc8593f
5 changed files with 131 additions and 8 deletions

View file

@ -31,8 +31,8 @@ func main() {
}
}
f30 := distro.New("fedora-30")
pipeline, err := f30.Pipeline(blueprint, format)
d := distro.New("")
pipeline, err := d.Pipeline(blueprint, format)
if err != nil {
panic(err.Error())
}