FS#55004 - makepkg --printsrcinfo" does not show "groups=base" for linux PKGBUILD

Attached to Project: Pacman
Opened by Erich Eckner (deepthought) - Tuesday, 01 August 2017, 17:35 GMT
Last edited by Allan McRae (Allan) - Tuesday, 06 February 2018, 01:44 GMT
Task Type Bug Report
Category makepkg
Status Closed
Assigned To No-one
Architecture All
Severity Low
Priority Normal
Reported Version 5.0.1
Due in Version Undecided
Due Date Undecided
Percent Complete 100%
Votes 0
Private No

Details

Description:

If I run "makepkg --printsrcinfo" in linux/repos/core-x86_64, there is no mention of "groups=base".
The attached patch fixes this, without changing other behaviour.

Additional info:
* package version(s)
pkgver=4.12.3
pkgrel=1

git revision b84448a5085a5e50a3bd09da090e594ff0ae025b

Cheers,
deep42thought
This task depends upon

Closed by  Allan McRae (Allan)
Tuesday, 06 February 2018, 01:44 GMT
Reason for closing:  Won't fix
Comment by Eli Schwartz (eschwartz) - Tuesday, 01 August 2017, 20:52 GMT
  • Field changed: Attached to Project (Arch Linux → Pacman)
  • Field changed: Summary ([linux] "makepkg --printsrcinfo" does not show "groups=base" → [makepkg] --printsrcinfo" does not show "groups=base" for linux PKGBUILD)
This is a makepkg bug, not a core/linux bug. util/pkgbuild.sh provides extract_function_variable, and the attr_regex used does not account for valid bash like `conditional && groups=('base')`.

It assumes that the variables it `grep`s for are preceded by nothing other than whitespace.
Comment by Andrew Gregory (andrewgregory) - Tuesday, 01 August 2017, 22:58 GMT
This is not a makepkg bug; it is an inherent limitation. makepkg has to actually parse the PKGBUILD and it will never be able to parse all valid bash. The linux PKGBUILD is simply too complex for --printsrcinfo to parse correctly. The only real solution is to stop trying to make the linux PKGBUILD reusable for arbitrary kernel builds and simplify it.
Comment by Eli Schwartz (eschwartz) - Wednesday, 02 August 2017, 02:28 GMT
I didn't really expect much as far as actual proper parsing of bash. :D

However, this raises an interesting question. Currently, makepkg says the wrong thing when a variable follows a conditional. But even with Erich's proposed fix, this would still be wrong when the pkgbase is changed.

So, should makepkg err on the greedy side, and read more potential variables, or on the conservative side, and read fewer? If the former, maybe the regex should be extended to match anything. If the latter, maybe we should look for `if` conditionals and exclude them...

I'm inclined to think, if anything, we should be greedy since the practical purpose of .SRCINFO is allow e.g. AUR resolution, proper dependency ordering -- more, possibly extraneous information is better than missing information.
Comment by Erich Eckner (deepthought) - Wednesday, 02 August 2017, 07:17 GMT
I think, the proper solution would be to disallow (or discourage) the whole complexity of bash in PKGBUILDs -- like it's already done for something like

if [ $CARCH = 'x86_64' ]; then
depends+=(lib32-something)
elif [ $CARCH = 'i686' ]; then
depends+=(libsomething)
fi

Meanwhile, I'm in favour of making makepkg more "greedy" as eschwartz proposed.
Comment by Allan McRae (Allan) - Tuesday, 06 February 2018, 01:43 GMT
Discouraging PKGBUILDs that try to do too much here is the only solution. Makepkg will not do more heavy parsing.

Loading...