[v1] rootfs: clean up the base-apt list conditionally in the image rootfs

Message ID 20241216055917.1284431-1-srinuvasan.a@siemens.com
State Accepted, archived
Headers show
Series [v1] rootfs: clean up the base-apt list conditionally in the image rootfs | expand

Commit Message

srinuvasan.a Dec. 16, 2024, 5:59 a.m. UTC
From: srinuvasan <srinuvasan.a@siemens.com>

base-apt list is created under /etc/apt/sources.list.d only when we
enable the ISAR_USE_CACHED_BASE_REPO as "1", otherwise, we use the
bootstrap.list

Presently the removal of base-apt.list is happening unconditionally,
hence remove the base-apt list only when we use the local cached repo.

isar-mmdebstrap generates the base-apt list with prefixes 0000 (0000base-apt.list)
and isar-bootstrap generates the base-apt list with no prefixes (base-apt.list)
handle the scenario to remove if any one of the list present under /etc/apt/sources.list.d

Signed-off-by: srinuvasan <srinuvasan.a@siemens.com>
---
 meta/classes/rootfs.bbclass | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

Comments

Uladzimir Bely Dec. 20, 2024, 7:47 a.m. UTC | #1
On Mon, 2024-12-16 at 11:29 +0530, srinuvasan.a via isar-users wrote:
> From: srinuvasan <srinuvasan.a@siemens.com>
> 
> base-apt list is created under /etc/apt/sources.list.d only when we
> enable the ISAR_USE_CACHED_BASE_REPO as "1", otherwise, we use the
> bootstrap.list
> 
> Presently the removal of base-apt.list is happening unconditionally,
> hence remove the base-apt list only when we use the local cached
> repo.
> 
> isar-mmdebstrap generates the base-apt list with prefixes 0000
> (0000base-apt.list)
> and isar-bootstrap generates the base-apt list with no prefixes
> (base-apt.list)
> handle the scenario to remove if any one of the list present under
> /etc/apt/sources.list.d
> 
> Signed-off-by: srinuvasan <srinuvasan.a@siemens.com>
> ---
>  meta/classes/rootfs.bbclass | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/meta/classes/rootfs.bbclass
> b/meta/classes/rootfs.bbclass
> index dd43fd4e..205da640 100644
> --- a/meta/classes/rootfs.bbclass
> +++ b/meta/classes/rootfs.bbclass
> @@ -359,16 +359,16 @@ rootfs_cleanup_isar_apt() {
>          set -e
>          rm -f "${ROOTFSDIR}/etc/apt/sources.list.d/isar-apt.list"
>          rm -f "${ROOTFSDIR}/etc/apt/preferences.d/isar-apt"
> +        rm -f "${ROOTFSDIR}/etc/apt/apt.conf.d/50isar"
>  EOSUDO
>  }
>  
> -ROOTFS_POSTPROCESS_COMMAND += "rootfs_cleanup_base_apt"
> +ROOTFS_POSTPROCESS_COMMAND += "${@'rootfs_cleanup_base_apt' if
> bb.utils.to_boolean(d.getVar('ISAR_USE_CACHED_BASE_REPO')) else ''}"
>  rootfs_cleanup_base_apt[weight] = "2"
>  rootfs_cleanup_base_apt() {
>      sudo -s <<'EOSUDO'
>          set -e
> -        rm -f "${ROOTFSDIR}/etc/apt/sources.list.d/base-apt.list"
> -        rm -f "${ROOTFSDIR}/etc/apt/apt.conf.d/50isar"
> +        rm -f "${ROOTFSDIR}/etc/apt/sources.list.d/*base-apt.list"
>  EOSUDO
>  }
>  
> -- 
> 2.39.5
> 

Applied to next, thanks.

Patch

diff --git a/meta/classes/rootfs.bbclass b/meta/classes/rootfs.bbclass
index dd43fd4e..205da640 100644
--- a/meta/classes/rootfs.bbclass
+++ b/meta/classes/rootfs.bbclass
@@ -359,16 +359,16 @@  rootfs_cleanup_isar_apt() {
         set -e
         rm -f "${ROOTFSDIR}/etc/apt/sources.list.d/isar-apt.list"
         rm -f "${ROOTFSDIR}/etc/apt/preferences.d/isar-apt"
+        rm -f "${ROOTFSDIR}/etc/apt/apt.conf.d/50isar"
 EOSUDO
 }
 
-ROOTFS_POSTPROCESS_COMMAND += "rootfs_cleanup_base_apt"
+ROOTFS_POSTPROCESS_COMMAND += "${@'rootfs_cleanup_base_apt' if bb.utils.to_boolean(d.getVar('ISAR_USE_CACHED_BASE_REPO')) else ''}"
 rootfs_cleanup_base_apt[weight] = "2"
 rootfs_cleanup_base_apt() {
     sudo -s <<'EOSUDO'
         set -e
-        rm -f "${ROOTFSDIR}/etc/apt/sources.list.d/base-apt.list"
-        rm -f "${ROOTFSDIR}/etc/apt/apt.conf.d/50isar"
+        rm -f "${ROOTFSDIR}/etc/apt/sources.list.d/*base-apt.list"
 EOSUDO
 }