root/build-tools/image-utils.sh
Scott Little b2286535c9 Update to build tools to support Build layering.
1: Building rpms now produces an rpm.lst file.  This file serves to
list all rpms produced by the build.  A seperate rpm.lst file
is producede for each build type (std, rt, installer). The file is
co-resident with the matching repodata directory.

The rpm.lst files will need to be published by cengn for each layer build.

The download tools in stx-tools will need to find the rpm.lst files
of lower layer builds, and use it to direct the download of rpms
from the lower layer.

2: Building rpms now produces an image.inc file.  This file serves
to list all rpms that the layer recommends be built into an iso.
The file is stored under the $MY_WORKSPACE/<build-type> subdirectory,
although it has identical content for any build-type.

The image.inc file will need to be published by cengn for each layer
build.

The download tools in stx-tools will need to download the per-layer
image.inc files to the $MY_REPO/cgcs-centos-repo/layer_image_inc/
sub-directory, renaming the file in some layer specific way.

The build-iso tool will process any *.inc files found under
$MY_REPO/cgcs-centos-repo/layer_image_inc/ ,
adding those rpms to the iso.

3) Add a mechanism for layer specific mock.cfg prototypes.
This will allow special handling of the real-time (aka 'rt'),
repositories for layer builds that need to do a 'rt' build.

4) Add support for a $MY_REPO/cgcs-centos-repo/rt subdirectory,
a place to build a repo of real-time rpms originating from
lower layer builds.

The download tools in stx-tools will need to populate the new
rt repos.

As of this writing, non-rt rpms remain in $MY_REPO/cgcs-centos-repo/.
i.e. there is not a new $MY_REPO/cgcs-centos-repo/std/ directory.

5) Some changes to make us more flexible about where we find
realease and bsp files.

6) Found that kernel mudules were not reliably building against
the hearnel-headers of our modified kernel.  Found that adding '--update'
to our mock build command was not working.  Does mock expect '--update'
to only be used independently of a build command?  It does work when
used in that manner, so that's what we will do.

7) The build-pkgs, build-srpms, build-rpms family of commands
can take a layer argument and/or will read the LAYER environment
variable.  Current the only use of this variable is to modify
the build-info.  It does NOT limit the compile to packages
for a specific layer.

Story: 2006166
Task: 37094

Depends-On: https://review.opendev.org/698756
Depends-On: https://review.opendev.org/700819
Change-Id: I817e08a19cdabe08b3fcc47dee63a36b461c13c0
Co-Authored-by: Martin Chen <haochuan.z.chen@intel.com>
Signed-off-by: Scott Little <scott.little@windriver.com>
2020-02-07 16:36:40 -05:00

113 lines
3.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 $GIT_LIST; do
path="$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 $GIT_LIST; do
path="$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> <list_type> <distro> [<layer>]
#
# Parameters:
# build_target: One of 'iso', 'guest' ...
# list_type: One of 'std', 'dev', 'layer'
# distro: One of 'centos', ...
# layer: One of 'compiler', 'distro', 'flock', ...
# Only required if list_type == layer
#
# 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 list_type=$2
local distro=$3
local layer=$4
if [ "${list_type}" = "layer" ]; then
local required_layer_cfg_name="required_layer_${build_target}_inc.cfg"
local layer_cfg_name="${distro}_build_layer.cfg"
local root_dir="${MY_REPO}/../stx-tools/centos-mirror-tools/config/${distro}/${layer}"
local layer_cfgs=""
layer_cfgs=$(find $(for x in $GIT_LIST; do echo $x/; done) -maxdepth 1 -name ${layer_cfg_name})
if [ -f ${root_dir}/${required_layer_cfg_name} ]; then
for line in $(grep -v '^#' ${root_dir}/${required_layer_cfg_name}); do
local lower_layer=${line%%,*}
local url=${line##*,}
grep -q "^${lower_layer}$" $layer_cfgs
if [ $? -ne 0 ]; then
curl ${url}
fi
done | sort --unique
fi
else
local root_dir=""
local root_file=""
local list_type_extension=""
local list_type_extension_bt=""
local search_target=""
if [ "${list_type}" != "std" ]; then
list_type_extension="_${list_type}"
list_type_extension_bt="-${list_type}"
fi
root_dir="${MY_REPO}/build-tools/build_${build_target}"
root_file="${root_dir}/image${list_type_extension_bt}.inc"
search_target=${distro}_${build_target}_image${list_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
fi
}