archive-fonts: Unify README handling

[why]
The readmes in the zip and tar.xz archives differ. The zips have only a
very small and generic `readme.md`. The tar.xz have that readme as well as
the `README.md` from the patched-fonts/ directory. This should be the same
for both.

To have two files with names that just differ in case (`readme.md` and
`README.md`) can be problematic on some platforms.

[how]
Combine both readmes into one file - put the generic info in the top of
the readme.

Also include the RELEASE_VERSION if known into the readme. That makes it
more easy to identify which Nerd Font release that archive came from.

RELEASE_VERSION is set in the release workflow.

Fixes: #1284

Reported-by: Jan Klass <kissaki@posteo.de>
Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
This commit is contained in:
Fini Jastrow 2023-06-05 21:01:23 +02:00 committed by Fini
parent c173f661a0
commit 28f5657782
2 changed files with 25 additions and 17 deletions

View file

@ -3,6 +3,7 @@
# Script Version: 1.2.0 # Script Version: 1.2.0
# Iterates over all patched fonts directories # Iterates over all patched fonts directories
# to generate release archives of the patched font(s) # to generate release archives of the patched font(s)
# Set RELEASE_VERSION to attribute a specific release
# #
# Example run with pattern matching: # Example run with pattern matching:
# ./archive-fonts heavydata # ./archive-fonts heavydata
@ -14,6 +15,12 @@ set -e
LINE_PREFIX="# [Nerd Fonts] " LINE_PREFIX="# [Nerd Fonts] "
root_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." >/dev/null 2>&1 || exit && pwd -P)" root_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." >/dev/null 2>&1 || exit && pwd -P)"
outputdir=${root_dir}/archives outputdir=${root_dir}/archives
if [ -n "${RELEASE_VERSION}" ]; then
release_txt="the Nerd Fonts release v${RELEASE_VERSION}"
else
echo "${LINE_PREFIX} Do not have release version information, using generic readme"
release_txt="a Nerd Fonts release"
fi
mkdir -p "$outputdir" mkdir -p "$outputdir"
@ -33,11 +40,6 @@ else
echo "$LINE_PREFIX No limiting pattern given, will search entire folder" echo "$LINE_PREFIX No limiting pattern given, will search entire folder"
fi fi
# create a mini readme with basic info on Nerd Fonts project
touch "$outputdir/readme.md"
mini_readme="$outputdir/readme.md"
cat "$root_dir/src/archive-readme.md" >> "$mini_readme"
# clear out the directory # clear out the directory
find "${outputdir:?}" -maxdepth 1 \( -name "${search_pattern}.zip" -o -name "${search_pattern}.tar.xz" \) -type f -delete find "${outputdir:?}" -maxdepth 1 \( -name "${search_pattern}.zip" -o -name "${search_pattern}.tar.xz" \) -type f -delete
@ -56,6 +58,20 @@ while read -r filename; do
while IFS= read -d $'\0' -r descriptor; do while IFS= read -d $'\0' -r descriptor; do
path=${descriptor//|*/} path=${descriptor//|*/}
file=${descriptor//*|/} file=${descriptor//*|/}
if [ "$file" = "README.md" ]; then
{
echo "# Nerd Fonts"
echo
echo "This is an archived font from ${release_txt}."
echo
echo "For more information see:"
echo "* https://github.com/ryanoasis/nerd-fonts/"
echo "* https://github.com/ryanoasis/nerd-fonts/releases/latest/"
echo
} > "${outputdir}/${file}"
cat "${path}/${file}" >> "${outputdir}/${file}"
continue
fi
if grep -qi '.[ot]tf' <<< "${file}" ; then if grep -qi '.[ot]tf' <<< "${file}" ; then
expected=$((expected - 1)) expected=$((expected - 1))
fi fi
@ -68,7 +84,7 @@ while read -r filename; do
echo "${LINE_PREFIX} Did not pack expected number of font files! Likely same font names for different paths." echo "${LINE_PREFIX} Did not pack expected number of font files! Likely same font names for different paths."
exit 1 exit 1
fi fi
(cd "${outputdir}" && tar rf "${outputdir}/${basename}.tar" "readme.md") (cd "${outputdir}" && tar rf "${outputdir}/${basename}.tar" "README.md")
xz -f -9 -T0 "${outputdir}/${basename}.tar" xz -f -9 -T0 "${outputdir}/${basename}.tar"
# ZIP stuff: # ZIP stuff:
@ -91,9 +107,9 @@ while read -r filename; do
find "$searchdir" -type f -iname "*licen[sc]e*" -o -iname 'ofl*' | awk -F/ '{a[$NF]=$0}END{for(i in a)print a[i]}' | zip -9 -j "$outputdir/$basename" -@ find "$searchdir" -type f -iname "*licen[sc]e*" -o -iname 'ofl*' | awk -F/ '{a[$NF]=$0}END{for(i in a)print a[i]}' | zip -9 -j "$outputdir/$basename" -@
fi; fi;
# add mini readme file # add readme file
zip -9 "$outputdir/$basename" -rj "$mini_readme" -q (cd "${outputdir}" && zip -9 "$outputdir/$basename" -j "README.md" -q)
done done
rm -f "$mini_readme" rm -f "${outputdir}/README.md"
ls -al "$outputdir" ls -al "$outputdir"

View file

@ -1,8 +0,0 @@
# Nerd Fonts
This is an archived font from a Nerd Fonts release.
For more information see:
* https://github.com/ryanoasis/nerd-fonts/
* https://github.com/ryanoasis/nerd-fonts/releases/latest/