On Friday, February 14, 2020 at 2:11:45 PM UTC+5:30, vijai kumar wrote:


On Friday, February 14, 2020 at 1:49:31 PM UTC+5:30, Jan Kiszka wrote:
On 14.02.20 06:48, Vijai Kumar K wrote:
> Collect the deb sources of the corresponding deb binaries cached
> in DEBDIR as part of postprocess for those to be later included
> into the final base-apt by do_cache.
>

So, inclusion into base-apt will come in a later patch? IOW: It's not
yet clear to me if this patch alone is already useful.

Hi Jan,

The new base-apt rework from Henning would download all the deb and deb-srcs in downloads/deb
download/deb-src directories respectively. The actual repo(using reprepro) is not created until base-apt:do_cache is called. For which
you have to trigger a offline build and set ISAR_USE_CACHED_BASE_REPO.

This patch is an extension to the downloads/deb-src downloading, where in all the source files of all downloaded deb files will cached,
but for it to be converted to repo, base-apt.bb:do_cache needs to be called.

So, basically this is a middle piece of Henning's workflow.


Thanks,
Vijai Kumar K


Thanks,
Jan

> Signed-off-by: Vijai Kumar K <Vijaikumar_...@mentor.com>
> ---
>   meta/classes/image.bbclass  |  2 +-
>   meta/classes/rootfs.bbclass | 29 +++++++++++++++++++++++++++++
>   2 files changed, 30 insertions(+), 1 deletion(-)
>
> diff --git a/meta/classes/image.bbclass b/meta/classes/image.bbclass
> index c5fddba..77306ce 100644
> --- a/meta/classes/image.bbclass
> +++ b/meta/classes/image.bbclass
> @@ -60,7 +60,7 @@ image_do_mounts() {
>   }
>  
>   ROOTFSDIR = "${IMAGE_ROOTFS}"
> -ROOTFS_FEATURES += "copy-package-cache clean-package-cache generate-manifest"
> +ROOTFS_FEATURES += "copy-package-cache clean-package-cache generate-manifest cache-deb-src"
>   ROOTFS_PACKAGES += "${IMAGE_PREINSTALL} ${IMAGE_INSTALL}"
>   ROOTFS_MANIFEST_DEPLOY_DIR ?= "${DEPLOY_DIR_IMAGE}"
>  
> diff --git a/meta/classes/rootfs.bbclass b/meta/classes/rootfs.bbclass
> index c3af7c1..971a299 100644
> --- a/meta/classes/rootfs.bbclass
> +++ b/meta/classes/rootfs.bbclass
> @@ -201,6 +201,35 @@ rootfs_generate_manifest () {
>           ${ROOTFS_MANIFEST_DEPLOY_DIR}/"${PF}".manifest
>   }
>  
> +ROOTFS_POSTPROCESS_COMMAND += "${@bb.utils.contains('ROOTFS_FEATURES', 'cache-deb-src', 'cache_deb_src', '', d)}"
> +cache_deb_src() {
> +    if [ "${ISAR_USE_CACHED_BASE_REPO}" = "1" ]; then
> +        return 0
> +    fi
> +    sudo -s <<'EOSUDO'
> +    sudo cp -L /etc/resolv.conf '${ROOTFSDIR}/etc'
> +    mkdir -p "${DEBSRCDIR}"/"${DISTRO}"
> +    mkdir -p '${ROOTFSDIR}/deb-src'
> +    mountpoint -q '${ROOTFSDIR}/deb-src' || \
> +    mount --bind '${DEBSRCDIR}' '${ROOTFSDIR}/deb-src'
> +EOSUDO
> +    sudo -E chroot ${ROOTFSDIR} /usr/bin/apt-get update
> +    find "${DEBDIR}"/"${DISTRO}" -name '*\.deb' | while read package; do
> +        local pkg="$( dpkg-deb --show --showformat '${Package}' "${package}" )"
> +        local dirname="$( dpkg-deb --show --showformat '${Source}' "${package}" )"
> +        if [ -z "${dirname}" ];then
> +            dirname="$pkg"
> +        fi
> +        sudo -E chroot --userspec=$( id -u ):$( id -g ) ${ROOTFSDIR} \
> +            sh -c 'mkdir -p "/deb-src/${1}/${2}" && cd "/deb-src/${1}/${2}" && apt-get -y source --download-only "$3"' download-src "${DISTRO}" "${dirname}" "${pkg}"
> +    done
> +    sudo -s <<'EOSUDO'
> +    mountpoint -q '${ROOTFSDIR}/deb-src' && \
> +    umount -l ${ROOTFSDIR}/deb-src
> +    sudo rm -rf '${ROOTFSDIR}/etc/resolv.conf'
> +EOSUDO
> +}
> +
>   do_rootfs_postprocess[vardeps] = "${ROOTFS_POSTPROCESS_COMMAND}"
>   python do_rootfs_postprocess() {
>       # Take care that its correctly mounted:
>

--
Siemens AG, Corporate Technology, CT RDA IOT SES-DE
Corporate Competence Center Embedded Linux