aboutsummaryrefslogtreecommitdiffstats
path: root/test/mocks/emssimulator/pnf-sw-upgrade-cba-builder/build-cba-for-pnf-sw-upgrade-with-em.sh
blob: 76102c3b1ea686faea075b37dff0c7cb13f59959 (plain)
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
#!/bin/bash

#  ============LICENSE_START=======================================================
#  Copyright (C) 2020 Huawei Technologies Co., Ltd. All rights reserved.
#  ================================================================================
#  Licensed under the Apache License, Version 2.0 (the "License");
#  you may not use this file except in compliance with the License.
#  You may obtain a copy of the License at
#
#       http://www.apache.org/licenses/LICENSE-2.0
#
#  Unless required by applicable law or agreed to in writing, software
#  distributed under the License is distributed on an "AS IS" BASIS,
#  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#  See the License for the specific language governing permissions and
#  limitations under the License.
#  ============LICENSE_END=========================================================

set -euo pipefail

readonly SOURCE_CBA="PNF_CDS_RESTCONF"
readonly TARGET_CBA="PNF_SW_UPGRADE_WITH_EM"
readonly CDS_CODE_DIR="cds-codes-for-pnf-sw-upgrade"

function use_specific_commit()
{
    local commit_id="$1"
    cd ${CDS_CODE_DIR}
    local tmp_branch="get-cba-for-pnf-sw-upgrade"
    if ! git branch | grep -q "${tmp_branch}"; then
        git checkout -b ${tmp_branch} ${commit_id}
    else
        git checkout -q ${tmp_branch}
    fi
    cd ${OLDPWD}
}

if [ ! -e ${CDS_CODE_DIR} ]; then
    git clone https://gerrit.onap.org/r/ccsdk/cds ${CDS_CODE_DIR}
else
    cd ${CDS_CODE_DIR}
	code_status=`git status -s`
    if [ -n "${code_status}" ]; then
        echo "Please keep the CDS codes are not modified."
        exit 1
    fi
    cd ${OLDPWD}
fi

# Lock the version of source CBA files
use_specific_commit f4ac359d80d043a2d0e6eaf1730813b81f2c837f

if [ -e ${TARGET_CBA} -o -e ${TARGET_CBA}.zip ]; then
    echo "${TARGET_CBA} or ${TARGET_CBA}.zip has existed, please rename or delete them."
    exit 1
fi

cp -ir ${CDS_CODE_DIR}/components/model-catalog/blueprint-model/uat-blueprints/${SOURCE_CBA} ${TARGET_CBA}
cp -ir patches ${TARGET_CBA}

cd ${TARGET_CBA}

mv Definitions/PNF_CDS_RESTCONF.json Definitions/PNF_SW_UPGRADE_WITH_EM.json
mv Templates/pnf-swug-config-template.vtl Templates/pnf-swug-activate-ne-sw-template.vtl

for p in patches/*.patch; do
    patch -p1 -i $p
done

rm -rf patches

zip -r ${TARGET_CBA}.zip .

cd ${OLDPWD}

mv -i ${TARGET_CBA}/${TARGET_CBA}.zip .