build: show linux distro in BUILT_ON info
This commit is contained in:
parent
ecb6c1c59e
commit
9832a2ed00
17
build
17
build
|
@ -15,18 +15,7 @@ cd -P -- "$(dirname -- "${BASH_SOURCE[0]}")"
|
|||
PKG_VSN="${PKG_VSN:-$(./pkg-vsn.sh)}"
|
||||
export PKG_VSN
|
||||
|
||||
if [ "$(uname -s)" = 'Darwin' ]; then
|
||||
SYSTEM=macos
|
||||
elif [ "$(uname -s)" = 'Linux' ]; then
|
||||
if grep -q -i 'centos' /etc/*-release; then
|
||||
DIST='centos'
|
||||
VERSION_ID="$(rpm --eval '%{centos_ver}')"
|
||||
else
|
||||
DIST="$(sed -n '/^ID=/p' /etc/os-release | sed -r 's/ID=(.*)/\1/g' | sed 's/"//g')"
|
||||
VERSION_ID="$(sed -n '/^VERSION_ID=/p' /etc/os-release | sed -r 's/VERSION_ID=(.*)/\1/g' | sed 's/"//g')"
|
||||
fi
|
||||
SYSTEM="$(echo "${DIST}${VERSION_ID}" | sed -r 's/([a-zA-Z]*)-.*/\1/g')"
|
||||
fi
|
||||
SYSTEM="$(./scripts/get-distro.sh)"
|
||||
|
||||
ARCH="$(uname -m)"
|
||||
case "$ARCH" in
|
||||
|
@ -46,8 +35,8 @@ export ARCH
|
|||
## Support RPM and Debian based linux systems
|
||||
##
|
||||
if [ "$(uname -s)" = 'Linux' ]; then
|
||||
case "${DIST:-}" in
|
||||
ubuntu|debian|raspbian)
|
||||
case "${SYSTEM:-}" in
|
||||
ubuntu*|debian*|raspbian*)
|
||||
PKGERDIR='deb'
|
||||
;;
|
||||
*)
|
||||
|
|
|
@ -1 +1 @@
|
|||
{{built_on_arch}}
|
||||
{{built_on_platform}}
|
||||
|
|
|
@ -173,11 +173,24 @@ relx(Vsn, RelType, PkgType) ->
|
|||
, {vm_args,false}
|
||||
, {release, {emqx, Vsn}, relx_apps(RelType)}
|
||||
, {overlay, relx_overlay(RelType)}
|
||||
, {overlay_vars, [ {built_on_arch, rebar_utils:get_arch()}
|
||||
, {overlay_vars, [ {built_on_platform, built_on()}
|
||||
, {emqx_description, emqx_description(RelType, IsEnterprise)}
|
||||
| overlay_vars(RelType, PkgType, IsEnterprise)]}
|
||||
].
|
||||
|
||||
built_on() ->
|
||||
On = rebar_utils:get_arch(),
|
||||
case distro() of
|
||||
false -> On;
|
||||
Distro -> On ++ "-" ++ Distro
|
||||
end.
|
||||
|
||||
distro() ->
|
||||
case os:type() of
|
||||
{unix, _} -> string:strip(os:cmd("scripts/get-distro.sh"), both, $\n);
|
||||
_ -> false
|
||||
end.
|
||||
|
||||
emqx_description(cloud, true) -> "EMQ X Enterprise";
|
||||
emqx_description(cloud, false) -> "EMQ X Broker";
|
||||
emqx_description(edge, _) -> "EMQ X Edge".
|
||||
|
|
|
@ -0,0 +1,19 @@
|
|||
#!/bin/bash
|
||||
|
||||
## This script prints Linux distro name and its version number
|
||||
## e.g. macos, centos8, ubuntu20.04
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
if [ "$(uname -s)" = 'Darwin' ]; then
|
||||
echo 'macos'
|
||||
elif [ "$(uname -s)" = 'Linux' ]; then
|
||||
if grep -q -i 'centos' /etc/*-release; then
|
||||
DIST='centos'
|
||||
VERSION_ID="$(rpm --eval '%{centos_ver}')"
|
||||
else
|
||||
DIST="$(sed -n '/^ID=/p' /etc/os-release | sed -r 's/ID=(.*)/\1/g' | sed 's/"//g')"
|
||||
VERSION_ID="$(sed -n '/^VERSION_ID=/p' /etc/os-release | sed -r 's/VERSION_ID=(.*)/\1/g' | sed 's/"//g')"
|
||||
fi
|
||||
echo "${DIST}${VERSION_ID}" | sed -r 's/([a-zA-Z]*)-.*/\1/g'
|
||||
fi
|
Loading…
Reference in New Issue