-
Notifications
You must be signed in to change notification settings - Fork 19
/
package.sh
executable file
·211 lines (195 loc) · 8.06 KB
/
package.sh
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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
#!/bin/sh
# --------------------------------------------------------------------------------
# This script is building packages for Alignak thanks to the fpm
# application (https://github.com/jordansissel/fpm).
# -----
# Using this script and fpm requires:
# sudo apt-get install ruby ruby-dev rubygems build-essential
# sudo gem install --no-ri --no-rdoc fpm
# -----
# This script updates the .bintray-*.json file to update:
# - the target repo, replacing sed_version_repo with the appropriate
# repository name: alignak-deb-testing or alignak-deb-stable
# - the version name, description and release date, replacing
# sed_version_name, sed_version_desc and sed_version_released
# -----
# Command line parameters:
# - git branch name:
# - master will build a stable version (alignak_deb-stable repository)
# -> python-alignak_x.x.x_all.deb
# - develop will build a develop version (alignak_deb-testing repository)
# -> python-alignak_x.x.x-dev_all.deb
# - any other will build a develop named version (alignak_deb-testing repository)
# -> python-alignak_x.x.x-mybranch_all.deb
#
# Note that it is not recommended to use anything else than alphabetic characters in the
# branch name according to the debian version name policy! Else, the package will not even
# install on the system!
#
# - python version:
# 2.7, 3.5 (when called from the Travis build, it is the most recent python 3 version)
#
# - package type:
# deb (default), rpm, freebsd, apk, pacman, ...
# Indeed all the package types supported by fpm
# --------------------------------------------------------------------------------
#set -ev
# Parse command line arguments
# Default is branch develop, python 3.5
git_branch=$1
python_version=$2
input_type="python"
output_type=$3
if [ $# -eq 0 ]; then
git_branch="develop"
python_version="3.5"
output_type="deb"
fi
if [ $# -eq 1 ]; then
python_version="3.5"
output_type="deb"
fi
if [ $# -eq 2 ]; then
output_type="deb"
fi
echo "Installing fpm..."
gem install --no-ri --no-rdoc fpm
echo "Building ${output_type} package for branch ${git_branch}, python version ${python_version}"
# Python prefix - no more used but kept for compatibility
python_prefix="python3"
systemd_service="python3/alignak.service"
if [ "${python_version}" = "2.7" ]; then
python_prefix="python"
systemd_service="python2/alignak.service"
# python_version="2"
#else
# python_version="3"
fi
# Package information - no more python-prefix but kept for compatibility
pkg_name="${python_prefix}-alignak"
pkg_description="Alignak, modern Nagios compatible monitoring framework"
pkg_url="http://alignak.net"
pkg_team="Alignak Team (contact@alignak.net)"
version=`python -c "from alignak import __version__;print(__version__)"`
version_date=`date "+%Y-%m-%d"`
mkdir -p dist
cp .bintray-${output_type}.json dist/.bintray-${output_type}.json
if [ "${git_branch}" = "master" ]; then
# Updating deploy script for Alignak stable version
sed -i -e "s|\"sed_package_name\"|\"${pkg_name}\"|g" dist/.bintray-${output_type}.json
sed -i -e "s|\"sed_version_name\"|\"${version}\"|g" dist/.bintray-${output_type}.json
sed -i -e "s|\"sed_version_desc\"|\"Stable version\"|g" dist/.bintray-${output_type}.json
sed -i -e "s|\"sed_version_released\"|\"${version_date}\"|g" dist/.bintray-${output_type}.json
# Stable repo
sed -i -e "s/sed_version_repo/alignak-${output_type}-stable/g" dist/.bintray-${output_type}.json
elif [ "${git_branch}" = "develop" ]; then
# Version is version number + develop
version="${version}-develop"
# version="-dev"
# Updating deploy script for Alignak develop version
sed -i -e "s|\"sed_package_name\"|\"${pkg_name}\"|g" dist/.bintray-${output_type}.json
sed -i -e "s|\"sed_version_name\"|\"${version}-${version_date}\"|g" dist/.bintray-${output_type}.json
sed -i -e "s|\"sed_version_desc\"|\"Development version for ${python_prefix}\"|g" dist/.bintray-${output_type}.json
sed -i -e "s|\"sed_version_released\"|\"${version_date}\"|g" dist/.bintray-${output_type}.json
# Use the testing repo
sed -i -e "s/sed_version_repo/alignak-${output_type}-testing/g" dist/.bintray-${output_type}.json
else
# Version is version number + branch name
version="${version}-${git_branch}"
# version="${git_branch}"
# Updating deploy script for any other branch / tag
sed -i -e "s|\"sed_package_name\"|\"${pkg_name}\"|g" dist/.bintray-${output_type}.json
sed -i -e "s|\"sed_version_name\"|\"${version}-${version_date}\"|g" dist/.bintray-${output_type}.json
sed -i -e "s|\"sed_version_desc\"|\"Branch $1 version for ${python_prefix}\"|g" dist/.bintray-${output_type}.json
sed -i -e "s|\"sed_version_released\"|\"${version_date}\"|g" dist/.bintray-${output_type}.json
# Use the testing repo
sed -i -e "s/sed_version_repo/alignak-${output_type}-testing/g" dist/.bintray-${output_type}.json
fi
echo "----------"
echo "BinTray configuration file:"
echo "----------"
cat dist/.bintray-${output_type}.json
echo "----------"
# Run fpm:
# Add --verbose for a verbose (very...) mode to have more information
# - from python to deb packages, for all architectures
# Use python dependencies - all Alignak python packages
# are packaged in the main distros so it will use the
# distro packages rather than the python one
# Force python interpreter else Travis deployment will use its own venv interpreter!
echo "Running fpm..."
if [ "${output_type}" = "deb" ]; then
fpm \
--force \
--input-type ${input_type} \
--output-type ${output_type} \
--package "./dist" \
--architecture all \
--license AGPL \
--version ${version} \
--name "${pkg_name}" \
--description "${pkg_description}" \
--url "${pkg_url}" \
--vendor "${pkg_team}" \
--maintainer "${pkg_team}" \
--python-package-name-prefix "${python_prefix}" \
--python-scripts-executable "/usr/bin/env python" \
--python-install-lib "/usr/local/lib/python${python_version}/site-packages" \
--python-install-data '/usr/local' \
--python-install-bin '/usr/local/bin' \
--no-python-dependencies \
--after-install "./bin/${python_prefix}-post-install.sh" \
--deb-no-default-config-files \
--deb-systemd ./bin/systemd/alignak-arbiter@.service \
--deb-systemd ./bin/systemd/alignak-broker@.service \
--deb-systemd ./bin/systemd/alignak-poller@.service \
--deb-systemd ./bin/systemd/alignak-reactionner@.service \
--deb-systemd ./bin/systemd/alignak-receiver@.service \
--deb-systemd ./bin/systemd/alignak-scheduler@.service \
--deb-systemd ./bin/systemd/alignak.service \
--deb-no-default-config-files \
./setup.py
elif [ "${output_type}" = "rpm" ]; then
fpm \
--force \
--input-type ${input_type} \
--output-type ${output_type} \
--package "./dist" \
--architecture all \
--license AGPL \
--version ${version} \
--name "${pkg_name}" \
--description "${pkg_description}" \
--url "${pkg_url}" \
--vendor "${pkg_team}" \
--maintainer "${pkg_team}" \
--python-package-name-prefix "${python_prefix}" \
--python-scripts-executable "/usr/bin/env python" \
--python-install-lib "/usr/lib/python${python_version}/site-packages" \
--python-install-data '/usr/local' \
--python-install-bin '/usr/local/bin' \
--no-python-dependencies \
--after-install "./bin/${python_prefix}-post-install.sh" \
./setup.py
else
fpm \
--force \
--input-type ${input_type} \
--output-type ${output_type} \
--package "./dist" \
--architecture all \
--license AGPL \
--version ${version} \
--name "${pkg_name}" \
--description "${pkg_description}" \
--url "${pkg_url}" \
--vendor "${pkg_team}" \
--maintainer "${pkg_team}" \
--python-scripts-executable "/usr/bin/env python" \
--python-install-lib "/usr/local/lib/python${python_version}/site-packages" \
--python-install-data '/usr/local' \
--python-install-bin '/usr/local/bin' \
--no-python-dependencies \
--after-install "./bin/${python_prefix}-post-install.sh" \
./setup.py
fi