Gentoo Archives: gentoo-commits

From: "Tomas Chvatal (scarabeus)" <scarabeus@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] gentoo-x86 commit in eclass: git-2.eclass webapp.eclass
Date: Thu, 19 May 2011 12:03:53
Message-Id: 20110519120341.AF30E20054@flycatcher.gentoo.org
1 scarabeus 11/05/19 12:03:41
2
3 Modified: git-2.eclass webapp.eclass
4 Log:
5 Add EGIT_PROJECT variable that allows us to specify folder where to check out the git repository.
6
7 Revision Changes Path
8 1.6 eclass/git-2.eclass
9
10 file : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/eclass/git-2.eclass?rev=1.6&view=markup
11 plain: http://sources.gentoo.org/viewvc.cgi/gentoo-x86/eclass/git-2.eclass?rev=1.6&content-type=text/plain
12 diff : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/eclass/git-2.eclass?r1=1.5&r2=1.6
13
14 Index: git-2.eclass
15 ===================================================================
16 RCS file: /var/cvsroot/gentoo-x86/eclass/git-2.eclass,v
17 retrieving revision 1.5
18 retrieving revision 1.6
19 diff -u -r1.5 -r1.6
20 --- git-2.eclass 2 May 2011 21:15:30 -0000 1.5
21 +++ git-2.eclass 19 May 2011 12:03:41 -0000 1.6
22 @@ -1,6 +1,6 @@
23 # Copyright 1999-2011 Gentoo Foundation
24 # Distributed under the terms of the GNU General Public License v2
25 -# $Header: /var/cvsroot/gentoo-x86/eclass/git-2.eclass,v 1.5 2011/05/02 21:15:30 mgorny Exp $
26 +# $Header: /var/cvsroot/gentoo-x86/eclass/git-2.eclass,v 1.6 2011/05/19 12:03:41 scarabeus Exp $
27
28 # @ECLASS: git-2.eclass
29 # @MAINTAINER:
30 @@ -46,12 +46,20 @@
31 #
32 # EGIT_MASTER="master"
33
34 +# @ECLASS-VARIABLE: EGIT_PROJECT
35 +# @DESCRIPTION:
36 +# Variable specifying name for the folder where we check out the git
37 +# repository. Value of this variable should be unique in the
38 +# EGIT_STORE_DIR as otherwise you would override another repository.
39 +#
40 +# EGIT_PROJECT="${EGIT_REPO_URI##*/}"
41 +
42 # @ECLASS-VARIABLE: EGIT_DIR
43 # @DESCRIPTION:
44 # Directory where we want to store the git data.
45 # This should not be overriden unless really required.
46 #
47 -# EGIT_DIR="${EGIT_STORE_DIR}/${EGIT_REPO_URI##*/}"
48 +# EGIT_DIR="${EGIT_STORE_DIR}/${EGIT_PROJECT}"
49
50 # @ECLASS-VARIABLE: EGIT_REPO_URI
51 # @REQUIRED
52 @@ -235,9 +243,15 @@
53 # allow writing into EGIT_STORE_DIR
54 addwrite "${EGIT_STORE_DIR}"
55 # calculate the proper store dir for data
56 + # If user didn't specify the EGIT_DIR, we check if he did specify
57 + # the EGIT_PROJECT or get the folder name from EGIT_REPO_URI.
58 [[ -z ${EGIT_REPO_URI##*/} ]] && EGIT_REPO_URI="${EGIT_REPO_URI%/}"
59 if [[ -z ${EGIT_DIR} ]]; then
60 - clone_dir=${EGIT_REPO_URI##*/}
61 + if [[ -n ${EGIT_PROJECT} ]]; then
62 + clone_dir=${EGIT_PROJECT}
63 + else
64 + clone_dir=${EGIT_REPO_URI##*/}
65 + fi
66 EGIT_DIR=${EGIT_STORE_DIR}/${clone_dir}
67 fi
68 export EGIT_DIR=${EGIT_DIR}
69
70
71
72 1.65 eclass/webapp.eclass
73
74 file : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/eclass/webapp.eclass?rev=1.65&view=markup
75 plain: http://sources.gentoo.org/viewvc.cgi/gentoo-x86/eclass/webapp.eclass?rev=1.65&content-type=text/plain
76 diff : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/eclass/webapp.eclass?r1=1.64&r2=1.65
77
78 Index: webapp.eclass
79 ===================================================================
80 RCS file: /var/cvsroot/gentoo-x86/eclass/webapp.eclass,v
81 retrieving revision 1.64
82 retrieving revision 1.65
83 diff -u -r1.64 -r1.65
84 --- webapp.eclass 9 May 2010 22:32:16 -0000 1.64
85 +++ webapp.eclass 19 May 2011 12:03:41 -0000 1.65
86 @@ -1,6 +1,6 @@
87 -# Copyright 1999-2006 Gentoo Foundation
88 +# Copyright 1999-2011 Gentoo Foundation
89 # Distributed under the terms of the GNU General Public License v2
90 -# $Header: /var/cvsroot/gentoo-x86/eclass/webapp.eclass,v 1.64 2010/05/09 22:32:16 darkside Exp $
91 +# $Header: /var/cvsroot/gentoo-x86/eclass/webapp.eclass,v 1.65 2011/05/19 12:03:41 scarabeus Exp $
92
93 # @ECLASS: webapp.eclass
94 # @MAINTAINER:
95 @@ -10,26 +10,37 @@
96 # The webapp eclass contains functions to handle web applications with
97 # webapp-config. Part of the implementation of GLEP #11
98
99 +# @ECLASS-VARIABLE: WABAPP_MINIMAL
100 +# @DESCRIPTION:
101 +# Minimal version of webapp-config the package requires for sucessfull install.
102 +: ${WEBAPP_MINIMAL:=1.50.15}
103 +
104 # @ECLASS-VARIABLE: WEBAPP_DEPEND
105 # @DESCRIPTION:
106 # An ebuild should use WEBAPP_DEPEND if a custom DEPEND needs to be built, most
107 # notably in combination with WEBAPP_OPTIONAL.
108 -WEBAPP_DEPEND=">=app-admin/webapp-config-1.50.15"
109 +: ${WEBAPP_DEPEND:=">=app-admin/webapp-config-${WEBAPP_MINIMAL}"}
110
111 -# @ECLASS-VARIABLE: WEBAPP_NO_AUTO_INSTALL
112 +# @ECLASS-VARIABLE: WEBAPP_AUTO_INSTALL
113 # @DESCRIPTION:
114 -# An ebuild sets this to `yes' if an automatic installation and/or upgrade is
115 +# An ebuild sets this to `no' if an automatic installation and/or upgrade is
116 # not possible. The ebuild should overwrite pkg_postinst() and explain the
117 # reason for this BEFORE calling webapp_pkg_postinst().
118 +: ${WEBAPP_AUTO_INSTALL:=yes}
119 +if [[ -n ${WEBAPP_NO_AUTO_INSTALL} ]]; then
120 + WEBAPP_AUTO_INSTALL=no
121 + ewarn "QA: using deprecated variable \"WEBAPP_NO_AUTO_INSTALL\"."
122 + ewarn "QA: please migrate to WEBAPP_AUTO_INSTALL with inverse logic"
123 + ewarn "QA: that defaults to yes."
124 +fi
125
126 # @ECLASS-VARIABLE: WEBAPP_OPTIONAL
127 # @DESCRIPTION:
128 # An ebuild sets this to `yes' to make webapp support optional, in which case
129 # you also need to take care of USE-flags and dependencies.
130 -
131 -if [[ "${WEBAPP_OPTIONAL}" != "yes" ]]; then
132 - [[ "${WEBAPP_NO_AUTO_INSTALL}" == "yes" ]] || IUSE="vhosts"
133 - SLOT="${PVR}"
134 +if [[ ${WEBAPP_OPTIONAL} != yes ]]; then
135 + [[ ${WEBAPP_AUTO_INSTALL} == yes ]] && IUSE="vhosts"
136 + : ${SLOT:=${PVR}}
137 DEPEND="${WEBAPP_DEPEND}"
138 RDEPEND="${DEPEND}"
139 fi
140 @@ -56,22 +67,18 @@
141 webapp_read_config() {
142 debug-print-function $FUNCNAME $*
143
144 - if has_version '>=app-admin/webapp-config-1.50'; then
145 - ENVVAR=$(${WEBAPP_CONFIG} --query ${PN} ${PVR}) || die "Could not read settings from webapp-config!"
146 - eval ${ENVVAR}
147 - else
148 - . ${ETC_CONFIG} || die "Unable to read ${ETC_CONFIG}"
149 - fi
150 + ENVVAR=$(${WEBAPP_CONFIG} --query ${PN} ${PVR}) || die "Could not read settings from webapp-config!"
151 + eval ${ENVVAR} || die
152 }
153
154 # Check whether a specified file exists in the given directory (`.' by default)
155 webapp_checkfileexists() {
156 debug-print-function $FUNCNAME $*
157
158 - local my_prefix=${2:+${2}/}
159 + local msg my_prefix=${2:+${2}/}
160
161 if [[ ! -e "${my_prefix}${1}" ]]; then
162 - msg="ebuild fault: file '${1}' not found"
163 + msg="ebuild error: file '${1}' not found"
164 eerror "$msg"
165 eerror "Please report this as a bug at http://bugs.gentoo.org/"
166 die "$msg"
167 @@ -101,19 +108,20 @@
168 webapp_getinstalltype() {
169 debug-print-function $FUNCNAME $*
170
171 + local my_output my_pn my_pvr
172 +
173 if ! has vhosts ${IUSE} || use vhosts; then
174 return
175 fi
176
177 - local my_output
178 my_output="$(webapp_check_installedat)"
179
180 if [[ $? -eq 0 ]]; then
181 # something is already installed there
182 # make sure it isn't the same version
183
184 - local my_pn="$(echo ${my_output} | awk '{ print $1 }')"
185 - local my_pvr="$(echo ${my_output} | awk '{ print $2 }')"
186 + my_pn="$(echo ${my_output} | awk '{ print $1 }')"
187 + my_pvr="$(echo ${my_output} | awk '{ print $2 }')"
188
189 REMOVE_PKG="${my_pn}-${my_pvr}"
190
191 @@ -133,6 +141,18 @@
192 fi
193 }
194
195 +# helper for webapp_serverowned()
196 +_webapp_serverowned() {
197 + debug-print-function $FUNCNAME $*
198 +
199 + webapp_checkfileexists "${1}" "${D}"
200 + local my_file="$(webapp_strip_appdir "${1}")"
201 + my_file="$(webapp_strip_cwd "${my_file}")"
202 +
203 + elog "(server owned) ${my_file}"
204 + echo "${my_file}" >> "${D}/${WA_SOLIST}"
205 +}
206 +
207 # ==============================================================================
208 # PUBLIC FUNCTIONS
209 # ==============================================================================
210 @@ -171,6 +191,8 @@
211 webapp_configfile() {
212 debug-print-function $FUNCNAME $*
213
214 + [[ $# -lt 1 ]] && die "${FUNCNAME}: I require at least 1 argument. Please read eclass documentation."
215 +
216 local m
217 for m in "$@"; do
218 webapp_checkfileexists "${m}" "${D}"
219 @@ -178,62 +200,75 @@
220 local my_file="$(webapp_strip_appdir "${m}")"
221 my_file="$(webapp_strip_cwd "${my_file}")"
222
223 - elog "(config) ${my_file}"
224 + elog "[webapp-config] ${my_file}"
225 echo "${my_file}" >> ${D}/${WA_CONFIGLIST}
226 done
227 }
228
229 # @FUNCTION: webapp_hook_script
230 -# @USAGE: <file>
231 +# @USAGE: <file> [more files ...]
232 # @DESCRIPTION:
233 # Install a script that will run after a virtual copy is created, and
234 # before a virtual copy has been removed.
235 webapp_hook_script() {
236 debug-print-function $FUNCNAME $*
237
238 - webapp_checkfileexists "${1}"
239 + [[ $# -lt 1 ]] && die "${FUNCNAME}: I require at least 1 argument. Please read eclass documentation."
240 +
241 + local m
242 + for m in "$@"; do
243 + webapp_checkfileexists "${m}"
244
245 - elog "(hook) ${1}"
246 - cp "${1}" "${D}/${MY_HOOKSCRIPTSDIR}/$(basename "${1}")" || die "Unable to install ${1} into ${D}/${MY_HOOKSCRIPTSDIR}/"
247 - chmod 555 "${D}/${MY_HOOKSCRIPTSDIR}/$(basename "${1}")"
248 + elog "[webapp-hook] ${m}"
249 + cp "${1}" "${D}/${MY_HOOKSCRIPTSDIR}/$(basename "${1}")" || die "Unable to install ${1} into \"${D}/${MY_HOOKSCRIPTSDIR}/\""
250 + chmod 555 "${D}/${MY_HOOKSCRIPTSDIR}/$(basename "${1}")"
251 + done
252 }
253
254 # @FUNCTION: webapp_postinst_txt
255 -# @USAGE: <lang> <file>
256 +# @USAGE: <lang> <file> [more files ...]
257 # @DESCRIPTION:
258 # Install a text file containing post-installation instructions.
259 webapp_postinst_txt() {
260 debug-print-function $FUNCNAME $*
261
262 - webapp_checkfileexists "${2}"
263 + local lang m
264
265 - elog "(info) ${2} (lang: ${1})"
266 - cp "${2}" "${D}/${MY_APPDIR}/postinst-${1}.txt"
267 + [[ $# -lt 2 ]] && die "${FUNCNAME}: I require at least 2 arguments. Please read eclass documentation."
268 +
269 + lang=${1}
270 + shift
271 +
272 + local m
273 + for m in "$@"; do
274 + webapp_checkfileexists "${m}"
275 +
276 + elog "[webapp-info] \"${m}\" (lang: ${lang})"
277 + cp "${m}" "${D}/${MY_APPDIR}/${m}-postinst-${lang}.txt" || die
278 + done
279 }
280
281 # @FUNCTION: webapp_postupgrade_txt
282 -# @USAGE: <lang> <file>
283 +# @USAGE: <lang> <file> [more files ...]
284 # @DESCRIPTION:
285 # Install a text file containing post-upgrade instructions.
286 webapp_postupgrade_txt() {
287 debug-print-function $FUNCNAME $*
288
289 - webapp_checkfileexists "${2}"
290 + local lang m
291
292 - elog "(info) ${2} (lang: ${1})"
293 - cp "${2}" "${D}/${MY_APPDIR}/postupgrade-${1}.txt"
294 -}
295 + [[ $# -lt 2 ]] && die "${FUNCNAME}: I require at least 2 arguments. Please read eclass documentation."
296
297 -# helper for webapp_serverowned()
298 -_webapp_serverowned() {
299 - debug-print-function $FUNCNAME $*
300 + lang=${1}
301 + shift
302
303 - webapp_checkfileexists "${1}" "${D}"
304 - local my_file="$(webapp_strip_appdir "${1}")"
305 - my_file="$(webapp_strip_cwd "${my_file}")"
306 + local m
307 + for m in "$@"; do
308 + webapp_checkfileexists "${m}"
309
310 - elog "(server owned) ${my_file}"
311 - echo "${my_file}" >> "${D}/${WA_SOLIST}"
312 + elog "[webapp-info] \"${m}\" (lang: ${lang})"
313 + cp "${m}" "${D}/${MY_APPDIR}/${m}-postupgrade-${lang}.txt" || die
314 + done
315 }
316
317 # @FUNCTION: webapp_serverowned
318 @@ -271,6 +306,8 @@
319 webapp_server_configfile() {
320 debug-print-function $FUNCNAME $*
321
322 + [[ $# -lt 2 ]] && die "${FUNCNAME}: I require at least 2 arguments. Please read eclass documentation."
323 +
324 webapp_checkfileexists "${2}"
325
326 # WARNING:
327 @@ -280,7 +317,7 @@
328
329 local my_file="${1}-${3:-$(basename "${2}")}"
330
331 - elog "(${1}) config file '${my_file}'"
332 + elog "[webapp] Server \"${1}\" config file \"${my_file}\""
333 cp "${2}" "${D}/${MY_SERVERCONFIGDIR}/${my_file}"
334 }
335
336 @@ -294,23 +331,23 @@
337 webapp_sqlscript() {
338 debug-print-function $FUNCNAME $*
339
340 - webapp_checkfileexists "${2}"
341 + [[ $# -lt 2 ]] && die "${FUNCNAME}: I require at least 2 arguments. Please read eclass documentation."
342
343 - dodir "${MY_SQLSCRIPTSDIR}/${1}"
344 + webapp_checkfileexists "${2}"
345
346 # WARNING:
347 #
348 # do NOT change the naming convention used here without changing all
349 # the other scripts that also rely upon these names
350
351 - if [[ -n "${3}" ]]; then
352 - elog "(${1}) upgrade script for ${PN}-${3} to ${PVR}"
353 - cp "${2}" "${D}${MY_SQLSCRIPTSDIR}/${1}/${3}_to_${PVR}.sql"
354 - chmod 600 "${D}${MY_SQLSCRIPTSDIR}/${1}/${3}_to_${PVR}.sql"
355 + insinto "${MY_SQLSCRIPTSDIR}/${1}"
356 + insopts -m0600
357 + if [[ -n ${3} ]]; then
358 + elog "[webapp] DB: \"${1}\" upgrade script for ${PN}-${3} to ${PVR}"
359 + newins "${2}" "${3}_to_${PVR}.sql" || die
360 else
361 - elog "(${1}) create script for ${PN}-${PVR}"
362 - cp "${2}" "${D}/${MY_SQLSCRIPTSDIR}/${1}/${PVR}_create.sql"
363 - chmod 600 "${D}/${MY_SQLSCRIPTSDIR}/${1}/${PVR}_create.sql"
364 + elog "[webapp] DB: \"${1}\" create script for ${PN}-${PVR}"
365 + newins "${2}" "${PVR}_create.sql"
366 fi
367 }
368
369 @@ -322,7 +359,7 @@
370 debug-print-function $FUNCNAME $*
371
372 # sanity checks, to catch bugs in the ebuild
373 - if [[ ! -f "${T}/${SETUP_CHECK_FILE}" ]]; then
374 + if [[ ! -f ${T}/${SETUP_CHECK_FILE} ]]; then
375 eerror
376 eerror "This ebuild did not call webapp_pkg_setup() at the beginning"
377 eerror "of the pkg_setup() function"
378 @@ -371,9 +408,8 @@
379 touch "${T}/${SETUP_CHECK_FILE}"
380
381 # special case - some ebuilds *do* need to overwride the SLOT
382 - if [[ "${SLOT}+" != "${PVR}+" && "${WEBAPP_MANUAL_SLOT}" != "yes" ]]; then
383 + [[ ${SLOT} != ${PVR} && ${WEBAPP_MANUAL_SLOT} != yes ]] && \
384 die "Set WEBAPP_MANUAL_SLOT=\"yes\" if you need to SLOT manually"
385 - fi
386
387 # pull in the shared configuration file
388 G_HOSTNAME="localhost"
389 @@ -391,17 +427,14 @@
390
391 if [[ $? -ne 0 ]]; then
392 # okay, whatever is there, it isn't webapp-config-compatible
393 - echo
394 ewarn
395 ewarn "You already have something installed in ${my_dir}"
396 ewarn
397 - ewarn "Whatever is in ${my_dir}, it's not"
398 + ewarn "Whatever is in \"${my_dir}\", it's not"
399 ewarn "compatible with webapp-config."
400 ewarn
401 ewarn "This ebuild may be overwriting important files."
402 ewarn
403 - echo
404 - ebeep 10
405 elif [[ "$(echo ${my_output} | awk '{ print $1 }')" != "${PN}" ]]; then
406 echo
407 eerror "You already have ${my_output} installed in ${my_dir}"
408 @@ -411,7 +444,6 @@
409 echo
410 die "Cannot upgrade contents of ${my_dir}"
411 fi
412 -
413 }
414
415 # @FUNCTION: webapp_src_install
416 @@ -479,23 +511,22 @@
417 local my_mode=-I
418 webapp_getinstalltype
419
420 - if [[ "${IS_REPLACE}" == "1" ]]; then
421 - elog "${PN}-${PVR} is already installed - replacing"
422 - my_mode=-I
423 - elif [[ "${IS_UPGRADE}" == "1" ]]; then
424 - elog "${REMOVE_PKG} is already installed - upgrading"
425 + if [[ ${IS_REPLACE} == 1 ]]; then
426 + elog "[webapp] ${PN}-${PVR} is already installed - replacing"
427 + elif [[ ${IS_UPGRADE} == 1 ]]; then
428 + elog "[webapp] ${REMOVE_PKG} is already installed - upgrading"
429 my_mode=-U
430 else
431 - elog "${PN}-${PVR} is not installed - using install mode"
432 + elog "[webapp] ${PN}-${PVR} is not installed - using install mode"
433 fi
434
435 my_cmd="${WEBAPP_CONFIG} ${my_mode} -h localhost -u root -d ${INSTALL_DIR} ${PN} ${PVR}"
436 - elog "Running ${my_cmd}"
437 + elog "[webapp] Running ${my_cmd}"
438 ${my_cmd}
439
440 echo
441 local cleaner="${WEBAPP_CLEANER} -p -C ${PN}"
442 - einfo "Running ${cleaner}"
443 + einfo "[webapp] Running ${cleaner}"
444 ${cleaner}
445 else
446 elog
447 @@ -544,10 +575,10 @@
448 ${WEBAPP_CONFIG} -C -h ${WEB_HOSTNAME} -d ${WEB_INSTALLDIR}
449 fi
450 else
451 - ewarn "Cannot find file ${x}/.webapp"
452 + ewarn "[webapp] Cannot find file ${x}/.webapp"
453 fi
454 done
455 - elif [[ "${my_output}" != "" ]]; then
456 + elif [[ -n ${my_output} ]]; then
457 echo
458 ewarn
459 ewarn "Don't forget to use webapp-config to remove any copies of"
460 @@ -556,9 +587,9 @@
461
462 echo "${my_output}" | while read x; do
463 if [[ -f "${x}"/.webapp ]]; then
464 - ewarn " ${x}"
465 + ewarn "[webapp] ${x}"
466 else
467 - ewarn "Cannot find file ${x}/.webapp"
468 + ewarn "[webapp] Cannot find file ${x}/.webapp"
469 fi
470 done