diff mbox series

[v6,2/3] automation: Add a clean rule for containers

Message ID b802d2523af791acfdb68b6f8603ff2f0f8573d6.1669904508.git.bertrand.marquis@arm.com (mailing list archive)
State New, archived
Headers show
Series Yocto Gitlab CI | expand

Commit Message

Bertrand Marquis Dec. 1, 2022, 2:25 p.m. UTC
Add make clean support to remove the containers from the local docker
registry.
make clean-<image_name> must be called to remove an image:
make clean-yocto/kirkstone-qemuarm: remove yocto kirkstone for qemuarm
image

Signed-off-by: Bertrand Marquis <bertrand.marquis@arm.com>
---
Changes in v6:
- Rework clean rule to prevent calling docker during make parsing
Changes in v5:
- remove cleaning of all images using make clean
Changes in v4:
- also generate clean rule for CONTAINERS_EXTRA
Changes in v3:
- none
Changes in v2:
- none
Changes in v1:
- patch added
---
 automation/build/Makefile | 10 ++++++++++
 1 file changed, 10 insertions(+)

Comments

Stefano Stabellini Dec. 1, 2022, 9:10 p.m. UTC | #1
On Thu, 1 Dec 2022, Bertrand Marquis wrote:
> Add make clean support to remove the containers from the local docker
> registry.
> make clean-<image_name> must be called to remove an image:
> make clean-yocto/kirkstone-qemuarm: remove yocto kirkstone for qemuarm
> image
> 
> Signed-off-by: Bertrand Marquis <bertrand.marquis@arm.com>

Acked-by: Stefano Stabellini <sstabellini@kernel.org>


> ---
> Changes in v6:
> - Rework clean rule to prevent calling docker during make parsing
> Changes in v5:
> - remove cleaning of all images using make clean
> Changes in v4:
> - also generate clean rule for CONTAINERS_EXTRA
> Changes in v3:
> - none
> Changes in v2:
> - none
> Changes in v1:
> - patch added
> ---
>  automation/build/Makefile | 10 ++++++++++
>  1 file changed, 10 insertions(+)
> 
> diff --git a/automation/build/Makefile b/automation/build/Makefile
> index c4aaa747ffdf..f1d56ce532a1 100644
> --- a/automation/build/Makefile
> +++ b/automation/build/Makefile
> @@ -28,3 +28,13 @@ all: $(CONTAINERS)
>  clean:
>  	rm -f yocto/*.dockerfile
>  
> +define CLEAN_RULE
> +.PHONY: clean-$(1)
> +clean-$(1):
> +	if [ -n "$$$$(docker image ls -q $(REGISTRY)/$(subst /,:,$(1)))" ]; then \
> +		docker image rm $(REGISTRY)/$(subst /,:,$(1)); \
> +	fi
> +
> +endef
> +
> +$(eval $(foreach img,$(CONTAINERS) $(CONTAINERS_EXTRA),$(call CLEAN_RULE,$(img))))
> -- 
> 2.25.1
>
Michal Orzel Dec. 2, 2022, 11:01 a.m. UTC | #2
Hi Bertrand,

On 01/12/2022 15:25, Bertrand Marquis wrote:
> 
> 
> Add make clean support to remove the containers from the local docker
> registry.
> make clean-<image_name> must be called to remove an image:
> make clean-yocto/kirkstone-qemuarm: remove yocto kirkstone for qemuarm
> image
> 
> Signed-off-by: Bertrand Marquis <bertrand.marquis@arm.com>
Reviewed-by: Michal Orzel <michal.orzel@amd.com>

~Michal
diff mbox series

Patch

diff --git a/automation/build/Makefile b/automation/build/Makefile
index c4aaa747ffdf..f1d56ce532a1 100644
--- a/automation/build/Makefile
+++ b/automation/build/Makefile
@@ -28,3 +28,13 @@  all: $(CONTAINERS)
 clean:
 	rm -f yocto/*.dockerfile
 
+define CLEAN_RULE
+.PHONY: clean-$(1)
+clean-$(1):
+	if [ -n "$$$$(docker image ls -q $(REGISTRY)/$(subst /,:,$(1)))" ]; then \
+		docker image rm $(REGISTRY)/$(subst /,:,$(1)); \
+	fi
+
+endef
+
+$(eval $(foreach img,$(CONTAINERS) $(CONTAINERS_EXTRA),$(call CLEAN_RULE,$(img))))