classes: add stx-image-list.bbclass to generate pkglist

Add stx-image-list.bbclass to generate pkglist automatically
so we don't need to maintain the pkglist manually and the
pkg lists in conf/distro/files/pkglist/ are removed.

After this change, the following pkglist file will be generated:
- For target build:
  tmp/deploy/images/intel-corei7-64/stx-image-aio-intel-corei7-64.pkglist
- For anaconda installer build:
  tmp-glibc/deploy/images/intel-corei7-64/stx-image-aio-installer-intel-corei7-64.stx-image-aio.pkglist

Signed-off-by: Jackie Huang <jackie.huang@windriver.com>
Signed-off-by: Babak Sarashki <Babak.SarAshki@windriver.com>
This commit is contained in:
Jackie Huang 2020-05-30 15:23:16 +08:00 committed by Babak Sarashki
parent 94ccd155d5
commit 1830c3d18d
6 changed files with 83 additions and 11287 deletions

View File

@ -15,8 +15,12 @@ INSTALLER_CONFDIR = "${IMAGE_ROOTFS}/installer-config"
KICKSTART_FILE ??= ""
KICKSTART_FILE_EXTRA ??= ""
WRL_INSTALLER_CONF ?= ""
REPO_INCLUDE_PKG ??= ""
REPO_EXCLUDE_PKG ?= ""
# Extra packages that will be added in the rpm repo in anaconda installer ISO image
REPO_EXTRA_PKG = "\
xfsprogs-* \
glibc-binary-localedata-* \
"
build_iso_prepend() {
install -d ${ISODIR}
@ -61,6 +65,17 @@ wrl_installer_hardlinktree() {
wrl_installer_copy_local_repos() {
deploy_dir_rpm=$1
target_build="$2"
target_image="$3"
target_image_input_pkglist=$(sed -n 's/^IMAGE_LIST="\(.*\)"/\1/p' ${target_build}/installersupport_${target_image})
if [ ! -f ${target_image_input_pkglist} ]; then
bberror "The target image pkglist '${target_image_input_pkglist}' doesn't exist!"
fi
target_image_output_pkglist="${IMGDEPLOYDIR}/${IMAGE_NAME}.${target_image}.pkglist"
target_image_output_pkglist_link="${IMGDEPLOYDIR}/${IMAGE_LINK_NAME}.${target_image}.pkglist"
if [ -d "$deploy_dir_rpm" ]; then
echo "Copy rpms from target build to installer image."
@ -85,20 +100,36 @@ wrl_installer_copy_local_repos() {
done
cd ${deploy_dir_rpm}
for pkg in `cat ${REPO_INCLUDE_PKG}`; do
pkg_file=$(find . -type f -name ${pkg}.rpm)
set -x
# Add the packages in target image pkglist
cat ${target_image_input_pkglist} > ${target_image_output_pkglist}.tmp
# Add the extra packages required by anaconda
for pkgs in ${REPO_EXTRA_PKG}; do
pkg_files=$(find . -type f -name ${pkgs})
if [ -z "${pkg_files}" ]; then
bbwarn "Package ${pkgs} not found, please check if there is anything wrong or just remove it from the list."
else
for pkg_file in ${pkg_files}; do
basename ${pkg_file} >> ${target_image_output_pkglist}.tmp
done
fi
done
cat ${target_image_output_pkglist}.tmp|sort|uniq > ${target_image_output_pkglist}
ln -s ${IMAGE_NAME}.${target_image}.pkglist ${target_image_output_pkglist_link}
rm -f ${target_image_output_pkglist}.tmp
for pkg in $(cat ${target_image_output_pkglist}); do
pkg_file=$(find . -type f -name ${pkg})
if [ -z "${pkg_file}" ]; then
bbwarn "Package ${pkg}.rpm not found, please check if there is anything wrong or just remove it from the list."
bbwarn "Package ${pkg} not found, please check if there is anything wrong or just remove it from the list."
else
cp --parents -vf ${pkg_file} ${IMAGE_ROOTFS}/Packages.$prj_name/
fi
done
cd -
for pkg in ${REPO_EXCLUDE_PKG}; do
rm -rf ${IMAGE_ROOTFS}/Packages.$prj_name/${pkg}
done
createrepo_c --update -q ${IMAGE_ROOTFS}/Packages.$prj_name/
fi
}
@ -187,7 +218,7 @@ _EOF
# Copy local repos while the image is not initramfs
bpn=${BPN}
if [ "${bpn##*initramfs}" = "${bpn%%initramfs*}" ]; then
wrl_installer_copy_local_repos $WORKDIR/oe-rootfs-repo/rpm
wrl_installer_copy_local_repos $WORKDIR/oe-rootfs-repo/rpm $target_build $target_image
fi
echo "$DISTRO::$prj_name::$DISTRO_NAME::$DISTRO_VERSION" >> ${IMAGE_ROOTFS}/.target_build_list
fi

View File

@ -0,0 +1,41 @@
#
## Copyright (C) 2019 Wind River Systems, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
IMAGE_LIST = "${IMGDEPLOYDIR}/${IMAGE_NAME}.rootfs.pkglist"
ROOTFS_POSTPROCESS_COMMAND_append = " write_image_list;"
python write_image_list () {
from oe.rootfs import image_list_installed_packages
deploy_dir = d.getVar('IMGDEPLOYDIR')
link_name = d.getVar('IMAGE_LINK_NAME')
image_list_file = d.getVar('IMAGE_LIST')
pkg_dict = image_list_installed_packages(d)
output = []
for pkg in sorted(pkg_dict):
output.append(pkg_dict[pkg]["filename"])
output_str = '\n'.join(output) + '\n'
with open(image_list_file, 'w+') as image_pkglist:
image_pkglist.write(output_str)
if os.path.exists(image_list_file):
pkglist_link = deploy_dir + "/" + link_name + ".pkglist"
if os.path.lexists(pkglist_link):
os.remove(pkglist_link)
os.symlink(os.path.basename(image_list_file), pkglist_link)
}

View File

@ -38,7 +38,6 @@ IMAGE_ROOTFS_EXTRA_SPACE =" + 102400"
inherit core-image stx-anaconda-image
KICKSTART_FILE ?= "${LAYER_PATH_meta-stx}/conf/distro/files/ks/poky_stx_aio_ks.cfg"
REPO_INCLUDE_PKG ?= "${LAYER_PATH_meta-stx}/conf/distro/files/pkglist/poky-stx-aio-rt-pkg-list.cfg"
# Only the ones prefix with poky_stx_ are tested and working
KICKSTART_FILE_EXTRA ?= " \

View File

@ -38,6 +38,7 @@ IMAGE_FEATURES += " \
ssh-server-openssh \
"
inherit stx-image-list
inherit stx-postrun
inherit extrausers-config
inherit core-image