File tree 2 files changed +77
-1
lines changed
src/sonic-build-hooks/hooks
2 files changed +77
-1
lines changed Original file line number Diff line number Diff line change @@ -137,7 +137,7 @@ $(shell CONFIGURED_ARCH=$(CONFIGURED_ARCH) MULTIARCH_QEMU_ENVIRON=$(MULTIARCH_QE
137
137
$(shell BUILD_SLAVE=y scripts/prepare_docker_buildinfo.sh $(SLAVE_BASE_IMAGE) $(SLAVE_DIR)/Dockerfile $(CONFIGURED_ARCH) "" $(BLDENV))
138
138
139
139
# Add the versions in the tag, if the version change, need to rebuild the slave
140
- SLAVE_BASE_TAG = $(shell cat $(SLAVE_DIR)/Dockerfile $(SLAVE_DIR)/buildinfo/versions/versions-* | sha1sum | awk '{print substr($$1,0,11);}')
140
+ SLAVE_BASE_TAG = $(shell cat $(SLAVE_DIR)/Dockerfile $(SLAVE_DIR)/buildinfo/versions/versions-* src/sonic-build-hooks/hooks/* | sha1sum | awk '{print substr($$1,0,11);}')
141
141
SLAVE_TAG = $(shell cat $(SLAVE_DIR)/Dockerfile.user $(SLAVE_DIR)/Dockerfile $(SLAVE_DIR)/buildinfo/versions/versions-* | sha1sum | awk '{print substr($$1,0,11);}')
142
142
143
143
OVERLAY_MODULE_CHECK := \
Original file line number Diff line number Diff line change
1
+ #! /bin/bash
2
+
3
+ parse_config (){
4
+ . /usr/local/share/buildinfo/scripts/buildinfo_base.sh
5
+ REAL_COMMAND=$( get_command git)
6
+
7
+ version_file=$VERSION_PATH /versions-git
8
+ new_version_file=$BUILD_VERSION_PATH /versions-git
9
+
10
+ MODE_CLONE=0
11
+ # parse input parameters
12
+ for i in " $@ "
13
+ do
14
+ if [[ $i == " clone" ]]; then
15
+ MODE_CLONE=1
16
+ fi
17
+ done
18
+ }
19
+
20
+ get_clone_path (){
21
+ # get paremater of clone path
22
+ while (( "$# " )) ; do
23
+ case $1 in
24
+ -b|--branch|--reference|--reference-if-able|-c|--config|--origin|-u|--upload-pack|-j|--jobs|--depth|--dissociate)
25
+ shift 2
26
+ ;;
27
+ clone|-l|--local|--no-hardlinks|-s|--shared|--dissociate|-q|--quiet|-v|--verbose|--progress|--server-option=* |--bare|--sparse|--filter=* |--template=* |--mirror|--reference|--shallow-* |--no-tags|--recurse-submodules* |--remote-submodules|--no-remote-submodules|--separate-git-dir* )
28
+ shift 1
29
+ ;;
30
+ * )
31
+ if [[ $URL == " " ]]; then
32
+ URL=$1
33
+ else
34
+ clone_PATH=$1
35
+ fi
36
+ shift 1
37
+ ;;
38
+ esac
39
+ done
40
+
41
+ # 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}' `
43
+ }
44
+
45
+ main (){
46
+ parse_config " $@ "
47
+
48
+ # execute git.
49
+ $REAL_COMMAND " $@ "
50
+ result=$?
51
+
52
+ # if sub command is not "clone", exit
53
+ if [[ $MODE_CLONE != 1 ]]; then
54
+ exit $result
55
+ fi
56
+
57
+ get_clone_path " $@ "
58
+ pushd $clone_PATH & > /dev/null
59
+ commit_latest=` $REAL_COMMAND log -n 1 | head -n 1| awk ' {print$2}' `
60
+ [ -f $version_file ] && commit=` grep $URL $version_file | awk -F, ' {print$2}' `
61
+
62
+ # control version or record version file
63
+ if [[ $ENABLE_VERSION_CONTROL_GIT == " y" ]]; then
64
+ # control version
65
+ [ ! -z $commit ] && $REAL_COMMAND reset --hard $commit & > /dev/null
66
+ else
67
+ # record version file
68
+ echo " $URL ==$commit_latest " >> $new_version_file
69
+ sort $new_version_file -o $new_version_file -u & > /dev/null
70
+ fi
71
+ popd & > /dev/null
72
+
73
+ exit $result
74
+ }
75
+
76
+ main " $@ "
You can’t perform that action at this time.
0 commit comments