update_mec_project.bash 6.47 KB
Newer Older
Yann Garcia's avatar
Yann Garcia committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#!/bin/bash

# Debug mode
#set -e
set -vx

# Usage: sudo ./update_mec_project.bash
# TODO Use git clone in temporary directory

OLDPWD=`pwd`

# Execution path
RUN_PATH="${0%/*}"

if [ "${VALIDATION_DIR}" == "" ]
then
17
    VALIDATION_DIR=${HOME}
Yann Garcia's avatar
Yann Garcia committed
18
19
20
21
22
23
24
fi

CHOWN_USER_GROUP=${USER}:${USER}
SRC_MEC_PATH=${VALIDATION_DIR}/dev/STF569_Mec

if [ "${PATH_DEV_MEC}" == "" ]
then
Yann Garcia's avatar
Yann Garcia committed
25
    PATH_DEV_MEC=${HOME}/dev/etsi_mec
Yann Garcia's avatar
Yann Garcia committed
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
fi
echo ${PATH_DEV_MEC}

if [ -d ${PATH_DEV_MEC} ]
then
    if [ -f ${HOME}/tmp/mec.tar.bz2 ]
    then
        mv ${HOME}/tmp/mec.tar.bz2 ${VALIDATION_DIR}/tmp/mec.tar.`date +'%Y%m%d'`.bz2
    fi
    find ${PATH_DEV_MEC} -name "*.o" -exec rm {} \;
    tar jchvf ${HOME}/tmp/mec.tar.bz2 ${PATH_DEV_MEC}
    rm -fr ${PATH_DEV_MEC}
fi

# Check if target directory exist
if [ ! -d ${PATH_DEV_MEC} ]
then
    mkdir -p ${PATH_DEV_MEC}/json ${PATH_DEV_MEC}/framework ${PATH_DEV_MEC}/include ${PATH_DEV_MEC}/bin ${PATH_DEV_MEC}/lib ${PATH_DEV_MEC}/objs ${PATH_DEV_MEC}/src ${PATH_DEV_MEC}/docs
fi

