Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[build] Fix reproducible build issues #8548

Merged
merged 3 commits into from
Aug 26, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .azure-pipelines/docker-sonic-slave.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,9 @@ parameters:
default: sonicdev

variables:
- ${{ if and(startsWith(variables['Build.SourceBranchName'], '202'), eq(length(variables['Build.SourceBranchName']), 6)) }}:
- ${{ if eq(variables['Build.SourceBranchName'], '202012' }}:
- name: BUILD_OPTIONS
value: 'SONIC_VERSION_CONTROL_COMPONENTS=deb,py2,py3,web'
value: 'SONIC_VERSION_CONTROL_COMPONENTS=deb,py2,py3,web,git,docker'

stages:
- stage: Build
Expand Down
2 changes: 1 addition & 1 deletion azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ stages:
variables:
CACHE_MODE: rcache
${{ if eq(variables['Build.SourceBranchName'], '202012') }}:
VERSION_CONTROL_OPTIONS: 'SONIC_VERSION_CONTROL_COMPONENTS=deb,py2,py3,web'
VERSION_CONTROL_OPTIONS: 'SONIC_VERSION_CONTROL_COMPONENTS=deb,py2,py3,web,git,docker'
jobs:
- template: .azure-pipelines/azure-pipelines-build.yml
parameters:
Expand Down
7 changes: 5 additions & 2 deletions scripts/docker_version_control.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,20 +21,23 @@ tag=`echo $image_tag | cut -f2 -d:`

if [[ ",$SONIC_VERSION_CONTROL_COMPONENTS," == *,all,* ]] || [[ ",$SONIC_VERSION_CONTROL_COMPONENTS," == *,docker,* ]]; then
# if docker image not in white list, exit
if [[ "$IMAGENAME" != sonic-slave-* ]] && [[ "$IMAGENAME" != docker-base* ]] && [[ "$IMAGENAME" != debian:* ]] && [[ "$IMAGENAME" != multiarch/debian-debootstrap:* ]];then
if [[ "$image_tag" != */debian:* ]] && [[ "$image_tag" != multiarch/debian-debootstrap:* ]];then
exit 0
fi
if [ -f $version_file ];then
hash_value=`grep "${ARCH}:${image_tag}" $version_file | awk -F== '{print$2}'`
fi
if [ -z $hash_value ];then
hash_value=unknown
echo "$image_tag sha256 value is unknown" >> ${new_version_file}.log
exit 0
fi
oldimage=${image_tag//\//\\/}
newimage="${oldimage}@$hash_value"
echo "sed -i \"s/$oldimage/$newimage/\" $DOCKERFILE" >> ${new_version_file}.log
sed -i "s/$oldimage/$newimage/" $DOCKERFILE
else
hash_value=`docker pull $image_tag | grep Digest | awk '{print$2}'`
hash_value=`docker pull $image_tag 2> ${new_version_file}.log | grep Digest | awk '{print$2}'`
if [ -z hash_value ];then
hash_value=unknown
fi
Expand Down
6 changes: 4 additions & 2 deletions src/sonic-build-hooks/hooks/git
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ get_clone_path(){
done

# if not specific clone path, get default clone path
[ -z $clone_PATH ] && clone_PATH=`echo $URL | rev | awk -F/ '{print$1}' | rev | awk -F. '{print$1}'`
# 1. trim tail slash sign. 2. trim all charactors before the last slash. 3.trim tail '.git'
[ -z $clone_PATH ] && clone_PATH=`echo $URL | sed 's/\/$//' | awk -F/ '{print$NF}' | awk -F. '{print$1}'`
}

main(){
Expand All @@ -62,7 +63,8 @@ main(){
# control version or record version file
if [[ $ENABLE_VERSION_CONTROL_GIT == "y" ]];then
# control version
[ ! -z $commit ] && $REAL_COMMAND reset --hard $commit &> /dev/null
[ -n $commit ] && echo "git reset --hard $commit" >> ${new_version_file}.log
[ -n $commit ] && $REAL_COMMAND reset --hard $commit &> ${new_version_file}.log
else
# record version file
echo "$URL==$commit_latest" >> $new_version_file
Expand Down