commit:     9c04ea27acdff25c41efd343713268b8dbf6b091
Author:     Robin H. Johnson <robbat2 <AT> gentoo <DOT> org>
AuthorDate: Sun Oct  8 23:07:20 2023 +0000
Commit:     Robin H. Johnson <robbat2 <AT> gentoo <DOT> org>
CommitDate: Sun Oct  8 23:07:20 2023 +0000
URL:        https://gitweb.gentoo.org/proj/releng.git/commit/?id=9c04ea27

copy_buildsync: convert current-* to directory instead of symlink

Signed-off-by: Robin H. Johnson <robbat2 <AT> gentoo.org>

 scripts/copy_buildsync.sh | 25 +++++++++++++++++++++++--
 1 file changed, 23 insertions(+), 2 deletions(-)

diff --git a/scripts/copy_buildsync.sh b/scripts/copy_buildsync.sh
index 851ccb57..9a13872a 100755
--- a/scripts/copy_buildsync.sh
+++ b/scripts/copy_buildsync.sh
@@ -200,8 +200,24 @@ process_arch() {
                echo -e "${variant_path} ${size}" >>"${f_tmp}"
                [[ ${variant_path} =~ tar.*$ ]] && echo -e "${variant_path} 
${size}" >>"${OUT_STAGE3_tmp}"
                [[ ${variant_path} =~ iso$ ]] && echo -e "${variant_path} 
${size}" >>"${OUT_ISO_tmp}"
-               rm -f "current-$v"
-               ln -sf "${variant_path%/*}" "current-$v"
+
+               # Previously, current-${v}/ was a symlink to the timestamp 
directory.
+               # This was apparently confusing to some users because it had 
way too many files.
+               # So instead make current-${v}/ a directory, containing just 
symlinks to
+               # the selected build.
+               #
+               # 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"
+
+               # 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.
+               ln -s --target-directory="current-$v"/ "../${variant_path}"*
 
                # Update keepfile
                echo "${variant_path}" | sed -e 's,/.*,,g' -e 's,^,/,g' -e 
's,$,$,g' >>"${keepfile_tmp}"
@@ -209,6 +225,11 @@ process_arch() {
                # Place latest-*txt into place in the base arch dir.
                mv -f "${f_tmp}" "${f}"
 
+               # current-${variant}/latest-${variant}.txt contains the 
RELATIVE filename
+               # So we have to strip the leading directory on the path.
+               # reuse the tmpfile from $f
+               sed "s,^${variant_date}/,,g" <"${f}" >"${f_tmp}" && mv -f 
"${f_tmp}" "current-$v"/"${f}"
+
        done
 
        # Atomic move these files if created.

Reply via email to