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: GForge 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
112 GForge is a web-based Collaborative Development Environment offering
113 easy access to CVS, mailing lists, bug tracking, message
114 boards/forums, task management, permanent file archival, and total
115 web-based administration.
117 # Macro for generating an environment variable (%1) with %2 random characters
118 %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";'`
120 # Change password for admin user
121 %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
123 %define GFORGE_DIR %{_datadir}/gforge
124 %define GFORGE_CONF_DIR %{_sysconfdir}/gforge
125 %define GFORGE_LANG_DIR %{_libdir}/gforge/translations
126 %define GFORGE_LIB_DIR %{_libdir}/gforge/lib
127 %define GFORGE_DB_DIR %{_libdir}/gforge/db
128 %define GFORGE_BIN_DIR %{_libdir}/gforge/bin
129 %define PLUGINS_LIB_DIR %{_libdir}/gforge/plugins
130 %define PLUGINS_CONF_DIR %{GFORGE_CONF_DIR}/plugins
131 %define CACHE_DIR /var/cache/gforge
132 %define UPLOAD_DIR /var/lib/gforge/upload
133 %define SCM_TARBALLS_DIR /var/lib/gforge/scmtarballs
134 %define SCM_SNAPSHOTS_DIR /var/lib/gforge/scmsnapshots
135 %define CROND_DIR /%{_sysconfdir}/cron.d
136 %define HTTPD_CONF_DIR /%{_sysconfdir}/%{httpddir}
137 %define SBIN_DIR %{_sbindir}
146 # cleaning build environment
147 [ "$RPM_BUILD_ROOT" != "/" ] && rm -rf $RPM_BUILD_ROOT
149 # creating required directories
150 install -m 755 -d $RPM_BUILD_ROOT/%{GFORGE_DIR}
151 install -m 755 -d $RPM_BUILD_ROOT/%{GFORGE_CONF_DIR}
152 install -m 755 -d $RPM_BUILD_ROOT/%{GFORGE_LANG_DIR}
153 install -m 755 -d $RPM_BUILD_ROOT/%{GFORGE_BIN_DIR}
154 install -m 755 -d $RPM_BUILD_ROOT/%{GFORGE_LIB_DIR}
155 install -m 755 -d $RPM_BUILD_ROOT/%{UPLOAD_DIR}
156 install -m 755 -d $RPM_BUILD_ROOT/%{CACHE_DIR}
157 install -m 755 -d $RPM_BUILD_ROOT/%{SCM_TARBALLS_DIR}
158 install -m 755 -d $RPM_BUILD_ROOT/%{PLUGINS_LIB_DIR}
159 install -m 755 -d $RPM_BUILD_ROOT/%{SBIN_DIR}
160 install -m 755 -d $RPM_BUILD_ROOT/%{HTTPD_CONF_DIR}/conf.d
161 install -m 755 -d $RPM_BUILD_ROOT/%{CROND_DIR}
164 for i in common cronjobs etc rpm-specific utils www ; do
165 cp -rp $i $RPM_BUILD_ROOT/%{GFORGE_DIR}/
167 install -m 750 setup $RPM_BUILD_ROOT/%{GFORGE_DIR}/
168 chmod 755 $RPM_BUILD_ROOT/%{GFORGE_DIR}/utils/fill-in-the-blanks.pl
169 chmod 755 $RPM_BUILD_ROOT/%{GFORGE_DIR}/utils/install-nsspgsql.sh
170 chmod 755 $RPM_BUILD_ROOT/%{GFORGE_DIR}/www/scm/viewvc/bin/cgi/viewvc.cgi
172 cp -rp db/. $RPM_BUILD_ROOT/%{GFORGE_DB_DIR}/
173 cp -p deb-specific/sf-2.6-complete.sql $RPM_BUILD_ROOT/%{GFORGE_DB_DIR}/
175 for i in deb-specific/sqlhelper.pm deb-specific/sqlparser.pm utils/include.pl ; do
176 cp -p $i $RPM_BUILD_ROOT/%{GFORGE_LIB_DIR}/
178 for i in db-upgrade.pl register-plugin unregister-plugin register-theme unregister-theme ; do
179 install -m 755 deb-specific/$i $RPM_BUILD_ROOT/%{GFORGE_BIN_DIR}/
183 ## use post install setup script instead
184 install -m 644 rpm-specific/httpd.d/gforge.conf $RPM_BUILD_ROOT/%{HTTPD_CONF_DIR}/conf.d/gforge.conf
187 install -m 600 rpm-specific/conf/gforge.conf $RPM_BUILD_ROOT/%{GFORGE_CONF_DIR}/
188 install -m 750 rpm-specific/scripts/gforge-config $RPM_BUILD_ROOT/%{SBIN_DIR}/
189 if ls translations/*.po &> /dev/null; then
190 cp translations/*.po $RPM_BUILD_ROOT/%{GFORGE_LANG_DIR}/
192 cp -rp rpm-specific/custom $RPM_BUILD_ROOT/%{GFORGE_CONF_DIR}
195 install -m 664 rpm-specific/cron.d/gforge $RPM_BUILD_ROOT/%{CROND_DIR}/
199 #tcpip_socket is no more use with postgres 8.x
200 #if su -l postgres -s /bin/sh -c 'psql template1 -c "SHOW tcpip_socket;"' | grep " off" &> /dev/null; then
202 # echo "# You should set tcpip_socket = true in your /var/lib/pgsql/data/postgresql.conf"
203 # echo "# before installing GForge and restart PostgreSQL."
204 # echo "# Then you should be able to install GForge RPM."
208 if ! id -u %gfuser >/dev/null 2>&1; then
209 groupadd -r %{gfgroup}
210 useradd -r -g %{gfgroup} -d %{GFORGE_DIR} -s /bin/bash -c "GForge User" %{gfuser}
214 if [ "$1" -eq "1" ]; then
215 # creating the database
217 su -l postgres -s /bin/sh -c "createdb -E UNICODE %{dbname} >/dev/null 2>&1"
218 su -l postgres -s /bin/sh -c "createlang plpgsql %{dbname} >/dev/null 2>&1"
220 # generating and updating site admin password
221 %randstr SITEADMIN_PASSWORD 8
223 echo "$SITEADMIN_PASSWORD" > %{GFORGE_CONF_DIR}/siteadmin.pass
224 chmod 0600 %{GFORGE_CONF_DIR}/siteadmin.pass
225 SITEADMIN_PASSWORD=`echo -n $SITEADMIN_PASSWORD | md5sum | awk '{print $1}'`
227 # creating gforge database user
228 %randstr GFORGEDATABASE_PASSWORD 8
230 su -l postgres -c "psql -c \"CREATE USER %{dbuser} WITH PASSWORD '$GFORGEDATABASE_PASSWORD' NOCREATEUSER\" %{dbname} >/dev/null 2>&1"
231 su -l postgres -c "psql -c \"CREATE USER gforge_nss WITH PASSWORD '$GFORGEDATABASE_PASSWORD' NOCREATEUSER\" %{dbname} >/dev/null 2>&1"
232 su -l postgres -c "psql -c \"CREATE USER gforge_mta WITH PASSWORD '$GFORGEDATABASE_PASSWORD' NOCREATEUSER\" %{dbname} >/dev/null 2>&1"
234 # updating PostgreSQL configuration
235 if ! grep -i '^ *host.*%{dbname}.*' /var/lib/pgsql/data/pg_hba.conf >/dev/null 2>&1; then
236 echo 'host %{dbname} %{dbuser} 127.0.0.1 255.255.255.255 md5' >> /var/lib/pgsql/data/pg_hba.conf
237 echo 'host %{dbname} gforge_nss 127.0.0.1 255.255.255.255 trust' >> /var/lib/pgsql/data/pg_hba.conf
238 echo 'host %{dbname} gforge_mta 127.0.0.1 255.255.255.255 trust' >> /var/lib/pgsql/data/pg_hba.conf
242 # adding "noreply" alias
243 for i in /etc/postfix/aliases /etc/mail/aliases /etc/aliases ; do
245 if ! grep -i '^ *noreply:' $i >/dev/null 2>&1; then
246 echo 'noreply: /dev/null' >> $i
253 # generating random session ID
256 # replacing variables in configuration files
258 s/DB_HOST/"%{dbhost}"/g;
259 s/DB_NAME/"%{dbname}"/g;
260 s/DB_USER/"%{dbuser}"/g;
261 s/DB_PASSWORD/"$GFORGEDATABASE_PASSWORD"/g;
262 s/SYSTEM_NAME/"%{sitename}"/g;
263 s/RANDOM_ID/"$SESSID"/g;
264 s/HOST_NAME/"%{hostname}"/g" %{GFORGE_CONF_DIR}/gforge.conf
267 adminemail=$(echo "%{adminemail}"| sed 's|@|\\\@|g')
269 s/SERVER_ADMIN/"$adminemail"/g" %{GFORGE_CONF_DIR}/gforge.conf
271 #wrong 20list http template for mailman on rpm
272 rm -f %{GFORGE_CONF_DIR}/httpd.d/20list
275 s#^GFORGE_CONF_DIR=.*#GFORGE_CONF_DIR="%{GFORGE_CONF_DIR}"#g" %{SBIN_DIR}/gforge-config
277 ## plugins installs apache templates in GFORGE_CONF_DIR
278 ln -s %{GFORGE_DIR}/etc/httpd.d %{GFORGE_CONF_DIR}/httpd.d
280 # initializing configuration
281 %{SBIN_DIR}/gforge-config
283 # creating the database
284 su -l %{gfuser} -c "%{GFORGE_BIN_DIR}/db-upgrade.pl 2>&1" | grep -v ^NOTICE
285 su -l postgres -c "psql -c 'UPDATE groups SET register_time=EXTRACT(EPOCH FROM NOW());' %{dbname} >/dev/null 2>&1"
286 %changepassword $SITEADMIN_PASSWORD
288 # creation *.mo files for gettext
289 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
293 if ! id -u anonymous >/dev/null 2>&1; then
294 useradd -m -s /bin/false anonymous
297 [ ! -f /usr/bin/php4 ] && ln -s /usr/bin/php /usr/bin/php4
299 chroot=`grep '^gforge_chroot:' /etc/gforge/gforge.conf | sed 's/.*:\s*\(.*\)/\1/'`
300 if [ ! -d /var/lib/gforge/chroot/ ] ; then
301 mkdir -p /var/lib/gforge/chroot/
304 ln -s %{GFORGE_DIR}/www/env.inc.php %{PLUGINS_LIB_DIR}
306 #Configuration de libnss-pgsql
307 ln -s %{GFORGE_DIR}/utils/install-nsspgsql.sh /usr/sbin
308 install-nsspgsql.sh setup
312 su -l %{gfuser} -c "%{GFORGE_BIN_DIR}/db-upgrade.pl 2>&1" | grep -v ^NOTICE
314 # updating configuration
315 %{SBIN_DIR}/gforge-config || :
317 # creation *.mo files for gettext
318 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
324 if [ "$1" -eq "0" ]; then
325 # dropping gforge users
326 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"
328 for file in siteadmin.pass local.pl httpd.secrets local.inc httpd.conf httpd.vhosts database.inc ; do
329 rm -f %{GFORGE_CONF_DIR}/$file
331 # Remove PostgreSQL access
332 if grep -i '^ *host.*%{dbname}.*' /var/lib/pgsql/data/pg_hba.conf >/dev/null 2>&1; then
333 perl -ni -e 'm@^ *host.*%{dbname}.*@ or print;' /var/lib/pgsql/data/pg_hba.conf >/dev/null 2>&1
334 perl -ni -e 'm@^ *local.*%{dbname}.*@ or print;' /var/lib/pgsql/data/pg_hba.conf >/dev/null 2>&1
337 if id -u %{gfuser} >/dev/null 2>&1; then
338 userdel %{gfuser} >/dev/null 2>&1
339 groupdel %{gfgroup} >/dev/null 2>&1
342 if ! id -u anonymous >/dev/null 2>&1; then
343 userdel anonymous 2>/dev/null || :
346 [ -L /usr/bin/php4 ] && rm -f /usr/bin/php4
351 [ "$RPM_BUILD_ROOT" != "/" ] && rm -rf $RPM_BUILD_ROOT
354 %defattr(-, root, root)
355 %doc AUTHORS AUTHORS.sourceforge COPYING ChangeLog INSTALL README*
357 %attr(0660, %{httpduser}, gforge) %config(noreplace) %{GFORGE_CONF_DIR}/gforge.conf
358 %attr(0750, root, root) %{SBIN_DIR}/gforge-config
359 %attr(0640, %{httpduser}, %{httpdgroup}) %config(noreplace) %{HTTPD_CONF_DIR}/conf.d/gforge.conf
360 %attr(0644, root, root) %{CROND_DIR}/gforge
361 %attr(0775, %{httpduser}, %{httpdgroup}) %dir %{UPLOAD_DIR}
362 %attr(0775, %{httpduser}, %{httpdgroup}) %dir %{CACHE_DIR}
372 * Wed Jun 29 2005 Open Wide <guillaume.smet@openwide.fr>
373 - fixed Xavier's patch
374 - added Mandrake support based on patch [#1194] by Kevin R. Bulgrien
375 * Wed Apr 27 2005 Rameau Xavier <xrameau@gmail.com> (for e-LaSer : http://www.e-laser.fr)
376 - Adding specification for SuSE Linux Enterprise Server 9 (in .spec)
377 - Moving all static definitions to global variables (in .spec)
378 * Thu Mar 03 2005 Guillaume Smet <guillaume-gforge@smet.org>
379 - removed useless stuff thanks to Christian's work on db-upgrade.pl
380 - s/refresh.sh/gforge-config to improve consistency with debian packaging
381 - it's better to display the output of db-upgrade.pl
382 * Sun Feb 20 2005 Guillaume Smet <guillaume-gforge@smet.org>
383 - added a dependency on gforge-lib-jpgraph
384 - added gforge-4.1-project_task_sql.patch
385 * Sat Feb 19 2005 Guillaume Smet <guillaume-gforge@smet.org>
387 - forced the vhost on port 80
388 - modified the db-upgrade.pl patch to keep nss stuff
389 - detects if tcpip_socket is set to true before installing the RPM
390 - fixed dependencies problem for RH9 and RHEL3
391 - creates gforge_nss and gforge_mta postgresql users
392 - drops created postgresql users on uninstall
393 - replaced -f test with ls
394 * Fri Jan 28 2005 Thales Information Systems <guillaume.smet@openwide.fr>
395 - fixed default values for release, sitename and hostname
396 - fixed remaining issues on upgrade
397 * Thu Jan 27 2005 Thales Information Systems <guillaume.smet@openwide.fr>
398 - it's now possible to add custom stuff in /etc/gforge/custom/
399 * Thu Dec 30 2004 Guillaume Smet <guillaume-gforge@smet.org>
400 - added Allow from all in vhost config
401 * Wed Dec 29 2004 Guillaume Smet <guillaume-gforge@smet.org>
402 - added the magic_quotes_gpc On in vhost as the default value for FC3 is now Off
403 * Sat Dec 25 2004 Guillaume Smet <guillaume-gforge@smet.org>
404 - it's now possible to add specific language files in the RPM
405 * Fri Dec 03 2004 Dassault Aviation <guillaume.smet@openwide.fr>
406 - fixed the vhost configuration
407 - fixed the default crontab
408 - the crontab is now a config file and is not replaced on update
409 - added refresh.sh in /etc/gforge/ to refresh the configuration easily
410 * Wed Nov 03 2004 Guillaume Smet <guillaume-gforge@smet.org>