[v8,06/14] deb-dl-dir: Factor out the mounting part

Message ID 20201125134414.26061-2-Vijaikumar_Kanagarajan@mentor.com
State Superseded, archived
Headers show
Series Deb-src caching | expand

Commit Message

Vijai Kumar K Nov. 25, 2020, 3:44 a.m. UTC
Factor out the mount and unmount section to separate function for
easy readability. No functional change intended.

Signed-off-by: Vijai Kumar K <Vijaikumar_Kanagarajan@mentor.com>
---
 meta/classes/deb-dl-dir.bbclass | 32 ++++++++++++++++++++++----------
 1 file changed, 22 insertions(+), 10 deletions(-)

Patch

diff --git a/meta/classes/deb-dl-dir.bbclass b/meta/classes/deb-dl-dir.bbclass
index ce691cf..b2d94e7 100644
--- a/meta/classes/deb-dl-dir.bbclass
+++ b/meta/classes/deb-dl-dir.bbclass
@@ -14,15 +14,30 @@  is_not_part_of_current_build() {
     [ -z "${output}" ]
 }
 
+debsrc_do_mounts() {
+    sudo -s <<EOSUDO
+    mkdir -p "${1}/deb-src"
+    mountpoint -q "${1}/deb-src" || \
+    mount --bind "${DEBSRCDIR}" "${1}/deb-src"
+EOSUDO
+}
+
+debsrc_undo_mounts() {
+    sudo -s <<EOSUDO
+    mkdir -p "${1}/deb-src"
+    mountpoint -q "${1}/deb-src" && \
+    umount -l "${1}/deb-src"
+    rm -rf "${1}/deb-src"
+EOSUDO
+}
+
 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
+
+    debsrc_do_mounts "${rootfs}"
+
     ( flock 9
     set -e
     printenv | grep -q BB_VERBOSE_LOGS && set -x
@@ -37,11 +52,8 @@  EOSUDO
             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
+
+    debsrc_undo_mounts "${rootfs}"
 }
 
 deb_dl_dir_import() {