root/build-tools/update-pxe-network-installer
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

127 lines
5.4 KiB
Bash
Executable File

#!/bin/bash -e
## this script is to update pxeboot images (vmlinuz, initrd.img and squashfs.img).
## based on RPMs generated by "build-pkgs" and "build-iso"
## created by Yong Hu (yong.hu@intel.com), 05/24/2018
find_and_copy_rpm () {
local name="${1}"
local pattern="${2}"
local build_type="${3}"
local dest_dir="${4}"
echo " --> find ${name} rpm"
found=$(find $MY_BUILD_DIR/${build_type}/rpmbuild/RPMS -type f -name "${pattern}" | head -n 1)
if [ ! -n "${found}" ];then
if [ "${build_type}" != "rt" ]; then
found=$(find $MY_REPO/cgcs-centos-repo/Binary -type l -name "${pattern}" | head -n 1)
else
found=$(find $MY_REPO/cgcs-centos-repo/${build_type}/Binary -type l -name "${pattern}" | head -n 1)
fi
fi
if [ -n "${found}" ] && [ -f "${found}" ];then
\cp -f "${found}" "${dest_dir}/"
else
echo "ERROR: failed to find ${name} RPM!"
exit -1
fi
}
echo "Start to update pxe-network-installer images .... "
timestamp=$(date +%F_%H%M)
cur_dir=$PWD
pxe_network_installer_dir=$MY_BUILD_DIR/pxe-network-installer
if [ ! -d $pxe_network_installer_dir ];then
mkdir -p $pxe_network_installer_dir
fi
cd $pxe_network_installer_dir
echo "step 1: copy original images: vmlinuz, initrd.img, squashfs.img"
CENTOS_REPO="cgcs-centos-repo"
orig_img_dir="orig"
if [ ! -d $orig_img_dir ];then
mkdir -p $orig_img_dir
fi
orig_initrd_img="$MY_REPO/$CENTOS_REPO/Binary/images/pxeboot/initrd.img"
if [ -f $orig_initrd_img ]; then
cp -f $orig_initrd_img $pxe_network_installer_dir/$orig_img_dir/.
else
echo "$orig_initrd_img does not exit"
exit -1
fi
orig_squashfs_img="$MY_REPO/$CENTOS_REPO/Binary/LiveOS/squashfs.img"
if [ -f $orig_squashfs_img ]; then
cp -f $orig_squashfs_img $pxe_network_installer_dir/$orig_img_dir/.
else
echo "$orig_squashfs_img does not exit"
exit -1
fi
echo ""
echo "step 2: prepare necessary kernel RPMs"
echo ""
kernel_rpms_std="$pxe_network_installer_dir/kernel-rpms/std"
kernel_rpms_rt="$pxe_network_installer_dir/kernel-rpms/rt"
echo "--> get $kernel_rpms_std ready"
echo "--> get $kernel_rpms_rt ready"
if [ -d $kernel_rpms_std ];then
mv $kernel_rpms_std $kernel_rpms_std-bak-$timestamp
fi
mkdir -p $kernel_rpms_std
if [ -d $kernel_rpms_rt ];then
mv $kernel_rpms_rt $kernel_rpms_rt-bak-$timestamp
fi
mkdir -p $kernel_rpms_rt
echo " -------- start to search standard kernel rpm and related kernel modules --------"
find_and_copy_rpm 'standard kernel' 'kernel-[0-9]*.x86_64.rpm' std "$kernel_rpms_std"
find_and_copy_rpm 'e1000e kernel module' 'kmod-e1000e-[0-9]*.x86_64.rpm' std "$kernel_rpms_std"
find_and_copy_rpm 'i40e kernel module' 'kmod-i40e-[0-9]*.x86_64.rpm' std "$kernel_rpms_std"
find_and_copy_rpm 'ixgbe kernel module' 'kmod-ixgbe-[0-9]*.x86_64.rpm' std "$kernel_rpms_std"
find_and_copy_rpm 'tpm kernel module' 'kmod-tpm-[0-9]*.x86_64.rpm' std "$kernel_rpms_std"
find_and_copy_rpm 'mlnx-ofa kernel module' 'mlnx-ofa_kernel-modules-[0-9]*.x86_64.rpm' std "$kernel_rpms_std"
echo " -------- successfully found standard kernel rpm and related kernel modules --------"
echo ""
rootfs_rpms="$pxe_network_installer_dir/rootfs-rpms"
if [ -d $rootfs_rpms ];then
mv $rootfs_rpms $rootfs_rpms-bak-$timestamp
fi
mkdir -p $rootfs_rpms
echo " step 3: start to search rpms for rootfs"
find_and_copy_rpm 'anaconda' 'anaconda-[0-9]*.x86_64.rpm' installer "$rootfs_rpms/."
find_and_copy_rpm 'anaconda-core' 'anaconda-core-[0-9]*.x86_64.rpm' installer "$rootfs_rpms/."
find_and_copy_rpm 'anaconda-tui' 'anaconda-tui-[0-9]*.x86_64.rpm' installer "$rootfs_rpms/."
find_and_copy_rpm 'anaconda-widgets' 'anaconda-widgets-[0-9]*.x86_64.rpm' installer "$rootfs_rpms/."
find_and_copy_rpm 'rpm' 'rpm-[0-9]*.x86_64.rpm' installer "$rootfs_rpms/."
find_and_copy_rpm 'rpm-build' 'rpm-build-[0-9]*.x86_64.rpm' installer "$rootfs_rpms/."
find_and_copy_rpm 'rpm-build-libs' 'rpm-build-libs-[0-9]*.x86_64.rpm' installer "$rootfs_rpms/."
find_and_copy_rpm 'rpm-libs' 'rpm-libs-[0-9]*.x86_64.rpm' installer "$rootfs_rpms/."
find_and_copy_rpm 'rpm-plugin-systemd-inhibit' 'rpm-plugin-systemd-inhibit-[0-9]*.x86_64.rpm' installer "$rootfs_rpms/."
find_and_copy_rpm 'rpm-python' 'rpm-python-[0-9]*.x86_64.rpm' installer "$rootfs_rpms/."
find_and_copy_rpm 'systemd' 'systemd-[0-9]*.x86_64.rpm' std "$rootfs_rpms/."
find_and_copy_rpm 'systemd-libs' 'systemd-libs-[0-9]*.x86_64.rpm' std "$rootfs_rpms/."
find_and_copy_rpm 'systemd-sysv' 'systemd-sysv-[0-9]*.x86_64.rpm' std "$rootfs_rpms/."
find_and_copy_rpm 'lz4' 'lz4-[0-9]*.x86_64.rpm' std "$rootfs_rpms/."
find_and_copy_rpm 'bind-utils' 'bind-utils-[0-9]*.x86_64.rpm' std "$rootfs_rpms/."
find_and_copy_rpm 'ima-evm-utils' 'ima-evm-utils-[0-9]*.x86_64.rpm' std "$rootfs_rpms/."
echo " ---------------- successfully found rpms for rootfs --------------------------------"
echo "step 4: make installer images in this work dir"
same_folder="$(dirname ${BASH_SOURCE[0]})"
mk_images_tool="$same_folder/make-installer-images.sh"
sudo $mk_images_tool $pxe_network_installer_dir
cd $cur_dir
echo "updating pxe-network-installer images -- done!"