Commit e325c561879d557ff17e9e9d1beb1dc294e4eecb

Authored by Rodrigo Siqueira de Melo
1 parent e400c2c3
Exists in updatev3

Update colab.spec version

Signed-off-by: Alexandre Almeida <alexandreab@live.com>
Signed-off-by: Lucas Kanashiro <kanashiro.duarte@gmail.com>
Showing 1 changed file with 104 additions and 142 deletions   Show diff stats
colab/colab.spec
1 1 %define name colab
2   -%define version 1.11.0
3   -%define default_release 2
  2 +%define version 1.10.4
  3 +%define default_release 4
4 4 %{!?release: %define release %{default_release}}
5 5 %define buildvenv /var/tmp/%{name}-%{version}
6 6  
7 7 Summary: Collaboration platform for communities
8 8 Name: %{name}
9 9 Version: %{version}
10   -Release: 0
  10 +Release: %{release}
11 11 Source0: %{name}-%{version}.tar.gz
12 12 License: GPLv2
13 13 Group: Development/Tools
14 14 BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-buildroot
15 15 Prefix: %{_prefix}
16 16 Vendor: Sergio Oliveira <sergio@tracy.com.br>
17   -Url: https://github.com/colab/colab
  17 +Url: https://github.com/colab-community/colab
18 18 BuildArch: noarch
19   -BuildRequires: colab-deps >= 1.11, python-virtualenv
20   -# FIXME colab should not depend on nginx!
21   -Requires: colab-deps >= 1.11, solr, mailman-api >= 0.3, nginx
  19 +BuildRequires: colab-deps >= 1.10, python-virtualenv
  20 +Requires: colab-deps >= 1.10, solr, mailman-api
22 21  
23 22 %description
24 23 Integrated software development platform.
... ... @@ -30,7 +29,7 @@ Integrated software development platform.
30 29 # install colab into virtualenv to make sure dependencies are OK
31 30 rm -rf %{buildvenv}
32 31 cp -r /usr/lib/colab %{buildvenv}
33   -PATH=%{buildvenv}/bin:$PATH pip install --use-wheel --no-index .
  32 +PATH=%{buildvenv}/bin:$PATH pip install --no-index .
34 33 virtualenv --relocatable %{buildvenv}
35 34  
36 35 # cleanup virtualenv
... ... @@ -44,30 +43,13 @@ rm -f cleanup.list
44 43 find %{buildvenv} -type d -empty -delete
45 44  
46 45 %install
47   -
48   -# install config file
49   -install -d -m 0755 %{buildroot}/etc/colab
50   -install -m 0644 misc/etc/colab/gunicorn.py %{buildroot}/etc/colab/gunicorn.py.example
51   -
52   -# Create settings dirs
53   -install -d -m 0755 %{buildroot}/etc/colab/settings.d
54   -install -d -m 0755 %{buildroot}/etc/colab/plugins.d
55   -
56   -# create log dir
57   -install -d -m 0755 %{buildroot}/var/log/colab
58   -
59   -# create celery dir
60   -install -d -m 0755 %{buildroot}/var/lib/colab/celery
61   -
62   -# Create assets dir (stores static files)
63   -install -d -m 0755 %{buildroot}/var/lib/colab/assets
  46 +mkdir -p %{buildroot}/etc/colab
  47 +mkdir -p %{buildroot}/usr/lib
