[1/4] classes: make sure container extension can run multiple times

Message ID 20210728152210.7089-2-henning.schild@siemens.com
State Superseded, archived
Headers show
Series Allow better control over container tags | expand

Commit Message

Henning Schild July 28, 2021, 7:22 a.m. UTC
If the container extension fails somewhere in the middle, it could leave
things behind resulting in issues when trying to run only that one task
again.

So make sure to remove stuff as root and remove another possibly
existing directory.

Signed-off-by: Henning Schild <henning.schild@siemens.com>
---
 meta/classes/image-container-extension.bbclass | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Silvano Cirujano Cuesta July 29, 2021, 12:29 a.m. UTC | #1
On 28/07/2021 17:22, Henning Schild wrote:
> If the container extension fails somewhere in the middle, it could leave
> things behind resulting in issues when trying to run only that one task
> again.
>
> So make sure to remove stuff as root and remove another possibly
> existing directory.
>
> Signed-off-by: Henning Schild <henning.schild@siemens.com>
> ---
>  meta/classes/image-container-extension.bbclass | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/meta/classes/image-container-extension.bbclass b/meta/classes/image-container-extension.bbclass
> index e26604a04f06..6537fc693265 100644
> --- a/meta/classes/image-container-extension.bbclass
> +++ b/meta/classes/image-container-extension.bbclass
> @@ -18,7 +18,7 @@ containerize_rootfs() {
>  
>      # prepare OCI container image skeleton
>      bbdebug 1 "prepare OCI container image skeleton"
> -    rm -rf "${oci_img_dir}"
> +    sudo rm -rf "${oci_img_dir}" "${oci_img_dir}_unpacked"
Correct, since those directory trees are beings created with 'sudo'.
>      sudo umoci init --layout "${oci_img_dir}"
>      sudo umoci new --image "${oci_img_dir}:${empty_tag}"
>      sudo umoci config --image "${oci_img_dir}:${empty_tag}" \

  Silvano Cirujano Cuesta

Patch

diff --git a/meta/classes/image-container-extension.bbclass b/meta/classes/image-container-extension.bbclass
index e26604a04f06..6537fc693265 100644
--- a/meta/classes/image-container-extension.bbclass
+++ b/meta/classes/image-container-extension.bbclass
@@ -18,7 +18,7 @@  containerize_rootfs() {
 
     # prepare OCI container image skeleton
     bbdebug 1 "prepare OCI container image skeleton"
-    rm -rf "${oci_img_dir}"
+    sudo rm -rf "${oci_img_dir}" "${oci_img_dir}_unpacked"
     sudo umoci init --layout "${oci_img_dir}"
     sudo umoci new --image "${oci_img_dir}:${empty_tag}"
     sudo umoci config --image "${oci_img_dir}:${empty_tag}" \