From 83e083c41d8ca099130fc5f0fa031d8c3b0740e6 Mon Sep 17 00:00:00 2001 From: Kyle Buller Date: Mon, 23 Sep 2019 19:13:34 -0500 Subject: [PATCH] Re-add `license-output` pkgmeta support This reverts commit 40d5aa8244a37751bf50924aa058b165b2d2ad4a. --- README.md | 1 + release.sh | 26 ++++++++++++++++++++++++++ 2 files changed, 27 insertions(+) diff --git a/README.md b/README.md index c9061bb..c0d93cf 100644 --- a/README.md +++ b/README.md @@ -64,6 +64,7 @@ for more info. parsed for ignore and externals will not have localization keywords replaced. - *ignore* - *plain-copy* +- *license-output* - *changelog-title* - *manual-changelog* - *move-folders* diff --git a/release.sh b/release.sh index 4253dcd..1e22364 100755 --- a/release.sh +++ b/release.sh @@ -810,6 +810,7 @@ changelog= changelog_markup="text" enable_nolib_creation= ignore= +license= unchanged= zip_root_dirs=() nolib_exclude= @@ -915,6 +916,9 @@ if [ -f "$pkgmeta_file" ]; then split="true" fi ;; + license-output) + license=$yaml_value + ;; manual-changelog) changelog=$yaml_value manual_changelog="true" @@ -2355,6 +2359,24 @@ else end_group "changelog" fi +### +### Create a license if not present and .pkgmeta requests one. +### + +if [[ -n "$license" && ! -f "$topdir/$license" && -n "$slug" ]]; then + start_group "Saving license as $license" "license" + # curseforge.com is protected by cloudflare, but wowace.com isn't? >.> + if license_text=$( curl -sf --retry 3 --retry-delay 10 "https://www.wowace.com/project/$slug/license" 2>/dev/null ); then + # text is wrapped with \n\n
\n\t

\n\t\t ... \n\t

\n
\n + echo "$license_text" | sed -e '1,4d' -e '5s/^\s*//' -e '$d' | sed '$d' > "$pkgdir/$license" + head -n10 "$pkgdir/$license" + [[ "$( wc -l < "$pkgdir/$license" )" -gt 10 ]] && echo "..." + else + echo "There was an error saving the license. ($?)" + fi + end_group "license" +fi + ### ### Process .pkgmeta to perform move-folders actions. ### @@ -2399,6 +2421,10 @@ if [ -f "$pkgmeta_file" ]; then echo "Moving $yaml_key to $yaml_value" mv -f "$srcdir"/* "$destdir" && rm -fr "$srcdir" zip_root_dirs+=("$yaml_value") + # Copy the license into $destdir if one doesn't already exist. + if [[ -n "$license" && -f "$pkgdir/$license" && ! -f "$destdir/$license" ]]; then + cp -f "$pkgdir/$license" "$destdir/$license" + fi # Check to see if the base source directory is empty _mf_basedir="/${yaml_key%/*}" while [[ -n "$_mf_basedir" && -z "$( ls -A "${releasedir}${_mf_basedir}" )" ]]; do