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 (2048 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id C430D158089 for ; Sun, 8 Oct 2023 23:32:33 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id D589B2BC017; Sun, 8 Oct 2023 23:32:32 +0000 (UTC) Received: from smtp.gentoo.org (dev.gentoo.org [IPv6:2001:470:ea4a:1:5054:ff:fec7:86e4]) (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 B9B552BC017 for ; Sun, 8 Oct 2023 23:32:32 +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) server-digest SHA256) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id AFC40335C5D for ; Sun, 8 Oct 2023 23:32:30 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id 2DBA88C9 for ; Sun, 8 Oct 2023 23:32:29 +0000 (UTC) From: "Robin H. Johnson" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Robin H. Johnson" Message-ID: <1696807935.04bc16e0867d0a19ba803570852610b63743c3f6.robbat2@gentoo> Subject: [gentoo-commits] proj/releng:master commit in: scripts/ X-VCS-Repository: proj/releng X-VCS-Files: scripts/copy_buildsync.sh X-VCS-Directories: scripts/ X-VCS-Committer: robbat2 X-VCS-Committer-Name: Robin H. Johnson X-VCS-Revision: 04bc16e0867d0a19ba803570852610b63743c3f6 X-VCS-Branch: master Date: Sun, 8 Oct 2023 23:32:29 +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: 1e7e6783-b7df-4672-b4ec-0773d01d65b4 X-Archives-Hash: 0470cdfd8ec1ae5b5c2eb9e940f9ff05 commit: 04bc16e0867d0a19ba803570852610b63743c3f6 Author: Robin H. Johnson gentoo org> AuthorDate: Sun Oct 8 23:32:15 2023 +0000 Commit: Robin H. Johnson gentoo org> CommitDate: Sun Oct 8 23:32:15 2023 +0000 URL: https://gitweb.gentoo.org/proj/releng.git/commit/?id=04bc16e0 copy_buildsync: fix corner cases for targets changing Signed-off-by: Robin H. Johnson gentoo.org> scripts/copy_buildsync.sh | 35 +++++++++++++++++++++++++++++++---- 1 file changed, 31 insertions(+), 4 deletions(-) diff --git a/scripts/copy_buildsync.sh b/scripts/copy_buildsync.sh index 9da5893d..71e890d9 100755 --- a/scripts/copy_buildsync.sh +++ b/scripts/copy_buildsync.sh @@ -209,15 +209,42 @@ process_arch() { # Link the files for a given variant into a current-${v}/ directory. # If it's an old link, remove to convert to directory. if test -L "current-$v" ; then rm "current-$v" ; fi - mkdir -p "current-$v" + + # If there is a file here, something went wrong. + if ! mkdir -p "current-$v" ; then + echo "$ARCH: could not mkdir current-${v}" 1>&2 + continue + fi # Remove old links in the directory. find "current-$v" -type l ! -name "$f" ! -name "${variant_date}*" # install new links - # do NOT use -f here, we do not want to override the existing files. - # this will ensure the mtime of the links does not change in most cases. - ( cd "current-$v" && ln -s --target-directory=. "../${variant_path}"* ) + # do NOT unconditionally use -f here, we do not want to override the + # existing files. this will ensure the mtime of the links does not change + # in most cases. + ( + # shellcheck disable=SC2164 # error-checked above + cd "current-$v" + for variant_file in "../${variant_path}"* ; do + doit=0 + # If it doesn't exist, add it. + if [[ ! -e "$variant_file" ]]; then + doit=1 + ln -s -t . "../${variant_path}" + else + # If it does exist, check carefully to see if anything is different + # Does it point to somewhere else? + # Is the target newer? + # If those are true, also bump the symlink. + vfb=$(basename "$variant_file") + vft=$(readlink -f "$vfb") + [[ "$vft" != "$(readlink -f "$variant_file")" ]] && doit=1 + [[ "$vfb" -nt "$vft" ]] && doit=1 + fi + [[ $doit -eq 1 ]] && ln -sf -t . "../${variant_file}" + done + ) # Update keepfile echo "${variant_path}" | sed -e 's,/.*,,g' -e 's,^,/,g' -e 's,$,$,g' >>"${keepfile_tmp}"