-# Copyright 1999-2017 Gentoo Foundation
+# Copyright 1999-2019 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2
# @ECLASS: cvs.eclass
# Set this to get a clean copy when updating (passes the
# -C option to cvs update)
-# @ECLASS-VARIABLE: ECVS_RUNAS
-# @DEFAULT_UNSET
-# @DESCRIPTION:
-# Specifies an alternate (non-root) user to use to run cvs. Currently
-# b0rked and wouldn't work with portage userpriv anyway without
-# special magic.
-
-# : ${ECVS_RUNAS:=$(whoami)}
-
# add cvs to deps
# ssh is used for ext auth
-# sudo is used to run as a specified user
DEPEND="dev-vcs/cvs"
-[[ -n ${ECVS_RUNAS} ]] && DEPEND+=" app-admin/sudo"
-
if [[ ${ECVS_AUTH} == "ext" ]] ; then
#default to ssh
[[ -z ${CVS_RSH} ]] && export CVS_RSH="ssh"
ECVS_UP_OPTS+=" -D ${ECVS_DATE}"
fi
- # It would be easiest to always be in "run-as mode", logic-wise,
- # if sudo didn't ask for a password even when sudo'ing to `whoami`.
-
- if [[ -z ${ECVS_RUNAS} ]] ; then
- run=""
- else
- run="sudo -u ${ECVS_RUNAS}"
- fi
-
# Create the top dir if needed
if [[ ! -d ${ECVS_TOP_DIR} ]] ; then
debug-print "${FUNCNAME}: checkout mode. creating cvs directory"
addwrite /foobar
addwrite /
- ${run} mkdir -p "/${ECVS_TOP_DIR}"
+ mkdir -p "/${ECVS_TOP_DIR}"
export SANDBOX_WRITE="${SANDBOX_WRITE//:\/foobar:\/}"
fi
# Disable the sandbox for this dir
addwrite "${ECVS_TOP_DIR}"
- # Chown the directory and all of its contents
- if [[ -n ${ECVS_RUNAS} ]] ; then
- ${run} chown -R "${ECVS_RUNAS}" "/${ECVS_TOP_DIR}"
- fi
-
# Determine the CVS command mode (checkout or update)
if [[ ! -d ${ECVS_TOP_DIR}/${ECVS_LOCALNAME}/CVS ]] ; then
mode=checkout
# Switch servers automagically if needed
if [[ ${mode} == "update" ]] ; then
cd "/${ECVS_TOP_DIR}/${ECVS_LOCALNAME}"
- local oldserver=$(${run} cat CVS/Root)
+ local oldserver=$(cat CVS/Root)
if [[ ${server} != "${oldserver}" ]] ; then
einfo "Changing the CVS server from ${oldserver} to ${server}:"
debug-print "${FUNCNAME}: Changing the CVS server from ${oldserver} to ${server}:"
einfo "Searching for CVS directories ..."
- local cvsdirs=$(${run} find . -iname CVS -print)
+ local cvsdirs=$(find . -iname CVS -print)
debug-print "${FUNCNAME}: CVS directories found:"
debug-print "${cvsdirs}"
local x
for x in ${cvsdirs} ; do
debug-print "In ${x}"
- ${run} echo "${server}" > "${x}/Root"
+ echo "${server}" > "${x}/Root"
done
fi
fi
# mess with ~/.cvspass
touch "${T}/cvspass"
export CVS_PASSFILE="${T}/cvspass"
- if [[ -n ${ECVS_RUNAS} ]] ; then
- chown "${ECVS_RUNAS}" "${T}/cvspass"
- fi
# The server string with the password in it, for login (only used for pserver)
cvsroot_pass=":${connection}:${ECVS_USER}:${ECVS_PASS}@${ECVS_SERVER}"
fi
# Commands to run
- cmdlogin=( ${run} ${ECVS_CVS_COMMAND} -d "${cvsroot_pass}" login )
- cmdupdate=( ${run} ${ECVS_CVS_COMMAND} -d "${cvsroot_nopass}" update ${ECVS_UP_OPTS} ${ECVS_LOCALNAME} )
- cmdcheckout=( ${run} ${ECVS_CVS_COMMAND} -d "${cvsroot_nopass}" checkout ${ECVS_CO_OPTS} ${ECVS_MODULE} )
+ cmdlogin=( ${ECVS_CVS_COMMAND} -d "${cvsroot_pass}" login )
+ cmdupdate=( ${ECVS_CVS_COMMAND} -d "${cvsroot_nopass}" update ${ECVS_UP_OPTS} ${ECVS_LOCALNAME} )
+ cmdcheckout=( ${ECVS_CVS_COMMAND} -d "${cvsroot_nopass}" checkout ${ECVS_CO_OPTS} ${ECVS_MODULE} )
# Execute commands
unset DISPLAY
fi
fi
-
- # Restore ownership. Not sure why this is needed, but someone
- # added it in the orig ECVS_RUNAS stuff.
- if [[ -n ${ECVS_RUNAS} ]] ; then
- chown $(whoami) "${T}/cvspass"
- fi
-
}
# @FUNCTION: cvs_src_unpack
ECVS_PASS=${ECVS_PASS}
ECVS_MODULE=${ECVS_MODULE}
ECVS_LOCAL=${ECVS_LOCAL}
- ECVS_RUNAS=${ECVS_RUNAS}
ECVS_LOCALNAME=${ECVS_LOCALNAME}"
[[ -z ${ECVS_MODULE} ]] && die "ERROR: CVS module not set, cannot continue."