From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id 95CA415807B for ; Fri, 18 Oct 2024 17:54:51 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id DD6B9E0869; Fri, 18 Oct 2024 17:54:50 +0000 (UTC) Received: from smtp.gentoo.org (woodpecker.gentoo.org [140.211.166.183]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id BA87DE0866 for ; Fri, 18 Oct 2024 17:54:50 +0000 (UTC) Received: from oystercatcher.gentoo.org (oystercatcher.gentoo.org [148.251.78.52]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id C43FB3430C6 for ; Fri, 18 Oct 2024 17:54:49 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id 5F68A19CB for ; Fri, 18 Oct 2024 17:54:48 +0000 (UTC) From: "Ulrich Müller" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Ulrich Müller" Message-ID: <1729274074.79d26649cb50e6f26be6728621459ae94c542d3b.ulm@gentoo> Subject: [gentoo-commits] repo/gentoo:master commit in: eclass/ X-VCS-Repository: repo/gentoo X-VCS-Files: eclass/cvs.eclass X-VCS-Directories: eclass/ X-VCS-Committer: ulm X-VCS-Committer-Name: Ulrich Müller X-VCS-Revision: 79d26649cb50e6f26be6728621459ae94c542d3b X-VCS-Branch: master Date: Fri, 18 Oct 2024 17:54:48 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply X-Archives-Salt: 12dbc77f-1d83-40f1-a0b9-1816f7cb802b X-Archives-Hash: 173b63506b3b4d7622ee1492eed8b87a commit: 79d26649cb50e6f26be6728621459ae94c542d3b Author: Ulrich Müller gentoo org> AuthorDate: Mon Oct 14 10:36:08 2024 +0000 Commit: Ulrich Müller gentoo org> CommitDate: Fri Oct 18 17:54:34 2024 +0000 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=79d26649 cvs.eclass: Add local declarations and die statements throughout Signed-off-by: Ulrich Müller gentoo.org> eclass/cvs.eclass | 120 +++++++++++++++++++++++------------------------------- 1 file 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}"< "${CVS_RSH}" < 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}"