| 1 | # |
|---|
| 2 | # $Id$ |
|---|
| 3 | # |
|---|
| 4 | |
|---|
| 5 | Name: PBREALPKG |
|---|
| 6 | Version: PBVER |
|---|
| 7 | Release: PBTAGPBSUF |
|---|
| 8 | License: PBLIC |
|---|
| 9 | Group: PBGRP |
|---|
| 10 | Url: PBURL |
|---|
| 11 | Source: PBREPO/PBSRC |
|---|
| 12 | #PBPATCHSRC |
|---|
| 13 | BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(id -u -n) |
|---|
| 14 | Requires: postgresql php php-pear php-pgsql libxml2 binutils bzip2 cpio mkisofs poppler-utils rpm tar unzip gzip httpd which PBDEP |
|---|
| 15 | BuildRequires: postgresql-devel libxml2 gcc make perl PBBUILDDEP |
|---|
| 16 | Summary: FOSSology is a licenses exploration tool |
|---|
| 17 | Summary(fr): FOSSology est un outil d'exploration de licenses |
|---|
| 18 | |
|---|
| 19 | %package devel |
|---|
| 20 | Summary: Devel part of FOSSology (a licenses exploration tool) |
|---|
| 21 | Summary(fr): Partie dedévelopment de FOSSology, outil d'exploration de licenses |
|---|
| 22 | Group: PBGRP |
|---|
| 23 | |
|---|
| 24 | %description |
|---|
| 25 | PBDESC |
|---|
| 26 | |
|---|
| 27 | %description -l fr |
|---|
| 28 | FOSSology est un outil d'exploration de licenses |
|---|
| 29 | |
|---|
| 30 | %description devel |
|---|
| 31 | Devel part. |
|---|
| 32 | PBDESC |
|---|
| 33 | |
|---|
| 34 | %description -l fr devel |
|---|
| 35 | Partie développement de FOSSology, outil d'exploration de licenses |
|---|
| 36 | |
|---|
| 37 | %prep |
|---|
| 38 | %setup -q |
|---|
| 39 | #PBPATCHCMD |
|---|
| 40 | |
|---|
| 41 | %build |
|---|
| 42 | make SYSCONFDIR=%{_sysconfdir} |
|---|
| 43 | #make %{?_smp_mflags} SYSCONFDIR=%{_sysconfdir} |
|---|
| 44 | |
|---|
| 45 | %install |
|---|
| 46 | %{__rm} -rf $RPM_BUILD_ROOT |
|---|
| 47 | make DESTDIR=$RPM_BUILD_ROOT PREFIX=%{_usr} SYSCONFDIR=%{_sysconfdir} LOCALSTATEDIR=%{_var} LIBDIR=%{_libdir} install |
|---|
| 48 | mkdir -p $RPM_BUILD_ROOT/%{_sysconfdir}/httpd/conf.d |
|---|
| 49 | cat > $RPM_BUILD_ROOT/%{_sysconfdir}/httpd/conf.d/PBPROJ.conf << EOF |
|---|
| 50 | Alias /repo/ /usr/share/PBPROJ/www/ |
|---|
| 51 | <Directory "/usr/share/PBPROJ/www"> |
|---|
| 52 | AllowOverride None |
|---|
| 53 | Options FollowSymLinks MultiViews |
|---|
| 54 | Order allow,deny |
|---|
| 55 | Allow from all |
|---|
| 56 | # uncomment to turn on php error reporting |
|---|
| 57 | #php_flag display_errors on |
|---|
| 58 | #php_value error_reporting 2039 |
|---|
| 59 | </Directory> |
|---|
| 60 | EOF |
|---|
| 61 | cp utils/fo-cleanold $RPM_BUILD_ROOT/%{_usr}/lib/PBPROJ/ |
|---|
| 62 | |
|---|
| 63 | #rm -f $RPM_BUILD_ROOT/%{_sysconfdir}/default/PBPROJ |
|---|
| 64 | |
|---|
| 65 | %clean |
|---|
| 66 | %{__rm} -rf $RPM_BUILD_ROOT |
|---|
| 67 | |
|---|
| 68 | %files |
|---|
| 69 | %defattr(-,root,root) |
|---|
| 70 | %doc ChangeLog |
|---|
| 71 | %doc COPYING COPYING.LGPL HACKING README INSTALL INSTALL.multi LICENSE |
|---|
| 72 | #AUTHORS NEWS |
|---|
| 73 | %config(noreplace) %{_sysconfdir}/httpd/conf.d/*.conf |
|---|
| 74 | %config(noreplace) %{_sysconfdir}/cron.d/* |
|---|
| 75 | %config(noreplace) %{_sysconfdir}/PBPROJ/* |
|---|
| 76 | %dir %{_sysconfdir}/PBPROJ |
|---|
| 77 | %dir %{_usr}/lib/PBPROJ |
|---|
| 78 | %dir %{_datadir}/PBPROJ |
|---|
| 79 | %{_sysconfdir}/init.d/* |
|---|
| 80 | %{_usr}/lib/PBPROJ/* |
|---|
| 81 | %{_datadir}/PBPROJ/* |
|---|
| 82 | %{_bindir}/* |
|---|
| 83 | %{_mandir}/man1/* |
|---|
| 84 | |
|---|
| 85 | %files devel |
|---|
| 86 | %{_includedir}/* |
|---|
| 87 | %{_libdir}/*.a |
|---|
| 88 | |
|---|
| 89 | %post |
|---|
| 90 | # Adjust the kernel shmmax (described in detail in section 2.1.3) |
|---|
| 91 | echo 512000000 > /proc/sys/kernel/shmmax |
|---|
| 92 | grep -q kernel.shmmax /etc/sysctl.conf |
|---|
| 93 | if [ $? -eq 0 ]; then |
|---|
| 94 | perl -pi -e "s/^[#\s]*kernel.shmmax\s*=.*/kernel.shmmax=512000000/" /etc/sysctl.conf |
|---|
| 95 | else |
|---|
| 96 | echo "kernel.shmmax=512000000" >> /etc/sysctl.conf |
|---|
| 97 | fi |
|---|
| 98 | |
|---|
| 99 | # Adjust postgresql config (described in detail in section 2.1.4) for Fossology |
|---|
| 100 | PGCONF=/var/lib/pgsql/data/postgresql.conf |
|---|
| 101 | if [ ! -f $PGCONF ]; then |
|---|
| 102 | cp /usr/share/pgsql/postgresql.conf.sample $PGCONF |
|---|
| 103 | fi |
|---|
| 104 | grep -qw listen_addresses $PGCONF |
|---|
| 105 | if [ $? -eq 0 ]; then |
|---|
| 106 | perl -pi -e "s/^[#\s]*listen_addresses.*=.*/listen_addresses = '*'/" $PGCONF |
|---|
| 107 | else |
|---|
| 108 | echo "listen_addresses = '*'" >> $PGCONF |
|---|
| 109 | fi |
|---|
| 110 | grep -qw max_connections $PGCONF |
|---|
| 111 | if [ $? -eq 0 ]; then |
|---|
| 112 | perl -pi -e "s/^[#\s]*max_connections.*=.*/max_connections = 50/" $PGCONF |
|---|
| 113 | else |
|---|
| 114 | echo "max_connections = 50" >> $PGCONF |
|---|
| 115 | fi |
|---|
| 116 | grep -qw shared_buffers $PGCONF |
|---|
| 117 | if [ $? -eq 0 ]; then |
|---|
| 118 | perl -pi -e "s/^[#\s]*shared_buffers.*=.*/shared_buffers = 32768/" $PGCONF |
|---|
| 119 | else |
|---|
| 120 | echo "shared_buffers = 32768" >> $PGCONF |
|---|
| 121 | fi |
|---|
| 122 | grep -qw work_mem $PGCONF |
|---|
| 123 | if [ $? -eq 0 ]; then |
|---|
| 124 | perl -pi -e "s/^[#\s]*work_mem.*=.*/work_mem = 10240/" $PGCONF |
|---|
| 125 | else |
|---|
| 126 | echo "work_mem = 10240" >> $PGCONF |
|---|
| 127 | fi |
|---|
| 128 | # min max_fsm_relations*16, 6 bytes each |
|---|
| 129 | grep -qw max_fsm_pages $PGCONF |
|---|
| 130 | if [ $? -eq 0 ]; then |
|---|
| 131 | perl -pi -e "s/^[#\s]*max_fsm_pages.*=.*/max_fsm_pages = 100000/" $PGCONF |
|---|
| 132 | else |
|---|
| 133 | echo "max_fsm_pages = 100000" >> $PGCONF |
|---|
| 134 | fi |
|---|
| 135 | grep -qw fsync $PGCONF |
|---|
| 136 | if [ $? -eq 0 ]; then |
|---|
| 137 | perl -pi -e "s/^[#\s]*fsync.*=.*/fsync = off/" $PGCONF |
|---|
| 138 | else |
|---|
| 139 | echo "fsync = off" >> $PGCONF |
|---|
| 140 | fi |
|---|
| 141 | # recover from partial page writes |
|---|
| 142 | grep -qw full_page_writes $PGCONF |
|---|
| 143 | if [ $? -eq 0 ]; then |
|---|
| 144 | perl -pi -e "s/^[#\s]*full_page_writes.*=.*/full_page_writes = off/" $PGCONF |
|---|
| 145 | else |
|---|
| 146 | echo "full_page_writes = off" >> $PGCONF |
|---|
| 147 | fi |
|---|
| 148 | grep -qw commit_delay $PGCONF |
|---|
| 149 | if [ $? -eq 0 ]; then |
|---|
| 150 | perl -pi -e "s/^[#\s]*commit_delay.*=.*/commit_delay = 1000/" $PGCONF |
|---|
| 151 | else |
|---|
| 152 | echo "commit_delay = 1000" >> $PGCONF |
|---|
| 153 | fi |
|---|
| 154 | grep -qw effective_cache_size $PGCONF |
|---|
| 155 | if [ $? -eq 0 ]; then |
|---|
| 156 | perl -pi -e "s/^[#\s]*effective_cache_size.*=.*/effective_cache_size = 25000/" $PGCONF |
|---|
| 157 | else |
|---|
| 158 | echo "effective_cache_size = 25000" >> $PGCONF |
|---|
| 159 | fi |
|---|
| 160 | # -1 is disabled, 0 logs all statements |
|---|
| 161 | grep -qw log_min_duration_statement $PGCONF |
|---|
| 162 | if [ $? -eq 0 ]; then |
|---|
| 163 | perl -pi -e "s/^[#\s]*log_min_duration_statement.*=.*/log_min_duration_statement = -1/" $PGCONF |
|---|
| 164 | else |
|---|
| 165 | echo "log_min_duration_statement = -1" >> $PGCONF |
|---|
| 166 | fi |
|---|
| 167 | # prepend a time stamp to all log entries |
|---|
| 168 | grep -qw log_line_prefix $PGCONF |
|---|
| 169 | if [ $? -eq 0 ]; then |
|---|
| 170 | perl -pi -e "s/^[#\s]*log_line_prefix.*=.*/log_line_prefix = '%t %h %c'/" $PGCONF |
|---|
| 171 | else |
|---|
| 172 | echo "log_line_prefix = '%t %h %c'" >> $PGCONF |
|---|
| 173 | fi |
|---|
| 174 | |
|---|
| 175 | # Check postgresql is running |
|---|
| 176 | LANGUAGE=C /etc/init.d/postgresql status 2>&1 | grep -q stop |
|---|
| 177 | if [ $? -eq 0 ]; then |
|---|
| 178 | /etc/init.d/postgresql start |
|---|
| 179 | fi |
|---|
| 180 | chkconfig --add postgresql |
|---|
| 181 | |
|---|
| 182 | cat >> /var/lib/pgsql/data/pg_hba.conf << EOF |
|---|
| 183 | # Added for FOSSology connection |
|---|
| 184 | # Local connections |
|---|
| 185 | local all all md5 |
|---|
| 186 | # IPv4 local connections: |
|---|
| 187 | host all all 127.0.0.1/32 md5 |
|---|
| 188 | host all all 127.0.0.1/32 md5 |
|---|
| 189 | # IPv6 local connections: |
|---|
| 190 | host all all ::1/128 ident sameuser |
|---|
| 191 | |
|---|
| 192 | EOF |
|---|
| 193 | perl -pi -e 's|(host\s+all\s+all\s+127.0.0.1/32\s+ident\s+sameuser)|#$1|' /var/lib/pgsql/data/pg_hba.conf |
|---|
| 194 | |
|---|
| 195 | # reload doesn't seem to work here :-( |
|---|
| 196 | /etc/init.d/postgresql restart |
|---|
| 197 | # To avaoid fossology setup to fail, leave it time to start |
|---|
| 198 | sleep 2 |
|---|
| 199 | |
|---|
| 200 | # Adjust PHP config (described in detail in section 2.1.5) |
|---|
| 201 | grep -qw memory_limit PBPHPINI |
|---|
| 202 | if [ $? -eq 0 ]; then |
|---|
| 203 | perl -pi -e "s/^[#\s]*memory_limit.*=.*/memory_limit = 702M/" PBPHPINI |
|---|
| 204 | else |
|---|
| 205 | echo "memory_limit = 702M" >> PBPHPINI |
|---|
| 206 | fi |
|---|
| 207 | grep -qw post_max_size PBPHPINI |
|---|
| 208 | if [ $? -eq 0 ]; then |
|---|
| 209 | perl -pi -e "s/^[#\s]*post_max_size.*=.*/post_max_size = 702M/" PBPHPINI |
|---|
| 210 | else |
|---|
| 211 | echo "post_max_size = 702M" >> PBPHPINI |
|---|
| 212 | fi |
|---|
| 213 | grep -qw upload_max_filesize PBPHPINI |
|---|
| 214 | if [ $? -eq 0 ]; then |
|---|
| 215 | perl -pi -e "s/^[#\s]*upload_max_filesize.*=.*/upload_max_filesize = 702M/" PBPHPINI |
|---|
| 216 | else |
|---|
| 217 | echo "upload_max_filesize = 702M" >> PBPHPINI |
|---|
| 218 | fi |
|---|
| 219 | grep -qw allow_call_time_pass_reference PBPHPINI |
|---|
| 220 | if [ $? -eq 0 ]; then |
|---|
| 221 | perl -pi -e "s/^[#\s]*allow_call_time_pass_reference.*=.*/allow_call_time_pass_reference = On/" PBPHPINI |
|---|
| 222 | else |
|---|
| 223 | echo "allow_call_time_pass_reference = On" >> PBPHPINI |
|---|
| 224 | fi |
|---|
| 225 | |
|---|
| 226 | # Add apache config for fossology (described in detail in section 2.1.6) - done in install |
|---|
| 227 | # Run the postinstall script |
|---|
| 228 | /usr/lib/PBPROJ/fo-postinstall |
|---|
| 229 | |
|---|
| 230 | # Adds user httpd to fossy group |
|---|
| 231 | perl -pi -e 's/^fossy:x:([0-9]+):/fossy:x:$1:httpd/' /etc/group |
|---|
| 232 | |
|---|
| 233 | # httpd |
|---|
| 234 | LANGUAGE=C /etc/init.d/httpd status 2>&1 | grep -q stop |
|---|
| 235 | if [ $? -eq 0 ]; then |
|---|
| 236 | /etc/init.d/httpd start |
|---|
| 237 | else |
|---|
| 238 | /etc/init.d/httpd reload |
|---|
| 239 | fi |
|---|
| 240 | chkconfig --add httpd |
|---|
| 241 | |
|---|
| 242 | # Create logfile to avoid issues later on |
|---|
| 243 | touch %{_var}/log/PBPROJ |
|---|
| 244 | # Handle logfile owner correctly |
|---|
| 245 | chown fossy:fossy %{_var}/log/PBPROJ |
|---|
| 246 | |
|---|
| 247 | # Test that things are installed correctly |
|---|
| 248 | /usr/lib/PBPROJ/fossology-scheduler -t |
|---|
| 249 | if [ $? -ne 0 ]; then |
|---|
| 250 | exit -1 |
|---|
| 251 | fi |
|---|
| 252 | |
|---|
| 253 | chkconfig --add PBPROJ |
|---|
| 254 | /etc/init.d/PBPROJ start |
|---|
| 255 | |
|---|
| 256 | %preun |
|---|
| 257 | # If FOSSology is running, stop it before removing. |
|---|
| 258 | /etc/init.d/PBPROJ stop |
|---|
| 259 | chkconfig --del PBPROJ 2>&1 > /dev/null |
|---|
| 260 | |
|---|
| 261 | # We should do some cleanup here (fossy account ...) |
|---|
| 262 | /usr/lib/PBPROJ/fo-cleanold |
|---|
| 263 | |
|---|
| 264 | %changelog |
|---|
| 265 | PBLOG |
|---|