licenses: install all licenses even if basenames are the same

For for example libandroid-support we now have
TERMUX_PKG_SRCDIR/License.txt
and
TERMUX_PKG_SRCDIR/wcwidth-$version/License.txt.
Previously the latter would have overwritten the first one in the
install step as the file names are the same.
This commit is contained in:
Henrik Grimler 2020-08-07 11:51:27 +02:00
parent 0d8c85543e
commit 188ab26025
1 changed files with 12 additions and 2 deletions

View File

@ -3,15 +3,25 @@ termux_step_install_license() {
mkdir -p "$TERMUX_PREFIX/share/doc/$TERMUX_PKG_NAME"
local LICENSE
local COUNTER=0
if [ ! "${TERMUX_PKG_LICENSE_FILE}" = "" ]; then
INSTALLED_LICENSES=()
COUNTER=1
while read -r LICENSE; do
if [ ! -f "$TERMUX_PKG_SRCDIR/$LICENSE" ]; then
termux_error_exit "$TERMUX_PKG_SRCDIR/$LICENSE does not exist"
fi
cp -f "${TERMUX_PKG_SRCDIR}/${LICENSE}" "${TERMUX_PREFIX}/share/doc/${TERMUX_PKG_NAME}"/
if [[ " ${INSTALLED_LICENSES[@]} " =~ " $(basename $LICENSE) " ]]; then
# We have already installed a license file named $(basename $LICENSE) so add a suffix to it
TARGET="$TERMUX_PREFIX/share/doc/${TERMUX_PKG_NAME}/$(basename $LICENSE).$COUNTER"
COUNTER=$((COUNTER + 1))
else
TARGET="$TERMUX_PREFIX/share/doc/${TERMUX_PKG_NAME}/$(basename $LICENSE)"
INSTALLED_LICENSES+=("$(basename $LICENSE)")
fi
cp -f "${TERMUX_PKG_SRCDIR}/${LICENSE}" "$TARGET"
done < <(echo "$TERMUX_PKG_LICENSE_FILE" | sed "s/,/\n/g")
else
local COUNTER=0
while read -r LICENSE; do
# These licenses contain copyright information, so
# we cannot use a generic license file