From 6324fe15b661fbb384eaa7581eba4bfab109e70e Mon Sep 17 00:00:00 2001 From: Vivek Date: Sat, 23 Mar 2024 16:53:05 -0700 Subject: [PATCH] Add log files into the cache tar for improved debugging (#18026) ### Why I did it Cache currently does not save the log of the deb. But it's useful to have the log to understand any cache related problems. ### How I did it #### How to verify it ``` vkarri@s-build-sonic-01:/sonic-buildimage$ tar -tvf /sonic/sonic_caches/libnl-3-200_3.5.0-1_amd64.deb-adc83b19e793491b1c6ea0f-0ea77d65c49ae3a11dffbca.tgz -rw-r--r-- vkarri/dip 496230 2024-01-12 19:49 target/debs/bookworm/libnl-3-200_3.5.0-1_amd64.deb.log ``` --- Makefile.cache | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Makefile.cache b/Makefile.cache index 2d9858d44a..909f329107 100644 --- a/Makefile.cache +++ b/Makefile.cache @@ -295,10 +295,12 @@ define SAVE_INTO_CACHE echo "Target $(1) dependencies are modifed - global save cache skipped" >> $($(1)_DST_PATH)/$(1).log $(eval $(1)_CACHE_DIR := $(SONIC_DPKG_LOCAL_CACHE_DIR)) ) - $($(1)_CACHE_USER) tar -C $($(1)_BASE_PATH) -mczvf $($(1)_CACHE_DIR)/$(MOD_CACHE_FILE) $(2) $(addprefix $($(1)_DST_PATH)/,$($(1)_DERIVED_DEBS) $($(1)_EXTRA_DEBS) ) \ + cp $($(1)_DST_PATH)/$(1).log $($(1)_DST_PATH)/$(1).cached.log + $($(1)_CACHE_USER) tar -C $($(1)_BASE_PATH) -mczvf $($(1)_CACHE_DIR)/$(MOD_CACHE_FILE) $(2) $(addprefix $($(1)_DST_PATH)/,$($(1)_DERIVED_DEBS) $($(1)_EXTRA_DEBS) $(1).cached.log) \ 1>>$($(1)_DST_PATH)/$(1).log sudo chmod 777 $($(1)_CACHE_DIR)/$(MOD_CACHE_FILE) - + rm -f $($(1)_DST_PATH)/$(1).cached.log + echo "File $($(1)_CACHE_DIR)/$(MOD_CACHE_FILE) saved in cache " >> $($(1)_DST_PATH)/$(1).log echo "[ CACHE::SAVED ] $($(1)_CACHE_DIR)/$(MOD_CACHE_FILE)" >> $($(1)_DST_PATH)/$(1).log