Skip to content

Commit

Permalink
Re-add license-output pkgmeta support
Browse files Browse the repository at this point in the history
This reverts commit 40d5aa8.
  • Loading branch information
nebularg committed Sep 23, 2022
1 parent 2470913 commit 83e083c
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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*
Expand Down
26 changes: 26 additions & 0 deletions release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -810,6 +810,7 @@ changelog=
changelog_markup="text"
enable_nolib_creation=
ignore=
license=
unchanged=
zip_root_dirs=()
nolib_exclude=
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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<div class="module">\n\t<p>\n\t\t ... \n\t</p>\n</div>\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.
###
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 83e083c

Please sign in to comment.