64 48  
65 49 # install virtualenv
66   -install -d -m 0755 %{buildroot}/usr/lib
67 50 rm -rf %{buildroot}/usr/lib/colab
68 51 cp -r %{buildvenv} %{buildroot}/usr/lib/colab
69 52 mkdir -p %{buildroot}/%{_bindir}
70   -
71 53 cat > %{buildroot}/%{_bindir}/colab-admin <<EOF
72 54 #!/bin/sh
73 55 set -e
... ... @@ -83,8 +65,6 @@ chmod +x %{buildroot}/%{_bindir}/colab-admin
83 65 # install initscript
84 66 install -d -m 0755 %{buildroot}/lib/systemd/system
85 67 install -m 0644 misc/lib/systemd/system/colab.service %{buildroot}/lib/systemd/system
86   -install -m 0644 misc/lib/systemd/system/celeryd.service %{buildroot}/lib/systemd/system
87   -install -m 0644 misc/lib/systemd/system/celerybeat.service %{buildroot}/lib/systemd/system
88 68 # install crontab
89 69 install -d -m 0755 %{buildroot}/etc/cron.d
90 70 install -m 0644 misc/etc/cron.d/colab %{buildroot}/etc/cron.d
... ... @@ -94,141 +74,123 @@ rm -rf $RPM_BUILD_ROOT
94 74 rm -rf %{buildvenv}
95 75  
96 76 %files
97   -%defattr(-, root, root)
98   -
99 77 /usr/lib/colab
100   -#/var/lib/colab # XXX: remove if doesnt break
101   -%attr(-, colab, colab) /var/lib/colab/assets
102   -%attr(-, colab, colab) /var/lib/colab/celery
103   -%attr(-, colab, colab) /var/log/colab
104 78 %{_bindir}/*
105 79 /etc/cron.d/colab
106   -#/etc/colab # XXX: remove if doesnt break
107   -/etc/colab/settings.d
108   -/etc/colab/plugins.d
109   -/etc/colab/gunicorn.py.example
110 80 /lib/systemd/system/colab.service
111   -/lib/systemd/system/celeryd.service
112   -/lib/systemd/system/celerybeat.service
113 81  
  82 +%post
  83 +groupadd colab || true
  84 +if ! id colab; then
  85 + useradd --system --gid colab --home-dir /usr/lib/colab --no-create-home colab
  86 +fi
114 87  
115   -%pre
  88 +mkdir -p /etc/colab
116 89  
117   -getent group colab > /dev/null || groupadd --system colab
118   -getent passwd colab > /dev/null || useradd --system --gid colab --home-dir /usr/lib/colab --no-create-home colab
  90 +if [ ! -f /etc/colab/settings.yaml ]; then
  91 + SECRET_KEY=$(openssl rand -hex 32)
  92 + cat > /etc/colab/settings.yaml <<EOF
  93 +## Set to false in production
  94 +DEBUG: true
  95 +TEMPLATE_DEBUG: true
  96 +
  97 +## System admins
  98 +ADMINS: &admin
  99 + -
  100 + - John Foo
  101 + - john@example.com
  102 + -
  103 + - Mary Bar
  104 + - mary@example.com
  105 +
  106 +MANAGERS: *admin
  107 +
  108 +COLAB_FROM_ADDRESS: '"Colab" <noreply@example.com>'
  109 +SERVER_EMAIL: '"Colab" <noreply@example.com>'
  110 +
  111 +EMAIL_HOST: localhost
  112 +EMAIL_PORT: 25
  113 +EMAIL_SUBJECT_PREFIX: '[colab]'
  114 +
  115 +SECRET_KEY: '$SECRET_KEY'
  116 +
  117 +SITE_URL: 'http://localhost:8001/'
  118 +BROWSERID_AUDIENCES:
  119 + - http://localhost:8001
  120 +# - http://example.com
  121 +# - https://example.org
  122 +# - http://example.net
  123 +
  124 +ALLOWED_HOSTS:
  125 + - localhost
  126 +# - example.com
  127 +# - example.org
  128 +# - example.net
  129 +
  130 +## Disable indexing
  131 +ROBOTS_NOINDEX: false
  132 +
  133 +## Disable browser id authentication
  134 +# BROWSERID_ENABLED: true
  135 +EOF
  136 + chown root:colab /etc/colab/settings.yaml
  137 + chmod 0640 /etc/colab/settings.yaml
  138 +fi
119 139  
  140 +mkdir -p /etc/colab/settings.d
  141 +
  142 +if [ ! -f /etc/colab/settings.d/00-database.yaml ]; then
  143 + cat > /etc/colab/settings.d/00-database.yaml <<EOF
  144 +DATABASES:
  145 + default:
  146 + ENGINE: django.db.backends.postgresql_psycopg2
  147 + NAME: colab
  148 + USER: colab
  149 + HOST: localhost
  150 + PORT: 5432
  151 +EOF
  152 + chown root:colab /etc/colab/settings.d/00-database.yaml
  153 + chmod 0640 /etc/colab/settings.d/00-database.yaml
  154 +fi
120 155  
121   -%post
  156 +# only applies if there is a local PostgreSQL server
  157 +if [ -x /usr/bin/postgres ]; then
122 158  
123   -mv /etc/colab/gunicorn.py.example /etc/colab/gunicorn.py
  159 + # start/enable the service
  160 + postgresql-setup initdb || true
  161 + systemctl start postgresql
  162 + systemctl enable postgresql
124 163  
125   -if [ ! -f /etc/colab/settings.py ]; then
126   - SECRET_KEY=$(openssl rand -hex 32)
127   - cat > /etc/colab/settings.py <<EOF
128   -
129   -# Set to false in production
130   -DEBUG = True
131   -TEMPLATE_DEBUG = True
132   -
133   -# System admins
134   -ADMINS = [['John Foo', 'john@example.com'], ['Mary Bar', 'mary@example.com']]
135   -
136   -MANAGERS = ADMINS
137   -
138   -COLAB_FROM_ADDRESS = '"Colab" <noreply@example.com>'
139   -SERVER_EMAIL = '"Colab" <noreply@example.com>'
140   -
141   -EMAIL_HOST = 'localhost'
142   -EMAIL_PORT = 25
143   -EMAIL_SUBJECT_PREFIX = '[colab]'
144   -
145   -SECRET_KEY = '$(openssl rand -hex 32)'
146   -
147   -ALLOWED_HOSTS = [
148   - 'localhost',
149   -# 'example.com',
150   -# 'example.org',
151   -# 'example.net',
152   -]
153   -
154   -# Database settings
155   -#
156   -# When DEBUG is True colab will create the DB on
157   -# the repository root. In case of production settings
158   -# (DEBUG False) the DB settings must be set.
159   -#
160   -# DATABASES = {
161   -# 'default': {
162   -# 'ENGINE': 'django.db.backends.sqlite3',
163   -# 'NAME': '/path/to/colab.sqlite3',
164   -# }
165   -# }
166   -
167   -# Disable indexing
168   -ROBOTS_NOINDEX = False
169   -
170   -LOGGING = {
171   - 'version': 1,
172   - 'disable_existing_loggers': True,
173   -
174   - 'formatters': {
175   - 'colab': { 'format' : '[colab] (%%(name)s) %%(levelname)s: %%(message)s'},
176   - 'verbose': { 'format' : '%%(asctime)s (%%(name)s) %%(levelname)s: %%(message)s'},
177   - },
178   -
179   - 'handlers': {
180   - 'null': {
181   - 'level': 'DEBUG',
182   - 'class': 'logging.NullHandler',
183   - },
184   - 'syslog': {
185   - 'level': 'WARNING',
186   - 'class': 'logging.handlers.SysLogHandler',
187   - 'formatter': 'colab',
188   - 'address': '/dev/log',
189   - },
190   - 'file': {
191   - 'level': 'DEBUG',
192   - 'class': 'logging.handlers.TimedRotatingFileHandler',
193   - 'filename': '/var/log/colab/colab.log',
194   - 'interval': 24, # 24 hours
195   - 'backupCount': 7, # keep last 7 backups
196   - 'encoding': 'UTF-8',
197   - 'formatter': 'verbose',
198   - },
199   - },
200   -
201   - 'loggers': {
202   - 'django': {
203   - 'handlers': ['file', 'syslog'],
204   - 'propagate': False,
205   - },
206   - 'revproxy': {
207   - 'handlers': ['file', 'syslog'],
208   - 'propagate': False,
209   - 'level': 'ERROR',
210   - },
211   - },
212   -}
  164 + if [ "$(sudo -u postgres -i psql --quiet --tuples-only -c "select count(*) from pg_user where usename = 'colab';")" -eq 0 ]; then
  165 + # create user
  166 + sudo -u postgres -i createuser colab
  167 + fi
213 168  
214   -EOF
  169 + if [ "$(sudo -u postgres -i psql --quiet --tuples-only -c "select count(1) from pg_database where datname = 'colab';")" -eq 0 ]; then
  170 + # create database
  171 + sudo -u postgres -i createdb --owner=colab colab
  172 + fi
215 173  
216   - chown root:colab /etc/colab/settings.py
217   - chmod 0640 /etc/colab/settings.py
  174 + colab-admin migrate
218 175 fi
219 176  
220   -# FIXME colab should not depend on nginx
221   -ln -s /var/lib/colab/assets /usr/share/nginx/colab
  177 +mkdir -p /var/lock/colab
  178 +chown colab:colab /var/lock/colab
  179 +
  180 +mkdir -p /var/lib/colab-assets
  181 +chown colab:colab /var/lib/colab-assets
  182 +
  183 +mkdir -p /usr/share/nginx/
222 184  
223   -colab-admin collectstatic --noinput
  185 +ln -s /var/lib/colab-assets /usr/share/nginx/colab
  186 +
  187 +yes yes | colab-admin collectstatic
224 188  
225 189 if [ $1 -gt 1 ]; then
226 190 # upgrade; restart if running
227 191 systemctl try-restart colab
228 192 fi
229 193  
230   -systemctl daemon-reload
231   -
232 194 %preun
233 195 if [ $1 -eq 0 ]; then
234 196 # package being removed
... ...