Alas, the build script wasn't designed for running under kterm.
First, it looks for git to check for PKGREV. I just hard coded that one based on the latest commit.
Second, it expects kindletool to be in /usr/bin/. As far as I can tell, MrPI doesn't bother with creating a /usr/bin/kindletool symlink and just calls kindletool from the full path. (incidentally, I just noticed MrPI recognizes the PW4 as a K5 instead of a PW2)
Last: Unexpected "(" in Line 16.
I'm not at all familiar with Linux shell, though, so I'm stumped as to how to edit line 16 to make it palatable for the Kindle.
Code:
KT_PM_FLAGS=( "-xPackageName=${PKGNAME}" "-xPackageVersion=${PKGVER}-g${PKGREV}" "-xPackageAuthor=barsanuphe" "-xPackageMaintainer=barsanuphe" "-X" )
After that error, I gave up trying to package librariansync on the Kindle.
Of course, after switching to the PC and reading the kindletool readme, I realized that line was likely unnecessary. Alas, I'm way too tired of typing on the Kindle's onscreen keyboard to try again.