# Update JSON files
echo 'Updating JSON files'
JSON_SRC_PATH=${SRC_MEC_PATH}/json
JSON_DST_PATH=${PATH_DEV_MEC}/json
cp ${JSON_SRC_PATH}/*.json ${JSON_DST_PATH}

# Update ETSI Framework files
echo 'Updating ETSI Framework files'
FWK_SRC_PATH=${SRC_MEC_PATH}/ccsrc
FWK_DST_PATH=${PATH_DEV_MEC}/framework
mkdir -p ${FWK_DST_PATH}/src ${FWK_DST_PATH}/include
chmod -R 775 ${FWK_DST_PATH}
# Create link to TITAN Abstract_Socket
ln -sf $TOP/../titan.TestPorts.Common_Components.Abstract_Socket/src/Abstract_Socket.cc ${FWK_DST_PATH}/src/Abstract_Socket.cc
ln -sf $TOP/../titan.TestPorts.Common_Components.Abstract_Socket/src/Abstract_Socket.hh ${FWK_DST_PATH}/include/Abstract_Socket.hh
FWK_DIR_LIST_HH=`find ${FWK_SRC_PATH}/Protocols/ -name "*.h*" -type f`
FWK_DIR_LIST_THH=`find ${FWK_SRC_PATH}/Protocols/ -name "*.t.h*" -type f`
FWK_DIR_LIST_CC=`find ${FWK_SRC_PATH}/Protocols/ -name "*.c*" -type f`
FWK_DIR_LIST_L=`find ${FWK_SRC_PATH}/Protocols/ -name "*.l" -type f`
FWK_DIR_LIST_Y=`find ${FWK_SRC_PATH}/Protocols/ -name "*.y" -type f`
for i in ${FWK_DIR_LIST_HH}
do
    cp $i ${FWK_DST_PATH}/include
done
for i in ${FWK_DIR_LIST_THH}
do
    cp $i ${FWK_DST_PATH}/include
done
for i in ${FWK_DIR_LIST_CC}
do
    cp $i ${FWK_DST_PATH}/src
done
if [ "${FWK_DIR_LIST_L}" != "" ]
then
    for i in ${FWK_DIR_LIST_L}
    do
        cp $i ${FWK_DST_PATH}/src
    done
fi
if [ "${FWK_DIR_LIST_Y}" != "" ]
then
    for i in ${FWK_DIR_LIST_Y}
    do
        cp $i ${FWK_DST_PATH}/src
    done
fi
FWK_DIR_LIST_HH=`find ${FWK_SRC_PATH}/Framework/ -name "*.h*" -type f`
FWK_DIR_LIST_CC=`find ${FWK_SRC_PATH}/Framework/ -name "*.c*" -type f`
for i in ${FWK_DIR_LIST_HH}
do
    cp $i ${FWK_DST_PATH}/include
done
for i in ${FWK_DIR_LIST_CC}
do
    cp $i ${FWK_DST_PATH}/src
done

# Update ATS TTCN-3 files
echo 'Update TTCN-3 files'
TTCN_3_ORG_PATH=${SRC_MEC_PATH}/ttcn
TTCN_3_DST_PATH=${PATH_DEV_MEC}/src
CC_SRC_PATH=${SRC_MEC_PATH}/ccsrc
Yann Garcia's avatar
Yann Garcia committed
108
TTCN_3_ATS_LIST='AtsMec'
Yann Garcia's avatar
Yann Garcia committed
109
110
111
112
113
114
115
116
for i in ${TTCN_3_ATS_LIST}
do
    if [ ! -d ${TTCN_3_DST_PATH}/$i ]
    then
        mkdir -p ${TTCN_3_DST_PATH}/$i/bin ${TTCN_3_DST_PATH}/$i/lib ${TTCN_3_DST_PATH}/$i/src ${TTCN_3_DST_PATH}/$i/include ${TTCN_3_DST_PATH}/$i/ttcn ${TTCN_3_DST_PATH}/$i/objs ${TTCN_3_DST_PATH}/$i/etc ${TTCN_3_DST_PATH}/$i/docs
        chmod -R 775 ${TTCN_3_DST_PATH}/$i
    fi
    cp ${TTCN_3_ORG_PATH}/$i/*.ttcn ${TTCN_3_DST_PATH}/$i/ttcn
117
    cp ${TTCN_3_ORG_PATH}/../etc/$i/*.cf* ${TTCN_3_DST_PATH}/$i/etc
Yann Garcia's avatar
Yann Garcia committed
118
119
120
121
122
123
124
125
126
    if [ -d ${TTCN_3_ORG_PATH}/../etc_simu ]
    then
        mkdir -p ${TTCN_3_ORG_PATH}/../etc_simu
        cp ${TTCN_3_ORG_PATH}/../etc_simu/$i/*.cfg ${TTCN_3_DST_PATH}/$i/etc_simu
    fi
    cp ${TTCN_3_ORG_PATH}/../docs/$i/o2.cfg ${TTCN_3_DST_PATH}/$i/docs
done

# Update libraries & CC files
Yann Garcia's avatar
Yann Garcia committed
127
TTCN_3_LIB_LIST='LibMec LibMec/LocationAPI LibMec/UEidentityAPI LibMec/RnisAPI LibMec/BwManagementAPI LibMec/Ams LibMec/AppEna LibMec/AppLCM LibMec/Grant LibMec/FixedAccessInformationAPI LibMec/MeoPkgm LibMec/MepmPkgm LibMec/UEAppInterfaceAPI LibMec/UEidentityAPI LibHttp LibCommon'
Yann Garcia's avatar
Yann Garcia committed
128
129
130
131
132
133
134
135
for i in ${TTCN_3_LIB_LIST}
do
    if [ ! -d ${TTCN_3_DST_PATH}/$i ]
    then
        mkdir -p ${TTCN_3_DST_PATH}/$i/docs ${TTCN_3_DST_PATH}/$i/src ${TTCN_3_DST_PATH}/$i/include ${TTCN_3_DST_PATH}/$i/ttcn ${TTCN_3_DST_PATH}/$i/json
    fi
    cp ${TTCN_3_ORG_PATH}/$i/*.ttcn ${TTCN_3_DST_PATH}/$i/ttcn
    # Update files
Yann Garcia's avatar
Yann Garcia committed
136
    if [ "$i" == "LibMec" ]
Yann Garcia's avatar
Yann Garcia committed
137
138
139
    then
        cp ${TTCN_3_ORG_PATH}/$i/ttcn/*.ttcn ${TTCN_3_DST_PATH}/$i/ttcn
        cp ${TTCN_3_ORG_PATH}/$i/json/*.json ${TTCN_3_DST_PATH}/$i/json
Yann Garcia's avatar
Yann Garcia committed
140
        cp ${CC_SRC_PATH}/externals/*_ExternalFunctions.cc ${TTCN_3_DST_PATH}/$i/src
Yann Garcia's avatar
Yann Garcia committed
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
    elif [ "$i" == "LibHttp" ]
    then
        cp ${TTCN_3_ORG_PATH}/LibIts/ttcn/Http/*.ttcn ${TTCN_3_DST_PATH}/$i/ttcn
        cp ${CC_SRC_PATH}/EncDec/$i/*_Encdec.cc ${TTCN_3_DST_PATH}/$i/src
        cp ${CC_SRC_PATH}/Ports/$i/*.hh ${TTCN_3_DST_PATH}/$i/include
        cp ${CC_SRC_PATH}/Ports/$i/*.cc ${TTCN_3_DST_PATH}/$i/src
        cp ${CC_SRC_PATH}/include/$i/*.hh ${TTCN_3_DST_PATH}/$i/include
        cp ${CC_SRC_PATH}/src/$i/*.cc ${TTCN_3_DST_PATH}/$i/src
        # Patch due to svn/gitlab moving
        cp ${SRC_MEC_PATH}/ttcn/patch_lib_http/*.ttcn ${TTCN_3_DST_PATH}/$i/ttcn
    elif [ "$i" == "LibCommon" ]
    then
        cp ${TTCN_3_ORG_PATH}/$i/ttcn/*.ttcn ${TTCN_3_DST_PATH}/$i/ttcn
        # Patch TITAN due to TTCN-3 compiler issues
        cp ${SRC_MEC_PATH}/ttcn/patch_lib_common_titan/*.ttcn ${TTCN_3_DST_PATH}/$i/ttcn
YannGarcia's avatar
YannGarcia committed
156
157
158
    else
        cp ${TTCN_3_ORG_PATH}/$i/ttcn/*.ttcn ${TTCN_3_DST_PATH}/$i/ttcn
        cp ${TTCN_3_ORG_PATH}/$i/json/*.json ${TTCN_3_DST_PATH}/$i/json
Yann Garcia's avatar
Yann Garcia committed
159
160
    fi
done
Yann Garcia's avatar
Yann Garcia committed
161
162
163
164
#######################################################################################
# Remove AtsMec_FixedAccessInformationAPI_TestCases, not supported yet
rm ${TTCN_3_DST_PATH}/AtsMec/ttcn/AtsMec_FixedAccessInfoAPI_TestCases.ttcn
#######################################################################################
Yann Garcia's avatar
Yann Garcia committed
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186

# Apply patches
PATH_PATCHES=`pwd`
if [ -d ${PATH_PATCHES} ]
then
    # Update Mec
    cp ${PATH_PATCHES}/mec_generate_makefile.bash ${PATH_DEV_MEC}/src/AtsMec/bin
    cp ${PATH_PATCHES}/run_mtc.bash ${PATH_DEV_MEC}/src/AtsMec/bin
    cp ${PATH_PATCHES}/run_ptcs.bash ${PATH_DEV_MEC}/src/AtsMec/bin
    cp ${PATH_PATCHES}/run_all.bash ${PATH_DEV_MEC}/src/AtsMec/bin
    cp ${PATH_PATCHES}/run_*_simu.bash ${PATH_DEV_MEC}/src/AtsMec/bin
fi

# Set rights
find ${PATH_DEV_MEC} -type f -exec chmod 664 {} \;
find ${PATH_DEV_MEC} -name "*.bash" -type f -exec chmod 775 {} \;
find ${PATH_DEV_MEC} -type d -exec chmod 775 {} \;
chown -R ${CHOWN_USER_GROUP} ${PATH_DEV_MEC}

cd ${OLDPWD}

exit 0