Skip to content

Commit 1b9b275

Browse files
04.Version cache - debug framework
Added DBGOPT Make variable to enable the cache framework scripts in trace mode. This option takes the part name of the script to enable the particular shell script in trace mode. Multiple shell script names can also be given. Eg: make DBGOPT="image|docker" Added verbose mode to dump the version merge details during build/dry-run mode. Eg: scripts/versions_manager.py freeze -v \ 'dryrun|cmod=docker-swss|cfile=versions-deb|cname=all|stage=sub|stage=add'
1 parent 3434bc6 commit 1b9b275

12 files changed

+186
-33
lines changed

Makefile.work

+4-1
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,7 @@ $(shell \
190190
DISTRO=$(BLDENV) \
191191
SONIC_VERSION_CACHE=$(SONIC_VERSION_CACHE) \
192192
SONIC_VERSION_CACHE_SOURCE=$(SONIC_VERSION_CACHE_SOURCE) \
193+
DBGOPT='$(DBGOPT)' \
193194
scripts/generate_buildinfo_config.sh)
194195

195196
# Generate the slave Dockerfile, and prepare build info for it
@@ -209,6 +210,7 @@ $(shell CONFIGURED_ARCH=$(CONFIGURED_ARCH) \
209210
PREPARE_DOCKER=BUILD_SLAVE=y \
210211
DEFAULT_CONTAINER_REGISTRY=$(DEFAULT_CONTAINER_REGISTRY) \
211212
SONIC_VERSION_CACHE=$(SONIC_VERSION_CACHE) \
213+
DBGOPT='$(DBGOPT)' \
212214
scripts/prepare_docker_buildinfo.sh \
213215
$(SLAVE_BASE_IMAGE) \
214216
$(SLAVE_DIR)/Dockerfile \
@@ -232,13 +234,14 @@ SLAVE_TAG = $(shell \
232234
(cat $(SLAVE_DIR)/Dockerfile.user \
233235
$(SLAVE_DIR)/Dockerfile \
234236
$(SLAVE_DIR)/buildinfo/versions/versions-* \
235-
.git/HEAD \
237+
.git/HEAD 2>/dev/null \
236238
&& echo $(USER)/$(PWD)/$(CONFIGURED_PLATFORM)) \
237239
| sha1sum \
238240
| awk '{print substr($$1,0,11);}')
239241

240242
COLLECT_DOCKER=DEFAULT_CONTAINER_REGISTRY=$(DEFAULT_CONTAINER_REGISTRY) \
241243
SONIC_VERSION_CACHE=$(SONIC_VERSION_CACHE) \
244+
DBGOPT='$(DBGOPT)' \
242245
scripts/collect_docker_version_files.sh \
243246
$(SLAVE_BASE_IMAGE) \
244247
target \

build_debian.sh

+2
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ TARGET_PATH=$TARGET_PATH scripts/build_debian_base_system.sh $CONFIGURED_ARCH $I
8282

8383
# Prepare buildinfo
8484
sudo SONIC_VERSION_CACHE=${SONIC_VERSION_CACHE} \
85+
DBGOPT="${DBGOPT}" \
8586
scripts/prepare_debian_image_buildinfo.sh $CONFIGURED_ARCH $IMAGE_DISTRO $FILESYSTEM_ROOT $http_proxy
8687

8788

@@ -638,6 +639,7 @@ fi
638639

639640
# Collect host image version files before cleanup
640641
SONIC_VERSION_CACHE=${SONIC_VERSION_CACHE} \
642+
DBGOPT="${DBGOPT}" \
641643
scripts/collect_host_image_version_files.sh $CONFIGURED_ARCH $IMAGE_DISTRO $TARGET_PATH $FILESYSTEM_ROOT
642644

643645
# Remove GCC

scripts/build_debian_base_system.sh

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
#!/bin/bash
22

3+
[[ ! -z "${DBGOPT}" && $0 =~ ${DBGOPT} ]] && set -x
4+
35
CONFIGURED_ARCH=$1
46
IMAGE_DISTRO=$2
57
FILESYSTEM_ROOT=$3

scripts/collect_build_version_files.sh

+7
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
#!/bin/bash
22

3+
[[ ! -z "${DBGOPT}" && $0 =~ ${DBGOPT} ]] && set -x
4+
35
RET=$1
46
BLDENV=$2
57
TARGET_PATH=$3
@@ -15,12 +17,17 @@ TIMESTAMP=$(date +"%Y%m%d%H%M%S")
1517
VERSION_BUILD_PATH=$TARGET_PATH/versions/build
1618
VERSION_SLAVE_PATH=$VERSION_BUILD_PATH/build-sonic-slave-${BLDENV}
1719
LOG_VERSION_PATH=$VERSION_BUILD_PATH/log-${TIMESTAMP}
20+
DEFAULT_VERSION_PATH=files/build/versions/default
21+
BUILD_LOG_PATH=/sonic/target/versions/log/sonic-slave-${BLDENV}/
1822

1923
sudo chmod -R a+rw $BUILDINFO_PATH
2024
collect_version_files $LOG_VERSION_PATH
2125
([ -d $BUILD_VERSION_PATH ] && [ ! -z "$(ls $BUILD_VERSION_PATH/)" ]) && cp -rf $BUILD_VERSION_PATH/* $LOG_VERSION_PATH/
2226
mkdir -p $VERSION_SLAVE_PATH
2327

28+
mkdir -p ${BUILD_LOG_PATH}
29+
([ -d ${LOG_PATH} ] && [ ! -z "$(ls ${LOG_PATH})" ]) && cp ${LOG_PATH}/* ${BUILD_LOG_PATH}
30+
2431
scripts/versions_manager.py merge -t $VERSION_SLAVE_PATH -b $LOG_VERSION_PATH -e $POST_VERSION_PATH
2532

2633
[ -d $BUILD_VERSION_PATH ] && rm -rf $BUILD_VERSION_PATH/*

scripts/collect_docker_version_files.sh

+6
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
#!/bin/bash
22

3+
[[ ! -z "${DBGOPT}" && $0 =~ ${DBGOPT} ]] && set -x
4+
35
BUILDINFO_BASE=/usr/local/share/buildinfo
46

57
SCRIPT_SRC_PATH=src/sonic-build-hooks
@@ -21,6 +23,8 @@ DOCKER_IMAGE_NAME=$(echo $DOCKER_IMAGE | cut -d: -f1 | sed "s/-$DOCKER_USERNAME\
2123
#Create the container specific to the user tag and slave tag
2224
DOCKER_CONTAINER=${DOCKER_IMAGE_TAG/:/-}
2325
TARGET_VERSIONS_PATH=$TARGET_PATH/versions/dockers/$DOCKER_IMAGE_NAME
26+
BUILD_LOG_PATH=target/versions/log/$DOCKER_IMAGE_NAME
27+
mkdir -p ${BUILD_LOG_PATH}
2428

2529
[ -d $TARGET_VERSIONS_PATH ] && rm -rf $TARGET_VERSIONS_PATH
2630
mkdir -p $TARGET_VERSIONS_PATH
@@ -42,5 +46,7 @@ docker tag ${DOCKER_IMAGE_TAG} tmp-${DOCKER_IMAGE_TAG}
4246
DOCKER_BUILDKIT=1 docker build -f ${DOCKER_PATH}/Dockerfile.cleanup --target output -o target/vcache/${DOCKER_IMAGE_NAME} ${DOCKER_PATH}
4347
DOCKER_BUILDKIT=1 docker build -f ${DOCKER_PATH}/Dockerfile.cleanup --no-cache --target final --tag ${DOCKER_IMAGE_TAG} ${DOCKER_PATH}
4448
docker rmi tmp-${DOCKER_IMAGE_TAG}
49+
docker cp -L $DOCKER_CONTAINER:/usr/local/share/buildinfo/log ${BUILD_LOG_PATH}/
50+
4551

4652
docker container rm $DOCKER_CONTAINER

scripts/collect_host_image_version_files.sh

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
#!/bin/bash
22

3+
[[ ! -z "${DBGOPT}" && $0 =~ ${DBGOPT} ]] && set -x
4+
35
SCRIPT_SRC_PATH=src/sonic-build-hooks
46
if [ -e ${SCRIPT_SRC_PATH} ]; then
57
. ${SCRIPT_SRC_PATH}/scripts/utils.sh

scripts/prepare_debian_image_buildinfo.sh

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
#!/bin/bash
22

3+
[[ ! -z "${DBGOPT}" && $0 =~ ${DBGOPT} ]] && set -x
4+
35

46
ARCH=$1
57
DISTRO=$2

scripts/prepare_docker_buildinfo.sh

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
#!/bin/bash
22

3+
[[ ! -z "${DBGOPT}" && $0 =~ ${DBGOPT} ]] && set -x
4+
35
BUILDINFO_BASE=/usr/local/share/buildinfo
46

57
SCRIPT_SRC_PATH=src/sonic-build-hooks

scripts/prepare_slave_container_buildinfo.sh

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
#!/bin/bash
22

3+
[[ ! -z "${DBGOPT}" && $0 =~ ${DBGOPT} ]] && set -x
4+
35
SLAVE_DIR=$1
46
ARCH=$2
57
DISTRO=$3

0 commit comments

Comments
 (0)