drupal/drupal.spec

changeset 529
7d4d11d301d6
child 530
5cd084e0397a
equal deleted inserted replaced
-1:000000000000 0:695677bb804b
1 ##
2 ## drupal.spec -- OpenPKG RPM Package Specification
3 ## Copyright (c) 2000-2011 OpenPKG Foundation e.V. <http://openpkg.net/>
4 ##
5 ## Permission to use, copy, modify, and distribute this software for
6 ## any purpose with or without fee is hereby granted, provided that
7 ## the above copyright notice and this permission notice appear in all
8 ## copies.
9 ##
10 ## THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
11 ## WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
12 ## MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
13 ## IN NO EVENT SHALL THE AUTHORS AND COPYRIGHT HOLDERS AND THEIR
14 ## CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
15 ## SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
16 ## LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
17 ## USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
18 ## ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
19 ## OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
20 ## OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
21 ## SUCH DAMAGE.
22 ##
23
24 # package information
25 Name: drupal
26 Summary: Content Management Platform
27 URL: http://www.drupal.org/
28 Vendor: Dries Buytaert et al.
29 Packager: OpenPKG Foundation e.V.
30 Distribution: OpenPKG Community
31 Class: PLUS
32 Group: CMS
33 License: GPL
34 Version: 6.22
35 Release: 20110526
36
37 # package options
38 %option with_mysql yes
39 %option with_pgsql no
40 %option with_dcron no
41
42 # checking for option conflicts
43 %if "%{with_mysql}" == "no" && "%{with_pgsql}" == "no"
44 %{error:one of the build-time options 'with_mysql' or 'with_pgsql' have to be enabled}
45 %endif
46 %if "%{with_mysql}" == "yes" && "%{with_pgsql}" == "yes"
47 %{error:only one of the build-time options 'with_mysql' or 'with_pgsql' can be enabled at a time}
48 %endif
49
50 # list of sources
51 Source0: http://ftp.drupal.org/files/projects/drupal-%{version}.tar.gz
52 Source1: drupal-setup.sh
53 Source2: drupal-cron.sh
54 Source3: drupal-apache.conf
55 Source4: rc.drupal
56 Patch0: drupal.patch
57
58 # build information
59 BuildPreReq: OpenPKG, openpkg >= 20100101, infozip
60 PreReq: OpenPKG, openpkg >= 20100101
61 PreReq: pcre, pcre::with_utf8
62 PreReq: apache
63 PreReq: apache::with_mod_deflate = yes
64 PreReq: apache-php
65 PreReq: apache-php::with_ctype = yes
66 PreReq: apache-php::with_gd = yes
67 PreReq: apache-php::with_mbstring = yes
68 PreReq: apache-php::with_session = yes
69 PreReq: apache-php::with_mm = yes
70 PreReq: apache-php::with_xml = yes
71 PreReq: apache-php::with_xslt = yes
72 PreReq: apache-php::with_sendmail = yes
73 %if "%{with_mysql}" == "yes"
74 PreReq: apache-php::with_mysql = yes
75 %endif
76 %if "%{with_pgsql}" == "yes"
77 PreReq: apache-php::with_pgsql = yes
78 %endif
79 %if "%{with_dcron}" == "yes"
80 PreReq: dcron
81 %endif
82 PreReq: MTA
83
84 %description
85 Drupal is a dynamic web site platform which allows an individual
86 or community of users to publish, manage and organize a
87 variety of content, Drupal integrates many popular features of
88 content management systems, weblogs, collaborative tools and
89 discussion-based community software into one easy-to-use package.
90
91 %track
92 prog drupal = {
93 version = %{version}
94 url = http://ftp.drupal.org/files/projects/
95 regex = drupal-(6\.\d+)\.tar\.gz
96 }
97
98 %prep
99 # unpack core distribution
100 %setup -q -n drupal-%{version}
101
102 # apply local patches
103 %patch -p0
104
105 %build
106
107 %install
108 # create installation hierarchy
109 %{l_shtool} mkdir -f -p -m 755 \
110 $RPM_BUILD_ROOT%{l_prefix}/sbin \
111 $RPM_BUILD_ROOT%{l_prefix}/etc/rc.d \
112 $RPM_BUILD_ROOT%{l_prefix}/etc/drupal/sites \
113 $RPM_BUILD_ROOT%{l_prefix}/share/drupal \
114 $RPM_BUILD_ROOT%{l_prefix}/var/drupal/files \
115 $RPM_BUILD_ROOT%{l_prefix}/var/drupal/run \
116 $RPM_BUILD_ROOT%{l_prefix}/var/drupal/log \
117 $RPM_BUILD_ROOT%{l_prefix}/var/drupal/dump \
118 $RPM_BUILD_ROOT%{l_prefix}/var/drupal/db
119
120 # avoid copying unnecessary text files
121 find . -name "*.orig" -print | xargs rm -f
122 rm -f CHANGELOG.txt COPYRIGHT.txt INSTALL.*.txt INSTALL.txt
123 rm -f LICENSE.txt MAINTAINERS.txt UPGRADE.txt
124
125 # install all files (and strip down installation afterwards)
126 cp -rp * .htaccess \
127 $RPM_BUILD_ROOT%{l_prefix}/share/drupal/
128
129 # pre-configure settings.php
130 %{l_shtool} subst \
131 %if "%{with_mysql}" == "yes"
132 -e 's|^\( *\$db_url\) *=.*$|\1 = "mysql://drupal:drupal@127.0.0.1/drupal";|' \
133 %endif
134 %if "%{with_pgsql}" == "yes"
135 -e 's|^\( *\$db_url\) *=.*$|\1 = "pgsql://drupal:drupal@127.0.0.1/drupal";|' \
136 %endif
137 $RPM_BUILD_ROOT%{l_prefix}/share/drupal/sites/default/default.settings.php
138
139 # set data location
140 ln -s ../../../../var/drupal/files \
141 $RPM_BUILD_ROOT%{l_prefix}/share/drupal/sites/default/files
142
143 # install run-command script
144 %if "%{with_dcron}" == "yes"
145 l_drupal_cron="no"
146 %else
147 l_drupal_cron="yes"
148 %endif
149 %{l_shtool} install -c -m 755 %{l_value -s -a} \
150 -e "s;@l_drupal_cron@;$l_drupal_cron;g" \
151 %{SOURCE rc.drupal} $RPM_BUILD_ROOT%{l_prefix}/etc/rc.d/
152
153 # install database setup script
154 %if "%{with_mysql}" == "yes"
155 l_dbtype="mysql"
156 %endif
157 %if "%{with_pgsql}" == "yes"
158 l_dbtype="pgsql"
159 %endif
160 %{l_shtool} install -c -m 755 %{l_value -s -a} \
161 -e "s;@l_dbtype@;$l_dbtype;g" \
162 -e "s;@l_bash@;%{l_bash};g" \
163 %{SOURCE drupal-setup.sh} $RPM_BUILD_ROOT%{l_prefix}/sbin/drupal-setup
164
165 # install crond(8) job script
166 %{l_shtool} install -c -m 755 %{l_value -s -a} \
167 %{SOURCE drupal-cron.sh} $RPM_BUILD_ROOT%{l_prefix}/sbin/drupal-cron
168 %if "%{with_dcron}" == "yes"
169 %{l_shtool} mkdir -f -p -m 755 \
170 $RPM_BUILD_ROOT%{l_prefix}/etc/dcron/crontabs
171 echo "*/5 * * * * su %{l_rusr} -c %{l_prefix}/sbin/drupal-cron" \
172 >$RPM_BUILD_ROOT%{l_prefix}/etc/dcron/crontabs/drupal
173 %endif
174
175 # install custom Apache configuration
176 l_hostname=`%{l_shtool} echo -e %h`
177 l_domainname=`%{l_shtool} echo -e %d | cut -c2-`
178 %{l_shtool} install -c -m 644 %{l_value -s -a} \
179 -e "s;@l_hostname@;$l_hostname;g" \
180 -e "s;@l_domainname@;$l_domainname;g" \
181 %{SOURCE drupal-apache.conf} \
182 $RPM_BUILD_ROOT%{l_prefix}/etc/drupal/
183
184 # determine installation files
185 %{l_rpmtool} files -v -ofiles -r$RPM_BUILD_ROOT \
186 %{l_files_std} \
187 '%config %{l_prefix}/etc/drupal' \
188 %if "%{with_dcron}" == "yes"
189 '%not %dir %{l_prefix}/etc/dcron' \
190 '%not %dir %{l_prefix}/etc/dcron/crontabs' \
191 '%attr(-,%{l_susr},%{l_mgrp}) %{l_prefix}/etc/dcron/crontabs/drupal' \
192 %endif
193 '%attr(-,%{l_rusr},%{l_rgrp}) %{l_prefix}/share/drupal' \
194 '%attr(555,%{l_rusr},%{l_rgrp}) %{l_prefix}/share/drupal/sites/default' \
195 '%attr(-,%{l_rusr},%{l_rgrp}) %{l_prefix}/var/drupal'
196
197 %files -f files
198
199 %clean
200
201 %post
202 if [ $1 -eq 1 ]; then
203 # display final hints on initial installation
204 ( echo "1. To complete this installation of Drupal please start the RDBMS"
205 echo " and initialize the Drupal database like this:"
206 %if "%{with_mysql}" == "yes"
207 echo " \$ $RPM_INSTALL_PREFIX/bin/openpkg rc mysql start"
208 %endif
209 %if "%{with_pgsql}" == "yes"
210 echo " \$ $RPM_INSTALL_PREFIX/bin/openpkg rc postgresql start"
211 %endif
212 echo " \$ $RPM_INSTALL_PREFIX/sbin/drupal-setup install"
213 echo ""
214 echo "2. Now start Drupal by running the command"
215 echo " \$ $RPM_INSTALL_PREFIX/bin/openpkg rc drupal start"
216 echo " and connect with a browser to the URL:"
217 echo " http://127.0.0.1:8080/drupal/install.php"
218 echo " Follow the instructions. On the page \"Database configuration\""
219 %if "%{with_mysql}" == "yes"
220 echo " use database type \"mysql\", database name \"drupal\", database"
221 %endif
222 %if "%{with_pgsql}" == "yes"
223 echo " use database type \"pgsql\", database name \"drupal\", database"
224 %endif
225 echo " username \"drupal\" and database password \"drupal\". Also create"
226 echo " an account and login. The first account will automatically become"
227 echo " the main administrator account with total control over Drupal."
228 echo ""
229 echo "3. By default, Drupal runs its own Apache server on IPv4 address"
230 echo " 127.0.0.1, TCP port 8080. Please change this by editing the"
231 echo " \"Listen 127.0.0.1:8080\" directive in"
232 echo " $RPM_INSTALL_PREFIX/etc/drupal/drupal-apache.conf"
233 echo " Also do not forget to cp -p"
234 echo " $RPM_INSTALL_PREFIX/share/drupal/sites/default/settings.php"
235 echo " $RPM_INSTALL_PREFIX/share/drupal/sites/settings.php"
236 echo " and adjust the \$base_url variable."
237 echo ""
238 echo "4. Access Drupal via:"
239 echo " http://127.0.0.1:8080/drupal/ (website view)"
240 echo " http://127.0.0.1:8080/drupal/admin (website admin)"
241 ) | %{l_rpmtool} msg -b -t notice
242 fi
243 if [ $1 -eq 2 ]; then
244 # display final hints on update installation
245 ( echo "Please perform a Drupal database upgrade by visiting the"
246 echo " http://127.0.0.1:8080/drupal/update.php"
247 echo "page on your Drupal website."
248 ) | %{l_rpmtool} msg -b -t notice
249
250 # after upgrade, restart service
251 eval `%{l_rc} drupal status 2>/dev/null`
252 [ ".$drupal_active" = .yes ] && %{l_rc} drupal restart
253 fi
254 exit 0
255
256 %preun
257 if [ $1 -eq 0 ]; then
258 # before erase, stop service and remove log files
259 %{l_rc} drupal stop 2>/dev/null
260 $RPM_INSTALL_PREFIX/sbin/drupal-setup uninstall >/dev/null 2>&1 || true
261 rm -f $RPM_INSTALL_PREFIX/var/drupal/files/* >/dev/null 2>&1 || true
262 rm -f $RPM_INSTALL_PREFIX/var/drupal/log/* >/dev/null 2>&1 || true
263 rm -f $RPM_INSTALL_PREFIX/var/drupal/run/* >/dev/null 2>&1 || true
264 rm -f $RPM_INSTALL_PREFIX/var/drupal/dump/* >/dev/null 2>&1 || true
265 rm -f $RPM_INSTALL_PREFIX/var/drupal/db/* >/dev/null 2>&1 || true
266 fi
267 exit 0
268

mercurial