summaryrefslogtreecommitdiff
path: root/CI/licensecheck
diff options
context:
space:
mode:
Diffstat (limited to 'CI/licensecheck')
-rwxr-xr-xCI/licensecheck/checkfile.sh12
-rwxr-xr-xCI/licensecheck/clientdata.sh9
-rwxr-xr-xCI/licensecheck/serverdata.py71
3 files changed, 92 insertions, 0 deletions
diff --git a/CI/licensecheck/checkfile.sh b/CI/licensecheck/checkfile.sh
new file mode 100755
index 0000000..2de49fe
--- /dev/null
+++ b/CI/licensecheck/checkfile.sh
@@ -0,0 +1,12 @@
+#!/usr/bin/env bash
+
+export name="$3"
+export name=${name##../../client-data/}
+
+grep "$name" $1 >/dev/null
+if [ "$?" != 0 ]; then
+ grep "$name " $2 >/dev/null
+ if [ "$?" != 0 ]; then
+ echo "Missing license for $name"
+ fi
+fi
diff --git a/CI/licensecheck/clientdata.sh b/CI/licensecheck/clientdata.sh
new file mode 100755
index 0000000..583b197
--- /dev/null
+++ b/CI/licensecheck/clientdata.sh
@@ -0,0 +1,9 @@
+#!/usr/bin/env bash
+
+export DIR="../../client-data"
+
+find -H $DIR -type f -name "*.png" -exec ./checkfile.sh $DIR/LICENSE $DIR/ART_LICENSE {} \;
+find -H $DIR/sfx -type f -name "*.ogg" -exec ./checkfile.sh $DIR/LICENSE $DIR/ART_LICENSE {} \;
+find -H $DIR -type f -name "*.tmx" -exec ./checkfile.sh $DIR/LICENSE $DIR/ART_LICENSE {} \;
+find -H $DIR -type f -name "*.jpg" -exec ./checkfile.sh $DIR/LICENSE $DIR/ART_LICENSE {} \;
+
diff --git a/CI/licensecheck/serverdata.py b/CI/licensecheck/serverdata.py
new file mode 100755
index 0000000..02f4aec
--- /dev/null
+++ b/CI/licensecheck/serverdata.py
@@ -0,0 +1,71 @@
+#! /usr/bin/env python2.7
+# -*- coding: utf8 -*-
+#
+# Copyright (C) 2018 TMW-2
+# Author: Jesusalva
+
+# Bad command:
+# ls --recursive --hyperlink=always --format=single-column ../../server-data/npc/|grep txt
+
+# Initialize stuff
+import subprocess
+import sys
+import os
+erp=[]
+
+# Clear previous NPC list
+try:
+ subprocess.call("rm npcs.txt", shell=True)
+except:
+ pass
+
+# Determine correct path
+PATH="../../server-data/npc/"
+if len(sys.argv) == 2:
+ PATH=sys.argv[1]
+
+# Generate NPC list
+subprocess.call("find "+PATH+" txt > npcs.txt", shell=True)
+npcs=open("npcs.txt", "r")
+
+# Begin
+print("Checking license info for NPCs")
+print("Source is at: "+PATH)
+
+for mpa in npcs:
+ mp=mpa.replace('\n','')
+ # Skip mapflags
+ if "mapflag" in mp:
+ continue
+ # Skip bad files
+ if not '.txt' in mp:
+ continue
+ # Skip certain folders
+ if "/dev/" in mp or "/00000SAVE/" in mp or "/test/" in mp:
+ continue
+
+ a=open(mp, 'r')
+ #print("Verify %s" % mp)
+ ok=False
+ for line in a:
+ if 'tmw2 script' in line.lower() or 'tmw-2 script' in line.lower() or 'tmw 2 script' in line.lower() or 'tmw2/lof script' in line.lower() or 'This file is generated automatically' in line or 'author' in line.lower() or 'tmw2 function' in line.lower() or 'tmw-2 function' in line.lower() or 'tmw 2 function' in line.lower():
+ ok=True
+ break
+
+ a.close()
+ if not ok:
+ erp.append(mp)
+
+npcs.close()
+if len(erp) > 0:
+ print("-----------------------------------------------------------------------")
+
+for i in sorted(erp):
+ print(i)
+
+print("-----------------------------------------------------------------------")
+print("Serverdata license check result")
+print("Errors: %d" % (len(erp)))
+if len(erp):
+ os.exit(1)
+