diff --git a/bin/tools/foamPackRelease b/bin/tools/foamPackRelease index 562584450c..399de71428 100755 --- a/bin/tools/foamPackRelease +++ b/bin/tools/foamPackRelease @@ -6,7 +6,7 @@ # \\ / A nd | www.openfoam.com # \\/ M anipulation | #------------------------------------------------------------------------------ -# Copyright (C) 2019-2021 OpenCFD Ltd. +# Copyright (C) 2019-2023 OpenCFD Ltd. #------------------------------------------------------------------------------ # License # This file is part of OpenFOAM, distributed under GPL-3.0-or-later. @@ -387,7 +387,7 @@ echo # OpenFOAM sources if [ "$withSource" != false ] then - echo 'git -c tar.umask=user archive --format=tar ${prefixDir:+--prefix="$prefixDir/"} -o "$outputDir/$tarName.tar" "$head"' + echo 'git -c tar.umask=0022 archive --format=tar ${prefixDir:+--prefix="$prefixDir/"} -o "$outputDir/$tarName.tar" "$head"' # Tag build information with underscore to distinguish from "real" build # information when git is available. @@ -404,6 +404,74 @@ fi #------------------------------------------------------------------------------ # Add in modules + +# Recursive addition of submodule content. +# NB: must be called from within the respective parent directory. +# Example, +# +# packModule abc (implied cd) +# packModule abc/def +# packModule abc/def/hij +# +packModule() +{ + local parent="$1" + + ( + if [ -n "$parent" ] + then + cd "${parent##*/}" 2>/dev/null || exit + fi + + git ls-tree -d HEAD | \ + while read mode gittype sha1 module + do + [ "$gittype" == commit ] || continue + + case "$module" in + (. | ./) + echo + echo "# ----" + echo "# module $parent : not initialized?" + echo "# ----" + continue + ;; + esac + + # Fully qualified + module="$parent${parent:+/}$module" + + echo + echo "# module" + echo "module='$module'" + echo "commit='$sha1'" + echo "tmpTarFile='$tarName-${module##*/}.tar'" + echo "# ----" + echo '(' + echo ' cd "$module" || exit' + echo ' newPrefix="$prefixDir${prefixDir:+/}$module"' + echo ' git -c tar.umask=0022 archive --format=tar --prefix="$newPrefix/" -o "$outputDir/$tmpTarFile" "$commit" || exit' + # Without {test,tests,validation} directories (potentially large) + echo ' tar --delete -f "$outputDir/$tmpTarFile" "$newPrefix/test" "$newPrefix/tests" "$newPrefix/validation" 2>/dev/null' + echo ' tar -Af "$outputDir/$tarName.tar" "$outputDir/$tmpTarFile"' + echo ' {' + echo ' echo' + echo ' echo "$module"' + echo ' echo commit="$commit"' + echo ' echo' + echo ' # Without {test,tests,validation} directories' + echo ' git ls-tree -r "$commit" | sed -e '"'"'/\t\(test\|\tests\|validation\)\//d'"'" + echo ' } >> "$outputDir/$manifest1"' + echo ')' + # Remove tmp tar file, even if git archive failed (creates zero-sized tar) + echo 'rm -f "$outputDir/$tmpTarFile"' + + packModule "$module" + done + ) +} + + if [ "$withModules" != false ] then echo @@ -415,33 +483,7 @@ then echo ' echo head="$head"' echo '} > "$outputDir/$manifest1"' - git --git-dir="$gitbase/.git" ls-tree "$head" modules/ | \ - while read mode gittype sha1 module - do - [ "$gittype" == commit ] || continue - - echo - echo "module=\""$module"\"" - echo "commit=\""$sha1"\"" - echo "tarModule=\""$tarName-${module##*/}"\"" - echo - echo 'if pushd "$module"; then' - echo 'moduleDir="$prefixDir${prefixDir:+/}$module"' - echo 'git -c tar.umask=user archive --format=tar --prefix="$moduleDir/" -o "$outputDir/$tarModule.tar" "$commit"' - echo '# Without test, validation dirs (potentially large)' - echo 'tar --delete -f "$outputDir/$tarModule.tar" "$moduleDir/test" "$moduleDir/validation" 2>/dev/null' - echo 'tar -Af "$outputDir/$tarName.tar" "$outputDir/$tarModule.tar"' - echo 'rm -f "$outputDir/$tarModule.tar"' - echo '{' - echo ' echo' - echo ' echo "$module"' - echo ' echo commit="$commit"' - echo ' echo' - echo ' # Without test, validation dirs' - echo ' git ls-tree -r "$commit" | sed -e '"'"'/\ttest\//d;/\tvalidation\//d'"'" - echo '} >> "$outputDir/$manifest1"' - echo 'popd; fi' - done + packModule modules echo echo '{ echo; echo "# End"; } >> "$outputDir/$manifest1"' @@ -459,8 +501,9 @@ echo 'rm -f "$buildInfo" "$manifest0" "$manifest1"' echo 'popd; fi' echo +echo "# -----------------------" echo "# End of creating archive" -echo +echo "# -----------------------" #------------------------------------------------------------------------------ # Compression