Skip to content

Commit

Permalink
fix(scripts/termux_step_install_license): fix logic error
Browse files Browse the repository at this point in the history
Move counter advance to the end of the while loop.
This fixes a logic error where the counter wouldn't advance
if the first license was "generic", and the second one was
author specific. This would cause `cp` to attempt to copy
through the dangling symlink to the generic license
in `termux-licenses` which fails and dies.
  • Loading branch information
TomJo2000 committed Jul 31, 2024
1 parent 5a6845f commit dbc0b55
Showing 1 changed file with 8 additions and 10 deletions.
18 changes: 8 additions & 10 deletions scripts/build/termux_step_install_license.sh
Original file line number Diff line number Diff line change
Expand Up @@ -60,29 +60,27 @@ termux_step_install_license() {
else
cp -f "${TERMUX_PKG_SRCDIR}/$FILE" "${TERMUX_PREFIX}/share/doc/${TERMUX_PKG_NAME}/copyright"
fi
# since this is a post-increment, (( 0 )) would be falsey
# thus `set -e` would kill the script on the first iteration
# using `true` prevents this
: $(( COUNTER++ ))
}
done
;;
# For the rest we can use a link to the generic license file
*) [[ -f "$TERMUX_SCRIPTDIR/packages/termux-licenses/LICENSES/${LICENSE}.txt" ]] && {
# the link target depends on the libc being used
if [[ "$TERMUX_PACKAGE_LIBRARY" == 'bionic' ]]; then
TO_LICENSE="../../LICENSES/${LICENSE}.txt"
elif [[ "$TERMUX_PACKAGE_LIBRARY" == 'glibc' ]]; then
TO_LICENSE="../../../../share/LICENSES/${LICENSE}.txt"
fi
case "$TERMUX_PACKAGE_LIBRARY" in
'bionic') TO_LICENSE="../../LICENSES/${LICENSE}.txt";;
'glibc') TO_LICENSE="../../../../share/LICENSES/${LICENSE}.txt";;
*) termux_error_exit "'$TERMUX_PACKAGE_LIBRARY' is not a supported libc";;

esac
if (( COUNTER )); then
ln -sf "$TO_LICENSE" "$TERMUX_PREFIX/share/doc/$TERMUX_PKG_NAME/copyright.$((COUNTER++))"
ln -sf "$TO_LICENSE" "$TERMUX_PREFIX/share/doc/$TERMUX_PKG_NAME/copyright.${COUNTER}"
else
ln -sf "$TO_LICENSE" "$TERMUX_PREFIX/share/doc/$TERMUX_PKG_NAME/copyright"
fi
}
;;
esac
(( ++COUNTER ))
done <<< "${TERMUX_PKG_LICENSE//,/$'\n'}"
local license_files
license_files="$(find -L "$TERMUX_PREFIX/share/doc/$TERMUX_PKG_NAME" -maxdepth 1 \( -type f -o -type l \) -name "copyright*")"
Expand Down

0 comments on commit dbc0b55

Please sign in to comment.