mirror of
https://github.com/minetest/contentdb.git
synced 2024-12-22 22:12:24 +01:00
Add check for license files to release validation
This commit is contained in:
parent
35701b1097
commit
c565f0bb50
@ -127,6 +127,9 @@ def post_release_check_update(self, release: PackageRelease, path):
|
||||
deps = ", ".join(depends)
|
||||
raise MinetestCheckError("Game has unresolved hard dependencies: " + deps)
|
||||
|
||||
if package.state != PackageState.APPROVED and tree.find_license_file() is None:
|
||||
raise MinetestCheckError("Package needs to have a LICENSE.txt/.md or COPYING file.")
|
||||
|
||||
# Add dependencies
|
||||
for meta in get_meta_packages(depends):
|
||||
db.session.add(Dependency(package, meta=meta, optional=False))
|
||||
|
@ -17,6 +17,7 @@
|
||||
|
||||
import os
|
||||
import re
|
||||
from typing import Optional
|
||||
|
||||
from . import MinetestCheckError, ContentType
|
||||
from .config import parse_conf
|
||||
@ -78,7 +79,7 @@ class PackageTreeNode:
|
||||
self.read_meta()
|
||||
|
||||
if self.type == ContentType.GAME:
|
||||
if not os.path.isdir(base_dir + "/mods"):
|
||||
if not os.path.isdir(os.path.join(base_dir, "mods")):
|
||||
raise MinetestCheckError("Game at {} does not have a mods/ folder".format(self.relative))
|
||||
self.add_children_from_mod_dir("mods")
|
||||
elif self.type == ContentType.MOD:
|
||||
@ -92,6 +93,15 @@ class PackageTreeNode:
|
||||
elif self.type == ContentType.MODPACK:
|
||||
self.add_children_from_mod_dir(None)
|
||||
|
||||
def find_license_file(self) -> Optional[str]:
|
||||
names = ["LICENSE", "LICENSE.md", "LICENSE.txt", "COPYING"]
|
||||
for name in names:
|
||||
path = os.path.join(self.baseDir, name)
|
||||
if os.path.isfile(path):
|
||||
return path
|
||||
|
||||
return None
|
||||
|
||||
def check_dir_casing(self, dirs):
|
||||
for dir in next(os.walk(self.baseDir))[1]:
|
||||
lowercase = dir.lower()
|
||||
|
Loading…
Reference in New Issue
Block a user