-
Notifications
You must be signed in to change notification settings - Fork 39
/
contrail-setup.spec
173 lines (152 loc) · 5.02 KB
/
contrail-setup.spec
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
# view contents of rpm file: rpm -qlp <filename>.rpm
%define _contrailopt /opt/contrail
%define _distropkgdir tools/packaging/common/control_files
%define _provdir %{_builddir}/../tools/provisioning
%define _is_centos65 %(grep -c 6.5 /etc/issue)
%if 0%{?_buildTag:1}
%define _relstr %{_buildTag}
%else
%define _relstr %(date -u +%y%m%d%H%M)
%endif
%{echo: "Building release %{_relstr}\n"}
%if 0%{?_fileList:1}
%define _flist %{_fileList}
%else
%define _flist None
%endif
%if 0%{?_srcVer:1}
%define _verstr %{_srcVer}
%else
%define _verstr 1
%endif
%if 0%{?_skuTag:1}
%define _sku %{_skuTag}
%else
%define _sku None
%endif
Name: contrail-setup
Version: %{_verstr}
Release: %{_relstr}%{?dist}
Summary: Contrail Setup %{?_gitVer}
BuildArch: noarch
Group: Applications/System
License: Commercial
URL: http://www.juniper.net/
Vendor: Juniper Networks Inc
Requires: tar
Requires: python-pip
Requires: python-netifaces
Requires: gcc
Requires: python-devel
Requires: python-netaddr
Requires: openstack-utils
%if 0%{?fedora} >= 17
#Requires: python-Fabric
Requires: python-crypto
%endif
%if 0%{?suse_version}
Requires: python-pycrypto
%endif
%if 0%{?rhel}
Requires: python-argparse
Requires: gdb
%endif
%if 0%{?rhel} > 6
Requires: net-tools
%endif
%if 0%{?_is_centos65} == 1
Requires: kexec-tools
%endif
%description
Contrail Setup package with scripts for provisioning
BuildRequires: systemd-units
%prep
#%setup -q
# start from git root.. run this
# git rev-parse --show-toplevel > %{SOURCE0}
# make sure we are in ctrlplane repo
# gitrepo=$(basename $(git remote show origin | grep "Fetch URL" | cut -d: -f3 ))
# if [ x$gitrepo != xctrlplane.git ]; then
gitrepo=contrail-controller
grep $gitrepo .git/config &> /dev/null
if [ $? -ne 0 ]; then
echo "please run rpmbuild from ctrlplane git tree"
exit -1
fi
%build
pushd %{_provdir}
rm -rf ContrailProvisioning.egg-info
rm -rf ContrailProvisioning-0.1dev
%{__python} setup.py sdist
popd
pushd src/config
tar cvfz ../../cfgm_utils.tgz utils
popd
pushd src/dns/scripts
tar cvfz ../../../dns_scripts.tgz *
popd
%install
# Setup directories
rm -rf %{buildroot}
install -d -m 755 %{buildroot}%{_contrailopt}
install -d -m 755 %{buildroot}%{_contrailopt}
install -d -m 755 %{buildroot}%{_contrailopt}/bin
install -d -m 777 %{buildroot}%{_localstatedir}/log/contrail
install -d -m 755 %{buildroot}%{_contrailopt}/contrail_packages
install -d -m 755 %{buildroot}%{_contrailopt}/python_packages
# install files
pushd %{_builddir}/..
echo BUILDID=`echo %{_relstr} | cut -d "~" -f1` > %{buildroot}%{_contrailopt}/contrail_packages/VERSION
install -p -m 755 tools/packaging/build/README %{buildroot}%{_contrailopt}/contrail_packages/README
install -p -m 755 tools/packaging/common/control_files/contrail_ifrename.sh %{buildroot}%{_contrailopt}/bin/getifname.sh
popd
# install etc files
install -p -m 644 cfgm_utils.tgz %{buildroot}%{_contrailopt}/cfgm_utils.tgz
install -p -m 644 dns_scripts.tgz %{buildroot}%{_contrailopt}/dns_scripts.tgz
pushd %{_provdir}
tar zxf dist/ContrailProvisioning-0.1dev.tar.gz
cd ContrailProvisioning-0.1dev
%{__python} setup.py install --root=%{buildroot} --install-scripts %{_contrailopt}/bin/
popd
%if 0%{?rhel}
pushd %{_builddir}/../distro/third_party
tar cvzf %{buildroot}%{_contrailopt}/python_packages/zope.interface-3.7.0.tar.gz ./zope.interface-3.7.0
install -p -m 644 paramiko-*.tar.gz %{buildroot}%{_contrailopt}/python_packages/
install -p -m 644 pycrypto-*.tar.gz %{buildroot}%{_contrailopt}/python_packages/
install -p -m 644 Fabric-*.tar.gz %{buildroot}%{_contrailopt}/python_packages/
popd
%endif
install -d -m 755 %{buildroot}/etc/contrail
if [ %{_flist} = None ]; then
%{_builddir}/../tools/packaging/build/create_pkg_list_file.py --sku %{_sku} %{buildroot}/etc/contrail/rpm_list.txt
else
cp %{_flist} %{buildroot}/etc/contrail/rpm_list.txt
fi
#install -p -m 644 %{_builddir}/../tools/packaging/common/rpm/rpm_list.txt %{buildroot}/etc/contrail/rpm_list.txt
%post
cd %{_contrailopt}
tar xzvf cfgm_utils.tgz
tar xzvf dns_scripts.tgz -C utils
rm %{_contrailopt}/bin/openstack-db %{_contrailopt}/bin/openstack-config
ln -sbf %{_contrailopt}/bin/* %{_bindir}
%files
%defattr(-, root, root)
%{_contrailopt}/bin
%{_contrailopt}/contrail_packages/VERSION
%{_contrailopt}/contrail_packages/README
%{_contrailopt}/cfgm_utils.tgz
%{_contrailopt}/dns_scripts.tgz
%{python_sitelib}/ContrailProvisioning-*.egg-info
%{python_sitelib}/contrail_provisioning
%if 0%{?rhel}
%{_contrailopt}/python_packages/zope.interface-3.7.0.tar.gz
%{_contrailopt}/python_packages/paramiko-*.tar.gz
%{_contrailopt}/python_packages/Fabric-*.tar.gz
%{_contrailopt}/python_packages/pycrypto-*.tar.gz
%endif
%if 0%{?_fileList:1}
/etc/contrail/rpm_list.txt
%endif
/etc/contrail
%dir %attr(0777, contrail, contrail) %{_localstatedir}/log/contrail
%changelog