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
50 # RedHat specific - distribution specific (fc = Fedora Core (or RHEL4 and Centos 4) - rh9 = RHL 9 - el3 = RHEL 3 or CentOS 3)
51 %if "%{_vendor}" == "redhat"
52 %if %{?dist:0}%{!?dist:1}
56 %define httpduser apache
57 %define httpdgroup apache
58 %define httpddir httpd
61 Requires: perl-DBD-Pg, php-pgsql
64 Requires: php-mbstring
66 %if "%{dist}" == "el3"
67 Requires: rh-postgresql, rh-postgresql-server
68 %define postgresqlservice rhdb
70 Requires: postgresql, postgresql-server
71 %define postgresqlservice postgresql
74 %define startpostgresql() service %postgresqlservice status | grep '(pid' >/dev/null 2>&1 || service %postgresqlservice start
75 %define reloadpostgresql() service %postgresqlservice reload
76 %define gracefulhttpd() service httpd graceful >/dev/null 2>&1
80 %if "%{_vendor}" == "suse"
81 %define httpduser wwwrun
82 %define httpdgroup www
83 %define httpddir apache2
85 Requires: postgresql, postgresql-server
86 Requires: pgperl, jpeg
88 Requires: php5-pgsql, php5-mbstring
90 # Start the postgresql service if needed
91 %define startpostgresql() /etc/init.d/postgresql status | grep 'running' >/dev/null 2>&1 || /etc/init.d/postgresql start
92 %define reloadpostgresql() /etc/init.d/postgresql reload >/dev/null 2>&1
93 %define gracefulhttpd() /etc/init.d/httpd graceful >/dev/null 2>&1
97 %if "%{_vendor}" == "MandrakeSoft"
98 %define httpduser apache
99 %define httpdgroup apache
100 %define httpddir httpd
101 %define postgresqlservice postgresql
103 Requires: php-mbstring, webserver
104 Requires: postgresql, postgresql-server
105 Requires: perl-DBD-Pg, php-pgsql
107 %define startpostgresql() service %postgresqlservice status | grep '(pid' >/dev/null 2>&1 || service %postgresqlservice start
108 %define reloadpostgresql() service %postgresqlservice reload
109 %define gracefulhttpd() service httpd graceful >/dev/null 2>&1
113 GForge is a web-based Collaborative Development Environment offering
114 easy access to CVS, mailing lists, bug tracking, message
115 boards/forums, task management, permanent file archival, and total
116 web-based administration.
118 # Macro for generating an environment variable (%1) with %2 random characters
119 %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";'`
121 # Change password for admin user
122 %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
124 %define GFORGE_DIR %{_datadir}/gforge
125 %define GFORGE_CONF_DIR %{_sysconfdir}/gforge
126 %define GFORGE_LANG_DIR %{_libdir}/gforge/translations
127 %define GFORGE_LIB_DIR %{_libdir}/gforge/lib
128 %define GFORGE_DB_DIR %{_libdir}/gforge/db
129 %define GFORGE_BIN_DIR %{_libdir}/gforge/bin
130 %define PLUGINS_LIB_DIR %{_libdir}/gforge/plugins
131 %define PLUGINS_CONF_DIR %{GFORGE_CONF_DIR}/plugins
132 %define CACHE_DIR /var/cache/gforge
133 %define UPLOAD_DIR /var/lib/gforge/upload
134 %define SCM_TARBALLS_DIR /var/lib/gforge/scmtarballs
135 %define SCM_SNAPSHOTS_DIR /var/lib/gforge/scmsnapshots
136 %define CROND_DIR /%{_sysconfdir}/cron.d
137 %define HTTPD_CONF_DIR /%{_sysconfdir}/%{httpddir}
138 %define SBIN_DIR %{_sbindir}
147 # cleaning build environment
148 [ "$RPM_BUILD_ROOT" != "/" ] && rm -rf $RPM_BUILD_ROOT
150 # creating required directories
151 install -m 755 -d $RPM_BUILD_ROOT/%{GFORGE_DIR}
152 install -m 755 -d $RPM_BUILD_ROOT/%{GFORGE_CONF_DIR}
153 install -m 755 -d $RPM_BUILD_ROOT/%{GFORGE_LANG_DIR}
154 install -m 755 -d $RPM_BUILD_ROOT/%{GFORGE_BIN_DIR}
155 install -m 755 -d $RPM_BUILD_ROOT/%{GFORGE_LIB_DIR}
156 install -m 755 -d $RPM_BUILD_ROOT/%{UPLOAD_DIR}
157 install -m 755 -d $RPM_BUILD_ROOT/%{CACHE_DIR}
158 install -m 755 -d $RPM_BUILD_ROOT/%{SCM_TARBALLS_DIR}
159 install -m 755 -d $RPM_BUILD_ROOT/%{PLUGINS_LIB_DIR}
160 install -m 755 -d $RPM_BUILD_ROOT/%{SBIN_DIR}
161 install -m 755 -d $RPM_BUILD_ROOT/%{HTTPD_CONF_DIR}/conf.d
162 install -m 755 -d $RPM_BUILD_ROOT/%{CROND_DIR}
165 for i in common cronjobs etc rpm-specific utils www ; do
166 cp -rp $i $RPM_BUILD_ROOT/%{GFORGE_DIR}/
169 #create a repository to link the plugins web pages
170 install -m 755 -d $RPM_BUILD_ROOT/%{GFORGE_DIR}/www/plugins
172 install -m 750 setup $RPM_BUILD_ROOT/%{GFORGE_DIR}/
173 chmod 755 $RPM_BUILD_ROOT/%{GFORGE_DIR}/utils/fill-in-the-blanks.pl
174 chmod 755 $RPM_BUILD_ROOT/%{GFORGE_DIR}/utils/install-nsspgsql.sh
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 ; 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}/
194 if ls translations/*.po &> /dev/null; then
195 cp translations/*.po $RPM_BUILD_ROOT/%{GFORGE_LANG_DIR}/
197 cp -rp rpm-specific/custom $RPM_BUILD_ROOT/%{GFORGE_CONF_DIR}
200 install -m 664 rpm-specific/cron.d/fusion/fusionforge $RPM_BUILD_ROOT/%{CROND_DIR}/
204 #tcpip_socket is no more use with postgres 8.x
205 #if su -l postgres -s /bin/sh -c 'psql template1 -c "SHOW tcpip_socket;"' | grep " off" &> /dev/null; then
207 # echo "# You should set tcpip_socket = true in your /var/lib/pgsql/data/postgresql.conf"
208 # echo "# before installing GForge and restart PostgreSQL."
209 # echo "# Then you should be able to install GForge RPM."
213 if ! id -u %gfuser >/dev/null 2>&1; then
214 groupadd -r %{gfgroup}
215 useradd -r -g %{gfgroup} -d %{GFORGE_DIR} -s /bin/bash -c "GForge User" %{gfuser}
219 if [ "$1" -eq "1" ]; then
220 # creating the database
222 su -l postgres -s /bin/sh -c "createdb -E UNICODE %{dbname} >/dev/null 2>&1"
223 su -l postgres -s /bin/sh -c "createlang plpgsql %{dbname} >/dev/null 2>&1"
225 # generating and updating site admin password
226 %randstr SITEADMIN_PASSWORD 8
228 # updating admin_password in gforge.conf
230 s#^admin_password=.*#admin_password="$SITEADMIN_PASSWORD"#g" %{GFORGE_CONF_DIR}/gforge.conf
232 SITEADMIN_PASSWORD=`echo -n $SITEADMIN_PASSWORD | md5sum | awk '{print $1}'`
234 # creating gforge database user
235 %randstr GFORGEDATABASE_PASSWORD 8
237 su -l postgres -c "psql -c \"CREATE USER %{dbuser} WITH PASSWORD '$GFORGEDATABASE_PASSWORD' NOCREATEUSER\" %{dbname} >/dev/null 2>&1"
238 su -l postgres -c "psql -c \"CREATE USER gforge_nss WITH PASSWORD '$GFORGEDATABASE_PASSWORD' NOCREATEUSER\" %{dbname} >/dev/null 2>&1"
239 su -l postgres -c "psql -c \"CREATE USER gforge_mta WITH PASSWORD '$GFORGEDATABASE_PASSWORD' NOCREATEUSER\" %{dbname} >/dev/null 2>&1"
241 # updating PostgreSQL configuration
242 if ! grep -i '^ *host.*%{dbname}.*' /var/lib/pgsql/data/pg_hba.conf >/dev/null 2>&1; then
243 echo 'host %{dbname} %{dbuser} 127.0.0.1 255.255.255.255 md5' >> /var/lib/pgsql/data/pg_hba.conf
244 echo 'host %{dbname} gforge_nss 127.0.0.1 255.255.255.255 trust' >> /var/lib/pgsql/data/pg_hba.conf
245 echo 'host %{dbname} gforge_mta 127.0.0.1 255.255.255.255 trust' >> /var/lib/pgsql/data/pg_hba.conf
249 # adding "noreply" alias
250 for i in /etc/postfix/aliases /etc/mail/aliases /etc/aliases ; do
252 if ! grep -i '^ *noreply:' $i >/dev/null 2>&1; then
253 echo 'noreply: /dev/null' >> $i
260 # generating random session ID
263 # replacing variables in configuration files
265 s/DB_HOST/"%{dbhost}"/g;
266 s/DB_NAME/"%{dbname}"/g;
267 s/DB_USER/"%{dbuser}"/g;
268 s/DB_PASSWORD/"$GFORGEDATABASE_PASSWORD"/g;
269 s/SYSTEM_NAME/"%{sitename}"/g;
270 s/RANDOM_ID/"$SESSID"/g;
271 s/HOST_NAME/"%{hostname}"/g" %{GFORGE_CONF_DIR}/gforge.conf
274 adminemail=$(echo "%{adminemail}"| sed 's|@|\\\@|g')
276 s/SERVER_ADMIN/"$adminemail"/g" %{GFORGE_CONF_DIR}/gforge.conf
279 path_jpgraph=$(rpm -ql php-jpgraph | grep jpgraph.php)
281 s#^sys_path_to_jpgraph=.*#sys_path_to_jpgraph=$path_jpgraph#g" %{GFORGE_CONF_DIR}/gforge.conf
283 #wrong 20list http template for mailman on rpm
284 rm -f %{GFORGE_CONF_DIR}/httpd.d/20list
287 s#^GFORGE_CONF_DIR=.*#GFORGE_CONF_DIR="%{GFORGE_CONF_DIR}"#g" %{SBIN_DIR}/gforge-config
289 ## plugins installs apache templates in GFORGE_CONF_DIR
290 ln -s %{GFORGE_DIR}/etc/httpd.d %{GFORGE_CONF_DIR}/httpd.d
292 # initializing configuration
293 %{SBIN_DIR}/gforge-config
295 # creating the database
296 su -l %{gfuser} -c "%{GFORGE_BIN_DIR}/db-upgrade.pl 2>&1" | grep -v ^NOTICE
297 su -l postgres -c "psql -c 'UPDATE groups SET register_time=EXTRACT(EPOCH FROM NOW());' %{dbname} >/dev/null 2>&1"
298 %changepassword $SITEADMIN_PASSWORD
300 # creation *.mo files for gettext
301 for l in eu bg ca zh_TW nl en eo fr de el he id it ja ko la nb pl pt_BR pt ru zh_CN es sv th ; do mkdir -p /usr/share/locale/$l/LC_MESSAGES && msgfmt -o /usr/share/locale/$l/LC_MESSAGES/gforge.mo %{GFORGE_LANG_DIR}/$l.po ; done
305 if ! id -u anonymous >/dev/null 2>&1; then
306 useradd -m -s /bin/false anonymous
309 # [ ! -f /usr/bin/php4 ] && ln -s /usr/bin/php /usr/bin/php4
311 chroot=`grep '^gforge_chroot:' /etc/gforge/gforge.conf | sed 's/.*:\s*\(.*\)/\1/'`
312 if [ ! -d /var/lib/gforge/chroot/ ] ; then
313 mkdir -p /var/lib/gforge/chroot/
316 ln -s %{GFORGE_DIR}/www/env.inc.php %{PLUGINS_LIB_DIR}/env.inc.php
318 #if not the env.inc.php include-path isn't correct
319 ln -s %{PLUGINS_LIB_DIR} %{GFORGE_DIR}/plugins
321 #Configuration de libnss-pgsql
322 ln -s %{GFORGE_DIR}/utils/install-nsspgsql.sh /usr/sbin
323 install-nsspgsql.sh setup
327 su -l %{gfuser} -c "%{GFORGE_BIN_DIR}/db-upgrade.pl 2>&1" | grep -v ^NOTICE
329 # updating configuration
330 %{SBIN_DIR}/gforge-config || :
332 # creation *.mo files for gettext
333 for l in eu bg ca zh_TW nl en eo fr de el he id it ja ko la nb pl pt_BR pt ru zh_CN es sv th ; do mkdir -p /usr/share/locale/$l/LC_MESSAGES && msgfmt -o /usr/share/locale/$l/LC_MESSAGES/gforge.mo %{GFORGE_LANG_DIR}/$l.po ; done
339 if [ "$1" -eq "0" ]; then
340 # dropping gforge users
341 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"
343 for file in local.pl httpd.secrets local.inc httpd.conf httpd.vhosts database.inc ; do
344 rm -f %{GFORGE_CONF_DIR}/$file
346 # Remove PostgreSQL access
347 if grep -i '^ *host.*%{dbname}.*' /var/lib/pgsql/data/pg_hba.conf >/dev/null 2>&1; then
348 perl -ni -e 'm@^ *host.*%{dbname}.*@ or print;' /var/lib/pgsql/data/pg_hba.conf >/dev/null 2>&1
349 perl -ni -e 'm@^ *local.*%{dbname}.*@ or print;' /var/lib/pgsql/data/pg_hba.conf >/dev/null 2>&1
352 if id -u %{gfuser} >/dev/null 2>&1; then
353 userdel %{gfuser} >/dev/null 2>&1
354 groupdel %{gfgroup} >/dev/null 2>&1
357 if ! id -u anonymous >/dev/null 2>&1; then
358 userdel anonymous 2>/dev/null || :
361 [ -L /usr/bin/php4 ] && rm -f /usr/bin/php4
366 [ "$RPM_BUILD_ROOT" != "/" ] && rm -rf $RPM_BUILD_ROOT
369 %defattr(-, root, root)
370 %doc AUTHORS AUTHORS.sourceforge COPYING ChangeLog INSTALL README*
372 %attr(0660, %{httpduser}, gforge) %config(noreplace) %{GFORGE_CONF_DIR}/gforge.conf
373 %attr(0750, root, root) %{SBIN_DIR}/gforge-config
374 %attr(0640, %{httpduser}, %{httpdgroup}) %config(noreplace) %{HTTPD_CONF_DIR}/conf.d/gforge.conf
375 %attr(0644, root, root) %{CROND_DIR}/fusionforge
376 %attr(0775, %{httpduser}, %{httpdgroup}) %dir %{UPLOAD_DIR}
377 %attr(0775, %{httpduser}, %{httpdgroup}) %dir %{CACHE_DIR}
387 * Wed Jun 29 2005 Open Wide <guillaume.smet@openwide.fr>
388 - fixed Xavier's patch
389 - added Mandrake support based on patch [#1194] by Kevin R. Bulgrien
390 * Wed Apr 27 2005 Rameau Xavier <xrameau@gmail.com> (for e-LaSer : http://www.e-laser.fr)
391 - Adding specification for SuSE Linux Enterprise Server 9 (in .spec)
392 - Moving all static definitions to global variables (in .spec)
393 * Thu Mar 03 2005 Guillaume Smet <guillaume-gforge@smet.org>
394 - removed useless stuff thanks to Christian's work on db-upgrade.pl
395 - s/refresh.sh/gforge-config to improve consistency with debian packaging
396 - it's better to display the output of db-upgrade.pl
397 * Sun Feb 20 2005 Guillaume Smet <guillaume-gforge@smet.org>
398 - added a dependency on gforge-lib-jpgraph
399 - added gforge-4.1-project_task_sql.patch
400 * Sat Feb 19 2005 Guillaume Smet <guillaume-gforge@smet.org>
402 - forced the vhost on port 80
403 - modified the db-upgrade.pl patch to keep nss stuff
404 - detects if tcpip_socket is set to true before installing the RPM
405 - fixed dependencies problem for RH9 and RHEL3
406 - creates gforge_nss and gforge_mta postgresql users
407 - drops created postgresql users on uninstall
408 - replaced -f test with ls
409 * Fri Jan 28 2005 Thales Information Systems <guillaume.smet@openwide.fr>
410 - fixed default values for release, sitename and hostname
411 - fixed remaining issues on upgrade
412 * Thu Jan 27 2005 Thales Information Systems <guillaume.smet@openwide.fr>
413 - it's now possible to add custom stuff in /etc/gforge/custom/
414 * Thu Dec 30 2004 Guillaume Smet <guillaume-gforge@smet.org>
415 - added Allow from all in vhost config
416 * Wed Dec 29 2004 Guillaume Smet <guillaume-gforge@smet.org>
417 - added the magic_quotes_gpc On in vhost as the default value for FC3 is now Off
418 * Sat Dec 25 2004 Guillaume Smet <guillaume-gforge@smet.org>
419 - it's now possible to add specific language files in the RPM
420 * Fri Dec 03 2004 Dassault Aviation <guillaume.smet@openwide.fr>
421 - fixed the vhost configuration
422 - fixed the default crontab
423 - the crontab is now a config file and is not replaced on update
424 - added refresh.sh in /etc/gforge/ to refresh the configuration easily
425 * Wed Nov 03 2004 Guillaume Smet <guillaume-gforge@smet.org>