Add psp-create-license-directory script

This commit is contained in:
Wouter Wijsman
2024-12-24 13:50:56 +01:00
parent 560b950687
commit 691f858991
3 changed files with 92 additions and 0 deletions

View File

@@ -29,12 +29,15 @@ AC_DEFUN([AC_PSPDEV_PATH],
pspdev_includedir="$pspdev/psp/include" pspdev_includedir="$pspdev/psp/include"
pspdev_libdir="$pspdev/psp/lib" pspdev_libdir="$pspdev/psp/lib"
pspdev_sharedir="$pspdev/psp/share" pspdev_sharedir="$pspdev/psp/share"
pspdev_bindir="$pspdev/bin"
PSPDEV_INCLUDEDIR="$pspdev_includedir" PSPDEV_INCLUDEDIR="$pspdev_includedir"
PSPDEV_LIBDIR="$pspdev_libdir" PSPDEV_LIBDIR="$pspdev_libdir"
PSPDEV_SHAREDIR="$pspdev_sharedir" PSPDEV_SHAREDIR="$pspdev_sharedir"
PSPDEV_BINDIR="$pspdev_bindir"
AC_SUBST(PSPDEV_INCLUDEDIR) AC_SUBST(PSPDEV_INCLUDEDIR)
AC_SUBST(PSPDEV_LIBDIR) AC_SUBST(PSPDEV_LIBDIR)
AC_SUBST(PSPDEV_SHAREDIR) AC_SUBST(PSPDEV_SHAREDIR)
AC_SUBST(PSPDEV_BINDIR)
]) ])
dnl Check for a tool prefixed with "psp-". dnl Check for a tool prefixed with "psp-".

View File

@@ -21,3 +21,6 @@ psp_prxgen_SOURCES = psp-prxgen.c getopt_long.c
psp_fixup_imports_SOURCES = psp-fixup-imports.c getopt_long.c sha1.c psp_fixup_imports_SOURCES = psp-fixup-imports.c getopt_long.c sha1.c
noinst_HEADERS = elftypes.h getopt.h prxtypes.h sha1.h types.h noinst_HEADERS = elftypes.h getopt.h prxtypes.h sha1.h types.h
psp_create_license_directorydir = @PSPDEV_BINDIR@
psp_create_license_directory_SCRIPTS = psp-create-license-directory

View File

@@ -0,0 +1,86 @@
#!/bin/bash
LICENSE_DIRECTORY="third-party-licenses"
EXIT_CODE=0
LIBRARIES=("pspsdk" "newlib" "pthread-embedded" $@)
SCRIPT_NAME="$(basename "$0")"
usage ( ) {
cat <<EOF
${SCRIPT_NAME} [OPTION] [LIBRARY]...
The ${SCRIPT_NAME} tool makes it easier to comply with licenses of used libraries.
It adds the licenses to the ${LICENSE_DIRECTORY} directory.
The licenses for pspsdk, newlib and pthread-embedded are always addded,
since they will always be compiled into your project.
options:
-h Print this message
-l List installed libraries
example:
If your project has included SDL2, SDL2_ttf and jsoncpp:
${SCRIPT_NAME} sdl2 sdl2-ttf jsoncpp
To get a list of installed libraries to get the name right use:
${SCRIPT_NAME} -l
EOF
}
get_dependencies ( ) {
if [ "${1}" != "pspsdk" ] && [ "${1}" != "newlib" ] && [ "${1}" != "pthread-embedded" ]; then
echo "$(psp-pacman -Qi ${1}|grep "^Depends On"|cut -d':' -f 2-|xargs echo)"
fi
}
copy_license_directory ( ) {
if [ -d "${PSPDEV}/psp/share/licenses/${1}" ]; then
if [ ! -d "${LICENSE_DIRECTORY}/${1}" ]; then
echo "Adding license for ${1} to ${LICENSE_DIRECTORY}"
fi
cp -rf "${PSPDEV}/psp/share/licenses/${1}" "${LICENSE_DIRECTORY}/"
for dependency in $(get_dependencies "${1}"); do
if [ "${dependency}" == "None" ]; then
continue
fi
if [ ! -d "${LICENSE_DIRECTORY}/${dependency}" ]; then
echo "Found dependency ${dependency} for ${1}"
fi
copy_license_directory "${dependency}"
done
else
echo "Failed to find license for library ${1}"
EXIT_CODE=2
fi
}
if [ -z "${PSPDEV}" ]; then
echo "The PSPDEV environment variable has not been set"
exit 1
fi
while getopts "hl" OPTION; do
case ${OPTION} in
h)
usage
exit 0
;;
l)
psp-pacman -Qq
exit 0
;;
*)
echo "${OPTION} - Unrecongnized option"
usage
exit 1
;;
esac
done
mkdir -p "${LICENSE_DIRECTORY}"
for library in ${LIBRARIES[@]}; do
copy_license_directory "${library}"
done
exit ${EXIT_CODE}