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, perl-Text-Autoformat, perl-Mail-Sendmail
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/%{SCM_SNAPSHOTS_DIR}
162 install -m 755 -d $RPM_BUILD_ROOT/%{PLUGINS_LIB_DIR}
163 install -m 755 -d $RPM_BUILD_ROOT/%{SBIN_DIR}
164 install -m 755 -d $RPM_BUILD_ROOT/%{HTTPD_CONF_DIR}/conf.d
165 install -m 755 -d $RPM_BUILD_ROOT/%{CROND_DIR}
168 for i in common cronjobs etc rpm-specific utils www ; do
169 cp -rp $i $RPM_BUILD_ROOT/%{GFORGE_DIR}/
171 #create a repository to link the plugins web pages
172 install -m 755 -d $RPM_BUILD_ROOT/%{GFORGE_DIR}/www/plugins
174 install -m 750 setup $RPM_BUILD_ROOT/%{GFORGE_DIR}/
175 chmod 755 $RPM_BUILD_ROOT/%{GFORGE_DIR}/utils/fill-in-the-blanks.pl
176 chmod 755 $RPM_BUILD_ROOT/%{GFORGE_DIR}/www/scm/viewvc/bin/cgi/viewvc.cgi
178 cp -rp db/. $RPM_BUILD_ROOT/%{GFORGE_DB_DIR}/
179 cp -p deb-specific/sf-2.6-complete.sql $RPM_BUILD_ROOT/%{GFORGE_DB_DIR}/
181 for i in deb-specific/sqlhelper.pm deb-specific/sqlparser.pm utils/include.pl ; do
182 cp -p $i $RPM_BUILD_ROOT/%{GFORGE_LIB_DIR}/
184 for i in db-upgrade.pl register-plugin unregister-plugin register-theme unregister-theme install-db.sh; do
185 install -m 755 deb-specific/$i $RPM_BUILD_ROOT/%{GFORGE_BIN_DIR}/
189 ## use post install setup script instead
190 install -m 644 rpm-specific/httpd.d/gforge.conf $RPM_BUILD_ROOT/%{HTTPD_CONF_DIR}/conf.d/gforge.conf
193 install -m 600 rpm-specific/conf/gforge.conf $RPM_BUILD_ROOT/%{GFORGE_CONF_DIR}/
194 install -m 750 rpm-specific/scripts/gforge-config $RPM_BUILD_ROOT/%{SBIN_DIR}/
197 cp -rp locales/* $RPM_BUILD_ROOT/%{GFORGE_LANG_DIR}/
200 install -m 664 packaging/cron.d/fusionforge $RPM_BUILD_ROOT/%{CROND_DIR}/
204 if ! id -u %gfuser >/dev/null 2>&1; then
205 groupadd -r %{gfgroup}
206 useradd -r -g %{gfgroup} -d %{GFORGE_DIR} -s /bin/bash -c "GForge User" %{gfuser}
210 if [ "$1" -eq "1" ]; then
212 # TODO : USE install-db.sh
213 # creating the database
215 su -l postgres -s /bin/sh -c "createdb -E UNICODE %{dbname} >/dev/null 2>&1"
216 su -l postgres -s /bin/sh -c "createlang plpgsql %{dbname} >/dev/null 2>&1"
218 # generating and updating site admin password
219 %randstr SITEADMIN_PASSWORD 8
221 # updating admin_password in gforge.conf
223 s#^admin_password=.*#admin_password="$SITEADMIN_PASSWORD"#g" %{GFORGE_CONF_DIR}/gforge.conf
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 # replacing variables in configuration files
236 s/DB_HOST/"%{dbhost}"/g;
237 s/DB_NAME/"%{dbname}"/g;
238 s/DB_USER/"%{dbuser}"/g;
239 s/DB_PASSWORD/"$GFORGEDATABASE_PASSWORD"/g;
240 s/SYSTEM_NAME/"%{sitename}"/g;
241 s/RANDOM_ID/"$SESSID"/g;
242 s/HOST_NAME/"%{hostname}"/g" %{GFORGE_CONF_DIR}/gforge.conf
245 adminemail=$(echo "%{adminemail}"| sed 's|@|\\\@|g')
247 s/SERVER_ADMIN/"$adminemail"/g" %{GFORGE_CONF_DIR}/gforge.conf
249 # updating PostgreSQL configuration
250 #if ! grep -i '^ *host.*%{dbname}.*' /var/lib/pgsql/data/pg_hba.conf >/dev/null 2>&1; then
251 # echo 'host %{dbname} %{dbuser} 127.0.0.1 255.255.255.255 md5' >> /var/lib/pgsql/data/pg_hba.conf
252 # echo 'local %{dbname} gforge_mta md5md5md5md5md5' >> /var/lib/pgsql/data/pg_hba.conf
253 # echo 'local %{dbname} gforge_nss trust' >> /var/lib/pgsql/data/pg_hba.conf
257 %{GFORGE_BIN_DIR}/install-db.sh configure-files
258 mv /var/lib/pgsql/data/pg_hba.conf /var/lib/pgsql/data/pg_hba.conf-orig
259 mv /var/lib/pgsql/data/pg_hba.conf.gforge-new /var/lib/pgsql/data/pg_hba.conf
262 # adding "noreply" alias
263 for i in /etc/postfix/aliases /etc/mail/aliases /etc/aliases ; do
265 if ! grep -i '^ *noreply:' $i >/dev/null 2>&1; then
266 echo 'noreply: /dev/null' >> $i
273 # generating random session ID
277 path_jpgraph=$(rpm -ql php-jpgraph | grep jpgraph.php | sed 's/\(.*\)jpgraph.php/\1/')
279 s#^sys_path_to_jpgraph=.*#sys_path_to_jpgraph=$path_jpgraph#g" %{GFORGE_CONF_DIR}/gforge.conf
281 #wrong 20list http template for mailman on rpm
282 rm -f %{GFORGE_CONF_DIR}/httpd.d/20list
285 s#^GFORGE_CONF_DIR=.*#GFORGE_CONF_DIR="%{GFORGE_CONF_DIR}"#g" %{SBIN_DIR}/gforge-config
287 ## plugins installs apache templates in GFORGE_CONF_DIR
288 ln -s %{GFORGE_DIR}/etc/httpd.d %{GFORGE_CONF_DIR}/httpd.d
290 # initializing configuration
291 %{SBIN_DIR}/gforge-config
293 # creating the database
294 su -l %{gfuser} -c "%{GFORGE_BIN_DIR}/db-upgrade.pl 2>&1" | grep -v ^NOTICE
295 su -l postgres -c "psql -c 'UPDATE groups SET register_time=EXTRACT(EPOCH FROM NOW());' %{dbname} >/dev/null 2>&1"
296 %changepassword $SITEADMIN_PASSWORD
300 if ! id -u anonymous >/dev/null 2>&1; then
301 useradd -m -s /bin/false anonymous
304 # [ ! -f /usr/bin/php4 ] && ln -s /usr/bin/php /usr/bin/php4
306 CHROOT=`grep '^gforge_chroot=' %{GFORGE_CONF_DIR}/gforge.conf | sed 's/.*=\s*\(.*\)/\1/'`
307 if [ ! -d $CHROOT ] ; then
311 GROUPS_DIR=`grep '^groupdir=' %{GFORGE_CONF_DIR}/gforge.conf | sed 's/.*=\s*\(.*\)/\1/'`
312 if [ ! -d ${CHROOT}${GROUPS_DIR} ] ; then
313 mkdir -p ${CHROOT}${GROUPS_DIR}
316 ln -s %{GFORGE_DIR}/www/env.inc.php %{PLUGINS_LIB_DIR}/env.inc.php
318 #creation of scm-gforge user
319 adduser --home-dir /var/lib/gforge/chroot/ scm-gforge
322 su -l %{gfuser} -c "%{GFORGE_BIN_DIR}/db-upgrade.pl 2>&1" | grep -v ^NOTICE
324 # updating configuration
325 %{SBIN_DIR}/gforge-config || :
332 if [ "$1" -eq "0" ]; then
333 # dropping gforge users
334 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"
336 for file in local.pl httpd.secrets local.inc httpd.conf httpd.vhosts database.inc ; do
337 rm -f %{GFORGE_CONF_DIR}/$file
339 # Remove PostgreSQL access
340 if grep -i '^ *host.*%{dbname}.*' /var/lib/pgsql/data/pg_hba.conf >/dev/null 2>&1; then
341 perl -ni -e 'm@^ *host.*%{dbname}.*@ or print;' /var/lib/pgsql/data/pg_hba.conf >/dev/null 2>&1
342 perl -ni -e 'm@^ *local.*%{dbname}.*@ or print;' /var/lib/pgsql/data/pg_hba.conf >/dev/null 2>&1
345 if id -u %{gfuser} >/dev/null 2>&1; then
346 userdel %{gfuser} >/dev/null 2>&1
347 groupdel %{gfgroup} >/dev/null 2>&1
350 if ! id -u anonymous >/dev/null 2>&1; then
351 userdel anonymous 2>/dev/null || :
354 #[ -L /usr/bin/php4 ] && rm -f /usr/bin/php4
359 [ "$RPM_BUILD_ROOT" != "/" ] && rm -rf $RPM_BUILD_ROOT
362 %defattr(-, root, root)
363 %doc AUTHORS AUTHORS.sourceforge COPYING ChangeLog INSTALL* README*
365 %attr(0660, %{httpduser}, gforge) %config(noreplace) %{GFORGE_CONF_DIR}/gforge.conf
366 %attr(0750, root, root) %{SBIN_DIR}/gforge-config
367 %attr(0640, %{httpduser}, %{httpdgroup}) %config(noreplace) %{HTTPD_CONF_DIR}/conf.d/gforge.conf
368 %attr(0644, root, root) %{CROND_DIR}/fusionforge
369 %attr(0775, %{httpduser}, %{httpdgroup}) %dir %{UPLOAD_DIR}
370 #%attr(0775, %{httpduser}, %{httpdgroup}) %dir %{CACHE_DIR}
378 * Wed Jun 29 2005 Open Wide <guillaume.smet@openwide.fr>
379 - fixed Xavier's patch
380 - added Mandrake support based on patch [#1194] by Kevin R. Bulgrien
381 * Wed Apr 27 2005 Rameau Xavier <xrameau@gmail.com> (for e-LaSer : http://www.e-laser.fr)
382 - Adding specification for SuSE Linux Enterprise Server 9 (in .spec)
383 - Moving all static definitions to global variables (in .spec)
384 * Thu Mar 03 2005 Guillaume Smet <guillaume-gforge@smet.org>
385 - removed useless stuff thanks to Christian's work on db-upgrade.pl
386 - s/refresh.sh/gforge-config to improve consistency with debian packaging
387 - it's better to display the output of db-upgrade.pl
388 * Sun Feb 20 2005 Guillaume Smet <guillaume-gforge@smet.org>
389 - added a dependency on gforge-lib-jpgraph
390 - added gforge-4.1-project_task_sql.patch
391 * Sat Feb 19 2005 Guillaume Smet <guillaume-gforge@smet.org>
393 - forced the vhost on port 80
394 - modified the db-upgrade.pl patch to keep nss stuff
395 - detects if tcpip_socket is set to true before installing the RPM
396 - fixed dependencies problem for RH9 and RHEL3
397 - creates gforge_nss and gforge_mta postgresql users
398 - drops created postgresql users on uninstall
399 - replaced -f test with ls
400 * Fri Jan 28 2005 Thales Information Systems <guillaume.smet@openwide.fr>
401 - fixed default values for release, sitename and hostname
402 - fixed remaining issues on upgrade
403 * Thu Jan 27 2005 Thales Information Systems <guillaume.smet@openwide.fr>
404 - it's now possible to add custom stuff in /etc/gforge/custom/
405 * Thu Dec 30 2004 Guillaume Smet <guillaume-gforge@smet.org>
406 - added Allow from all in vhost config
407 * Wed Dec 29 2004 Guillaume Smet <guillaume-gforge@smet.org>
408 - added the magic_quotes_gpc On in vhost as the default value for FC3 is now Off
409 * Sat Dec 25 2004 Guillaume Smet <guillaume-gforge@smet.org>
410 - it's now possible to add specific language files in the RPM
411 * Fri Dec 03 2004 Dassault Aviation <guillaume.smet@openwide.fr>
412 - fixed the vhost configuration
413 - fixed the default crontab
414 - the crontab is now a config file and is not replaced on update
415 - added refresh.sh in /etc/gforge/ to refresh the configuration easily
416 * Wed Nov 03 2004 Guillaume Smet <guillaume-gforge@smet.org>