-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrunner.sh
More file actions
executable file
·103 lines (74 loc) · 1.74 KB
/
runner.sh
File metadata and controls
executable file
·103 lines (74 loc) · 1.74 KB
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
#!/bin/bash
set -e
echo $6
# fix ruby version
if [ "$5" == "rpm" ]; then
source /opt/rh/rh-ruby27/enable
fi
export GIT_SSL_NO_VERIFY=true
REPO_URL="https://github.com"
echo "start building rpm.."
echo "target url "+$REPO_URL
echo "repo "+$1+$2
echo "branch "+$3
BUILD_DIR=$2"_"$3"_"$5
# create branch dir
rm -rf ~/$BUILD_DIR
echo "create dir $BUILD_DIR"
mkdir ~/$BUILD_DIR
# clone repo
cd ~/$BUILD_DIR/
git clone $REPO_URL/$1/$2.git
cd $2
git checkout $3
# set version
last_tag=$(git rev-list --tags --max-count=1)
echo "Tag version "$ver
if [ -z "$last_tag" ]
then
echo "No tag version"
ver="0.1.0"
else
ver=$(git describe --tags $last_tag)
fi
# if dev - add 4dig commit
if [ "$3" == "master" ]; then
echo "build master version: $ver"
else
cmt=$(git rev-parse --short HEAD)
ver="$ver-$cmt"
echo "build develop version: $ver"
fi
# move to dest
rm -rf ~/$BUILD_DIR/$2/.git
cp -r ~/$BUILD_DIR/$2 /opt/
# execute build script if exists
if [ -f "./install.sh" ]; then
bash ./install.sh
rm -rf /opt/$2/install.sh
fi
# build rpm/deb
if [ -d "/opt/$2/conf-scripts" ]; then
# Control will enter here if $DIRECTORY exists.
fpm -s dir -t $5 -n $2 -v $ver --prefix /opt/$2\
--before-install /opt/$2/conf-scripts/before-install\
--after-install /opt/$2/conf-scripts/after-install\
--before-remove /opt/$2/conf-scripts/before-install\
-C /opt/$2
else
fpm -s dir -t $5 -n $2 -v $ver --prefix /opt/$2\
-C /opt/$2
fi
# mv to repo
if [ "$3" == "master" ]; then
mv ~/$BUILD_DIR/$2/*.$5 ~/$5-master/
else
mv ~/$BUILD_DIR/$2/*.$5 ~/$5-develop/
fi
# remove files
cd ~
rm -rf ~/$BUILD_DIR
# update repo
cd ~/repo_scripts/$5
./update_repo.sh $3
echo "repo $5 updated.."