Message ID | 20200930060259.12422-4-Vijaikumar_Kanagarajan@mentor.com |
---|---|
State | Superseded, archived |
Headers | show |
Series | Deb-src caching | expand |
On Wed, Sep 30, 2020 at 11:32:49AM +0530, Vijai Kumar K wrote: > diff --git a/meta/classes/image.bbclass b/meta/classes/image.bbclass > index 2391529..6ca5759 100644 > --- a/meta/classes/image.bbclass > +++ b/meta/classes/image.bbclass > @@ -63,7 +63,7 @@ image_do_mounts() { > } > > ROOTFSDIR = "${IMAGE_ROOTFS}" > -ROOTFS_FEATURES += "clean-package-cache generate-manifest" > +ROOTFS_FEATURES += "clean-package-cache generate-manifest cach-deb-src" Should it be "cache-deb-src"? The same for p9. With kind regards, Baurzhan.
On Wednesday, November 25, 2020 at 1:19:36 AM UTC+5:30 i...@radix50.net wrote: > On Wed, Sep 30, 2020 at 11:32:49AM +0530, Vijai Kumar K wrote: > > diff --git a/meta/classes/image.bbclass b/meta/classes/image.bbclass > > index 2391529..6ca5759 100644 > > --- a/meta/classes/image.bbclass > > +++ b/meta/classes/image.bbclass > > @@ -63,7 +63,7 @@ image_do_mounts() { > > } > > > > ROOTFSDIR = "${IMAGE_ROOTFS}" > > -ROOTFS_FEATURES += "clean-package-cache generate-manifest" > > +ROOTFS_FEATURES += "clean-package-cache generate-manifest cach-deb-src" > > Should it be "cache-deb-src"? The same for p9. > Yes. It is cache-deb-src with hypens(-). The original function is with underscore. If you see a better name let me know. We can change it. Thanks, Vijai Kumar K > > With kind regards, > Baurzhan. >
On Thu, Nov 26, 2020 at 02:52:22AM -0800, vijaikumar....@gmail.com wrote: > > > -ROOTFS_FEATURES += "clean-package-cache generate-manifest" > > > +ROOTFS_FEATURES += "clean-package-cache generate-manifest cach-deb-src" > > > > Should it be "cache-deb-src"? The same for p9. > > Yes. It is cache-deb-src with hypens(-). The original function is with > underscore. > > If you see a better name let me know. We can change it. Sorry for the confusion, I meant that ROOTFS_FEATURES mentions cach-deb-src, "cach" without "e". With kind regards, Baurzhan.
On Thursday, November 26, 2020 at 4:33:13 PM UTC+5:30 i...@radix50.net wrote: > On Thu, Nov 26, 2020 at 02:52:22AM -0800, vijaikumar....@gmail.com wrote: > > > > -ROOTFS_FEATURES += "clean-package-cache generate-manifest" > > > > +ROOTFS_FEATURES += "clean-package-cache generate-manifest > cach-deb-src" > > > > > > Should it be "cache-deb-src"? The same for p9. > > > > Yes. It is cache-deb-src with hypens(-). The original function is with > > underscore. > > > > If you see a better name let me know. We can change it. > > Sorry for the confusion, I meant that ROOTFS_FEATURES mentions > cach-deb-src, > "cach" without "e". > Aha. Indeed. Good catch. will fix that in v9. Thanks, Vijai Kumar > > With kind regards, > Baurzhan. >
diff --git a/meta/classes/deb-dl-dir.bbclass b/meta/classes/deb-dl-dir.bbclass index 29a3d67..659fe4b 100644 --- a/meta/classes/deb-dl-dir.bbclass +++ b/meta/classes/deb-dl-dir.bbclass @@ -5,6 +5,33 @@ inherit repository +debsrc_download() { + export rootfs="$1" + export rootfs_distro="$2" + mkdir -p "${DEBSRCDIR}"/"${rootfs_distro}" + sudo -E -s <<'EOSUDO' + mkdir -p "${rootfs}/deb-src" + mountpoint -q "${rootfs}/deb-src" || \ + mount --bind "${DEBSRCDIR}" "${rootfs}/deb-src" +EOSUDO + ( flock 9 + set -e + printenv | grep -q BB_VERBOSE_LOGS && set -x + find "${rootfs}/var/cache/apt/archives/" -maxdepth 1 -type f -iname '*\.deb' | while read package; do + local src="$( dpkg-deb --show --showformat '${source:Package}' "${package}" )" + local version="$( dpkg-deb --show --showformat '${source:Version}' "${package}" )" + + sudo -E chroot --userspec=$( id -u ):$( id -g ) ${rootfs} \ + sh -c ' mkdir -p "/deb-src/${1}/${2}" && cd "/deb-src/${1}/${2}" && apt-get -y --download-only --only-source source "$2"="$3" ' download-src "${rootfs_distro}" "${src}" "${version}" + done + ) 9>"${DEBSRCDIR}/${rootfs_distro}.lock" + sudo -E -s <<'EOSUDO' + mountpoint -q "${rootfs}/deb-src" && \ + umount -l "${rootfs}/deb-src" + rm -rf "${rootfs}/deb-src" +EOSUDO +} + deb_dl_dir_import() { export pc="${DEBDIR}/${2}" export rootfs="${1}" diff --git a/meta/classes/image.bbclass b/meta/classes/image.bbclass index 2391529..6ca5759 100644 --- a/meta/classes/image.bbclass +++ b/meta/classes/image.bbclass @@ -63,7 +63,7 @@ image_do_mounts() { } ROOTFSDIR = "${IMAGE_ROOTFS}" -ROOTFS_FEATURES += "clean-package-cache generate-manifest" +ROOTFS_FEATURES += "clean-package-cache generate-manifest cach-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 6316321..cfabeae 100644 --- a/meta/classes/rootfs.bbclass +++ b/meta/classes/rootfs.bbclass @@ -185,6 +185,14 @@ python do_rootfs_install() { } addtask rootfs_install before do_rootfs_postprocess after do_unpack +ROOTFS_POSTPROCESS_COMMAND += "${@bb.utils.contains('ROOTFS_FEATURES', 'cache-deb-src', 'cache_deb_src', '', d)}" +cache_deb_src() { + rootfs_install_resolvconf + deb_dl_dir_import ${ROOTFSDIR} ${ROOTFS_DISTRO} + debsrc_download ${ROOTFSDIR} ${ROOTFS_DISTRO} + rootfs_install_clean_files +} + ROOTFS_POSTPROCESS_COMMAND += "${@bb.utils.contains('ROOTFS_FEATURES', 'clean-package-cache', 'rootfs_postprocess_clean_package_cache', '', d)}" rootfs_postprocess_clean_package_cache() { sudo -E chroot '${ROOTFSDIR}' \
Collect the deb sources of the corresponding deb binaries cached in DEBDIR as part of image postprocess. Signed-off-by: Vijai Kumar K <Vijaikumar_Kanagarajan@mentor.com> --- meta/classes/deb-dl-dir.bbclass | 27 +++++++++++++++++++++++++++ meta/classes/image.bbclass | 2 +- meta/classes/rootfs.bbclass | 8 ++++++++ 3 files changed, 36 insertions(+), 1 deletion(-)