termux / termux-language-server

🛠️ A language server for some specific bash scripts
https://termux-language-server.readthedocs.io/
GNU General Public License v3.0
74 stars 7 forks source link

[PKGBUILD] Parsing of Bash arrays erroneous #6

Closed Spixmaster closed 9 months ago

Spixmaster commented 9 months ago

This line arch=("x86_64") results in the following error:

'"' is not one of ['any', 'pentium4', 'i486', 'i686', 'x86_64', 'x86_64_v3', 'arm', 'armv6h', 'armv7h', 'armv8', 'aarch64']

This happens for all Bash arrays. The quotes are recognised as own elements.

license=("MIT") errors with '"' is not one of ['AGPL3', 'Apache', ....

This bug was probably introduced with a fix for https://github.com/termux/termux-language-server/issues/4.

Freed-Wu commented 9 months ago

screen-2023-11-29-20-40-56

Yes, only double quotes will trigger this bug. single quotes will not.

Freed-Wu commented 9 months ago

Can you check if the lastest version can fix this bug? :bug:

Spixmaster commented 9 months ago

No, the error is different now. license=("MIT") causes 'MIT' is not one of ['AGPL3', 'Apache', ....

Freed-Wu commented 9 months ago

I forget to add MIT to legal licenses: https://github.com/termux/termux-language-server/blob/main/src/termux_language_server/assets/json/PKGBUILD.json#L73-L105

Freed-Wu commented 9 months ago

It is not a large bug. I'll fix it.

TomJo2000 commented 9 months ago

I forget to add MIT to legal licenses

Shouldn't it be accepting any of the SPDX license identifiers? https://spdx.org/licenses/ Maybe with some occasional exceptions for stuff like the BSL-1.1 which has particularly onerous restrictions.

Freed-Wu commented 9 months ago

Android Termux's build.sh and Gentoo's *.ebuild use SPDX. https://github.com/termux/termux-language-server/blob/main/src/termux_language_server/misc/licenses.py#L7

However, ArchLinux's PKGBUILD not:

license (array) This field specifies the license(s) that apply to the package. Commonly used licenses can be found in /usr/share/licenses/common. If you see the package’s license there, simply reference it in the license field (e.g., license=('GPL')). If the package provides a license not available in /usr/share/licenses/common, then you should include it in the package itself and set license=('custom') or license=('custom:LicenseName'). The license should be placed in $pkgdir/usr/share/licenses/$pkgname/ when building the package. If multiple licenses are applicable, list all of them: license=('GPL' 'FDL').

I have to handle it by list /usr/share/licenses/common https://github.com/termux/termux-language-server/blob/main/src/termux_language_server/misc/pkgbuild.py#L200-L202

Freed-Wu commented 9 months ago

This is the licenses which Archlinux's PKGBUILD used. MIT is missing. I doubt this is upstream's forgotness?

https://gitlab.archlinux.org/archlinux/packaging/packages/licenses/-/blob/main/PKGBUILD?ref_type=heads#L54-155

Spixmaster commented 9 months ago

License families MIT and BSD are treated differently. You can read more here.

Freed-Wu commented 9 months ago

Oh, I see. We must add manually these licenses which are treated differently.

Freed-Wu commented 9 months ago

Can you try the latest version to see if it can fix this bug?

Freed-Wu commented 9 months ago

Note: Arch Linux is currently undergoing a transition to SPDX style identifiers. Some issues may still require ironing out. This section focuses on the SPDX format. If you encounter any trouble, please report them and discuss with the community.

Yes, When I start to use archlinux, it haven't yet support SPDX. Good changes! :+1:

Spixmaster commented 9 months ago

Can you try the latest version to see if it can fix this bug?

Yes, v0.0.15 fixes the issue. Thanks!

Freed-Wu commented 9 months ago

There is one thing need to be noticed. Although this language server can handle quotes in diagnosis, the completion will not complete quotes. That is, user can get completion like x86_64, x86_64_v3, not "x86_64" or 'x86_64'. (However, this feature is also can be tried to realized in future, if more people want to complete quotes)

arch

license

depends