Mon, 15 Oct 2012 21:20:29 +0200
Import package vendor original spec for necessary manipulations.
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 ##
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: 7.15
35 Release: 20120800
37 # package options
38 %option with_mysql yes
39 %option with_pgsql no
40 %option with_dcron no
42 # checking for option conflicts
43 %if "%{with_mysql}" == "no" && "%{with_pgsql}" == "no"
44 %{error:one of the buildtime 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 buildtime options 'with_mysql' or 'with_pgsql' can be enabled at a time}
48 %endif
50 # list of sources
51 Source0: ftp://ftp.drupal.org/pub/drupal/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
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
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.
91 %track
92 prog drupal = {
93 version = %{version}
94 url = http://ftp.drupal.org/files/projects/
95 regex = drupal-(\d\.\d+)\.tar\.gz
96 }
98 %prep
99 # unpack core distribution
100 %setup -q -n drupal-%{version}
102 # apply local patches
103 %patch -p0
105 %build
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}/share/drupal \
113 $RPM_BUILD_ROOT%{l_prefix}/var/drupal/files \
114 $RPM_BUILD_ROOT%{l_prefix}/var/drupal/run \
115 $RPM_BUILD_ROOT%{l_prefix}/var/drupal/log \
116 $RPM_BUILD_ROOT%{l_prefix}/var/drupal/dump \
117 $RPM_BUILD_ROOT%{l_prefix}/var/drupal/db
119 # avoid copying unnecessary text files
120 find . -name "*.orig" -print | xargs rm -f
121 rm -f CHANGELOG.txt COPYRIGHT.txt INSTALL.*.txt INSTALL.txt
122 rm -f LICENSE.txt MAINTAINERS.txt UPGRADE.txt
124 # install all files (and strip down installation afterwards)
125 cp -rp * .htaccess \
126 $RPM_BUILD_ROOT%{l_prefix}/share/drupal/
128 # set data location
129 ln -s ../../../../var/drupal/files \
130 $RPM_BUILD_ROOT%{l_prefix}/share/drupal/sites/default/files
132 # install runcommand script
133 %if "%{with_dcron}" == "yes"
134 l_drupal_cron="no"
135 %else
136 l_drupal_cron="yes"
137 %endif
138 %{l_shtool} install -c -m 755 %{l_value -s -a} \
139 -e "s;@l_drupal_cron@;$l_drupal_cron;g" \
140 %{SOURCE rc.drupal} $RPM_BUILD_ROOT%{l_prefix}/etc/rc.d/
142 # install database setup script
143 %if "%{with_mysql}" == "yes"
144 l_dbtype="mysql"
145 %endif
146 %if "%{with_pgsql}" == "yes"
147 l_dbtype="pgsql"
148 %endif
149 %{l_shtool} install -c -m 755 %{l_value -s -a} \
150 -e "s;@l_dbtype@;$l_dbtype;g" \
151 -e "s;@l_bash@;%{l_bash};g" \
152 %{SOURCE drupal-setup.sh} $RPM_BUILD_ROOT%{l_prefix}/sbin/drupal-setup
154 # install crond(8) job script
155 %{l_shtool} install -c -m 755 %{l_value -s -a} \
156 %{SOURCE drupal-cron.sh} $RPM_BUILD_ROOT%{l_prefix}/sbin/drupal-cron
157 %if "%{with_dcron}" == "yes"
158 %{l_shtool} mkdir -f -p -m 755 \
159 $RPM_BUILD_ROOT%{l_prefix}/etc/dcron/crontabs
160 echo "*/5 * * * * su %{l_rusr} -c %{l_prefix}/sbin/drupal-cron" \
161 >$RPM_BUILD_ROOT%{l_prefix}/etc/dcron/crontabs/drupal
162 %endif
164 # install custom Apache configuration
165 l_hostname=`%{l_shtool} echo -e %h`
166 l_domainname=`%{l_shtool} echo -e %d | cut -c2-`
167 %{l_shtool} install -c -m 644 %{l_value -s -a} \
168 -e "s;@l_hostname@;$l_hostname;g" \
169 -e "s;@l_domainname@;$l_domainname;g" \
170 %{SOURCE drupal-apache.conf} \
171 $RPM_BUILD_ROOT%{l_prefix}/etc/drupal/
173 # determine installation files
174 %{l_rpmtool} files -v -ofiles -r$RPM_BUILD_ROOT \
175 %{l_files_std} \
176 '%config %{l_prefix}/etc/drupal' \
177 %if "%{with_dcron}" == "yes"
178 '%not %dir %{l_prefix}/etc/dcron' \
179 '%not %dir %{l_prefix}/etc/dcron/crontabs' \
180 '%attr(-,%{l_susr},%{l_mgrp}) %{l_prefix}/etc/dcron/crontabs/drupal' \
181 %endif
182 '%attr(-,%{l_rusr},%{l_rgrp}) %{l_prefix}/share/drupal' \
183 '%attr(555,%{l_rusr},%{l_rgrp}) %{l_prefix}/share/drupal/sites/default' \
184 '%attr(-,%{l_rusr},%{l_rgrp}) %{l_prefix}/var/drupal'
186 %files -f files
188 %clean
190 %post
191 if [ $1 -eq 1 ]; then
192 # display final hints on initial installation
193 ( echo "1. To complete this installation of Drupal please start the RDBMS"
194 echo " and initialize the Drupal database like this:"
195 %if "%{with_mysql}" == "yes"
196 echo " \$ $RPM_INSTALL_PREFIX/bin/openpkg rc mysql start"
197 %endif
198 %if "%{with_pgsql}" == "yes"
199 echo " \$ $RPM_INSTALL_PREFIX/bin/openpkg rc postgresql start"
200 %endif
201 echo " \$ $RPM_INSTALL_PREFIX/sbin/drupal-setup install"
202 echo ""
203 echo "2. Now start Drupal by running the command"
204 echo " \$ $RPM_INSTALL_PREFIX/bin/openpkg rc drupal start"
205 echo " and connect with a browser to the URL:"
206 echo " http://127.0.0.1:8080/drupal/install.php"
207 echo " Follow the instructions. On the page \"Database configuration\""
208 %if "%{with_mysql}" == "yes"
209 echo " use database type \"mysql\", database name \"drupal\", database"
210 %endif
211 %if "%{with_pgsql}" == "yes"
212 echo " use database type \"pgsql\", database name \"drupal\", database"
213 %endif
214 echo " username \"drupal\" and database password \"drupal\". Also create"
215 echo " an account and login. The first account will automatically become"
216 echo " the main administrator account with total control over Drupal."
217 echo ""
218 echo "3. By default, Drupal runs its own Apache server on IPv4 address"
219 echo " 127.0.0.1, TCP port 8080. Please change this by editing the"
220 echo " \"Listen 127.0.0.1:8080\" directive in"
221 echo " $RPM_INSTALL_PREFIX/etc/drupal/drupal-apache.conf"
222 echo " Also do not forget to cp -p"
223 echo " $RPM_INSTALL_PREFIX/share/drupal/sites/default/settings.php"
224 echo " $RPM_INSTALL_PREFIX/share/drupal/sites/settings.php"
225 echo " and adjust the \$base_url variable."
226 echo ""
227 echo "4. Access Drupal via:"
228 echo " http://127.0.0.1:8080/drupal/ (website view)"
229 echo " http://127.0.0.1:8080/drupal/admin (website admin)"
230 ) | %{l_rpmtool} msg -b -t notice
231 fi
232 if [ $1 -eq 2 ]; then
233 # display final hints on update installation
234 ( echo "Please perform a Drupal database upgrade by visiting the"
235 echo " http://127.0.0.1:8080/drupal/update.php"
236 echo "page on your Drupal website."
237 ) | %{l_rpmtool} msg -b -t notice
239 # after upgrade, restart service
240 eval `%{l_rc} drupal status 2>/dev/null`
241 [ ".$drupal_active" = .yes ] && %{l_rc} drupal restart
242 fi
243 exit 0
245 %preun
246 if [ $1 -eq 0 ]; then
247 # before erase, stop service and remove log files
248 %{l_rc} drupal stop 2>/dev/null
249 $RPM_INSTALL_PREFIX/sbin/drupal-setup uninstall >/dev/null 2>&1 || true
250 rm -f $RPM_INSTALL_PREFIX/var/drupal/files/* >/dev/null 2>&1 || true
251 rm -f $RPM_INSTALL_PREFIX/var/drupal/log/* >/dev/null 2>&1 || true
252 rm -f $RPM_INSTALL_PREFIX/var/drupal/run/* >/dev/null 2>&1 || true
253 rm -f $RPM_INSTALL_PREFIX/var/drupal/dump/* >/dev/null 2>&1 || true
254 rm -f $RPM_INSTALL_PREFIX/var/drupal/db/* >/dev/null 2>&1 || true
255 fi
256 exit 0