/[gentoo-x86]/eclass/cvs.eclass
Gentoo

Diff of /eclass/cvs.eclass

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 1.78 Revision 1.79
1# Copyright 1999-2013 Gentoo Foundation 1# Copyright 1999-2013 Gentoo Foundation
2# Distributed under the terms of the GNU General Public License v2 2# Distributed under the terms of the GNU General Public License v2
3# $Header: /var/cvsroot/gentoo-x86/eclass/cvs.eclass,v 1.78 2013/01/22 07:02:06 vapier Exp $ 3# $Header: /var/cvsroot/gentoo-x86/eclass/cvs.eclass,v 1.79 2013/01/22 07:25:59 vapier Exp $
4 4
5# @ECLASS: cvs.eclass 5# @ECLASS: cvs.eclass
6# @MAINTAINER: 6# @MAINTAINER:
7# vapier@gentoo.org (and anyone who wants to help) 7# vapier@gentoo.org (and anyone who wants to help)
8# @BLURB: This eclass provides generic cvs fetching functions 8# @BLURB: This eclass provides generic cvs fetching functions
91# have e.g. a wrong $S setting. 91# have e.g. a wrong $S setting.
92 92
93# @ECLASS-VARIABLE: ECVS_TOP_DIR 93# @ECLASS-VARIABLE: ECVS_TOP_DIR
94# @DESCRIPTION: 94# @DESCRIPTION:
95# The directory under which CVS modules are checked out. 95# The directory under which CVS modules are checked out.
96[ -z "$ECVS_TOP_DIR" ] && ECVS_TOP_DIR="${PORTAGE_ACTUAL_DISTDIR-${DISTDIR}}/cvs-src" 96: ${ECVS_TOP_DIR:="${PORTAGE_ACTUAL_DISTDIR-${DISTDIR}}/cvs-src"}
97 97
98# @ECLASS-VARIABLE: ECVS_SERVER 98# @ECLASS-VARIABLE: ECVS_SERVER
99# @DESCRIPTION: 99# @DESCRIPTION:
100# CVS path 100# CVS path
101# 101#
104# ":pserver:anonymous@anoncvs.kde.org:/home/kde"; this is generated 104# ":pserver:anonymous@anoncvs.kde.org:/home/kde"; this is generated
105# using other settings also. 105# using other settings also.
106# 106#
107# Set this to "offline" to disable fetching (i.e. to assume the module 107# Set this to "offline" to disable fetching (i.e. to assume the module
108# is already checked out in ECVS_TOP_DIR). 108# is already checked out in ECVS_TOP_DIR).
109[ -z "$ECVS_SERVER" ] && ECVS_SERVER="offline" 109: ${ECVS_SERVER:="offline"}
110 110
111# @ECLASS-VARIABLE: ECVS_MODULE 111# @ECLASS-VARIABLE: ECVS_MODULE
112# @REQUIRED 112# @REQUIRED
113# @DESCRIPTION: 113# @DESCRIPTION:
114# The name of the CVS module to be fetched 114# The name of the CVS module to be fetched
115# 115#
116# This must be set when cvs_src_unpack is called. This can include 116# This must be set when cvs_src_unpack is called. This can include
117# several directory levels, i.e. "foo/bar/baz" 117# several directory levels, i.e. "foo/bar/baz"
118
119#[ -z "$ECVS_MODULE" ] && die "$ECLASS: error: ECVS_MODULE not set, cannot continue" 118#[[ -z ${ECVS_MODULE} ]] && die "$ECLASS: error: ECVS_MODULE not set, cannot continue"
120 119
121# @ECLASS-VARIABLE: ECVS_BRANCH 120# @ECLASS-VARIABLE: ECVS_BRANCH
122# @DEFAULT_UNSET 121# @DEFAULT_UNSET
123# @DESCRIPTION: 122# @DESCRIPTION:
124# The name of the branch/tag to use 123# The name of the branch/tag to use
125# 124#
126# The default is "HEAD". The following default _will_ reset your 125# The default is "HEAD". The following default _will_ reset your
127# branch checkout to head if used. 126# branch checkout to head if used.
128 127#: ${ECVS_BRANCH:="HEAD"}
129#[ -z "$ECVS_BRANCH" ] && ECVS_BRANCH="HEAD"
130 128
131# @ECLASS-VARIABLE: ECVS_AUTH 129# @ECLASS-VARIABLE: ECVS_AUTH
132# @DESCRIPTION: 130# @DESCRIPTION:
133# Authentication method to use 131# Authentication method to use
134# 132#
141# - Added "no" as a server type, which uses no AUTH method, nor 139# - Added "no" as a server type, which uses no AUTH method, nor
142# does it login 140# does it login
143# e.g. 141# e.g.
144# "cvs -danoncvs@savannah.gnu.org:/cvsroot/backbone co System" 142# "cvs -danoncvs@savannah.gnu.org:/cvsroot/backbone co System"
145# ( from gnustep-apps/textedit ) 143# ( from gnustep-apps/textedit )
146[ -z "$ECVS_AUTH" ] && ECVS_AUTH="pserver" 144: ${ECVS_AUTH:="pserver"}
147 145
148# @ECLASS-VARIABLE: ECVS_USER 146# @ECLASS-VARIABLE: ECVS_USER
149# @DESCRIPTION: 147# @DESCRIPTION:
150# Username to use for authentication on the remote server. 148# Username to use for authentication on the remote server.
151[ -z "$ECVS_USER" ] && ECVS_USER="anonymous" 149: ${ECVS_USER:="anonymous"}
152 150
153# @ECLASS-VARIABLE: ECVS_PASS 151# @ECLASS-VARIABLE: ECVS_PASS
152# @DEFAULT_UNSET
154# @DESCRIPTION: 153# @DESCRIPTION:
155# Password to use for authentication on the remote server 154# Password to use for authentication on the remote server
156[ -z "$ECVS_PASS" ] && ECVS_PASS=""
157 155
158# @ECLASS-VARIABLE: ECVS_SSH_HOST_KEY 156# @ECLASS-VARIABLE: ECVS_SSH_HOST_KEY
159# @DEFAULT_UNSET 157# @DEFAULT_UNSET
160# @DESCRIPTION: 158# @DESCRIPTION:
161# If SSH is used for `ext' authentication, use this variable to 159# If SSH is used for `ext' authentication, use this variable to
176# @DESCRIPTION: 174# @DESCRIPTION:
177# Specifies an alternate (non-root) user to use to run cvs. Currently 175# Specifies an alternate (non-root) user to use to run cvs. Currently
178# b0rked and wouldn't work with portage userpriv anyway without 176# b0rked and wouldn't work with portage userpriv anyway without
179# special magic. 177# special magic.
180 178
181# [ -z "$ECVS_RUNAS" ] && ECVS_RUNAS="`whoami`" 179# : ${ECVS_RUNAS:=$(whoami)}
182 180
183# ECVS_SUBDIR -- deprecated, do not use 181# ECVS_SUBDIR -- deprecated, do not use
184[ -n "$ECVS_SUBDIR" ] && die "ERROR: deprecated ECVS_SUBDIR defined. Please fix this ebuild." 182[[ -n ${ECVS_SUBDIR} ]] && die "ERROR: deprecated ECVS_SUBDIR defined. Please fix this ebuild."
185 183
186# add cvs to deps 184# add cvs to deps
187# ssh is used for ext auth 185# ssh is used for ext auth
188# sudo is used to run as a specified user 186# sudo is used to run as a specified user
189DEPEND="dev-vcs/cvs" 187DEPEND="dev-vcs/cvs"
190 188
191[ -n "$ECVS_RUNAS" ] && DEPEND="$DEPEND app-admin/sudo" 189[[ -n ${ECVS_RUNAS} ]] && DEPEND+=" app-admin/sudo"
192 190
193if [ "$ECVS_AUTH" == "ext" ]; then 191if [[ ${ECVS_AUTH} == "ext" ]] ; then
194 #default to ssh 192 #default to ssh
195 [ -z "$CVS_RSH" ] && export CVS_RSH="ssh" 193 [[ -z ${CVS_RSH} ]] && export CVS_RSH="ssh"
196 if [ "$CVS_RSH" != "ssh" ]; then 194 if [[ ${CVS_RSH} != "ssh" ]] ; then
197 die "Support for ext auth with clients other than ssh has not been implemented yet" 195 die "Support for ext auth with clients other than ssh has not been implemented yet"
198 fi 196 fi
199 DEPEND="${DEPEND} net-misc/openssh" 197 DEPEND+=" net-misc/openssh"
200fi 198fi
201 199
202# called from cvs_src_unpack 200# called from cvs_src_unpack
203cvs_fetch() { 201cvs_fetch() {
204 202
205 # Make these options local variables so that the global values are 203 # Make these options local variables so that the global values are
206 # not affected by modifications in this function. 204 # not affected by modifications in this function.
207 205
208 local ECVS_COMMAND="${ECVS_COMMAND}" 206 local ECVS_COMMAND=${ECVS_COMMAND}
209 local ECVS_UP_OPTS="${ECVS_UP_OPTS}" 207 local ECVS_UP_OPTS=${ECVS_UP_OPTS}
210 local ECVS_CO_OPTS="${ECVS_CO_OPTS}" 208 local ECVS_CO_OPTS=${ECVS_CO_OPTS}
211 209
212 debug-print-function $FUNCNAME $* 210 debug-print-function ${FUNCNAME} "$@"
213 211
214 # Update variables that are modified by ebuild parameters, which 212 # Update variables that are modified by ebuild parameters, which
215 # should be effective every time cvs_fetch is called, and not just 213 # should be effective every time cvs_fetch is called, and not just
216 # every time cvs.eclass is inherited 214 # every time cvs.eclass is inherited
217 215
218 # Handle parameter for local (non-recursive) fetching 216 # Handle parameter for local (non-recursive) fetching
219 217
220 if [ -n "$ECVS_LOCAL" ]; then 218 if [[ -n ${ECVS_LOCAL} ]] ; then
221 ECVS_UP_OPTS="$ECVS_UP_OPTS -l" 219 ECVS_UP_OPTS+=" -l"
222 ECVS_CO_OPTS="$ECVS_CO_OPTS -l" 220 ECVS_CO_OPTS+=" -l"
223 fi 221 fi
224 222
225 # Handle ECVS_BRANCH option 223 # Handle ECVS_BRANCH option
226 # 224 #
227 # Because CVS auto-switches branches, we just have to pass the 225 # Because CVS auto-switches branches, we just have to pass the
228 # correct -rBRANCH option when updating. 226 # correct -rBRANCH option when updating.
229 227
230 if [ -n "$ECVS_BRANCH" ]; then 228 if [[ -n ${ECVS_BRANCH} ]] ; then
231 ECVS_UP_OPTS="$ECVS_UP_OPTS -r$ECVS_BRANCH" 229 ECVS_UP_OPTS+=" -r${ECVS_BRANCH}"
232 ECVS_CO_OPTS="$ECVS_CO_OPTS -r$ECVS_BRANCH" 230 ECVS_CO_OPTS+=" -r${ECVS_BRANCH}"
233 fi 231 fi
234 232
235 # Handle ECVS_LOCALNAME, which specifies the local directory name 233 # Handle ECVS_LOCALNAME, which specifies the local directory name
236 # to use. Note that the -d command option is not equivalent to 234 # to use. Note that the -d command option is not equivalent to
237 # the global -d option. 235 # the global -d option.
238 236
239 if [ "$ECVS_LOCALNAME" != "$ECVS_MODULE" ]; then 237 if [[ ${ECVS_LOCALNAME} != "${ECVS_MODULE}" ]] ; then
240 ECVS_CO_OPTS="$ECVS_CO_OPTS -d $ECVS_LOCALNAME" 238 ECVS_CO_OPTS+=" -d ${ECVS_LOCALNAME}"
241 fi 239 fi
242 240
243
244 if [ -n "$ECVS_CLEAN" ]; then 241 if [[ -n ${ECVS_CLEAN} ]] ; then
245 ECVS_UP_OPTS="$ECVS_UP_OPTS -C" 242 ECVS_UP_OPTS+=" -C"
246 fi 243 fi
247
248 244
249 # It would be easiest to always be in "run-as mode", logic-wise, 245 # It would be easiest to always be in "run-as mode", logic-wise,
250 # if sudo didn't ask for a password even when sudo'ing to `whoami`. 246 # if sudo didn't ask for a password even when sudo'ing to `whoami`.
251 247
252 if [ -z "$ECVS_RUNAS" ]; then 248 if [[ -z ${ECVS_RUNAS} ]] ; then
253 run="" 249 run=""
254 else 250 else
255 run="sudo -u $ECVS_RUNAS" 251 run="sudo -u ${ECVS_RUNAS}"
256 fi 252 fi
257 253
258 # Create the top dir if needed 254 # Create the top dir if needed
259 255
260 if [ ! -d "$ECVS_TOP_DIR" ]; then 256 if [[ ! -d ${ECVS_TOP_DIR} ]] ; then
261
262 # Note that the addwrite statements in this block are only 257 # Note that the addwrite statements in this block are only
263 # there to allow creating ECVS_TOP_DIR; we allow writing 258 # there to allow creating ECVS_TOP_DIR; we allow writing
264 # inside it separately. 259 # inside it separately.
265 260
266 # This is because it's simpler than trying to find out the 261 # This is because it's simpler than trying to find out the
267 # parent path of the directory, which would need to be the 262 # parent path of the directory, which would need to be the
268 # real path and not a symlink for things to work (so we can't 263 # real path and not a symlink for things to work (so we can't
269 # just remove the last path element in the string) 264 # just remove the last path element in the string)
270 265
271 debug-print "$FUNCNAME: checkout mode. creating cvs directory" 266 debug-print "${FUNCNAME}: checkout mode. creating cvs directory"
272 addwrite /foobar 267 addwrite /foobar
273 addwrite / 268 addwrite /
274 $run mkdir -p "/$ECVS_TOP_DIR" 269 ${run} mkdir -p "/${ECVS_TOP_DIR}"
275 export SANDBOX_WRITE="${SANDBOX_WRITE//:\/foobar:\/}" 270 export SANDBOX_WRITE="${SANDBOX_WRITE//:\/foobar:\/}"
276 fi 271 fi
277 272
278 # In case ECVS_TOP_DIR is a symlink to a dir, get the real path, 273 # In case ECVS_TOP_DIR is a symlink to a dir, get the real path,
279 # otherwise addwrite() doesn't work. 274 # otherwise addwrite() doesn't work.
280 275
281 cd -P "$ECVS_TOP_DIR" > /dev/null 276 cd -P "${ECVS_TOP_DIR}" >/dev/null
282 ECVS_TOP_DIR="`/bin/pwd`" 277 ECVS_TOP_DIR=$(pwd)
283 278
284 # Disable the sandbox for this dir 279 # Disable the sandbox for this dir
285 addwrite "$ECVS_TOP_DIR" 280 addwrite "${ECVS_TOP_DIR}"
286 281
287 # Chown the directory and all of its contents 282 # Chown the directory and all of its contents
288 if [ -n "$ECVS_RUNAS" ]; then 283 if [[ -n ${ECVS_RUNAS} ]] ; then
289 $run chown -R "$ECVS_RUNAS" "/$ECVS_TOP_DIR" 284 ${run} chown -R "${ECVS_RUNAS}" "/${ECVS_TOP_DIR}"
290 fi 285 fi
291 286
292 # Determine the CVS command mode (checkout or update) 287 # Determine the CVS command mode (checkout or update)
293 if [ ! -d "$ECVS_TOP_DIR/$ECVS_LOCALNAME/CVS" ]; then 288 if [[ ! -d ${ECVS_TOP_DIR}/${ECVS_LOCALNAME}/CVS ]] ; then
294 mode=checkout 289 mode=checkout
295 else 290 else
296 mode=update 291 mode=update
297 fi 292 fi
298 293
299
300 # Our server string (i.e. CVSROOT) without the password so it can 294 # Our server string (i.e. CVSROOT) without the password so it can
301 # be put in Root 295 # be put in Root
302 if [ "$ECVS_AUTH" == "no" ] 296 if [[ ${ECVS_AUTH} == "no" ]] ; then
303 then
304 local server="${ECVS_USER}@${ECVS_SERVER}" 297 local server="${ECVS_USER}@${ECVS_SERVER}"
305 else 298 else
306 local connection="${ECVS_AUTH}" 299 local connection="${ECVS_AUTH}"
307 [[ -n ${ECVS_PROXY} ]] && connection="${connection};proxy=${ECVS_PROXY}" 300 [[ -n ${ECVS_PROXY} ]] && connection+=";proxy=${ECVS_PROXY}"
308 [[ -n ${ECVS_PROXY_PORT} ]] && connection="${connection};proxyport=${ECVS_PROXY_PORT}" 301 [[ -n ${ECVS_PROXY_PORT} ]] && connection+=";proxyport=${ECVS_PROXY_PORT}"
309 local server=":${connection}:${ECVS_USER}@${ECVS_SERVER}" 302 local server=":${connection}:${ECVS_USER}@${ECVS_SERVER}"
310 fi 303 fi
311 304
312 # Switch servers automagically if needed 305 # Switch servers automagically if needed
313 if [ "$mode" == "update" ]; then 306 if [[ ${mode} == "update" ]] ; then
314 cd /$ECVS_TOP_DIR/$ECVS_LOCALNAME 307 cd "/${ECVS_TOP_DIR}/${ECVS_LOCALNAME}"
315 local oldserver="`$run cat CVS/Root`" 308 local oldserver=$(${run} cat CVS/Root)
316 if [ "$server" != "$oldserver" ]; then 309 if [[ ${server} != "${oldserver}" ]] ; then
317
318 einfo "Changing the CVS server from $oldserver to $server:" 310 einfo "Changing the CVS server from ${oldserver} to ${server}:"
319 debug-print "$FUNCNAME: Changing the CVS server from $oldserver to $server:" 311 debug-print "${FUNCNAME}: Changing the CVS server from ${oldserver} to ${server}:"
320 312
321 einfo "Searching for CVS directories ..." 313 einfo "Searching for CVS directories ..."
322 local cvsdirs="`$run find . -iname CVS -print`" 314 local cvsdirs=$(${run} find . -iname CVS -print)
323 debug-print "$FUNCNAME: CVS directories found:" 315 debug-print "${FUNCNAME}: CVS directories found:"
324 debug-print "$cvsdirs" 316 debug-print "${cvsdirs}"
325 317
326 einfo "Modifying CVS directories ..." 318 einfo "Modifying CVS directories ..."
319 local x
327 for x in $cvsdirs; do 320 for x in ${cvsdirs} ; do
328 debug-print "In $x" 321 debug-print "In ${x}"
329 $run echo "$server" > "$x/Root" 322 ${run} echo "${server}" > "${x}/Root"
330 done 323 done
331
332 fi 324 fi
333 fi 325 fi
334 326
335 # Prepare a cvspass file just for this session, we don't want to 327 # Prepare a cvspass file just for this session, we don't want to
336 # mess with ~/.cvspass 328 # mess with ~/.cvspass
337 touch "${T}/cvspass" 329 touch "${T}/cvspass"
338 export CVS_PASSFILE="${T}/cvspass" 330 export CVS_PASSFILE="${T}/cvspass"
339 if [ -n "$ECVS_RUNAS" ]; then 331 if [[ -n ${ECVS_RUNAS} ]] ; then
340 chown "$ECVS_RUNAS" "${T}/cvspass" 332 chown "${ECVS_RUNAS}" "${T}/cvspass"
341 fi 333 fi
342 334
343 # The server string with the password in it, for login 335 # The server string with the password in it, for login
344 cvsroot_pass=":${ECVS_AUTH}:${ECVS_USER}:${ECVS_PASS}@${ECVS_SERVER}" 336 cvsroot_pass=":${ECVS_AUTH}:${ECVS_USER}:${ECVS_PASS}@${ECVS_SERVER}"
345 337
346 # Ditto without the password, for checkout/update after login, so 338 # Ditto without the password, for checkout/update after login, so
347 # that the CVS/Root files don't contain the password in plaintext 339 # that the CVS/Root files don't contain the password in plaintext
348 if [ "$ECVS_AUTH" == "no" ] 340 if [[ ${ECVS_AUTH} == "no" ]] ; then
349 then
350 cvsroot_nopass="${ECVS_USER}@${ECVS_SERVER}" 341 cvsroot_nopass="${ECVS_USER}@${ECVS_SERVER}"
351 else 342 else
352 cvsroot_nopass=":${ECVS_AUTH}:${ECVS_USER}@${ECVS_SERVER}" 343 cvsroot_nopass=":${ECVS_AUTH}:${ECVS_USER}@${ECVS_SERVER}"
353 fi 344 fi
354 345
358 cmdcheckout="${run} ${ECVS_CVS_COMMAND} -d \"${cvsroot_nopass}\" checkout ${ECVS_CO_OPTS} ${ECVS_MODULE}" 349 cmdcheckout="${run} ${ECVS_CVS_COMMAND} -d \"${cvsroot_nopass}\" checkout ${ECVS_CO_OPTS} ${ECVS_MODULE}"
359 350
360 # Execute commands 351 # Execute commands
361 352
362 cd "${ECVS_TOP_DIR}" 353 cd "${ECVS_TOP_DIR}"
363 if [ "${ECVS_AUTH}" == "pserver" ]; then 354 if [[ ${ECVS_AUTH} == "pserver" ]] ; then
364 einfo "Running $cmdlogin" 355 einfo "Running ${cmdlogin}"
365 eval $cmdlogin || die "cvs login command failed" 356 eval ${cmdlogin} || die "cvs login command failed"
366 if [ "${mode}" == "update" ]; then 357 if [[ ${mode} == "update" ]] ; then
367 einfo "Running $cmdupdate" 358 einfo "Running ${cmdupdate}"
368 eval $cmdupdate || die "cvs update command failed" 359 eval ${cmdupdate} || die "cvs update command failed"
369 elif [ "${mode}" == "checkout" ]; then 360 elif [[ ${mode} == "checkout" ]] ; then
370 einfo "Running $cmdcheckout" 361 einfo "Running ${cmdcheckout}"
371 eval $cmdcheckout|| die "cvs checkout command failed" 362 eval ${cmdcheckout} || die "cvs checkout command failed"
372 fi 363 fi
373 elif [ "${ECVS_AUTH}" == "ext" ] || [ "${ECVS_AUTH}" == "no" ]; then 364 elif [[ ${ECVS_AUTH} == "ext" || ${ECVS_AUTH} == "no" ]] ; then
374
375 # Hack to support SSH password authentication 365 # Hack to support SSH password authentication
376 366
377 # Backup environment variable values 367 # Backup environment variable values
378 local CVS_ECLASS_ORIG_CVS_RSH="${CVS_RSH}" 368 local CVS_ECLASS_ORIG_CVS_RSH="${CVS_RSH}"
379 369
380 if [ "${SSH_ASKPASS+set}" == "set" ]; then 370 if [[ ${SSH_ASKPASS+set} == "set" ]] ; then
381 local CVS_ECLASS_ORIG_SSH_ASKPASS="${SSH_ASKPASS}" 371 local CVS_ECLASS_ORIG_SSH_ASKPASS="${SSH_ASKPASS}"
382 else 372 else
383 unset CVS_ECLASS_ORIG_SSH_ASKPASS 373 unset CVS_ECLASS_ORIG_SSH_ASKPASS
384 fi 374 fi
385 375
386 if [ "${DISPLAY+set}" == "set" ]; then 376 if [[ ${DISPLAY+set} == "set" ]] ; then
387 local CVS_ECLASS_ORIG_DISPLAY="${DISPLAY}" 377 local CVS_ECLASS_ORIG_DISPLAY="${DISPLAY}"
388 else 378 else
389 unset CVS_ECLASS_ORIG_DISPLAY 379 unset CVS_ECLASS_ORIG_DISPLAY
390 fi 380 fi
391 381
392 if [ "${CVS_RSH}" == "ssh" ]; then 382 if [[ ${CVS_RSH} == "ssh" ]] ; then
393
394 # Force SSH to use SSH_ASKPASS by creating python wrapper 383 # Force SSH to use SSH_ASKPASS by creating python wrapper
395 384
396 export CVS_RSH="${T}/cvs_sshwrapper" 385 export CVS_RSH="${T}/cvs_sshwrapper"
397 cat > "${CVS_RSH}"<<EOF 386 cat > "${CVS_RSH}"<<EOF
398#!/usr/bin/python 387#!/usr/bin/python
423 412
424 local CVS_ECLASS_KNOWN_HOSTS="${T}/cvs_ssh_known_hosts" 413 local CVS_ECLASS_KNOWN_HOSTS="${T}/cvs_ssh_known_hosts"
425 echo "newarglist.insert(1, '-oUserKnownHostsFile=${CVS_ECLASS_KNOWN_HOSTS}')" \ 414 echo "newarglist.insert(1, '-oUserKnownHostsFile=${CVS_ECLASS_KNOWN_HOSTS}')" \
426 >> "${CVS_RSH}" 415 >> "${CVS_RSH}"
427 416
428 if [ -z "${ECVS_SSH_HOST_KEY}" ]; then 417 if [[ -z ${ECVS_SSH_HOST_KEY} ]] ; then
429 ewarn "Warning: The SSH host key of the remote server will not be verified." 418 ewarn "Warning: The SSH host key of the remote server will not be verified."
430 einfo "A temporary known hosts list will be used." 419 einfo "A temporary known hosts list will be used."
431 local CVS_ECLASS_STRICT_HOST_CHECKING="no" 420 local CVS_ECLASS_STRICT_HOST_CHECKING="no"
432 touch "${CVS_ECLASS_KNOWN_HOSTS}" 421 touch "${CVS_ECLASS_KNOWN_HOSTS}"
433 else 422 else
445 chmod a+x "${CVS_RSH}" 434 chmod a+x "${CVS_RSH}"
446 435
447 # Make sure DISPLAY is set (SSH will not use SSH_ASKPASS 436 # Make sure DISPLAY is set (SSH will not use SSH_ASKPASS
448 # if DISPLAY is not set) 437 # if DISPLAY is not set)
449 438
450 [ -z "${DISPLAY}" ] && DISPLAY="DISPLAY" 439 : ${DISPLAY:="DISPLAY"}
451 export DISPLAY 440 export DISPLAY
452 441
453 # Create a dummy executable to echo $ECVS_PASS 442 # Create a dummy executable to echo ${ECVS_PASS}
454 443
455 export SSH_ASKPASS="${T}/cvs_sshechopass" 444 export SSH_ASKPASS="${T}/cvs_sshechopass"
456 if [ "${ECVS_AUTH}" != "no" ]; then 445 if [[ ${ECVS_AUTH} != "no" ]] ; then
457 echo -en "#!/bin/bash\necho \"$ECVS_PASS\"\n" \ 446 echo -en "#!/bin/bash\necho \"${ECVS_PASS}\"\n" \
458 > "${SSH_ASKPASS}" 447 > "${SSH_ASKPASS}"
459 else 448 else
460 echo -en "#!/bin/bash\nreturn\n" \ 449 echo -en "#!/bin/bash\nreturn\n" \
461 > "${SSH_ASKPASS}" 450 > "${SSH_ASKPASS}"
462
463 fi 451 fi
464 chmod a+x "${SSH_ASKPASS}" 452 chmod a+x "${SSH_ASKPASS}"
465 fi 453 fi
466 454
467 if [ "${mode}" == "update" ]; then 455 if [[ ${mode} == "update" ]] ; then
468 einfo "Running $cmdupdate" 456 einfo "Running ${cmdupdate}"
469 eval $cmdupdate || die "cvs update command failed" 457 eval ${cmdupdate} || die "cvs update command failed"
470 elif [ "${mode}" == "checkout" ]; then 458 elif [[ ${mode} == "checkout" ]] ; then
471 einfo "Running $cmdcheckout" 459 einfo "Running ${cmdcheckout}"
472 eval $cmdcheckout|| die "cvs checkout command failed" 460 eval ${cmdcheckout} || die "cvs checkout command failed"
473 fi 461 fi
474 462
475 # Restore environment variable values 463 # Restore environment variable values
476 export CVS_RSH="${CVS_ECLASS_ORIG_CVS_RSH}" 464 export CVS_RSH="${CVS_ECLASS_ORIG_CVS_RSH}"
477 if [ "${CVS_ECLASS_ORIG_SSH_ASKPASS+set}" == "set" ]; then 465 if [[ ${CVS_ECLASS_ORIG_SSH_ASKPASS+set} == "set" ]] ; then
478 export SSH_ASKPASS="${CVS_ECLASS_ORIG_SSH_ASKPASS}" 466 export SSH_ASKPASS="${CVS_ECLASS_ORIG_SSH_ASKPASS}"
479 else 467 else
480 unset SSH_ASKPASS 468 unset SSH_ASKPASS
481 fi 469 fi
482 470
483 if [ "${CVS_ECLASS_ORIG_DISPLAY+set}" == "set" ]; then 471 if [[ ${CVS_ECLASS_ORIG_DISPLAY+set} == "set" ]] ; then
484 export DISPLAY="${CVS_ECLASS_ORIG_DISPLAY}" 472 export DISPLAY="${CVS_ECLASS_ORIG_DISPLAY}"
485 else 473 else
486 unset DISPLAY 474 unset DISPLAY
487 fi 475 fi
488 fi 476 fi
489 477
490 # Restore ownership. Not sure why this is needed, but someone 478 # Restore ownership. Not sure why this is needed, but someone
491 # added it in the orig ECVS_RUNAS stuff. 479 # added it in the orig ECVS_RUNAS stuff.
492 if [ -n "$ECVS_RUNAS" ]; then 480 if [[ -n ${ECVS_RUNAS} ]] ; then
493 chown `whoami` "${T}/cvspass" 481 chown $(whoami) "${T}/cvspass"
494 fi 482 fi
495 483
496} 484}
497 485
498# @FUNCTION: cvs_src_unpack 486# @FUNCTION: cvs_src_unpack
499# @DESCRIPTION: 487# @DESCRIPTION:
500# The cvs src_unpack function, which will be exported 488# The cvs src_unpack function, which will be exported
501cvs_src_unpack() { 489cvs_src_unpack() {
502 490
503 debug-print-function $FUNCNAME $* 491 debug-print-function ${FUNCNAME} "$@"
504 492
505 debug-print "$FUNCNAME: init: 493 debug-print "${FUNCNAME}: init:
506 ECVS_CVS_COMMAND=$ECVS_CVS_COMMAND 494 ECVS_CVS_COMMAND=${ECVS_CVS_COMMAND}
507 ECVS_UP_OPTS=$ECVS_UP_OPTS 495 ECVS_UP_OPTS=${ECVS_UP_OPTS}
508 ECVS_CO_OPTS=$ECVS_CO_OPTS 496 ECVS_CO_OPTS=${ECVS_CO_OPTS}
509 ECVS_TOP_DIR=$ECVS_TOP_DIR 497 ECVS_TOP_DIR=${ECVS_TOP_DIR}
510 ECVS_SERVER=$ECVS_SERVER 498 ECVS_SERVER=${ECVS_SERVER}
511 ECVS_USER=$ECVS_USER 499 ECVS_USER=${ECVS_USER}
512 ECVS_PASS=$ECVS_PASS 500 ECVS_PASS=${ECVS_PASS}
513 ECVS_MODULE=$ECVS_MODULE 501 ECVS_MODULE=${ECVS_MODULE}
514 ECVS_LOCAL=$ECVS_LOCAL 502 ECVS_LOCAL=${ECVS_LOCAL}
515 ECVS_RUNAS=$ECVS_RUNAS 503 ECVS_RUNAS=${ECVS_RUNAS}
516 ECVS_LOCALNAME=$ECVS_LOCALNAME" 504 ECVS_LOCALNAME=${ECVS_LOCALNAME}"
517 505
518 [ -z "$ECVS_MODULE" ] && die "ERROR: CVS module not set, cannot continue." 506 [[ -z ${ECVS_MODULE} ]] && die "ERROR: CVS module not set, cannot continue."
519 507
520 local ECVS_LOCALNAME="${ECVS_LOCALNAME}" 508 local ECVS_LOCALNAME=${ECVS_LOCALNAME:-${ECVS_MODULE}}
521
522 if [ -z "$ECVS_LOCALNAME" ]; then
523 ECVS_LOCALNAME="$ECVS_MODULE"
524 fi
525 509
526 local sanitized_pn=$(echo "${PN}" | LC_ALL=C sed -e 's:[^A-Za-z0-9_]:_:g') 510 local sanitized_pn=$(echo "${PN}" | LC_ALL=C sed -e 's:[^A-Za-z0-9_]:_:g')
527 local offline_pkg_var="ECVS_OFFLINE_${sanitized_pn}" 511 local offline_pkg_var="ECVS_OFFLINE_${sanitized_pn}"
528 if [[ -n ${!offline_pkg_var}${ECVS_OFFLINE} ]] || [[ "$ECVS_SERVER" == "offline" ]] ; then 512 if [[ -n ${!offline_pkg_var}${ECVS_OFFLINE} ]] || [[ ${ECVS_SERVER} == "offline" ]] ; then
529 # We're not required to fetch anything; the module already 513 # We're not required to fetch anything; the module already
530 # exists and shouldn't be updated. 514 # exists and shouldn't be updated.
531 if [ -d "${ECVS_TOP_DIR}/${ECVS_LOCALNAME}" ]; then 515 if [[ -d ${ECVS_TOP_DIR}/${ECVS_LOCALNAME} ]] ; then
532 debug-print "$FUNCNAME: offline mode" 516 debug-print "${FUNCNAME}: offline mode"
533 else 517 else
534 debug-print "$FUNCNAME: Offline mode specified but directory ${ECVS_TOP_DIR}/${ECVS_LOCALNAME} not found, exiting with error" 518 debug-print "${FUNCNAME}: Offline mode specified but directory ${ECVS_TOP_DIR}/${ECVS_LOCALNAME} not found, exiting with error"
535 die "ERROR: Offline mode specified, but directory ${ECVS_TOP_DIR}/${ECVS_LOCALNAME} not found. Aborting." 519 die "ERROR: Offline mode specified, but directory ${ECVS_TOP_DIR}/${ECVS_LOCALNAME} not found. Aborting."
536 fi 520 fi
537 elif [ -n "$ECVS_SERVER" ]; then # ECVS_SERVER!=offline --> real fetching mode 521 elif [[ -n ${ECVS_SERVER} ]] ; then # ECVS_SERVER!=offline --> real fetching mode
538 einfo "Fetching CVS module $ECVS_MODULE into $ECVS_TOP_DIR ..." 522 einfo "Fetching CVS module ${ECVS_MODULE} into ${ECVS_TOP_DIR} ..."
539 cvs_fetch 523 cvs_fetch
540 else # ECVS_SERVER not set 524 else # ECVS_SERVER not set
541 die "ERROR: CVS server not specified, cannot continue." 525 die "ERROR: CVS server not specified, cannot continue."
542 fi 526 fi
543 527
544 einfo "Copying $ECVS_MODULE from $ECVS_TOP_DIR ..." 528 einfo "Copying ${ECVS_MODULE} from ${ECVS_TOP_DIR} ..."
545 debug-print "Copying module $ECVS_MODULE local_mode=$ECVS_LOCAL from $ECVS_TOP_DIR ..." 529 debug-print "Copying module ${ECVS_MODULE} local_mode=${ECVS_LOCAL} from ${ECVS_TOP_DIR} ..."
546 530
547 # This is probably redundant, but best to make sure. 531 # This is probably redundant, but best to make sure.
548 mkdir -p "$WORKDIR/$ECVS_LOCALNAME" 532 mkdir -p "${WORKDIR}/${ECVS_LOCALNAME}"
549 533
550 if [ -n "$ECVS_LOCAL" ]; then 534 if [[ -n ${ECVS_LOCAL} ]] ; then
551 cp -f "$ECVS_TOP_DIR/$ECVS_LOCALNAME"/* "$WORKDIR/$ECVS_LOCALNAME" 535 cp -f "${ECVS_TOP_DIR}/${ECVS_LOCALNAME}"/* "${WORKDIR}/${ECVS_LOCALNAME}"
552 else 536 else
553 cp -Rf "$ECVS_TOP_DIR/$ECVS_LOCALNAME" "$WORKDIR/$ECVS_LOCALNAME/.." 537 cp -Rf "${ECVS_TOP_DIR}/${ECVS_LOCALNAME}" "${WORKDIR}/${ECVS_LOCALNAME}/.."
554 fi 538 fi
555 539
556 # Not exactly perfect, but should be pretty close #333773 540 # Not exactly perfect, but should be pretty close #333773
557 export ECVS_VERSION=$(find "$ECVS_TOP_DIR/$ECVS_LOCALNAME/" -ipath '*/CVS/Entries' -exec cat {} + | LC_ALL=C sort | sha1sum | awk '{print $1}') 541 export ECVS_VERSION=$(
542 find "${ECVS_TOP_DIR}/${ECVS_LOCALNAME}/" -ipath '*/CVS/Entries' -exec cat {} + | \
543 LC_ALL=C sort | \
544 sha1sum | \
545 awk '{print $1}'
546 )
558 547
559 # If the directory is empty, remove it; empty directories cannot 548 # If the directory is empty, remove it; empty directories cannot
560 # exist in cvs. This happens when, for example, kde-source 549 # exist in cvs. This happens when, for example, kde-source
561 # requests module/doc/subdir which doesn't exist. Still create 550 # requests module/doc/subdir which doesn't exist. Still create
562 # the empty directory in workdir though. 551 # the empty directory in workdir though.
563 if [ "`ls -A \"${ECVS_TOP_DIR}/${ECVS_LOCALNAME}\"`" == "CVS" ]; then 552 if [[ $(ls -A "${ECVS_TOP_DIR}/${ECVS_LOCALNAME}") == "CVS" ]] ; then
564 debug-print "$FUNCNAME: removing empty CVS directory $ECVS_LOCALNAME" 553 debug-print "${FUNCNAME}: removing empty CVS directory ${ECVS_LOCALNAME}"
565 rm -rf "${ECVS_TOP_DIR}/${ECVS_LOCALNAME}" 554 rm -rf "${ECVS_TOP_DIR}/${ECVS_LOCALNAME}"
566 fi 555 fi
567 556
568 # Implement some of base_src_unpack's functionality; note however 557 # Implement some of base_src_unpack's functionality; note however
569 # that base.eclass may not have been inherited! 558 # that base.eclass may not have been inherited!
570 if [ -n "$PATCHES" ]; then 559 if [[ -n ${PATCHES} ]] ; then
571 debug-print "$FUNCNAME: PATCHES=$PATCHES, S=$S, autopatching" 560 debug-print "${FUNCNAME}: PATCHES=${PATCHES,} S=${S}, autopatching"
572 cd "$S" 561 cd "${S}"
573 epatch ${PATCHES} 562 epatch ${PATCHES}
574 # Make sure we don't try to apply patches more than once, 563 # Make sure we don't try to apply patches more than once,
575 # since cvs_src_unpack is usually called several times from 564 # since cvs_src_unpack is usually called several times from
576 # e.g. kde-source_src_unpack 565 # e.g. kde-source_src_unpack
577 export PATCHES="" 566 export PATCHES=""

Legend:
Removed from v.1.78  
changed lines
  Added in v.1.79

  ViewVC Help
Powered by ViewVC 1.1.20