forked from APS-Networks/ubuntu-onlp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.sh
executable file
·189 lines (139 loc) · 5.74 KB
/
build.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
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
#! /usr/bin/env bash
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
sudo apt-get install python python-pip g++ libi2c-dev libeditline-dev libedit-dev zlib1g-dev ipmitool
pip install pyaml
export ONL=${SCRIPT_DIR}/OpenNetworkLinuxv2
export ONIE_VENDOR=stordis
export ONL_ARCH=x86-64
export ONL_MACHINE=bf6064x-t
export PLATFORM=${ONL_ARCH}-${ONIE_VENDOR}-${ONL_MACHINE}
export SUBMODULE_INFRA="${ONL}/sm/infra"
export SUBMODULE_BIGCODE="${ONL}/sm/bigcode"
export BUILDER="${SUBMODULE_INFRA}/builder/unix"
export BUILDER_MODULE_DATABASE="${ONL}/modules/modules.json"
export BUILDER_MODULE_DATABASE_ROOT="${ONL}"
export BUILDER_MODULE_MANIFEST="${ONL}/modules/modules.mk"
export CC=gcc
#export CFLAGS="-Wno-error -Wno-error=restrict -Wno-error=format-overflow -Wno-error=cpp -lm -Wl,z,now"
#export CFLAGS="-Wno-error=restrict -Wno-error=format-overflow" # -Wno-error -Wno-error=cpp"
export CFLAGS="-g -O0 -pg"
export NO_USE_GCC_VERSION_TOOL=1
export TOOLCHAIN=x86_64-linux-gnu
export ONL_DEBIAN_SUITE=buster
if [ ! -d ${ONL} ]; then
git clone --depth 1 [email protected]:APS-Networks/OpenNetworkLinuxv2.git $ONL --branch i2c-lock-mutex
cd ${ONL}
${ONL}/tools/submodules.py ${ONL} sm/infra
${ONL}/tools/submodules.py ${ONL} sm/bigcode
${ONL}/tools/submodules.py ${ONL} sm/build-artifacts
cd ${ONL}
git reset --hard
git clean -xfd
cd packages/platforms
# rm -rf accton \
# alphanetworks \
# celestica \
# dell \
# dellemc \
# delta \
# ingrasys \
# inventec \
# kvm \
# lenovo \
# mellanox \
# mitac \
# netberg \
# nxp \
# qemu \
# quanta \
# wnc
patch -p1 < ${SCRIPT_DIR}/patches/editline.patch
else
cd ${ONL}
git clean -xfd
git submodule foreach --recursive git clean -xfd
git reset HEAD --hard
# git submodule foreach --recursive git reset --hard
# git submodule update --init --recursive
git pull
fi
cd ${ONL}
mkdir -p $(dirname ${BUILDER_MODULE_DATABASE})
patch -p1 < ${SCRIPT_DIR}/patches/onlp-i2c.patch
PLATFORM_PATCHES=$(find ${SCRIPT_DIR}/patches/${PLATFORM} -type f -name "*.patch" -o -name "*.diff")
for patch in ${PLATFORM_PATCHES}; do
echo "Applying patch ${patch}"
patch -p1 < $patch
done
BIN_OUTPUT_DIR=/usr/bin
LIB_OUTPUT_DIR=/lib/x86_64-linux-gnu/
BUILD_DIR_ONLPD=${ONL}/packages/base/any/onlp/builds/onlpd/BUILD
BUILD_DIR_ONLPS=${ONL}/packages/platforms/${ONIE_VENDOR}/${ONL_ARCH}/${ONL_MACHINE}/onlp/builds/onlps/BUILD
BUILD_DIR_DEFAULTS=${ONL}/packages/base/any/onlp/builds/onlp-platform-defaults/BUILD
BUILD_DIR_LIB_VENDOR=${ONL}/packages/platforms/${ONIE_VENDOR}/${ONL_ARCH}/${ONL_MACHINE}/onlp/builds/lib/BUILD
BUILD_DIR_LIB_ONLP=${ONL}/packages/base/any/onlp/builds/onlp/BUILD
rm -rf ${BUILD_DIR_ONLPD}
rm -rf ${BUILD_DIR_ONLPS}
rm -rf ${BUILD_DIR_DEFAULTS}
rm -rf ${BUILD_DIR_LIB_VENDOR}
rm -rf ${BUILD_DIR_LIB_ONLP}
cd $ONL
export MODULEMANIFEST=$(${BUILDER}/tools/modtool.py \
--db ${BUILDER_MODULE_DATABASE} \
--dbroot ${BUILDER_MODULE_DATABASE_ROOT} \
--make-manifest ${BUILDER_MODULE_MANIFEST})
read -r -d '' MAKE_ARGS << EOF
VERBOSE=0 \
AR=ar \
ARCH=amd64 \
BUILDER=${BUILDER} \
BUILDER_MODULE_DATABASE=${BUILDER_MODULE_DATABASE} \
BUILDER_MODULE_DATABASE_ROOT=${BUILDER_MODULE_DATABASE_ROOT} \
BUILDER_MODULE_MANIFEST=${BUILDER_MODULE_MANIFEST} \
MODULEMANIFEST=${MODULEMANIFEST} \
GCC=${CC} \
ONL=${ONL} \
ONL_DEBIAN_SUITE=${ONL_DEBIAN_SUITE} \
SUBMODULE_BIGCODE=${SUBMODULE_BIGCODE} \
SUBMODULE_INFRA=${SUBMODULE_INFRA} \
TOOLCHAIN=${TOOLCHAIN} \
PLATFORMS_LIST=${PLATFORM}-r0 \
PLATFORMS=${PLATFORM}-r0 \
ONLPM_OPTION_PLATFORM_WHITELIST=${PLATFORM}-r0
EOF
#cp ../onlplib-i2c.patch .
make -C packages/base/any/onlp/builds -j ${ONL_MAKE_PARALLEL} ${MAKE_ARGS} GCC_FLAGS="${CFLAGS}" alltargets
make -C packages/base/any/onlp/builds/onlpd -j ${ONL_MAKE_PARALLEL} ${MAKE_ARGS} GCC_FLAGS="${CFLAGS}" alltargets
make -C packages/platforms/${ONIE_VENDOR}/${ONL_ARCH}/${ONL_MACHINE}/onlp/builds \
-j ${ONL_MAKE_PARALLEL} ${MAKE_ARGS} GCC_FLAGS="${CFLAGS}" alltargets
cd ${SCRIPT_DIR}
BIN_ONLPD=${BUILD_DIR_ONLPD}/${ONL_DEBIAN_SUITE}/${TOOLCHAIN}/bin/onlpd
BIN_ONLPS=${BUILD_DIR_ONLPS}/${ONL_DEBIAN_SUITE}/${TOOLCHAIN}/bin/onlps
LIB_DEFAULTS=${BUILD_DIR_DEFAULTS}/${ONL_DEBIAN_SUITE}/${TOOLCHAIN}/bin/libonlp-platform-defaults.so
LIB_VENDOR=${BUILD_DIR_LIB_VENDOR}/${ONL_DEBIAN_SUITE}/${TOOLCHAIN}/bin/libonlp-${ONL_ARCH}-${ONIE_VENDOR}-${ONL_MACHINE}.so
LIB_ONLP=${BUILD_DIR_LIB_ONLP}/${ONL_DEBIAN_SUITE}/${TOOLCHAIN}/bin/libonlp.so
LIB_PLATFORM=${OUTPUT_DIR}/lib/libonlp-platform.so
#mkdir -p output/bin
#mkdir -p output/lib
sudo rm -f ${OUTPUT_DIR}/bin/onlpd
sudo rm -f ${OUTPUT_DIR}/bin/onlps
sudo rm -f ${LIB_OUTPUT_DIR}/libonlp-platform-defaults.so
sudo rm -f ${LIB_OUTPUT_DIR}/libonlp-${ONL_ARCH}-${ONIE_VENDOR}-${ONL_MACHINE}.so
sudo rm -f ${LIB_OUTPUT_DIR}/libonlp.so
sudo rm -f ${LIB_OUTPUT_DIR}/libonlp-platform.so
sudo rm -f ${LIB_OUTPUT_DIR}/libonlp.so.1
sudo rm -f ${LIB_OUTPUT_DIR}/libonlp-platform.so.1
sudo rm -f ${LIB_OUTPUT_DIR}/libonlp-platform-defaults.so.1
sudo cp ${BIN_ONLPD} ${OUTPUT_DIR}/bin/.
sudo cp ${BIN_ONLPS} ${OUTPUT_DIR}/bin/.
sudo cp ${LIB_DEFAULTS} ${LIB_OUTPUT_DIR}/.
sudo cp ${LIB_VENDOR} ${LIB_OUTPUT_DIR}/.
sudo cp ${LIB_ONLP} ${LIB_OUTPUT_DIR}/.
cd ${LIB_OUTPUT_DIR}
sudo ln -f -s libonlp-${ONL_ARCH}-${ONIE_VENDOR}-${ONL_MACHINE}.so libonlp-platform.so
sudo ln -f -s libonlp.so libonlp.so.1
sudo ln -f -s libonlp-platform.so libonlp-platform.so.1
sudo ln -f -s libonlp-platform-defaults.so libonlp-platform-defaults.so.1
sudo mkdir -p /etc/onl
echo ${ONL_ARCH}-${ONIE_VENDOR}-${ONL_MACHINE}-r0 | sudo tee /etc/onl/platform
sudo ldconfig