Skip to content

Commit bd3803d

Browse files
[build] Fix reproducible build issues
1 parent 07a0a09 commit bd3803d

File tree

4 files changed

+11
-6
lines changed

4 files changed

+11
-6
lines changed

.azure-pipelines/docker-sonic-slave.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,9 @@ parameters:
4646
default: sonicdev
4747

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

5353
stages:
5454
- stage: Build

azure-pipelines.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ stages:
3737
variables:
3838
CACHE_MODE: rcache
3939
${{ if eq(variables['Build.SourceBranchName'], '202012') }}:
40-
VERSION_CONTROL_OPTIONS: 'SONIC_VERSION_CONTROL_COMPONENTS=deb,py2,py3,web'
40+
VERSION_CONTROL_OPTIONS: 'SONIC_VERSION_CONTROL_COMPONENTS=deb,py2,py3,web,git,docker'
4141
jobs:
4242
- template: .azure-pipelines/azure-pipelines-build.yml
4343
parameters:

scripts/docker_version_control.sh

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,17 +21,20 @@ tag=`echo $image_tag | cut -f2 -d:`
2121

2222
if [[ ",$SONIC_VERSION_CONTROL_COMPONENTS," == *,all,* ]] || [[ ",$SONIC_VERSION_CONTROL_COMPONENTS," == *,docker,* ]]; then
2323
# if docker image not in white list, exit
24-
if [[ "$IMAGENAME" != sonic-slave-* ]] && [[ "$IMAGENAME" != docker-base* ]] && [[ "$IMAGENAME" != debian:* ]] && [[ "$IMAGENAME" != multiarch/debian-debootstrap:* ]];then
24+
if [[ "$image_tag" != */debian:* ]] && [[ "$image_tag" != multiarch/debian-debootstrap:* ]];then
2525
exit 0
2626
fi
2727
if [ -f $version_file ];then
2828
hash_value=`grep "${ARCH}:${image_tag}" $version_file | awk -F== '{print$2}'`
2929
fi
3030
if [ -z $hash_value ];then
3131
hash_value=unknown
32+
echo "$image_tag sha256 value is unknown" >> ${new_version_file}.log
33+
exit 0
3234
fi
3335
oldimage=${image_tag//\//\\/}
3436
newimage="${oldimage}@$hash_value"
37+
echo "sed -i \"s/$oldimage/$newimage/\" $DOCKERFILE" >> ${new_version_file}.log
3538
sed -i "s/$oldimage/$newimage/" $DOCKERFILE
3639
else
3740
hash_value=`docker pull $image_tag | grep Digest | awk '{print$2}'`

src/sonic-build-hooks/hooks/git

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,8 @@ get_clone_path(){
3939
done
4040

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

4546
main(){
@@ -62,7 +63,8 @@ main(){
6263
# control version or record version file
6364
if [[ $ENABLE_VERSION_CONTROL_GIT == "y" ]];then
6465
# control version
65-
[ ! -z $commit ] && $REAL_COMMAND reset --hard $commit &> /dev/null
66+
[ -n $commit ] && echo "git reset --hard $commit" >> ${new_version_file}.log
67+
[ -n $commit ] && $REAL_COMMAND reset --hard $commit &> ${new_version_file}.log
6668
else
6769
# record version file
6870
echo "$URL==$commit_latest" >> $new_version_file

0 commit comments

Comments
 (0)