Skip to content

Commit 83e083c

Browse files
committed
Re-add license-output pkgmeta support
This reverts commit 40d5aa8.
1 parent 2470913 commit 83e083c

File tree

2 files changed

+27
-0
lines changed

2 files changed

+27
-0
lines changed

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ for more info.
6464
parsed for ignore and externals will not have localization keywords replaced.
6565
- *ignore*
6666
- *plain-copy*
67+
- *license-output*
6768
- *changelog-title*
6869
- *manual-changelog*
6970
- *move-folders*

release.sh

+26
Original file line numberDiff line numberDiff line change
@@ -810,6 +810,7 @@ changelog=
810810
changelog_markup="text"
811811
enable_nolib_creation=
812812
ignore=
813+
license=
813814
unchanged=
814815
zip_root_dirs=()
815816
nolib_exclude=
@@ -915,6 +916,9 @@ if [ -f "$pkgmeta_file" ]; then
915916
split="true"
916917
fi
917918
;;
919+
license-output)
920+
license=$yaml_value
921+
;;
918922
manual-changelog)
919923
changelog=$yaml_value
920924
manual_changelog="true"
@@ -2355,6 +2359,24 @@ else
23552359
end_group "changelog"
23562360
fi
23572361

2362+
###
2363+
### Create a license if not present and .pkgmeta requests one.
2364+
###
2365+
2366+
if [[ -n "$license" && ! -f "$topdir/$license" && -n "$slug" ]]; then
2367+
start_group "Saving license as $license" "license"
2368+
# curseforge.com is protected by cloudflare, but wowace.com isn't? >.>
2369+
if license_text=$( curl -sf --retry 3 --retry-delay 10 "https://www.wowace.com/project/$slug/license" 2>/dev/null ); then
2370+
# text is wrapped with \n\n<div class="module">\n\t<p>\n\t\t ... \n\t</p>\n</div>\n
2371+
echo "$license_text" | sed -e '1,4d' -e '5s/^\s*//' -e '$d' | sed '$d' > "$pkgdir/$license"
2372+
head -n10 "$pkgdir/$license"
2373+
[[ "$( wc -l < "$pkgdir/$license" )" -gt 10 ]] && echo "..."
2374+
else
2375+
echo "There was an error saving the license. ($?)"
2376+
fi
2377+
end_group "license"
2378+
fi
2379+
23582380
###
23592381
### Process .pkgmeta to perform move-folders actions.
23602382
###
@@ -2399,6 +2421,10 @@ if [ -f "$pkgmeta_file" ]; then
23992421
echo "Moving $yaml_key to $yaml_value"
24002422
mv -f "$srcdir"/* "$destdir" && rm -fr "$srcdir"
24012423
zip_root_dirs+=("$yaml_value")
2424+
# Copy the license into $destdir if one doesn't already exist.
2425+
if [[ -n "$license" && -f "$pkgdir/$license" && ! -f "$destdir/$license" ]]; then
2426+
cp -f "$pkgdir/$license" "$destdir/$license"
2427+
fi
24022428
# Check to see if the base source directory is empty
24032429
_mf_basedir="/${yaml_key%/*}"
24042430
while [[ -n "$_mf_basedir" && -z "$( ls -A "${releasedir}${_mf_basedir}" )" ]]; do

0 commit comments

Comments
 (0)