1 %define dbhost localhost
4 %define dbpassword gforge
6 %if %{?hostname:0}%{!?hostname:1}
7 %define hostname localhost
9 %if %{?sitename:0}%{!?sitename:1}
10 %define sitename MyForge
12 %{!?release:%define release 1}
14 %if %{?dist:0}%{!?dist:1}
18 %define httpduser apache
20 %define gfgroup gforge
22 Summary: GForge Collaborative Development Environment
28 Group: Development/Tools
29 Source0: %{name}-%{version}.tar.bz2
30 URL: http://www.gforge.org/
31 BuildRoot: %{_tmppath}/%{name}-%{version}-root
33 Patch1000: gforge-4.0-deb_rpm.patch
36 Requires: /bin/sh, /bin/bash
37 Requires: perl, perl-DBI, perl-DBD-Pg, perl-HTML-Parser
39 Requires: php, php-pgsql
41 # Distribution specific (fc = Fedora Core - rh9 = Red Hat Linux 9 - el3 = Red Hat Enterprise Linux 3 or CentOS 3)
43 Requires: php-mbstring
45 %if "%{dist}" == "el3"
46 Requires: rh-postgresql, rh-postgresql-server
47 %define postgresqlservice rhdb
49 Requires: postgresql, postgresql-server
50 %define postgresqlservice postgresql
54 GForge is a web-based Collaborative Development Environment offering
55 easy access to CVS, mailing lists, bug tracking, message
56 boards/forums, task management, permanent file archival, and total
57 web-based administration.
59 # Macro for generating an environment variable (%1) with %2 random characters
60 %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";'`
62 # Change password for admin user
63 %define changepassword() echo "UPDATE users SET user_pw='%1' WHERE user_name='admin'" | su -l postgres -s /bin/sh -c "psql %dbname" >/dev/null 2>&1
65 # Start the postgresql service if needed
66 %define startpostgresql() service %postgresqlservice status | grep '(pid' >/dev/null 2>&1 || service %postgresqlservice start
75 # cleaning build environment
76 [ "$RPM_BUILD_ROOT" != "/" ] && rm -rf $RPM_BUILD_ROOT
79 GFORGE_DIR=$RPM_BUILD_ROOT/%{_datadir}/gforge
80 CACHE_DIR=$RPM_BUILD_ROOT/var/cache/gforge
81 UPLOAD_DIR=$RPM_BUILD_ROOT/var/lib/gforge/upload
82 SCM_TARBALLS_DIR=$RPM_BUILD_ROOT/var/lib/gforge/scmtarballs
83 SCM_SNAPSHOTS_DIR=$RPM_BUILD_ROOT/var/lib/gforge/scmsnapshots
84 HTTPD_CONF_DIR=$RPM_BUILD_ROOT/%{_sysconfdir}/httpd
85 GFORGE_CONF_DIR=$RPM_BUILD_ROOT/%{_sysconfdir}/gforge
86 GFORGE_LIB_DIR=$RPM_BUILD_ROOT/%{_libdir}/gforge
87 PLUGINS_DIR=$GFORGE_LIB_DIR/plugins
88 CROND_DIR=$RPM_BUILD_ROOT/%{_sysconfdir}/cron.d
91 mkdir -p $GFORGE_DIR $GFORGE_LIB_DIR
92 for i in common cronjobs etc rpm-specific utils www ; do
93 cp -rp $i $GFORGE_DIR/
95 chmod 755 $GFORGE_DIR/utils/fill-in-the-blanks.pl
97 install -m 750 setup $GFORGE_DIR/
98 cp -rp db $GFORGE_LIB_DIR/
99 cp -p deb-specific/sf-2.6-complete.sql $GFORGE_LIB_DIR/db/
100 mkdir -p $GFORGE_LIB_DIR/lib $GFORGE_LIB_DIR/bin
101 for i in deb-specific/sqlhelper.pm deb-specific/sqlparser.pm utils/include.pl ; do
102 cp -p $i $GFORGE_LIB_DIR/lib/
104 for i in db-upgrade.pl register-plugin unregister-plugin register-theme unregister-theme ; do
105 install -m 755 deb-specific/$i $GFORGE_LIB_DIR/bin/
108 # creating required directories
111 mkdir -p $SCM_TARBALLS_DIR
112 mkdir -p $PLUGINS_DIR
115 mkdir -p $HTTPD_CONF_DIR/conf.d
116 install -m 644 rpm-specific/conf/vhost.conf $HTTPD_CONF_DIR/conf.d/gforge.conf
119 mkdir -p $GFORGE_CONF_DIR
120 install -m 600 rpm-specific/conf/gforge.conf $GFORGE_CONF_DIR/
121 install -m 750 rpm-specific/scripts/refresh.sh $GFORGE_CONF_DIR/
122 mkdir -p $GFORGE_CONF_DIR/languages-local
123 if [ ls rpm-specific/languages/*.tab &> /dev/null ]; then
124 cp rpm-specific/languages/*.tab $GFORGE_CONF_DIR/languages-local/
126 cp -rp rpm-specific/custom $GFORGE_CONF_DIR
130 install -m 664 rpm-specific/cron.d/gforge $CROND_DIR/
134 if su -l postgres -s /bin/sh -c 'psql template1 -c "SHOW tcpip_socket;"' | grep " off" &> /dev/null; then
136 echo "# You should set tcpip_socket=true in your /var/lib/pgsql/data/postgresql.conf"
137 echo "# before installing GForge and restart PostgreSQL."
138 echo "# Then you should be able to install GForge RPM."
142 if ! id -u %gfuser >/dev/null 2>&1; then
143 groupadd -r %{gfgroup}
144 useradd -r -g %{gfgroup} -d %{_datadir}/gforge -s /bin/bash -c "GForge User" %{gfuser}
148 if [ "$1" -eq "1" ]; then
149 # creating the database
151 su -l postgres -s /bin/sh -c "createdb -E UNICODE %{dbname} >/dev/null 2>&1"
152 su -l postgres -s /bin/sh -c "createlang plpgsql %{dbname} >/dev/null 2>&1"
154 # generating and updating site admin password
155 %randstr SITEADMIN_PASSWORD 8
157 echo "$SITEADMIN_PASSWORD" > %{_sysconfdir}/gforge/siteadmin.pass
158 chmod 0600 %{_sysconfdir}/gforge/siteadmin.pass
159 SITEADMIN_PASSWORD=`echo -n $SITEADMIN_PASSWORD | md5sum | awk '{print $1}'`
161 # creating gforge database user
162 %randstr GFORGEDATABASE_PASSWORD 8
164 su -l postgres -c "psql -c \"CREATE USER %{dbuser} WITH PASSWORD '$GFORGEDATABASE_PASSWORD' NOCREATEUSER\" %{dbname} >/dev/null 2>&1"
165 su -l postgres -c "psql -c \"CREATE USER gforge_nss WITH PASSWORD '$GFORGEDATABASE_PASSWORD' NOCREATEUSER\" %{dbname} >/dev/null 2>&1"
166 su -l postgres -c "psql -c \"CREATE USER gforge_mta WITH PASSWORD '$GFORGEDATABASE_PASSWORD' NOCREATEUSER\" %{dbname} >/dev/null 2>&1"
168 # updating PostgreSQL configuration
169 if ! grep -i '^ *host.*%{dbname}.*' /var/lib/pgsql/data/pg_hba.conf >/dev/null 2>&1; then
170 echo 'host %{dbname} %{dbuser} 127.0.0.1 255.255.255.255 md5' >> /var/lib/pgsql/data/pg_hba.conf
171 echo 'local %{dbname} gforge_nss md5' >> /var/lib/pgsql/data/pg_hba.conf
172 echo 'local %{dbname} gforge_mta md5' >> /var/lib/pgsql/data/pg_hba.conf
173 service %postgresqlservice reload
176 # adding "noreply" alias
177 for i in /etc/postfix/aliases /etc/mail/aliases /etc/aliases ; do
179 if ! grep -i '^ *noreply:' $i >/dev/null 2>&1; then
180 echo 'noreply: /dev/null' >> $i
187 # generating random session ID
190 # replacing variables in configuration files
192 s/DB_HOST/"%{dbhost}"/g;
193 s/DB_NAME/"%{dbname}"/g;
194 s/DB_USER/"%{dbuser}"/g;
195 s/DB_PASSWORD/"$GFORGEDATABASE_PASSWORD"/g;
196 s/SYSTEM_NAME/"%{sitename}"/g;
197 s/RANDOM_ID/"$SESSID"/g;
198 s/HOST_NAME/"%{hostname}"/g" %{_sysconfdir}/gforge/gforge.conf
199 perl -pi -e "s/HOST_NAME/%{hostname}/g" /etc/httpd/conf.d/gforge.conf
201 # initializing configuration
202 cd %{_datadir}/gforge && ./setup -confdir %{_sysconfdir}/gforge/ -input %{_sysconfdir}/gforge/gforge.conf -noapache >/dev/null 2>&1
204 # creating the database
205 su -l %{gfuser} -c "%{_libdir}/gforge/bin/db-upgrade.pl >/dev/null 2>&1"
206 su -l postgres -c "psql -c 'UPDATE groups SET register_time=EXTRACT(EPOCH FROM NOW());' %{dbname} >/dev/null 2>&1"
207 %changepassword $SITEADMIN_PASSWORD
209 service httpd graceful >/dev/null 2>&1
212 su -l %{gfuser} -c "%{_libdir}/gforge/bin/db-upgrade.pl >/dev/null 2>&1"
214 # updating configuration
215 cd %{_datadir}/gforge && ./setup -confdir %{_sysconfdir}/gforge/ -input %{_sysconfdir}/gforge/gforge.conf -noapache >/dev/null 2>&1 || :
219 if [ "$1" -eq "0" ]; then
220 # dropping gforge users
221 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"
223 for file in siteadmin.pass local.pl httpd.secrets local.inc httpd.conf httpd.vhosts database.inc ; do
224 rm -f %{_sysconfdir}/gforge/$file
226 # Remove PostgreSQL access
227 if grep -i '^ *host.*%{dbname}.*' /var/lib/pgsql/data/pg_hba.conf >/dev/null 2>&1; then
228 perl -ni -e 'm@^ *host.*%{dbname}.*@ or print;' /var/lib/pgsql/data/pg_hba.conf >/dev/null 2>&1
229 perl -ni -e 'm@^ *local.*%{dbname}.*@ or print;' /var/lib/pgsql/data/pg_hba.conf >/dev/null 2>&1
232 if id -u %{gfuser} >/dev/null 2>&1; then
233 userdel %{gfuser} >/dev/null 2>&1
234 groupdel %{gfgroup} 2>/dev/null || :
239 [ "$RPM_BUILD_ROOT" != "/" ] && rm -rf $RPM_BUILD_ROOT
242 %defattr(-, root, root)
243 %doc AUTHORS AUTHORS.sourceforge COPYING ChangeLog INSTALL README*
245 %attr(0660, apache, gforge) %config(noreplace) %{_sysconfdir}/gforge/gforge.conf
246 %attr(0750, root, root) %{_sysconfdir}/gforge/refresh.sh
247 %attr(0640, apache, apache) %config(noreplace) %{_sysconfdir}/httpd/conf.d/gforge.conf
248 %attr(0664, root, root) %config(noreplace) %{_sysconfdir}/cron.d/gforge
249 %attr(0775, apache, apache) %dir /var/lib/gforge/upload
250 %attr(0775, apache, apache) %dir /var/cache/gforge
253 %{_sysconfdir}/gforge/languages-local
254 %{_sysconfdir}/gforge/custom
255 /var/lib/gforge/scmtarballs
258 * Sat Feb 19 2005 Guillaume Smet <guillaume-gforge@smet.org>
260 - forced the vhost on port 80
261 - modified the db-upgrade.pl patch to keep nss stuff
262 - detects if tcpip_socket is set to true before installing the RPM
263 - fixed dependencies problem for RH9 and RHEL3
264 - creates gforge_nss and gforge_mta postgresql users
265 - drops created postgresql users on uninstall
266 - replaced -f test with ls
267 * Fri Jan 28 2005 Thales Information Systems <guillaume.smet@openwide.fr>
268 - fixed default values for release, sitename and hostname
269 - fixed remaining issues on upgrade
270 * Thu Jan 27 2005 Thales Information Systems <guillaume.smet@openwide.fr>
271 - it's now possible to add custom stuff in /etc/gforge/custom/
272 * Thu Dec 30 2004 Guillaume Smet <guillaume-gforge@smet.org>
273 - added Allow from all in vhost config
274 * Wed Dec 29 2004 Guillaume Smet <guillaume-gforge@smet.org>
275 - added the magic_quotes_gpc On in vhost as the default value for FC3 is now Off
276 * Sat Dec 25 2004 Guillaume Smet <guillaume-gforge@smet.org>
277 - it's now possible to add specific language files in the RPM
278 * Fri Dec 03 2004 Dassault Aviation <guillaume.smet@openwide.fr>
279 - fixed the vhost configuration
280 - fixed the default crontab
281 - the crontab is now a config file and is not replaced on update
282 - added refresh.sh in /etc/gforge/ to refresh the configuration easily
283 * Wed Nov 03 2004 Guillaume Smet <guillaume-gforge@smet.org>