diff options
author | Ulrich Müller <ulm@gentoo.org> | 2024-10-14 12:36:08 +0200 |
---|---|---|
committer | Ulrich Müller <ulm@gentoo.org> | 2024-10-18 19:54:34 +0200 |
commit | 79d26649cb50e6f26be6728621459ae94c542d3b (patch) | |
tree | 497f59189ddd4d611ece23678a280a943921ccb9 /eclass | |
parent | dev-ml/ppxlib: add 0.33.0 (diff) | |
download | gentoo-79d26649cb50e6f26be6728621459ae94c542d3b.tar.gz gentoo-79d26649cb50e6f26be6728621459ae94c542d3b.tar.bz2 gentoo-79d26649cb50e6f26be6728621459ae94c542d3b.zip |
cvs.eclass: Add local declarations and die statements throughout
Signed-off-by: Ulrich Müller <ulm@gentoo.org>
Diffstat (limited to 'eclass')
-rw-r--r-- | eclass/cvs.eclass | 120 |
1 files changed, 52 insertions, 68 deletions
diff --git a/eclass/cvs.eclass b/eclass/cvs.eclass index dbacc2c09cfe..ec0ad2ec8f71 100644 --- a/eclass/cvs.eclass +++ b/eclass/cvs.eclass @@ -1,4 +1,4 @@ -# Copyright 1999-2023 Gentoo Authors +# Copyright 1999-2024 Gentoo Authors # Distributed under the terms of the GNU General Public License v2 # @ECLASS: cvs.eclass @@ -268,13 +268,14 @@ cvs_fetch() { # In case ECVS_TOP_DIR is a symlink to a dir, get the real path, # otherwise addwrite() doesn't work. - cd -P "${ECVS_TOP_DIR}" >/dev/null + cd -P "${ECVS_TOP_DIR}" >/dev/null || die ECVS_TOP_DIR=$(pwd) # Disable the sandbox for this dir addwrite "${ECVS_TOP_DIR}" # Determine the CVS command mode (checkout or update) + local mode if [[ ! -d ${ECVS_TOP_DIR}/${ECVS_LOCALNAME}/CVS ]] ; then mode=checkout else @@ -294,14 +295,14 @@ cvs_fetch() { # Switch servers automagically if needed if [[ ${mode} == "update" ]] ; then - cd "/${ECVS_TOP_DIR}/${ECVS_LOCALNAME}" - local oldserver=$(cat CVS/Root) + cd "/${ECVS_TOP_DIR}/${ECVS_LOCALNAME}" || die + local oldserver=$(cat CVS/Root || die) 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=$(find . -iname CVS -print) + local cvsdirs=$(find . -iname CVS -print || die) debug-print "${FUNCNAME}: CVS directories found:" debug-print "${cvsdirs}" @@ -309,21 +310,22 @@ cvs_fetch() { local x for x in ${cvsdirs} ; do debug-print "In ${x}" - echo "${server}" > "${x}/Root" + echo "${server}" > "${x}/Root" || die done fi fi # Prepare a cvspass file just for this session, we don't want to # mess with ~/.cvspass - touch "${T}/cvspass" - export CVS_PASSFILE="${T}/cvspass" + local -x CVS_PASSFILE="${T}/cvspass" + touch "${CVS_PASSFILE}" || die # The server string with the password in it, for login (only used for pserver) - cvsroot_pass=":${connection}:${ECVS_USER}:${ECVS_PASS}@${ECVS_SERVER}" + local cvsroot_pass=":${connection}:${ECVS_USER}:${ECVS_PASS}@${ECVS_SERVER}" # Ditto without the password, for checkout/update after login, so # that the CVS/Root files don't contain the password in plaintext + local cvsroot_nopass if [[ ${ECVS_AUTH} == "no" ]] ; then cvsroot_nopass="${ECVS_USER}@${ECVS_SERVER}" else @@ -331,13 +333,21 @@ cvs_fetch() { fi # Commands to run - 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} ) + local cmdlogin=( + ${ECVS_CVS_COMMAND} -d "${cvsroot_pass}" login + ) + local cmdupdate=( + ${ECVS_CVS_COMMAND} -d "${cvsroot_nopass}" update + ${ECVS_UP_OPTS} ${ECVS_LOCALNAME} + ) + local cmdcheckout=( + ${ECVS_CVS_COMMAND} -d "${cvsroot_nopass}" checkout + ${ECVS_CO_OPTS} ${ECVS_MODULE} + ) # Execute commands - cd "${ECVS_TOP_DIR}" + cd "${ECVS_TOP_DIR}" || die if [[ ${ECVS_AUTH} == "pserver" ]] ; then einfo "Running ${cmdlogin[*]}" "${cmdlogin[@]}" || die "cvs login command failed" @@ -351,26 +361,11 @@ cvs_fetch() { elif [[ ${ECVS_AUTH} == "ext" || ${ECVS_AUTH} == "no" ]] ; then # Hack to support SSH password authentication - # Backup environment variable values - local CVS_ECLASS_ORIG_CVS_RSH="${CVS_RSH}" - - if [[ ${SSH_ASKPASS+set} == "set" ]] ; then - local CVS_ECLASS_ORIG_SSH_ASKPASS="${SSH_ASKPASS}" - else - unset CVS_ECLASS_ORIG_SSH_ASKPASS - fi - - if [[ ${DISPLAY+set} == "set" ]] ; then - local CVS_ECLASS_ORIG_DISPLAY="${DISPLAY}" - else - unset CVS_ECLASS_ORIG_DISPLAY - fi - if [[ ${CVS_RSH} == "ssh" ]] ; then # Force SSH to use SSH_ASKPASS by creating python wrapper - export CVS_RSH="${T}/cvs_sshwrapper" - cat > "${CVS_RSH}"<<EOF + local -x CVS_RSH="${T}/cvs_sshwrapper" + cat > "${CVS_RSH}" <<EOF || die #!${EPREFIX}/usr/bin/python import fcntl import os @@ -391,52 +386,52 @@ EOF # disable X11 forwarding which causes .xauth access violations # - 20041205 Armando Di Cianno <fafhrd@gentoo.org> echo "newarglist.insert(1, '-oClearAllForwardings=yes')" \ - >> "${CVS_RSH}" + >> "${CVS_RSH}" || die echo "newarglist.insert(1, '-oForwardX11=no')" \ - >> "${CVS_RSH}" + >> "${CVS_RSH}" || die # Handle SSH host key checking - local CVS_ECLASS_KNOWN_HOSTS="${T}/cvs_ssh_known_hosts" - echo "newarglist.insert(1, '-oUserKnownHostsFile=${CVS_ECLASS_KNOWN_HOSTS}')" \ - >> "${CVS_RSH}" + local known_hosts_file="${T}/cvs_ssh_known_hosts" + echo "newarglist.insert(1, '-oUserKnownHostsFile=${known_hosts_file}')" \ + >> "${CVS_RSH}" || die + local strict_host_key_checking if [[ -z ${ECVS_SSH_HOST_KEY} ]] ; then ewarn "Warning: The SSH host key of the remote server will not be verified." einfo "A temporary known hosts list will be used." - local CVS_ECLASS_STRICT_HOST_CHECKING="no" - touch "${CVS_ECLASS_KNOWN_HOSTS}" + strict_host_key_checking="no" + touch "${known_hosts_file}" || die else - local CVS_ECLASS_STRICT_HOST_CHECKING="yes" - echo "${ECVS_SSH_HOST_KEY}" > "${CVS_ECLASS_KNOWN_HOSTS}" + strict_host_key_checking="yes" + echo "${ECVS_SSH_HOST_KEY}" > "${known_hosts_file}" || die fi echo -n "newarglist.insert(1, '-oStrictHostKeyChecking=" \ - >> "${CVS_RSH}" - echo "${CVS_ECLASS_STRICT_HOST_CHECKING}')" \ - >> "${CVS_RSH}" + >> "${CVS_RSH}" || die + echo "${strict_host_key_checking}')" \ + >> "${CVS_RSH}" || die echo "os.execv('${EPREFIX}/usr/bin/ssh', newarglist)" \ - >> "${CVS_RSH}" + >> "${CVS_RSH}" || die - chmod a+x "${CVS_RSH}" + chmod a+x "${CVS_RSH}" || die # Make sure DISPLAY is set (SSH will not use SSH_ASKPASS # if DISPLAY is not set) - : "${DISPLAY:="DISPLAY"}" - export DISPLAY + local -x DISPLAY="${DISPLAY:-DISPLAY}" # Create a dummy executable to echo ${ECVS_PASS} - export SSH_ASKPASS="${T}/cvs_sshechopass" + local -x SSH_ASKPASS="${T}/cvs_sshechopass" if [[ ${ECVS_AUTH} != "no" ]] ; then echo -en "#!/bin/bash\necho \"${ECVS_PASS}\"\n" \ - > "${SSH_ASKPASS}" + > "${SSH_ASKPASS}" || die else echo -en "#!/bin/bash\nreturn\n" \ - > "${SSH_ASKPASS}" + > "${SSH_ASKPASS}" || die fi - chmod a+x "${SSH_ASKPASS}" + chmod a+x "${SSH_ASKPASS}" || die fi if [[ ${mode} == "update" ]] ; then @@ -446,20 +441,6 @@ EOF einfo "Running ${cmdcheckout[*]}" "${cmdcheckout[@]}" || die "cvs checkout command failed" fi - - # Restore environment variable values - export CVS_RSH="${CVS_ECLASS_ORIG_CVS_RSH}" - if [[ ${CVS_ECLASS_ORIG_SSH_ASKPASS+set} == "set" ]] ; then - export SSH_ASKPASS="${CVS_ECLASS_ORIG_SSH_ASKPASS}" - else - unset SSH_ASKPASS - fi - - if [[ ${CVS_ECLASS_ORIG_DISPLAY+set} == "set" ]] ; then - export DISPLAY="${CVS_ECLASS_ORIG_DISPLAY}" - else - unset DISPLAY - fi fi } @@ -508,12 +489,14 @@ cvs_src_unpack() { debug-print "Copying module ${ECVS_MODULE} local_mode=${ECVS_LOCAL} from ${ECVS_TOP_DIR} ..." # This is probably redundant, but best to make sure. - mkdir -p "${WORKDIR}/${ECVS_LOCALNAME}" + mkdir -p "${WORKDIR}/${ECVS_LOCALNAME}" || die if [[ -n ${ECVS_LOCAL} ]] ; then - cp -f "${ECVS_TOP_DIR}/${ECVS_LOCALNAME}"/* "${WORKDIR}/${ECVS_LOCALNAME}" + cp -f "${ECVS_TOP_DIR}/${ECVS_LOCALNAME}"/* \ + "${WORKDIR}/${ECVS_LOCALNAME}" || die else - cp -Rf "${ECVS_TOP_DIR}/${ECVS_LOCALNAME}" "${WORKDIR}/${ECVS_LOCALNAME}/.." + cp -Rf "${ECVS_TOP_DIR}/${ECVS_LOCALNAME}" \ + "${WORKDIR}/${ECVS_LOCALNAME}/.." || die fi # Not exactly perfect, but should be pretty close #333773 @@ -522,6 +505,7 @@ cvs_src_unpack() { LC_ALL=C sort | \ sha1sum | \ awk '{print $1}' + assert ) # If the directory is empty, remove it; empty directories cannot @@ -530,7 +514,7 @@ cvs_src_unpack() { # the empty directory in workdir though. if [[ $(ls -A "${ECVS_TOP_DIR}/${ECVS_LOCALNAME}") == "CVS" ]] ; then debug-print "${FUNCNAME}: removing empty CVS directory ${ECVS_LOCALNAME}" - rm -rf "${ECVS_TOP_DIR}/${ECVS_LOCALNAME}" + rm -rf "${ECVS_TOP_DIR}/${ECVS_LOCALNAME}" || die fi einfo "CVS module ${ECVS_MODULE} is now in ${WORKDIR}" |