root/build-tools/image-utils.sh
Scott Little 83d4446d74 Prepare the build tools for code restucturing
Build tools need to be made ready for the code
restructuring:

1) new repos
2) relocation of release-info.inc and bsp files
3) Removal of the stx- prefix from sub-repos.

Changes:
1) Create new functions to find the release-info.inc and
bsp file under both pre and post restructure paths.

2) Update .gitignore to ignore all the new repos that
are to be created.

3) Remove an argument sanity check from build-helm-charts.sh.
It is making invalid assumptions about where applications
can be found in the directory structure.

4) build-iso will need to look to additional repos to find
packages from lower layers.

Change-Id: If62444390d0a5a363974c6ff8cdaceca35978bda
Story: 2006166
Task: 35687
Signed-off-by: Scott Little <scott.little@windriver.com>
2019-09-05 15:18:10 -04:00

87 lines
2.0 KiB
Bash
Executable File

#
# Copyright (c) 2018 Wind River Systems, Inc.
#
# SPDX-License-Identifier: Apache-2.0
#
#
# A place for any functions related to image.inc files
#
IMAGE_UTILS_DIR="$(dirname "$(readlink -f "${BASH_SOURCE[0]}" )" )"
source "${IMAGE_UTILS_DIR}/git-utils.sh"
get_release_info () {
local dir=""
local path=""
for dir in utilities integ stx-utilities stx-integ; do
path="$MY_REPO/stx/$dir/utilities/build-info/release-info.inc"
if [ -f "$path" ]; then
echo "$path"
return 0
fi
done
echo "/invalid-path-to-release-info.inc"
return 1
}
get_bsp_dir () {
local dir=""
local path=""
for dir in stx-metal metal; do
path="$MY_REPO/stx/$dir/bsp-files"
if [ -d "$path" ]; then
echo "$path"
return 0
fi
done
echo "/invalid-path-to-bsp-files"
return 1
}
#
# image_inc_list <build_target> <build_type> <distro>
#
# Parameters:
# build_target: One of 'iso', 'guest' ...
# build_type: One of 'std', 'rt', 'dev' ...
# distro: One of 'centos', ...
#
# Returns: A list of unique package that must be included for
# the desired distro's build target and build type.
# This is the union of the global and per git
# image.inc files.
image_inc_list () {
local build_target=$1
local build_type=$2
local distro=$3
local root_file=""
local build_type_extension=""
local search_target=""
if [ "${build_type}" != "std" ]; then
build_type_extension="_${build_type}"
build_type_extension_bt="-${build_type}"
fi
root_dir="${MY_REPO}/build-tools/build_${build_target}"
root_file="${root_dir}/image${build_type_extension_bt}.inc"
search_target=${distro}_${build_target}_image${build_type_extension}.inc
(
if [ -f ${root_file} ]; then
grep '^[^#]' ${root_file}
fi
for d in $GIT_LIST; do
find $d/ -maxdepth 1 -name "${search_target}" -exec grep '^[^#]' {} +
done
) | sort --unique
}