-
Notifications
You must be signed in to change notification settings - Fork 16
/
sonic_202106_apply_patch_ezb_Falcon.sh
150 lines (126 loc) · 4.25 KB
/
sonic_202106_apply_patch_ezb_Falcon.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
#!/bin/bash
# Copyright (c) Marvell, Inc. All rights reservered. Confidential.
# Description: Applying open PRs needed for compilation
#
# patch script for ARM64/Intel Falcon board
#
#
# CONFIGURATIONS:-
#
SONIC_COMMIT="e2b8e2d1da6977592043ec8b48ca4b0b12768f53"
#
# END of CONFIGURATIONS
#
# PREDEFINED VALUES
CUR_DIR=$(basename `pwd`)
LOG_FILE=patches_result.log
FULL_PATH=`pwd`
# Path for 202106 patches
WGET_PATH="https://raw.githubusercontent.com/Marvell-switching/sonic-scripts/master/files/202106/"
# Patches
PATCHES="generic_fixes_or_wa.patch
marvell_arm64_Falcon.patch
marvell_x86.patch
sonic_config_engine.patch"
# Sub module patches
declare -a SUB_PATCHES=(SP1 SP2 SP3 SP4)
declare -A SP1=([NAME]="sonic_swss.patch" [DIR]="src/sonic-swss")
declare -A SP2=([NAME]="sonic_sairedis.patch" [DIR]="src/sonic-sairedis")
declare -A SP3=([NAME]="sonic_utilities.patch" [DIR]="src/sonic-utilities")
declare -A SP4=([NAME]="sonic_linux_kernel.patch" [DIR]="src/sonic-linux-kernel")
log()
{
echo $@
echo $@ >> ${FULL_PATH}/${LOG_FILE}
}
pre_patch_help()
{
log "STEPS TO BUILD:"
log "git clone https://github.com/sonic-net/sonic-buildimage.git -b 202106"
log "cd sonic-buildimage"
log "git checkout $SONIC_COMMIT"
log "make init"
log "<<Apply patches using patch script>>"
log "bash $0"
log "<<FOR ARM64>> make configure PLATFORM=marvell-arm64 PLATFORM_ARCH=arm64"
log "<<FOR INTEL>> make configure PLATFORM=marvell"
log "make all"
}
apply_patches()
{
for patch in $PATCHES
do
echo $patch
pushd patches
wget -c $WGET_PATH/$patch
popd
patch -p1 < patches/$patch
if [ $? -ne 0 ]; then
log "ERROR: Failed to apply patch $patch"
exit 1
fi
done
}
apply_submodule_patches()
{
CWD=`pwd`
for SP in ${SUB_PATCHES[*]}
do
patch=${SP}[NAME]
dir=${SP}[DIR]
echo "${!patch}"
pushd patches
wget -c $WGET_PATH/${!patch}
popd
pushd ${!dir}
patch -p1 < $CWD/patches/${!patch}
if [ $? -ne 0 ]; then
log "ERROR: Failed to apply patch ${!patch}"
exit 1
fi
popd
done
}
apply_hwsku_changes()
{
# Download hwsku
wget -c https://raw.githubusercontent.com/Marvell-switching/sonic-scripts/master/files/mrvl_sonic_hwsku_ezb_falcon.tgz
rm -fr device/marvell/x86_64-marvell_db98cx8580_32cd-r0 || true
rm -fr device/marvell/arm64-marvell_db98cx8580_32cd-r0 || true
rm -fr device/marvell/x86_64-marvell_db98cx8540_16cd-r0 || true
rm -fr device/marvell/arm64-marvell_db98cx8540_16cd-r0 || true
tar -C device/marvell/ -xzf mrvl_sonic_hwsku_ezb_falcon.tgz
cp -dr device/marvell/arm64-marvell_db98cx8580_32cd-r0 device/marvell/x86_64-marvell_db98cx8580_32cd-r0
cp -dr device/marvell/arm64-marvell_db98cx8540_16cd-r0 device/marvell/x86_64-marvell_db98cx8540_16cd-r0
cp -dr device/marvell/arm64-marvell_db98cx8514_10cc-r0 device/marvell/x86_64-marvell_db98cx8514_10cc-r0
rm device/marvell/arm64-marvell_db98cx8580_32cd-r0/plugins/x86_64_sfputil.py
rm device/marvell/arm64-marvell_db98cx8540_16cd-r0/plugins/x86_64_sfputil.py
rm device/marvell/arm64-marvell_db98cx8514_10cc-r0/plugins/x86_64_sfputil.py
mv device/marvell/x86_64-marvell_db98cx8580_32cd-r0/plugins/x86_64_sfputil.py device/marvell/x86_64-marvell_db98cx8580_32cd-r0/plugins/sfputil.py
mv device/marvell/x86_64-marvell_db98cx8540_16cd-r0/plugins/x86_64_sfputil.py device/marvell/x86_64-marvell_db98cx8540_16cd-r0/plugins/sfputil.py
mv device/marvell/x86_64-marvell_db98cx8514_10cc-r0/plugins/x86_64_sfputil.py device/marvell/x86_64-marvell_db98cx8514_10cc-r0/plugins/sfputil.py
}
main()
{
sonic_buildimage_commit=`git rev-parse HEAD`
if [ "$CUR_DIR" != "sonic-buildimage" ]; then
log "ERROR: Need to be at sonic-builimage git clone path"
pre_patch_help
exit
fi
if [ "${sonic_buildimage_commit}" != "$SONIC_COMMIT" ]; then
log "Checkout sonic-buildimage commit to proceed"
log "git checkout ${SONIC_COMMIT}"
pre_patch_help
exit
fi
date > ${FULL_PATH}/${LOG_FILE}
[ -d patches ] || mkdir patches
# Apply patches
apply_patches
# Apply submodule patches
apply_submodule_patches
# Apply hwsku changes
apply_hwsku_changes
}
main $@