Fixed spec file to handle symbolic links and config files properly
[plstackapi.git] / opencloud.spec
1 Summary: OpenCloud core services
2 Name: opencloud
3 Version: 1.0.23
4 Release: 0
5 License: GPL+
6 Group: Development/Tools
7 Source0: %{_tmppath}/%{name}-%{version}.tar.gz
8 BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}
9 requires: postgresql
10 requires: postgresql-server
11 requires: python-psycopg2
12 requires: graphviz
13 requires: graphviz-devel
14 requires: graphviz-python
15 requires: libxslt-devel
16 requires: python-pip
17 requires: tar
18 requires: gcc
19 requires: python-httplib2
20 requires: GeoIP
21
22 %description
23 %{summary}
24
25 %prep
26 %setup -q
27
28 %build
29 # Empty section.
30
31 %pre
32 #pip-python install django==1.5
33 pip-python install djangorestframework
34 pip-python install markdown  # Markdown support for the browseable API.
35 pip-python install pyyaml    # YAML content-type support.
36 pip-python install django-filter  # Filtering support
37 pip-python install lxml  # XML manipulation library
38 pip-python install netaddr # IP Addr library
39 pip-python install pytz
40 pip-python install django-timezones
41 pip-python install requests
42 pip-python install django-crispy-forms
43 pip-python install django-geoposition
44 pip-python install django-extensions
45 pip-python install django-suit
46 pip-python install django-evolution
47 pip-python install django-bitfield
48 pip-python install django-ipware
49
50 easy_install django_evolution
51 easy_install python_gflags
52 easy_install google_api_python_client
53
54 wget -P /usr/lib/python2.7/site-packages/suit/static/suit/js http://code.jquery.com/jquery-1.9.1.min.js
55
56 if [ ! -f /usr/share/GeoIP/GeoLiteCity.dat ]; then
57    rm -f /usr/share/GeoIP/GeoLiteCity.*
58    wget -P /usr/share/GeoIP http://geolite.maxmind.com/download/geoip/database/GeoLiteCity.dat.gz
59    gzip -d /usr/share/GeoIP/GeoLiteCity*.gz
60 fi
61
62 if [ "$1" == 2 ] ; then
63     if [[ -e /opt/planetstack/scripts/opencloud ]]; then
64         echo "UPGRADE - saving current state"
65         /opt/planetstack/scripts/opencloud dumpdata
66     fi
67 fi
68
69 %install
70 rm -rf %{buildroot}
71 mkdir -p  %{buildroot}
72 install -d %{buildroot}/opt/planetstack
73 install -d %{buildroot}/etc/init.d
74
75 # in builddir
76
77
78 # don't copy symbolic links (they are handled in %post)
79 rsync -rptgoD ./planetstack %{buildroot}/opt/.  
80 cp observer-initscript %{buildroot}/etc/init.d/plstackobserver
81
82 find %{buildroot}/opt/planetstack -type f -print | sed "s@^$RPM_BUILD_ROOT@@g" > %{_tmppath}/tmp-filelist
83 echo /etc/init.d/plstackobserver >> %{_tmppath}/tmp-filelist
84
85 # remove config files from the file list (see %config below)
86 cat > %{_tmppath}/config-files << "EOF"
87 /opt/planetstack/plstackapi_config
88 /opt/planetstack/deployment_auth.py
89 EOF
90
91 sort %{_tmppath}/tmp-filelist > %{_tmppath}/tmp-filelist.sorted
92 sort %{_tmppath}/config-files > %{_tmppath}/config-files.sorted
93 comm -13 %{_tmppath}/config-files.sorted %{_tmppath}/tmp-filelist.sorted > %{_tmppath}/tmp-filelist
94
95 cp %{_tmppath}/tmp-filelist /tmp/tmp-filelist
96
97 %clean
98 rm -rf %{buildroot}
99
100 %files -f %{_tmppath}/tmp-filelist
101 %defattr(-,root,root,-)
102 %config /opt/planetstack/plstackapi_config
103 %config /opt/planetstack/deployment_auth.py
104
105 %post
106 ln -s ec2_observer /opt/planetstack/observer
107 ln -s config-opencloud.py /opt/planetstack/syndicate_observer/syndicatelib_config/config.py
108
109 if [ "$1" == 1 ] ; then
110     echo "NEW INSTALL - initializing database"
111     /opt/planetstack/scripts/opencloud initdb
112 else
113     echo "UPGRADE - doing evolution"
114     /opt/planetstack/scripts/opencloud evolvedb
115 fi
116 # start the server
117 /opt/planetstack/scripts/opencloud runserver
118
119 %preun
120 if [ "$1" = 0 ] ; then
121     echo "UNINSTALL - destroying planetstack"
122     rm -rf /opt/planetstack
123 fi
124
125 %changelog
126 * Sat Feb 22 2014  Siobhan Tully  1.0.0
127 - First Build
128