From 5bc81e3a304369505b5a0b5f649995d039884681 Mon Sep 17 00:00:00 2001 From: Arsen Musayelyan Date: Mon, 21 Nov 2022 21:03:56 -0800 Subject: [PATCH] Add DISTRO_ID_LIKE environment variable --- build.go | 5 +++++ docs/build-scripts.md | 6 ++++++ 2 files changed, 11 insertions(+) diff --git a/build.go b/build.go index b941136..b23ae55 100644 --- a/build.go +++ b/build.go @@ -22,6 +22,7 @@ import ( "bytes" "context" "encoding/hex" + "fmt" "io" "os" "path/filepath" @@ -122,6 +123,9 @@ func buildPackage(ctx context.Context, script string, mgr manager.Manager) ([]st var distroChanged bool if distID, ok := os.LookupEnv("LURE_DISTRO"); ok { info.ID = distID + // Since the distro was overwritten, we don't know what the + // like distros are, so set to nil + info.Like = nil distroChanged = true } @@ -479,6 +483,7 @@ func genBuildEnv(info *distro.OSRelease) []string { "DISTRO_PRETTY_NAME="+info.PrettyName, "DISTRO_ID="+info.ID, "DISTRO_VERSION_ID="+info.VersionID, + "DISTRO_ID_LIKE="+strings.Join(info.Like, " "), "ARCH="+arch, "NCPU="+strconv.Itoa(runtime.NumCPU()), diff --git a/docs/build-scripts.md b/docs/build-scripts.md index 75a63cc..f51f74b 100644 --- a/docs/build-scripts.md +++ b/docs/build-scripts.md @@ -301,6 +301,12 @@ The `DISTRO_ID` variable is the identifier of the distro as defined in its `os-r For example, it's set to `fedora` in a Fedora 36 docker image +### DISTRO_ID_LIKE + +The `DISTRO_ID_LIKE` variable contains identifiers of similar distros to the one running, separated by spaces. + +For example, it's set to `opensuse suse` in an OpenSUSE Tumbleweed docker image and `rhel fedora` in a CentOS 8 docker image. + ### DISTRO_VERSION_ID The `DISTRO_VERSION_ID` variable is the version identifier of the distro as defined in its `os-release` file.