[Fuego] [PATCH v2] need_check: add linux distro automatic detection
Tim.Bird at sony.com
Tim.Bird at sony.com
Wed Feb 7 04:04:18 UTC 2018
OK - it should be obvious by now that I'm going back and catching
up on old e-mails that I should have applied weeks ago.
Sorry for the delay. Some of these outstanding patches fell through
the cracks.
This is now applied.
Thanks,
-- Tim
> -----Original Message-----
> From: Daniel Sangorrin on Thursday, January 11, 2018 5:53 PM
>
> This function can be used by tests that need to know the
> distribution in the target board. The automatic detection
> can be disabled/overriden by manually setting the variables
> BOARD_DISTRO_ID and BOARD_DISTRO_VERSION_ID in the board
> file.
>
> IMPORTANT: this is not a substitute for individual command
> checks. For example, even if the BOARD_DISTRO_ID is "debian"
> test writers should still check for the existance of "apt-get"
> in case they want to use it.
>
> Signed-off-by: Daniel Sangorrin <daniel.sangorrin at toshiba.co.jp>
> ---
> engine/scripts/need_check.sh | 27 +++++++++++++++++++++++++++
> 1 file changed, 27 insertions(+)
>
> diff --git a/engine/scripts/need_check.sh b/engine/scripts/need_check.sh
> index 1fd6d6d..2b00d46 100755
> --- a/engine/scripts/need_check.sh
> +++ b/engine/scripts/need_check.sh
> @@ -123,6 +123,33 @@ function get_free_storage {
> echo $result
> }
>
> +# This function detects the Linux distribution used on the target board and
> +# exports the following variables:
> +# BOARD_DISTRO_ID (e.g. ubuntu, debian, centos)
> +# BOARD_DISTRO_VERSION_ID (e.g. "16.04", "8", "7")
> +#
> +# If the distribution cannot be automatically detected it will return 1.
> +# Defining BOARD_DISTRO_ID and BOARD_DISTRO_VERSION_ID on the
> board file
> +# disables automatic detection.
> +function check_distro {
> + if [ -z "$BOARD_DISTRO_ID" ] || [ -z "$BOARD_DISTRO_VERSION_ID" ];
> then
> + os_release_tmpfile=$(mktemp)
> + if get "/etc/os-release" $os_release_tmpfile ; then
> + export BOARD_DISTRO_ID="$(grep ^ID= $os_release_tmpfile | cut -c
> 4-)"
> + export BOARD_DISTRO_VERSION_ID="$(grep ^VERSION_ID=
> $os_release_tmpfile | cut -c 12-)"
> + fi
> + rm $os_release_tmpfile
> + fi
> +
> + if [ -z "$BOARD_DISTRO_ID" ] || [ -z "$BOARD_DISTRO_VERSION_ID" ];
> then
> + echo "ERROR: could not detect the distribution running on the board."
> + echo "Define BOARD_DISTRO_ID and BOARD_DISTRO_VERSION_ID in
> your board file."
> + return 1
> + else
> + echo "Board distribution is $BOARD_DISTRO_ID
> $BOARD_DISTRO_VERSION_ID"
> + fi
> +}
> +
> # $1 has a single string holding a space-separated args:
> # arg1 = size
> # arg2 = directory to check
> --
> 2.7.4
>
>
> _______________________________________________
> Fuego mailing list
> Fuego at lists.linuxfoundation.org
> https://lists.linuxfoundation.org/mailman/listinfo/fuego
More information about the Fuego
mailing list