forked from Unireverse/mlu-ops-ci
-
Notifications
You must be signed in to change notification settings - Fork 0
/
independent_build.sh
213 lines (187 loc) · 7.75 KB
/
independent_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
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
#! /bin/bash
set -e
usage() {
echo "Usage: $0 -t RELEASE_TYPE"
echo "-t release or daily. By default release. If release, need to give module version"
}
python2 json_parser.py
output='dependency.txt'
RELEASE_TYPE="release"
MODULE_VERSION=""
PACKAGE_ARCH="$(uname -m)"
# get the package type
while getopts "t:" opt
do
case $opt in
t) RELEASE_TYPE=$OPTARG;;
*) usage; exit 1;;
esac
done
echo "======================================="
echo "RELEASE_TYPE: "$RELEASE_TYPE
echo "========================================"
if [ "$RELEASE_TYPE" = "release" ]; then
build_version=$(cat build.property|grep "version"|cut -d ':' -f2|cut -d '-' -f1|cut -d '"' -f2|cut -d '.' -f1-3)
else
shortversion=$(cat build.property|grep "version"|cut -d ':' -f2|cut -d '-' -f1|cut -d '"' -f2|cut -d '.' -f1-3)
datetime=$(date +'%Y%m%d_%H%M%S')
commit_commithash=$(git describe --tags --always)
build_version=${shortversion}-${datetime}-${commit_commithash}
fi
echo "build version $build_version for $RELEASE_TYPE"
# dep-package-version
PACKAGE_MODULES=`cat $output | awk -F ':' '{print $1}'`
echo "PACKAGE_MODULES: $PACKAGE_MODULES"
PACKAGE_BRANCH=`cat $output | awk -F ':' '{print $2}'`
echo "PACKAGE_BRANCH: $PACKAGE_BRANCH"
PACKAGE_MODULE_VERS=`cat $output | awk -F ':' '{print $3}'`
echo "PACKAGE_MODULE_VERS: $PACKAGE_MODULE_VERS"
PACKAGE_SERVER="http://daily.software.cambricon.com"
PACKAGE_OS="Linux"
arr_modules=(`echo $PACKAGE_MODULES`)
arr_branch=(`echo $PACKAGE_BRANCH`)
arr_vers=(`echo $PACKAGE_MODULE_VERS`)
n=${#arr_vers[@]}
sub_pkg_to_extract=(cncc cnas cnperf cngdb cndrv cnrt cnbin cnpapi cndev cntoolkit-cloud)
echo "number of dependency: $n"
PACKAGE_EXTRACT_DIR="dep_libs_extract"
if [ -f "/etc/os-release" ]; then
source /etc/os-release
if [ ${ID} == "ubuntu" ]; then
for (( i =0; i < ${n}; i++))
do
PACKAGE_DIST="Ubuntu"
PACKAGE_DIST_VER=${VERSION_ID}
PACKAGE_PATH=${PACKAGE_SERVER}"/"${arr_branch[$i]}"/"${arr_modules[$i]}"/"${PACKAGE_OS}"/"${PACKAGE_ARCH}"/"${PACKAGE_DIST}"/"${PACKAGE_DIST_VER}"/"${arr_vers[$i]}"/"
echo "PACKAGE_PATH: $PACKAGE_PATH"
REAL_PATH=`echo ${PACKAGE_PATH} | awk -F '//' '{print $2}'`
echo "real_path $REAL_PATH"
wget -A deb -m -p -E -k -K -np ${PACKAGE_PATH}
mkdir -p ${PACKAGE_EXTRACT_DIR}
pushd ${PACKAGE_EXTRACT_DIR}
for filename in ../${REAL_PATH}*.deb; do
echo "filename: $filename"
dpkg -x --force-overwrite ${filename} .
echo "test succeuss"
if [ ${arr_modules[$i]} == "cntoolkit" ]; then
pure_ver=`echo ${arr_vers[$i]} | cut -d '-' -f 1`
for pkg in ${sub_pkg_to_extract[@]}
do
fname=$(ls -1 ./var/cntoolkit-${pure_ver}/${pkg}* | grep -E "${pkg}[^[:alnum:]][0-9].*")
echo "extract ${fname}"
dpkg -x --force-overwrite ${fname} ./
done
fi
done
popd
done
elif [ ${ID} == "debian" ]; then
for (( i =0; i < ${n}; i++))
do
PACKAGE_DIST="Debian"
PACKAGE_DIST_VER=${VERSION_ID}
echo "PACKAGE_FILE: $PACKAGE_FILE"
PACKAGE_PATH=${PACKAGE_SERVER}"/"${arr_branch[$i]}"/"${arr_modules[$i]}"/"${PACKAGE_OS}"/"${PACKAGE_ARCH}"/"${PACKAGE_DIST}"/"${PACKAGE_DIST_VER}"/"${arr_vers[$i]}"/"
echo "PACKAGE_PATH: $PACKAGE_PATH"
REAL_PATH=`echo ${PACKAGE_PATH} | awk -F '//' '{print $2}'`
echo "real_path $REAL_PATH"
wget -A deb -m -p -E -k -K -np ${PACKAGE_PATH}
mkdir -p ${PACKAGE_EXTRACT_DIR}
pushd ${PACKAGE_EXTRACT_DIR}
for filename in ../${REAL_PATH}*.deb; do
echo "filename: $filename"
dpkg -x --force-overwrite ${filename} ./
if [ ${arr_modules[$i]} == "cntoolkit" ]; then
pure_ver=`echo ${arr_vers[$i]} | cut -d '-' -f 1`
for pkg in ${sub_pkg_to_extract[@]}
do
fname=$(ls -1 ./var/cntoolkit-${pure_ver}/${pkg}* | grep -E "${pkg}[^[:alnum:]][0-9].*")
echo "extract ${fname}"
dpkg -x --force-overwrite ${fname} ./
done
fi
done
popd
done
elif [ ${ID} == "centos" ]; then
for (( i =0; i < ${n}; i++))
do
PACKAGE_DIST="CentOS"
PACKAGE_DIST_VER=${VERSION_ID}
PACKAGE_PATH=${PACKAGE_SERVER}"/"${arr_branch[$i]}"/"${arr_modules[$i]}"/"${PACKAGE_OS}"/"${PACKAGE_ARCH}"/"${PACKAGE_DIST}"/"${PACKAGE_DIST_VER}"/"${arr_vers[$i]}"/"
echo "PACKAGE_PATH: $PACKAGE_PATH"
REAL_PATH=`echo ${PACKAGE_PATH} | awk -F '//' '{print $2}'`
echo "real_path $REAL_PATH"
wget -A rpm -m -p -E -k -K -np ${PACKAGE_PATH}
mkdir -p ${PACKAGE_EXTRACT_DIR}
pushd ${PACKAGE_EXTRACT_DIR}
for filename in ../${REAL_PATH}*.rpm; do
echo "filename: $filename"
rpm2cpio $filename | cpio -div
if [ ${arr_modules[$i]} == "cntoolkit" ]; then
pure_ver=`echo ${arr_vers[$i]} | cut -d '-' -f 1`
for pkg in ${sub_pkg_to_extract[@]}
do
fname=$(ls -1 ./var/cntoolkit-${pure_ver}/${pkg}* | grep -E "${pkg}[^[:alnum:]][0-9].*")
echo "extract ${fname}"
rpm2cpio ${fname} | cpio -u -di
done
fi
done
popd
done
elif [ ${ID} == "kylin" ]; then
for (( i =0; i < ${n}; i++))
do
PACKAGE_DIST="Kylin"
PACKAGE_DIST_VER=${VERSION_ID}
PACKAGE_PATH=${PACKAGE_SERVER}"/"${arr_branch[$i]}"/"${arr_modules[$i]}"/"${PACKAGE_OS}"/"${PACKAGE_ARCH}"/"${PACKAGE_DIST}"/"${PACKAGE_DIST_VER}"/"${arr_vers[$i]}"/"
echo "PACKAGE_PATH: $PACKAGE_PATH"
REAL_PATH=`echo ${PACKAGE_PATH} | awk -F '//' '{print $2}'`
echo "real_path $REAL_PATH"
wget -A rpm -m -p -E -k -K -np ${PACKAGE_PATH}
mkdir -p ${PACKAGE_EXTRACT_DIR}
pushd ${PACKAGE_EXTRACT_DIR}
for filename in ../${REAL_PATH}*.rpm; do
echo "filename: $filename"
rpm2cpio $filename | cpio -div
if [ ${arr_modules[$i]} == "cntoolkit" ]; then
pure_ver=`echo ${arr_vers[$i]} | cut -d '-' -f 1`
echo "pure_ver: ${pure_ver}"
for lib in var/${arr_modules[$i]}"-"${pure_ver}/*.rpm; do
rpm2cpio $lib | cpio -div
done
fi
done
popd
done
fi
fi
export NEUWARE_HOME=${PWD}/${PACKAGE_EXTRACT_DIR}/usr/local/neuware
export PATH=${PWD}/${PACKAGE_EXTRACT_DIR}/usr/local/neuware/bin:$PATH
export LD_LIBRARY_PATH=${NEUWARE_HOME}/lib64:$LD_LIBRARY_PATH
./build.sh --sub_module=bangc
if [ $? != 0 ]; then
echo "[independent_build.sh] bangc-ops-build failed"
exit 1
fi
echo "[independent_build.sh] bangc-ops-build success"
BUILD_DIR="bangc-ops/build"
BANGCOPS_DIR="bangc-ops"
PACKAGE_DIR="package/usr/local/neuware"
mkdir -p ${PACKAGE_DIR}
mkdir -p ${PACKAGE_DIR}/include
mkdir -p ${PACKAGE_DIR}/lib64
cp -rf ${BUILD_DIR}/lib/libmluops.so* ${PACKAGE_DIR}/lib64
cp bangc-ops/mlu_op.h ${PACKAGE_DIR}/include
TEST_DIR="test_workspace/mluops"
mkdir -p ${TEST_DIR}/build
mkdir -p ${TEST_DIR}/lib
mkdir -p ${TEST_DIR}/test
cp -rf ${BUILD_DIR}/test ${TEST_DIR}/build
cp -rf ${BUILD_DIR}/lib/libgtest_shared.a ${TEST_DIR}/lib
cp -rf ${BUILD_DIR}/lib/libmluop_test_proto.a ${TEST_DIR}/lib
cp -rf ${BANGCOPS_DIR}/test/* ${TEST_DIR}/test
DEPS_DIR=`echo ${PACKAGE_SERVER} | awk -F '//' '{print $2}'`
rm -rf $DEPS_DIR
rm dependency.txt