ci: update script permissions
[barometer.git] / ci / utility / intel_cmt_cat_build_install_rpm.sh
1 #!/bin/bash
2 # Copyright 2017 Intel Corporation
3 #
4 # Licensed under the Apache License, Version 2.0 (the "License");
5 # you may not use this file except in compliance with the License.
6 # You may obtain a copy of the License at
7 #
8 #     http://www.apache.org/licenses/LICENSE-2.0
9 #
10 # Unless required by applicable law or agreed to in writing, software
11 # distributed under the License is distributed on an "AS IS" BASIS,
12 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 # See the License for the specific language governing permissions and
14 # limitations under the License.
15
16 DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
17 source $DIR/package-list.sh
18
19 VERSION="v0.1.5-1"
20
21 bash $DIR/check_git_repo.sh $CMTCAT_DIR $CMTCAT_REPO
22 if [[ $? != 0 ]]
23 then
24         rm -rf $CMTCAT_DIR
25         git clone --branch $CMTCAT_BRANCH $CMTCAT_REPO $CMTCAT_DIR
26 else
27         cd $CMTCAT_DIR
28         git reset HEAD --hard
29         git pull
30         git checkout -f $CMTCAT_BRANCH
31 fi
32
33 cd $CMTCAT_DIR
34 make
35 sudo make install
36
37 wget https://github.com/01org/intel-cmt-cat/archive/${VERSION}.tar.gz --directory-prefix=$CMTCAT_DIR
38
39 mv $CMTCAT_DIR/${VERSION}.tar.gz $RPM_WORKDIR/SOURCES/
40
41 rpmbuild --define "_topdir $RPM_WORKDIR" -bb $CMTCAT_DIR/rpm/intel-cmt-cat.spec
42
43 rpm -q intel-cmt-cat
44 if [ $? -eq 0 ]
45 then
46         echo "*** intel-cmt-cat is already installed"
47 else
48         RPM_NAME=`ls -1 $RPM_DIR | grep -E "cmt-cat-[0-9]"`
49         sudo rpm -ivf $RPM_DIR/$RPM_NAME
50 fi