aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKonstantin Aladyshev <aladyshev22@gmail.com>2021-10-30 00:43:09 +0300
committerKonstantin Aladyshev <aladyshev22@gmail.com>2021-10-30 00:43:09 +0300
commit18f21fc0a341f026de182027937cc7a5f0e0f6cf (patch)
treec61d8509db4b2b9cba09d9623ca5ae254e0850c3
parent4817afa8f3b58bb61cabec0a538d6bfe02372787 (diff)
downloadUEFI-Lessons-18f21fc0a341f026de182027937cc7a5f0e0f6cf.tar.gz
UEFI-Lessons-18f21fc0a341f026de182027937cc7a5f0e0f6cf.tar.bz2
UEFI-Lessons-18f21fc0a341f026de182027937cc7a5f0e0f6cf.zip
Add script to add license header to files
Signed-off-by: Konstantin Aladyshev <aladyshev22@gmail.com>
-rwxr-xr-xscripts/addLicense.sh56
1 files changed, 56 insertions, 0 deletions
diff --git a/scripts/addLicense.sh b/scripts/addLicense.sh
new file mode 100755
index 0000000..890a2d2
--- /dev/null
+++ b/scripts/addLicense.sh
@@ -0,0 +1,56 @@
+##
+# Copyright (c) 2021, Konstantin Aladyshev <aladyshev22@gmail.com>
+#
+# SPDX-License-Identifier: MIT
+##
+
+COPYRIGHT_C="\
+/*
+ * Copyright (c) 2021, Konstantin Aladyshev <aladyshev22@gmail.com>
+ *
+ * SPDX-License-Identifier: MIT
+ */
+"
+
+COPYRIGHT_UNI="\
+//
+// Copyright (c) 2021, Konstantin Aladyshev <aladyshev22@gmail.com>
+//
+// SPDX-License-Identifier: MIT
+//
+"
+
+COPYRIGHT_META="\
+##
+# Copyright (c) 2021, Konstantin Aladyshev <aladyshev22@gmail.com>
+#
+# SPDX-License-Identifier: MIT
+##
+"
+
+DIR="$(dirname $(dirname "$(readlink -f "$0")"))"
+
+function insertCopyright {
+ FILENAME=${1}
+ COPYRIGHT=${2}
+ grep "Copyright" "${FILENAME}" > /dev/null
+ if [ $? -eq 1 ]; then
+ echo "${COPYRIGHT}" | cat - "${FILENAME}" > /tmp/out && mv /tmp/out "${FILENAME}";
+ fi
+}
+
+for i in $(find ${DIR} -type f -name "*.c");
+do
+ insertCopyright "${i}" "${COPYRIGHT_C}"
+done
+
+for i in $(find ${DIR} -type f -name "*.uni");
+do
+ insertCopyright "${i}" "${COPYRIGHT_UNI}"
+done
+
+for i in $(find ${DIR} -type f -name "*.dsc" -o -name "*.dec" -o -name "*.inf");
+do
+ insertCopyright "${i}" "${COPYRIGHT_META}"
+done
+