The variables are set to the git revision from which the build is triggered and rpm version from the spec file, if it is build using RPM. This can be later used to query exact source version while running osbuild-composer. It is necessary to use both, because none of them is available in all possible scenarios. Use either git-rev (preferably) or RPM version (NEVRA) instead of the "devel" build type. It was just a placeholder.
27 lines
730 B
Go
27 lines
730 B
Go
package common
|
|
|
|
import "fmt"
|
|
|
|
// These constants are set during buildtime using additional
|
|
// compiler flags. Not all of them are necessarily defined
|
|
// because RPMs can be build from a tarball and spec file without
|
|
// being in a git repository. On the other hand when building
|
|
// composer inside of a container, there is no RPM layer so in
|
|
// that case the RPM version doesn't exist at all.
|
|
var (
|
|
// Git revision from which this code was built
|
|
GitRev = "undefined"
|
|
|
|
// RPM Version
|
|
RpmVersion = "undefined"
|
|
)
|
|
|
|
func BuildVersion() string {
|
|
if GitRev != "undefined" {
|
|
return fmt.Sprintf("git-rev:%s", GitRev)
|
|
} else if RpmVersion != "undefined" {
|
|
return fmt.Sprintf("NEVRA:%s", RpmVersion)
|
|
} else {
|
|
return "devel"
|
|
}
|
|
}
|