From 188ab260252cef5e15b5b318276d1edb76358160 Mon Sep 17 00:00:00 2001 From: Henrik Grimler Date: Fri, 7 Aug 2020 11:51:27 +0200 Subject: [PATCH] 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. --- scripts/build/termux_step_install_license.sh | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/scripts/build/termux_step_install_license.sh b/scripts/build/termux_step_install_license.sh index 5f04c97d8..ab6d5d498 100644 --- a/scripts/build/termux_step_install_license.sh +++ b/scripts/build/termux_step_install_license.sh @@ -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