1 #%define dbhost localhost
5 %if %{?hostname:0}%{!?hostname:1}
6 %define hostname `hostname`
8 %if %{?sitename:0}%{!?sitename:1}
9 %define sitename MyForge
11 %if %{?adminemail:0}%{!?adminemail:1}
12 %if "%hostname" == "localhost"
13 %define adminemail root@localhost.localdomain
15 %define adminemail root@%hostname
18 %{!?release:%define release 1}
21 %define gfgroup gforge
23 Summary: FusionForge Collaborative Development Environment
29 Group: Development/Tools
30 Source0: %{name}-%{version}.tar.bz2
31 URL: http://www.gforge.org/
32 BuildRoot: %{_tmppath}/%{name}-%{version}-root
34 Patch1000: gforge-4.0-deb_rpm.patch
37 Requires: /bin/sh, /bin/bash
38 Requires: perl, perl-DBI, perl-HTML-Parser
40 Requires: php-jpgraph php-gd
41 #update sys_path_to_jpgraph in gforge.conf if you remove this line
42 #Requires: /var/www/jpgraph/jpgraph.php
43 #Requires: libnss-pgsql >= 1.4
49 # RedHat specific - distribution specific (fc = Fedora Core (or RHEL4 and Centos 4) - rh9 = RHL 9 - el3 = RHEL 3 or CentOS 3)
50 %if "%{_vendor}" == "redhat"
51 %if %{?dist:0}%{!?dist:1}
55 %define httpduser apache
56 %define httpdgroup apache
57 %define httpddir httpd
60 Requires: perl-DBD-Pg, php-pgsql
63 Requires: php-mbstring
65 %if "%{dist}" == "el3"
66 Requires: rh-postgresql, rh-postgresql-server
67 %define postgresqlservice rhdb
69 Requires: postgresql, postgresql-server
70 %define postgresqlservice postgresql
73 %define startpostgresql() service %postgresqlservice status | grep '(pid' >/dev/null 2>&1 || service %postgresqlservice start
74 %define reloadpostgresql() service %postgresqlservice reload
75 %define gracefulhttpd() service httpd graceful >/dev/null 2>&1
79 %if "%{_vendor}" == "suse"
80 %define httpduser wwwrun
81 %define httpdgroup www
82 %define httpddir apache2
84 Requires: postgresql, postgresql-server
85 Requires: pgperl, jpeg
87 Requires: php5-pgsql, php5-mbstring
89 # Start the postgresql service if needed
90 %define startpostgresql() /etc/init.d/postgresql status | grep 'running' >/dev/null 2>&1 || /etc/init.d/postgresql start
91 %define reloadpostgresql() /etc/init.d/postgresql reload >/dev/null 2>&1
92 %define gracefulhttpd() /etc/init.d/httpd graceful >/dev/null 2>&1
96 %if "%{_vendor}" == "MandrakeSoft"
97 %define httpduser apache
98 %define httpdgroup apache
99 %define httpddir httpd
100 %define postgresqlservice postgresql
102 Requires: php-mbstring, webserver
103 Requires: postgresql, postgresql-server
104 Requires: perl-DBD-Pg, php-pgsql
106 %define startpostgresql() service %postgresqlservice status | grep '(pid' >/dev/null 2>&1 || service %postgresqlservice start
107 %define reloadpostgresql() service %postgresqlservice reload
108 %define gracefulhttpd() service httpd graceful >/dev/null 2>&1
111 Provides: gforge = %{Version}
114 FusionForge provides many tools to aid collaboration in a
115 development project, such as bug-tracking, task management,
116 mailing-lists, SCM repository, forums, support request helper,
117 web/FTP hosting, release management, etc. All these services are
118 integrated into one web site and managed through a web interface.
120 # Macro for generating an environment variable (%1) with %2 random characters
121 %define randstr() %1=`perl -e 'for ($i = 0, $bit = "!", $key = ""; $i < %2; $i++) {while ($bit !~ /^[0-9A-Za-z]$/) { $bit = chr(rand(90) + 32); } $key .= $bit; $bit = "!"; } print "$key";'`
123 # Change password for admin user
124 %define changepassword() echo "UPDATE users SET user_pw='%1', email='%{adminemail}' WHERE user_name='admin'" | su -l postgres -s /bin/sh -c "psql %dbname" >/dev/null 2>&1
126 %define GFORGE_DIR %{_datadir}/gforge
127 %define GFORGE_CONF_DIR %{_sysconfdir}/gforge
128 %define GFORGE_LANG_DIR %{_datadir}/locale
129 %define GFORGE_LIB_DIR %{GFORGE_DIR}/lib
130 %define GFORGE_DB_DIR %{GFORGE_DIR}/db
131 %define GFORGE_BIN_DIR %{GFORGE_DIR}/bin
132 %define PLUGINS_LIB_DIR %{GFORGE_DIR}/plugins
133 %define PLUGINS_CONF_DIR %{GFORGE_CONF_DIR}/plugins
134 %define CACHE_DIR /var/cache/gforge
135 %define UPLOAD_DIR /var/lib/gforge/upload
136 %define SCM_TARBALLS_DIR /var/lib/gforge/scmtarballs
137 %define SCM_SNAPSHOTS_DIR /var/lib/gforge/scmsnapshots
138 %define CROND_DIR /%{_sysconfdir}/cron.d
139 %define HTTPD_CONF_DIR /%{_sysconfdir}/%{httpddir}
140 %define SBIN_DIR %{_sbindir}
149 # cleaning build environment
150 [ "$RPM_BUILD_ROOT" != "/" ] && rm -rf $RPM_BUILD_ROOT
152 # creating required directories
153 install -m 755 -d $RPM_BUILD_ROOT/%{GFORGE_DIR}
154 install -m 755 -d $RPM_BUILD_ROOT/%{GFORGE_CONF_DIR}
155 install -m 755 -d $RPM_BUILD_ROOT/%{GFORGE_LANG_DIR}
156 install -m 755 -d $RPM_BUILD_ROOT/%{GFORGE_BIN_DIR}
157 install -m 755 -d $RPM_BUILD_ROOT/%{GFORGE_LIB_DIR}
158 install -m 755 -d $RPM_BUILD_ROOT/%{UPLOAD_DIR}
159 install -m 755 -d $RPM_BUILD_ROOT/%{CACHE_DIR}
160 install -m 755 -d $RPM_BUILD_ROOT/%{SCM_TARBALLS_DIR}
161 install -m 755 -d $RPM_BUILD_ROOT/%{PLUGINS_LIB_DIR}
162 install -m 755 -d $RPM_BUILD_ROOT/%{SBIN_DIR}
163 install -m 755 -d $RPM_BUILD_ROOT/%{HTTPD_CONF_DIR}/conf.d
164 install -m 755 -d $RPM_BUILD_ROOT/%{CROND_DIR}
167 for i in common cronjobs etc rpm-specific utils www ; do
168 cp -rp $i $RPM_BUILD_ROOT/%{GFORGE_DIR}/
170 #create a repository to link the plugins web pages
171 install -m 755 -d $RPM_BUILD_ROOT/%{GFORGE_DIR}/www/plugins
173 install -m 750 setup $RPM_BUILD_ROOT/%{GFORGE_DIR}/
174 chmod 755 $RPM_BUILD_ROOT/%{GFORGE_DIR}/utils/fill-in-the-blanks.pl
175 chmod 755 $RPM_BUILD_ROOT/%{GFORGE_DIR}/www/scm/viewvc/bin/cgi/viewvc.cgi
177 cp -rp db/. $RPM_BUILD_ROOT/%{GFORGE_DB_DIR}/
178 cp -p deb-specific/sf-2.6-complete.sql $RPM_BUILD_ROOT/%{GFORGE_DB_DIR}/
180 for i in deb-specific/sqlhelper.pm deb-specific/sqlparser.pm utils/include.pl ; do
181 cp -p $i $RPM_BUILD_ROOT/%{GFORGE_LIB_DIR}/
183 for i in db-upgrade.pl register-plugin unregister-plugin register-theme unregister-theme install-db.sh; do
184 install -m 755 deb-specific/$i $RPM_BUILD_ROOT/%{GFORGE_BIN_DIR}/
188 ## use post install setup script instead
189 install -m 644 rpm-specific/httpd.d/gforge.conf $RPM_BUILD_ROOT/%{HTTPD_CONF_DIR}/conf.d/gforge.conf
192 install -m 600 rpm-specific/conf/gforge.conf $RPM_BUILD_ROOT/%{GFORGE_CONF_DIR}/
193 install -m 750 rpm-specific/scripts/gforge-config $RPM_BUILD_ROOT/%{SBIN_DIR}/
196 cp -rp locales/* $RPM_BUILD_ROOT/%{GFORGE_LANG_DIR}/
199 install -m 664 cron.d/fusionforge $RPM_BUILD_ROOT/%{CROND_DIR}/
203 if ! id -u %gfuser >/dev/null 2>&1; then
204 groupadd -r %{gfgroup}
205 useradd -r -g %{gfgroup} -d %{GFORGE_DIR} -s /bin/bash -c "GForge User" %{gfuser}
209 if [ "$1" -eq "1" ]; then
211 # TODO : USE install-db.sh
212 # creating the database
214 su -l postgres -s /bin/sh -c "createdb -E UNICODE %{dbname} >/dev/null 2>&1"
215 su -l postgres -s /bin/sh -c "createlang plpgsql %{dbname} >/dev/null 2>&1"
217 # generating and updating site admin password
218 %randstr SITEADMIN_PASSWORD 8
220 # updating admin_password in gforge.conf
222 s#^admin_password=.*#admin_password="$SITEADMIN_PASSWORD"#g" %{GFORGE_CONF_DIR}/gforge.conf
224 SITEADMIN_PASSWORD=`echo -n $SITEADMIN_PASSWORD | md5sum | awk '{print $1}'`
226 # creating gforge database user
227 %randstr GFORGEDATABASE_PASSWORD 8
229 su -l postgres -c "psql -c \"CREATE USER %{dbuser} WITH PASSWORD '$GFORGEDATABASE_PASSWORD' NOCREATEUSER\" %{dbname} >/dev/null 2>&1"
230 su -l postgres -c "psql -c \"CREATE USER gforge_nss WITH PASSWORD '$GFORGEDATABASE_PASSWORD' NOCREATEUSER\" %{dbname} >/dev/null 2>&1"
231 su -l postgres -c "psql -c \"CREATE USER gforge_mta WITH PASSWORD '$GFORGEDATABASE_PASSWORD' NOCREATEUSER\" %{dbname} >/dev/null 2>&1"
233 # replacing variables in configuration files
235 s/DB_HOST/"%{dbhost}"/g;
236 s/DB_NAME/"%{dbname}"/g;
237 s/DB_USER/"%{dbuser}"/g;
238 s/DB_PASSWORD/"$GFORGEDATABASE_PASSWORD"/g;
239 s/SYSTEM_NAME/"%{sitename}"/g;
240 s/RANDOM_ID/"$SESSID"/g;
241 s/HOST_NAME/"%{hostname}"/g" %{GFORGE_CONF_DIR}/gforge.conf
244 adminemail=$(echo "%{adminemail}"| sed 's|@|\\\@|g')
246 s/SERVER_ADMIN/"$adminemail"/g" %{GFORGE_CONF_DIR}/gforge.conf
248 # updating PostgreSQL configuration
249 #if ! grep -i '^ *host.*%{dbname}.*' /var/lib/pgsql/data/pg_hba.conf >/dev/null 2>&1; then
250 # echo 'host %{dbname} %{dbuser} 127.0.0.1 255.255.255.255 md5' >> /var/lib/pgsql/data/pg_hba.conf
251 # echo 'local %{dbname} gforge_mta md5md5md5md5md5' >> /var/lib/pgsql/data/pg_hba.conf
252 # echo 'local %{dbname} gforge_nss trust' >> /var/lib/pgsql/data/pg_hba.conf
256 %{GFORGE_BIN_DIR}/install-db.sh configure-files
257 mv /var/lib/pgsql/data/pg_hba.conf /var/lib/pgsql/data/pg_hba.conf-orig
258 mv /var/lib/pgsql/data/pg_hba.conf.gforge-new /var/lib/pgsql/data/pg_hba.conf
261 # adding "noreply" alias
262 for i in /etc/postfix/aliases /etc/mail/aliases /etc/aliases ; do
264 if ! grep -i '^ *noreply:' $i >/dev/null 2>&1; then
265 echo 'noreply: /dev/null' >> $i
272 # generating random session ID
276 path_jpgraph=$(rpm -ql php-jpgraph | grep jpgraph.php | sed 's/\(.*\)jpgraph.php/\1/')
278 s#^sys_path_to_jpgraph=.*#sys_path_to_jpgraph=$path_jpgraph#g" %{GFORGE_CONF_DIR}/gforge.conf
280 #wrong 20list http template for mailman on rpm
281 rm -f %{GFORGE_CONF_DIR}/httpd.d/20list
284 s#^GFORGE_CONF_DIR=.*#GFORGE_CONF_DIR="%{GFORGE_CONF_DIR}"#g" %{SBIN_DIR}/gforge-config
286 ## plugins installs apache templates in GFORGE_CONF_DIR
287 ln -s %{GFORGE_DIR}/etc/httpd.d %{GFORGE_CONF_DIR}/httpd.d
289 # initializing configuration
290 %{SBIN_DIR}/gforge-config
292 # creating the database
293 su -l %{gfuser} -c "%{GFORGE_BIN_DIR}/db-upgrade.pl 2>&1" | grep -v ^NOTICE
294 su -l postgres -c "psql -c 'UPDATE groups SET register_time=EXTRACT(EPOCH FROM NOW());' %{dbname} >/dev/null 2>&1"
295 %changepassword $SITEADMIN_PASSWORD
299 if ! id -u anonymous >/dev/null 2>&1; then
300 useradd -m -s /bin/false anonymous
303 # [ ! -f /usr/bin/php4 ] && ln -s /usr/bin/php /usr/bin/php4
305 CHROOT=`grep '^gforge_chroot=' %{GFORGE_CONF_DIR}/gforge.conf | sed 's/.*=\s*\(.*\)/\1/'`
306 if [ ! -d $CHROOT ] ; then
310 ln -s %{GFORGE_DIR}/www/env.inc.php %{PLUGINS_LIB_DIR}/env.inc.php
312 #if not the env.inc.php include-path isn't correct //not necessary if no more /usr/lib/gforge
313 #ln -s %{PLUGINS_LIB_DIR} %{GFORGE_DIR}/plugins
317 su -l %{gfuser} -c "%{GFORGE_BIN_DIR}/db-upgrade.pl 2>&1" | grep -v ^NOTICE
319 # updating configuration
320 %{SBIN_DIR}/gforge-config || :
327 if [ "$1" -eq "0" ]; then
328 # dropping gforge users
329 su -l postgres -s /bin/sh -c "dropuser %{dbuser} >/dev/null 2>&1 ; dropuser gforge_nss >/dev/null 2>&1 ; dropuser gforge_mta >/dev/null 2>&1"
331 for file in local.pl httpd.secrets local.inc httpd.conf httpd.vhosts database.inc ; do
332 rm -f %{GFORGE_CONF_DIR}/$file
334 # Remove PostgreSQL access
335 if grep -i '^ *host.*%{dbname}.*' /var/lib/pgsql/data/pg_hba.conf >/dev/null 2>&1; then
336 perl -ni -e 'm@^ *host.*%{dbname}.*@ or print;' /var/lib/pgsql/data/pg_hba.conf >/dev/null 2>&1
337 perl -ni -e 'm@^ *local.*%{dbname}.*@ or print;' /var/lib/pgsql/data/pg_hba.conf >/dev/null 2>&1
340 if id -u %{gfuser} >/dev/null 2>&1; then
341 userdel %{gfuser} >/dev/null 2>&1
342 groupdel %{gfgroup} >/dev/null 2>&1
345 if ! id -u anonymous >/dev/null 2>&1; then
346 userdel anonymous 2>/dev/null || :
349 [ -L /usr/bin/php4 ] && rm -f /usr/bin/php4
354 [ "$RPM_BUILD_ROOT" != "/" ] && rm -rf $RPM_BUILD_ROOT
357 %defattr(-, root, root)
358 %doc AUTHORS AUTHORS.sourceforge COPYING ChangeLog INSTALL README*
360 %attr(0660, %{httpduser}, gforge) %config(noreplace) %{GFORGE_CONF_DIR}/gforge.conf
361 %attr(0750, root, root) %{SBIN_DIR}/gforge-config
362 %attr(0640, %{httpduser}, %{httpdgroup}) %config(noreplace) %{HTTPD_CONF_DIR}/conf.d/gforge.conf
363 %attr(0644, root, root) %{CROND_DIR}/fusionforge
364 %attr(0775, %{httpduser}, %{httpdgroup}) %dir %{UPLOAD_DIR}
365 %attr(0775, %{httpduser}, %{httpdgroup}) %dir %{CACHE_DIR}
376 * Wed Jun 29 2005 Open Wide <guillaume.smet@openwide.fr>
377 - fixed Xavier's patch
378 - added Mandrake support based on patch [#1194] by Kevin R. Bulgrien
379 * Wed Apr 27 2005 Rameau Xavier <xrameau@gmail.com> (for e-LaSer : http://www.e-laser.fr)
380 - Adding specification for SuSE Linux Enterprise Server 9 (in .spec)
381 - Moving all static definitions to global variables (in .spec)
382 * Thu Mar 03 2005 Guillaume Smet <guillaume-gforge@smet.org>
383 - removed useless stuff thanks to Christian's work on db-upgrade.pl
384 - s/refresh.sh/gforge-config to improve consistency with debian packaging
385 - it's better to display the output of db-upgrade.pl
386 * Sun Feb 20 2005 Guillaume Smet <guillaume-gforge@smet.org>
387 - added a dependency on gforge-lib-jpgraph
388 - added gforge-4.1-project_task_sql.patch
389 * Sat Feb 19 2005 Guillaume Smet <guillaume-gforge@smet.org>
391 - forced the vhost on port 80
392 - modified the db-upgrade.pl patch to keep nss stuff
393 - detects if tcpip_socket is set to true before installing the RPM
394 - fixed dependencies problem for RH9 and RHEL3
395 - creates gforge_nss and gforge_mta postgresql users
396 - drops created postgresql users on uninstall
397 - replaced -f test with ls
398 * Fri Jan 28 2005 Thales Information Systems <guillaume.smet@openwide.fr>
399 - fixed default values for release, sitename and hostname
400 - fixed remaining issues on upgrade
401 * Thu Jan 27 2005 Thales Information Systems <guillaume.smet@openwide.fr>
402 - it's now possible to add custom stuff in /etc/gforge/custom/
403 * Thu Dec 30 2004 Guillaume Smet <guillaume-gforge@smet.org>
404 - added Allow from all in vhost config
405 * Wed Dec 29 2004 Guillaume Smet <guillaume-gforge@smet.org>
406 - added the magic_quotes_gpc On in vhost as the default value for FC3 is now Off
407 * Sat Dec 25 2004 Guillaume Smet <guillaume-gforge@smet.org>
408 - it's now possible to add specific language files in the RPM
409 * Fri Dec 03 2004 Dassault Aviation <guillaume.smet@openwide.fr>
410 - fixed the vhost configuration
411 - fixed the default crontab
412 - the crontab is now a config file and is not replaced on update
413 - added refresh.sh in /etc/gforge/ to refresh the configuration easily
414 * Wed Nov 03 2004 Guillaume Smet <guillaume-gforge@smet.org>