Initial repo population
[ric-app/mc.git] / src / sidecars / listener / build_dev_env.sh
1 #!/usr/bin/env bash
2 # vim: ts=4 sw=4 noet:
3 #--------------------------------------------------------------------------------
4 #       Copyright (c) 2018-2019 AT&T Intellectual Property.
5 #
6 #   Licensed under the Apache License, Version 2.0 (the "License");
7 #   you may not use this file except in compliance with the License.
8 #   You may obtain a copy of the License at
9 #
10 #          http://www.apache.org/licenses/LICENSE-2.0
11 #
12 #   Unless required by applicable law or agreed to in writing, software
13 #   distributed under the License is distributed on an "AS IS" BASIS,
14 #   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 #   See the License for the specific language governing permissions and
16 #   limitations under the License.
17 #--------------------------------------------------------------------------------
18
19
20
21 # ---------------------------------------------------------------------------
22 #       Mnemonic:       bld_dev_env.sh
23 #       Abstract:       This script is meant to be executed by a RUN command in
24 #                               a docker file. It fetches NNG, builds/installs it, and then
25 #                               does a wget of the desired RMR version's packages and installs
26 #                               them. RMR is fetched from package cloud.
27 #
28 #       Date:           22 August 2019
29 #       Author:         E. Scott Daniels
30 # ---------------------------------------------------------------------------
31
32 rmr_ver=1.9.0
33 nng_ver=v1.1.1
34
35 while [[ $1 == -* ]]
36 do
37         case $1 in 
38                 -n) nng_ver=$2; shift;;
39                 -r)     rmr_ver=$2; shift;;
40         esac
41
42         shift
43 done
44
45 if [[ $nng_ver != "v"* ]]
46 then
47         nng_ver="v$nng_ver"
48 fi
49
50 set -e                                                  # from this point on crash on any error
51 mkdir -p /playpen/build/nng
52 cd /playpen/build/nng
53 git clone https://github.com/nanomsg/nng.git
54 cd nng
55 git checkout $nng_ver
56 mkdir .build
57 cd .build
58 echo "building nng (messages supressed unless there is an error)"
59
60 set +e
61 if ! cmake ..  >/tmp/cmake.nng.log 2>&1
62 then
63         cat /tmp/cmake.nng.log
64         echo ""
65         echo "### ERROR ### NNG cmake configuration failed"
66         exit 1
67 fi
68
69 if ! make install >/tmp/build.nng.log 2>&1
70 then
71         cat /tmp/build.nng.log
72         echo ""
73         echo "### ERROR ### NNG build failed"
74         exit 1
75 fi
76
77 set -e
78 echo "nng build finished ok"
79 cd /playpen
80 rm -fr /playpen/build/nng
81
82 echo "installing RMR packages version = $rmr_ver"
83 mkdir -p /playpen/build/pkgs
84 cd /playpen/build/pkgs
85
86 base_url=https://packagecloud.io/o-ran-sc/master/packages/debian/stretch/
87 base_url=https://packagecloud.io/o-ran-sc/staging/packages/debian/stretch/
88 pc_url=${base_url}rmr_${rmr_ver}_amd64.deb/download.deb
89 pc_dev_url=${base_url}rmr-dev_${rmr_ver}_amd64.deb/download.deb
90
91 wget -q -O rmr.deb $pc_url
92 wget -q -O rmr-dev.deb $pc_dev_url
93
94 ls -al
95 dpkg -i *.deb
96 cd /playpen
97 rm -fr /playpen/build/pkgs
98 echo "RMR package install finished"