@@ -810,6 +810,7 @@ changelog=
810
810
changelog_markup=" text"
811
811
enable_nolib_creation=
812
812
ignore=
813
+ license=
813
814
unchanged=
814
815
zip_root_dirs=()
815
816
nolib_exclude=
@@ -915,6 +916,9 @@ if [ -f "$pkgmeta_file" ]; then
915
916
split=" true"
916
917
fi
917
918
;;
919
+ license-output)
920
+ license=$yaml_value
921
+ ;;
918
922
manual-changelog)
919
923
changelog=$yaml_value
920
924
manual_changelog=" true"
@@ -2355,6 +2359,24 @@ else
2355
2359
end_group " changelog"
2356
2360
fi
2357
2361
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
+
2358
2380
# ##
2359
2381
# ## Process .pkgmeta to perform move-folders actions.
2360
2382
# ##
@@ -2399,6 +2421,10 @@ if [ -f "$pkgmeta_file" ]; then
2399
2421
echo " Moving $yaml_key to $yaml_value "
2400
2422
mv -f " $srcdir " /* " $destdir " && rm -fr " $srcdir "
2401
2423
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
2402
2428
# Check to see if the base source directory is empty
2403
2429
_mf_basedir=" /${yaml_key%/* } "
2404
2430
while [[ -n " $_mf_basedir " && -z " $( ls -A " ${releasedir}${_mf_basedir} " ) " ]]; do
0 commit comments