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}/
168 #create a repository to link the plugins web pages
169 install -m 755 -d $RPM_BUILD_ROOT/%{GFORGE_DIR}/www/plugins
171 install -m 750 setup $RPM_BUILD_ROOT/%{GFORGE_DIR}/
172 chmod 755 $RPM_BUILD_ROOT/%{GFORGE_DIR}/utils/fill-in-the-blanks.pl
173 #chmod 755 $RPM_BUILD_ROOT/%{GFORGE_DIR}/utils/install-nsspgsql.sh
174 chmod 755 $RPM_BUILD_ROOT/%{GFORGE_DIR}/www/scm/viewvc/bin/cgi/viewvc.cgi
176 cp -rp db/. $RPM_BUILD_ROOT/%{GFORGE_DB_DIR}/
177 cp -p deb-specific/sf-2.6-complete.sql $RPM_BUILD_ROOT/%{GFORGE_DB_DIR}/
179 for i in deb-specific/sqlhelper.pm deb-specific/sqlparser.pm utils/include.pl ; do
180 cp -p $i $RPM_BUILD_ROOT/%{GFORGE_LIB_DIR}/
182 for i in db-upgrade.pl register-plugin unregister-plugin register-theme unregister-theme ; do
183 install -m 755 deb-specific/$i $RPM_BUILD_ROOT/%{GFORGE_BIN_DIR}/
187 ## use post install setup script instead
188 install -m 644 rpm-specific/httpd.d/gforge.conf $RPM_BUILD_ROOT/%{HTTPD_CONF_DIR}/conf.d/gforge.conf
191 install -m 600 rpm-specific/conf/gforge.conf $RPM_BUILD_ROOT/%{GFORGE_CONF_DIR}/
192 install -m 750 rpm-specific/scripts/gforge-config $RPM_BUILD_ROOT/%{SBIN_DIR}/
193 if ls translations/*.po &> /dev/null; then
194 cp translations/*.po $RPM_BUILD_ROOT/%{GFORGE_LANG_DIR}/
196 cp -rp rpm-specific/custom $RPM_BUILD_ROOT/%{GFORGE_CONF_DIR}
199 install -m 664 rpm-specific/cron.d/fusionforge $RPM_BUILD_ROOT/%{CROND_DIR}/
203 #tcpip_socket is no more use with postgres 8.x
204 #if su -l postgres -s /bin/sh -c 'psql template1 -c "SHOW tcpip_socket;"' | grep " off" &> /dev/null; then
206 # echo "# You should set tcpip_socket = true in your /var/lib/pgsql/data/postgresql.conf"
207 # echo "# before installing GForge and restart PostgreSQL."
208 # echo "# Then you should be able to install GForge RPM."
212 if ! id -u %gfuser >/dev/null 2>&1; then
213 groupadd -r %{gfgroup}
214 useradd -r -g %{gfgroup} -d %{GFORGE_DIR} -s /bin/bash -c "GForge User" %{gfuser}
218 if [ "$1" -eq "1" ]; then
219 # creating the database
221 su -l postgres -s /bin/sh -c "createdb -E UNICODE %{dbname} >/dev/null 2>&1"
222 su -l postgres -s /bin/sh -c "createlang plpgsql %{dbname} >/dev/null 2>&1"
224 # generating and updating site admin password
225 %randstr SITEADMIN_PASSWORD 8
227 # updating admin_password in gforge.conf
229 s#^admin_password=.*#admin_password="$SITEADMIN_PASSWORD"#g" %{GFORGE_CONF_DIR}/gforge.conf
231 SITEADMIN_PASSWORD=`echo -n $SITEADMIN_PASSWORD | md5sum | awk '{print $1}'`
233 # creating gforge database user
234 %randstr GFORGEDATABASE_PASSWORD 8
236 su -l postgres -c "psql -c \"CREATE USER %{dbuser} WITH PASSWORD '$GFORGEDATABASE_PASSWORD' NOCREATEUSER\" %{dbname} >/dev/null 2>&1"
237 su -l postgres -c "psql -c \"CREATE USER gforge_mta WITH PASSWORD '$GFORGEDATABASE_PASSWORD' NOCREATEUSER\" %{dbname} >/dev/null 2>&1"
239 # updating PostgreSQL configuration
240 if ! grep -i '^ *host.*%{dbname}.*' /var/lib/pgsql/data/pg_hba.conf >/dev/null 2>&1; then
241 echo 'host %{dbname} %{dbuser} 127.0.0.1 255.255.255.255 md5' >> /var/lib/pgsql/data/pg_hba.conf
242 echo 'host %{dbname} gforge_mta 127.0.0.1 255.255.255.255 trust' >> /var/lib/pgsql/data/pg_hba.conf
246 # adding "noreply" alias
247 for i in /etc/postfix/aliases /etc/mail/aliases /etc/aliases ; do
249 if ! grep -i '^ *noreply:' $i >/dev/null 2>&1; then
250 echo 'noreply: /dev/null' >> $i
257 # generating random session ID
260 # replacing variables in configuration files
262 s/DB_HOST/"%{dbhost}"/g;
263 s/DB_NAME/"%{dbname}"/g;
264 s/DB_USER/"%{dbuser}"/g;
265 s/DB_PASSWORD/"$GFORGEDATABASE_PASSWORD"/g;
266 s/SYSTEM_NAME/"%{sitename}"/g;
267 s/RANDOM_ID/"$SESSID"/g;
268 s/HOST_NAME/"%{hostname}"/g" %{GFORGE_CONF_DIR}/gforge.conf
271 adminemail=$(echo "%{adminemail}"| sed 's|@|\\\@|g')
273 s/SERVER_ADMIN/"$adminemail"/g" %{GFORGE_CONF_DIR}/gforge.conf
276 path_jpgraph=$(rpm -ql php-jpgraph | grep jpgraph.php)
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
297 # creation *.mo files for gettext
298 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
302 if ! id -u anonymous >/dev/null 2>&1; then
303 useradd -m -s /bin/false anonymous
306 # [ ! -f /usr/bin/php4 ] && ln -s /usr/bin/php /usr/bin/php4
308 CHROOT=`grep '^gforge_chroot=' %{GFORGE_CONF_DIR}/gforge.conf | sed 's/.*=\s*\(.*\)/\1/'`
309 if [ ! -d $CHROOT ] ; then
313 ln -s %{GFORGE_DIR}/www/env.inc.php %{PLUGINS_LIB_DIR}/env.inc.php
315 #if not the env.inc.php include-path isn't correct
316 ln -s %{PLUGINS_LIB_DIR} %{GFORGE_DIR}/plugins
318 #Configuration de libnss-pgsql
319 #ln -s %{GFORGE_DIR}/utils/install-nsspgsql.sh /usr/sbin
320 #install-nsspgsql.sh setup
324 su -l %{gfuser} -c "%{GFORGE_BIN_DIR}/db-upgrade.pl 2>&1" | grep -v ^NOTICE
326 # updating configuration
327 %{SBIN_DIR}/gforge-config || :
329 # creation *.mo files for gettext
330 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
336 if [ "$1" -eq "0" ]; then
337 # dropping gforge users
338 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"
340 for file in local.pl httpd.secrets local.inc httpd.conf httpd.vhosts database.inc ; do
341 rm -f %{GFORGE_CONF_DIR}/$file
343 # Remove PostgreSQL access
344 if grep -i '^ *host.*%{dbname}.*' /var/lib/pgsql/data/pg_hba.conf >/dev/null 2>&1; then
345 perl -ni -e 'm@^ *host.*%{dbname}.*@ or print;' /var/lib/pgsql/data/pg_hba.conf >/dev/null 2>&1
346 perl -ni -e 'm@^ *local.*%{dbname}.*@ or print;' /var/lib/pgsql/data/pg_hba.conf >/dev/null 2>&1
349 if id -u %{gfuser} >/dev/null 2>&1; then
350 userdel %{gfuser} >/dev/null 2>&1
351 groupdel %{gfgroup} >/dev/null 2>&1
354 if ! id -u anonymous >/dev/null 2>&1; then
355 userdel anonymous 2>/dev/null || :
358 [ -L /usr/bin/php4 ] && rm -f /usr/bin/php4
363 [ "$RPM_BUILD_ROOT" != "/" ] && rm -rf $RPM_BUILD_ROOT
366 %defattr(-, root, root)
367 %doc AUTHORS AUTHORS.sourceforge COPYING ChangeLog INSTALL README*
369 %attr(0660, %{httpduser}, gforge) %config(noreplace) %{GFORGE_CONF_DIR}/gforge.conf
370 %attr(0750, root, root) %{SBIN_DIR}/gforge-config
371 %attr(0640, %{httpduser}, %{httpdgroup}) %config(noreplace) %{HTTPD_CONF_DIR}/conf.d/gforge.conf
372 %attr(0644, root, root) %{CROND_DIR}/fusionforge
373 %attr(0775, %{httpduser}, %{httpdgroup}) %dir %{UPLOAD_DIR}
374 %attr(0775, %{httpduser}, %{httpdgroup}) %dir %{CACHE_DIR}
385 * Wed Jun 29 2005 Open Wide <guillaume.smet@openwide.fr>
386 - fixed Xavier's patch
387 - added Mandrake support based on patch [#1194] by Kevin R. Bulgrien
388 * Wed Apr 27 2005 Rameau Xavier <xrameau@gmail.com> (for e-LaSer : http://www.e-laser.fr)
389 - Adding specification for SuSE Linux Enterprise Server 9 (in .spec)
390 - Moving all static definitions to global variables (in .spec)
391 * Thu Mar 03 2005 Guillaume Smet <guillaume-gforge@smet.org>
392 - removed useless stuff thanks to Christian's work on db-upgrade.pl
393 - s/refresh.sh/gforge-config to improve consistency with debian packaging
394 - it's better to display the output of db-upgrade.pl
395 * Sun Feb 20 2005 Guillaume Smet <guillaume-gforge@smet.org>
396 - added a dependency on gforge-lib-jpgraph
397 - added gforge-4.1-project_task_sql.patch
398 * Sat Feb 19 2005 Guillaume Smet <guillaume-gforge@smet.org>
400 - forced the vhost on port 80
401 - modified the db-upgrade.pl patch to keep nss stuff
402 - detects if tcpip_socket is set to true before installing the RPM
403 - fixed dependencies problem for RH9 and RHEL3
404 - creates gforge_nss and gforge_mta postgresql users
405 - drops created postgresql users on uninstall
406 - replaced -f test with ls
407 * Fri Jan 28 2005 Thales Information Systems <guillaume.smet@openwide.fr>
408 - fixed default values for release, sitename and hostname
409 - fixed remaining issues on upgrade
410 * Thu Jan 27 2005 Thales Information Systems <guillaume.smet@openwide.fr>
411 - it's now possible to add custom stuff in /etc/gforge/custom/
412 * Thu Dec 30 2004 Guillaume Smet <guillaume-gforge@smet.org>
413 - added Allow from all in vhost config
414 * Wed Dec 29 2004 Guillaume Smet <guillaume-gforge@smet.org>
415 - added the magic_quotes_gpc On in vhost as the default value for FC3 is now Off
416 * Sat Dec 25 2004 Guillaume Smet <guillaume-gforge@smet.org>
417 - it's now possible to add specific language files in the RPM
418 * Fri Dec 03 2004 Dassault Aviation <guillaume.smet@openwide.fr>
419 - fixed the vhost configuration
420 - fixed the default crontab
421 - the crontab is now a config file and is not replaced on update
422 - added refresh.sh in /etc/gforge/ to refresh the configuration easily
423 * Wed Nov 03 2004 Guillaume Smet <guillaume-gforge@smet.org>