Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[RFC] image_types_qcom: create image-specific subfolders #122

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions ci/base.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ local_conf_header:
INHERIT += "buildhistory"
INHERIT += "rm_work"
qcomflash: |
IMAGE_CLASSES += "image_types_qcom"
IMAGE_FSTYPES += "qcomflash"
IMAGE_CLASSES += "image_types_qcom image_types_qcom_pkg"
IMAGE_FSTYPES += "qcomflash qcomflashpkg"
extra: |
EXTRA_IMAGE_FEATURES = "allow-empty-password empty-root-password allow-root-login"
IMAGE_ROOTFS_EXTRA_SPACE = "307200"
Expand Down
42 changes: 25 additions & 17 deletions classes-recipe/image_types_qcom.bbclass
Original file line number Diff line number Diff line change
Expand Up @@ -18,59 +18,67 @@ QCOM_DTB_FILE ?= "dtb.bin"
QCOM_ROOTFS_FILE ?= "rootfs.img"
IMAGE_QCOMFLASH_FS_TYPE ??= "ext4"

QCOMFLASH_DIR = "${WORKDIR}/qcomflash"
IMAGE_CMD:qcomflash = "create_qcomflash_pkg"
QCOMFLASH_DIR = "${IMGDEPLOYDIR}/${IMAGE_BASENAME}-${MACHINE}"
IMAGE_CMD:qcomflash = "create_qcomflash"
do_image_qcomflash[dirs] = "${QCOMFLASH_DIR}"
do_image_qcomflash[cleandirs] = "${QCOMFLASH_DIR}"
do_image_qcomflash[depends] += "qcom-gen-partition-bins:do_deploy virtual/kernel:do_deploy \
${@'${QCOM_ESP_IMAGE}:do_image_complete' if d.getVar('QCOM_ESP_IMAGE') != '' else ''}"
IMAGE_TYPEDEP:qcomflash += "${IMAGE_QCOMFLASH_FS_TYPE}"

create_qcomflash_pkg() {
create_image_relative_link () {
filename=$1

if [ -z "$2" ]; then
linkname=$(basename $filename)
else
linkname=$2
fi

ln -sf ../$(basename $filename) $linkname
}

create_qcomflash() {
# esp image
if [ -n "${QCOM_ESP_FILE}" ]; then
install -m 0644 ${DEPLOY_DIR_IMAGE}/${QCOM_ESP_IMAGE}-${MACHINE}.rootfs.vfat ${QCOM_ESP_FILE}
create_image_relative_link ${DEPLOY_DIR_IMAGE}/${QCOM_ESP_IMAGE}-${MACHINE}.rootfs.vfat ${QCOM_ESP_FILE}
fi

# dtb image
if [ -n "${QCOM_DTB_DEFAULT}" ] && \
[ -f "${DEPLOY_DIR_IMAGE}/dtb-${QCOM_DTB_DEFAULT}-image.vfat" ]; then
# default image
install -m 0644 ${DEPLOY_DIR_IMAGE}/dtb-${QCOM_DTB_DEFAULT}-image.vfat ${QCOM_DTB_FILE}
create_image_relative_link ${DEPLOY_DIR_IMAGE}/dtb-${QCOM_DTB_DEFAULT}-image.vfat ${QCOM_DTB_FILE}
# copy all images so they can be made available via the same tarball
for dtbimg in ${DEPLOY_DIR_IMAGE}/dtb-*-image.vfat; do
install -m 0644 ${dtbimg} .
create_image_relative_link ${dtbimg}
done
fi

# rootfs image
install -m 0644 ${IMGDEPLOYDIR}/${IMAGE_LINK_NAME}.${IMAGE_QCOMFLASH_FS_TYPE} ${QCOM_ROOTFS_FILE}
create_image_relative_link ${IMGDEPLOYDIR}/${IMAGE_LINK_NAME}.${IMAGE_QCOMFLASH_FS_TYPE} ${QCOM_ROOTFS_FILE}

# partition bins
for pbin in `find ${DEPLOY_DIR_IMAGE} -type f -name 'gpt_main*.bin' \
-o -name 'gpt_backup*.bin' -o -name 'patch*.xml'`; do
install -m 0644 ${pbin} .
create_image_relative_link ${pbin}
done
# skip BLANK_GPT and WIPE_PARTITIONS for rawprogram xml files
for rawpg in `find ${DEPLOY_DIR_IMAGE} -type f -name 'rawprogram*.xml' \
! -name 'rawprogram*_BLANK_GPT.xml' ! -name 'rawprogram*_WIPE_PARTITIONS.xml'`; do
install -m 0644 ${rawpg} .
create_image_relative_link ${rawpg}
done
for logfs in `find ${DEPLOY_DIR_IMAGE} -type f -name 'logfs_*.bin'`; do
install -m 0644 ${logfs} .
create_image_relative_link ${logfs}
done
for zeros in `find ${DEPLOY_DIR_IMAGE} -type f -name 'zeros_*.bin'`; do
install -m 0644 ${zeros} .
create_image_relative_link ${zeros}
done

# boot firmware
for bfw in `find ${DEPLOY_DIR_IMAGE} -type f -name '*.elf' -o -name '*.mbn' -o -name '*.fv'`; do
install -m 0644 ${bfw} .
create_image_relative_link ${bfw}
done

# Create qcomflash tarball
${IMAGE_CMD_TAR} --sparse --numeric-owner --transform="s,^\./,${IMAGE_BASENAME}-${MACHINE}/," -cf- . | gzip -f -9 -n -c --rsyncable > ${IMGDEPLOYDIR}/${IMAGE_NAME}.qcomflash.tar.gz
ln -sf ${IMAGE_NAME}.qcomflash.tar.gz ${IMGDEPLOYDIR}/${IMAGE_LINK_NAME}.qcomflash.tar.gz
}

create_qcomflash_pkg[vardepsexclude] += "DATETIME"
create_qcomflash[vardepsexclude] += "DATETIME"
16 changes: 16 additions & 0 deletions classes-recipe/image_types_qcom_pkg.bbclass
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Copyright (c) 2023-2024 Qualcomm Innovation Center, Inc. All rights reserved.
# SPDX-License-Identifier: BSD-3-Clause-Clear

inherit image_types

IMAGE_TYPES += "qcomflashpkg"

QCOMFLASH_DIR = "${DEPLOY_DIR_IMAGE}/${IMAGE_BASENAME}-${MACHINE}"
IMAGE_CMD:qcomflashpkg = "create_qcomflash_tarball"
IMAGE_TYPEDEP:qcomflashpkg += "qcomflash"

create_qcomflash_tarball() {
# Create qcomflash tarball
${IMAGE_CMD_TAR} --sparse --numeric-owner --transform="s,^\./,${IMAGE_BASENAME}-${MACHINE}/," -hcf- -C ${QCOMFLASH_DIR} . | gzip -f -9 -n -c --rsyncable > ${IMGDEPLOYDIR}/${IMAGE_NAME}.qcomflash.tar.gz
ln -sf ${IMAGE_NAME}.qcomflash.tar.gz ${IMGDEPLOYDIR}/${IMAGE_LINK_NAME}.qcomflash.tar.gz
}
Loading