Fix rootfs source list handling in image.bbclass

Message ID 20241127174426.4098-1-vidyasagar.gc@siemens.com
State Accepted, archived
Headers show
Series Fix rootfs source list handling in image.bbclass | expand

Commit Message

Vidyasagar G C Nov. 27, 2024, 5:44 p.m. UTC
Ensure that the APT sources list is only moved if both the sources-list
file and the sources.list.d directory exist. This prevents errors when
APT is not installed, as the sources.list.d directory will be missing.

Signed-off-by: Vidyasagar G C <vidyasagar.gc@siemens.com>
---
 meta/classes/image.bbclass | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Uladzimir Bely Dec. 6, 2024, 7:28 a.m. UTC | #1
On Wed, 2024-11-27 at 23:14 +0530, Vidyasagar G C wrote:
> Ensure that the APT sources list is only moved if both the sources-
> list
> file and the sources.list.d directory exist. This prevents errors
> when
> APT is not installed, as the sources.list.d directory will be
> missing.
> 
> Signed-off-by: Vidyasagar G C <vidyasagar.gc@siemens.com>
> ---
>  meta/classes/image.bbclass | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/meta/classes/image.bbclass b/meta/classes/image.bbclass
> index 472df3cf..31be4267 100644
> --- a/meta/classes/image.bbclass
> +++ b/meta/classes/image.bbclass
> @@ -418,7 +418,7 @@ do_rootfs_finalize() {
>                  -maxdepth 1 -name 'qemu-*-static' -type f -delete
>          fi
>  
> -        if [ -e "${ROOTFSDIR}/etc/apt/sources-list" ]; then
> +        if [ -e "${ROOTFSDIR}/etc/apt/sources-list" ] && [ -e
> "${ROOTFSDIR}/etc/apt/sources-list.d" ]; then
>              mv "${ROOTFSDIR}/etc/apt/sources-list" \
>                  "${ROOTFSDIR}/etc/apt/sources.list.d/bootstrap.list"
>          fi
> -- 
> 2.39.2
> 

Applied to next, thanks.

Patch

diff --git a/meta/classes/image.bbclass b/meta/classes/image.bbclass
index 472df3cf..31be4267 100644
--- a/meta/classes/image.bbclass
+++ b/meta/classes/image.bbclass
@@ -418,7 +418,7 @@  do_rootfs_finalize() {
                 -maxdepth 1 -name 'qemu-*-static' -type f -delete
         fi
 
-        if [ -e "${ROOTFSDIR}/etc/apt/sources-list" ]; then
+        if [ -e "${ROOTFSDIR}/etc/apt/sources-list" ] && [ -e "${ROOTFSDIR}/etc/apt/sources-list.d" ]; then
             mv "${ROOTFSDIR}/etc/apt/sources-list" \
                 "${ROOTFSDIR}/etc/apt/sources.list.d/bootstrap.list"
         fi