Skip to content

Commit

Permalink
record components version in base os
Browse files Browse the repository at this point in the history
Signed-off-by: Stepan Blyschak <stepanb@nvidia.com>
  • Loading branch information
stepanblyschak committed Mar 25, 2021
1 parent 24d299e commit 3912caf
Show file tree
Hide file tree
Showing 7 changed files with 47 additions and 20 deletions.
19 changes: 9 additions & 10 deletions build_debian.sh
Original file line number Diff line number Diff line change
Expand Up @@ -467,16 +467,15 @@ fi

## Version file
sudo mkdir -p $FILESYSTEM_ROOT/etc/sonic
sudo tee $FILESYSTEM_ROOT/etc/sonic/sonic_version.yml > /dev/null <<EOF
build_version: '${SONIC_IMAGE_VERSION}'
debian_version: '$(cat $FILESYSTEM_ROOT/etc/debian_version)'
kernel_version: '$kversion'
asic_type: $sonic_asic_platform
commit_id: '$(git rev-parse --short HEAD)'
build_date: $(date -u)
build_number: ${BUILD_NUMBER:-0}
built_by: $USER@$BUILD_HOSTNAME
EOF
export build_version="${SONIC_IMAGE_VERSION}"
export debian_version="$(cat $FILESYSTEM_ROOT/etc/debian_version)"
export kernel_version="${kversion}"
export asic_type="${sonic_asic_platform}"
export commit_id="$(git rev-parse --short HEAD)"
export build_date="$(date -u)"
export build_number="${BUILD_NUMBER:-0}"
export built_by="$USER@$BUILD_HOSTNAME"
j2 files/build_templates/sonic_version.yml.j2 | sudo tee $FILESYSTEM_ROOT/etc/sonic/sonic_version.yml

## Copy over clean-up script
sudo cp ./files/scripts/core_cleanup.py $FILESYSTEM_ROOT/usr/bin/core_cleanup.py
Expand Down
20 changes: 20 additions & 0 deletions files/build_templates/sonic_version.yml.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
---
build_version: '{{ build_version }}'
{% if debian_version is defined -%}
debian_version: '{{ debian_version }}'
{% endif -%}
{% if kernel_version is defined -%}
kernel_version: '{{ kernel_version }}'
{% endif -%}
asic_type: {{ asic_type }}
commit_id: '{{ commit_id }}'
build_date: {{ build_date }}
build_number: {{ build_number }}
built_by: {{ built_by }}
{% if components is defined -%}
{% for component in components.split() | unique -%}
{% set name, version = component.split('==') -%}
{{ name }}: {{ version }}
{% endfor -%}
{% endif -%}

15 changes: 7 additions & 8 deletions platform/vs/sonic-version/build_sonic_version.sh
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
tee $1 > /dev/null <<EOF
build_version: '$sonic_version'
asic_type: $sonic_asic_platform
commit_id: '$(git rev-parse --short HEAD)'
build_date: $(date -u)
build_number: ${BUILD_NUMBER:-0}
built_by: $USER@$BUILD_HOSTNAME
EOF
export build_version="${sonic_version}"
export asic_type="${sonic_asic_platform}"
export commit_id="$(git rev-parse --short HEAD)"
export build_date="$(date -u)"
export build_number="${BUILD_NUMBER:-0}"
export built_by="$USER@$BUILD_HOSTNAME"
j2 sonic_version.yml.j2 > $1
1 change: 1 addition & 0 deletions platform/vs/sonic-version/sonic_version.yml.j2
2 changes: 2 additions & 0 deletions rules/functions
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,8 @@ $(2)_MAIN_DEB = $(1)
$(1)_DERIVED_DEBS += $(2)
$(2)_URL = $($(1)_URL)
$(2)_SRC_PATH = $($(1)_SRC_PATH)
$(2)_NAME = $($(1)_NAME)
$(2)_VERSION = $($(1)_VERSION)
SONIC_DERIVED_DEBS += $(2)
endef

Expand Down
6 changes: 5 additions & 1 deletion rules/sonic-utilities.mk
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
# sonic utilities package

SONIC_UTILITIES_PY3 = sonic_utilities-1.2-py3-none-any.whl
SONIC_UTILITIES_PY3_VERSION = 1.2
SONIC_UTILITIES_PY3_NAME = sonic_utilities
SONIC_UTILITIES_PY3 = $(SONIC_UTILITIES_PY3_NAME)-$(SONIC_UTILITIES_PY3_VERSION)-py3-none-any.whl
$(SONIC_UTILITIES_PY3)_SRC_PATH = $(SRC_PATH)/sonic-utilities
$(SONIC_UTILITIES_PY3)_PYTHON_VERSION = 3
$(SONIC_UTILITIES_PY3)_NAME = $(SONIC_UTILITIES_PY3_NAME)
$(SONIC_UTILITIES_PY3)_VERSION = $(SONIC_UTILITIES_PY3_VERSION)
$(SONIC_UTILITIES_PY3)_DEPENDS += $(SONIC_PY_COMMON_PY3) \
$(SWSSSDK_PY3) \
$(SONIC_CONFIG_ENGINE_PY3) \
Expand Down
4 changes: 3 additions & 1 deletion slave.mk
Original file line number Diff line number Diff line change
Expand Up @@ -932,7 +932,9 @@ $(addprefix $(TARGET_PATH)/, $(SONIC_INSTALLERS)) : $(TARGET_PATH)/% : \
export python_swss_debs+=" $(addprefix $(IMAGE_DISTRO_DEBS_PATH)/,$(LIBSWSSCOMMON)) $(addprefix $(IMAGE_DISTRO_DEBS_PATH)/,$(PYTHON_SWSSCOMMON)) $(addprefix $(IMAGE_DISTRO_DEBS_PATH)/,$(PYTHON3_SWSSCOMMON))"
export sonic_utilities_py3_wheel_path="$(addprefix $(PYTHON_WHEELS_PATH)/,$(SONIC_UTILITIES_PY3))"
export sonic_host_services_py3_wheel_path="$(addprefix $(PYTHON_WHEELS_PATH)/,$(SONIC_HOST_SERVICES_PY3))"

export components="$(foreach component,$(notdir $^),\
$(shell [[ ! -z '$($(component)_VERSION)' && ! -z '$($(component)_NAME)' ]] && \
echo $($(component)_NAME)==$($(component)_VERSION)))"
$(foreach docker, $($*_DOCKERS),\
export docker_image="$(docker)"
export docker_image_name="$(basename $(docker))"
Expand Down

0 comments on commit 3912caf

Please sign in to comment.