Pacman

Historical bug tracker for the Pacman package manager.

The pacman bug tracker has moved to gitlab:
https://gitlab.archlinux.org/pacman/pacman/-/issues

This tracker remains open for interaction with historical bugs during the transition period. Any new bugs reports will be closed without further action.
Tasklist

FS#16622 - Add a fallback package() to call package_"$pkgname" for pkgname arrays of length one

Attached to Project: Pacman
Opened by Isaac G (IsaacG) - Tuesday, 13 October 2009, 19:03 GMT
Last edited by Allan McRae (Allan) - Tuesday, 17 November 2009, 11:30 GMT
Task Type Feature Request
Category makepkg
Status Closed
Assigned To Allan McRae (Allan)
Architecture All
Severity Low
Priority Normal
Reported Version 3.3.1
Due in Version 3.4.0
Due Date Undecided
Percent Complete 100%
Votes 1
Private No

Details

When pkgname is an array, makepkg calls the function package_"$name" for each name in the array.
When pkgname is an scalar, makepkg calls the function package.

bash does not differentiate arrays from scalars.

Hence if I got a PKGBUILD file that has an array of pkgname's and I only want one package so I remove all but one element from the array, makepkg will attempt to call the function package which will not exist. A fix/workaround to this issue would be to add this line somewhere before the PKGBUILD file is sourced:

package () { [ -n "${pkgname[0]}" ] && package_"${pkgname[0]}"; }
or
package () { [ -n "$pkgname" ] && package_"$pkgname"; }

This way, if the PKGBUILD defines a function package, it overwrites the above definition and the above has no affect. If the PKGBUILD does not define a function package(), then you don't expect it to be called. If it is called and package_"$pkgname" exists, that is probably what you want to call.

This would fix the issue mentioned in the paragraph beginning "Hence".
This task depends upon

Closed by  Allan McRae (Allan)
Tuesday, 17 November 2009, 11:30 GMT
Reason for closing:  Fixed
Additional comments about closing:  git commit 9c34dfd9
Comment by Xavier (shining) - Tuesday, 13 October 2009, 19:37 GMT
I think the implementation in makepkg would be slightly different.
But in case of normal pkgbuild, it seems it would make sense to check for package_"$pkgname"() if package() does not exist.
Just for sake of consistency with split pkgbuild.
Comment by Allan McRae (Allan) - Tuesday, 13 October 2009, 23:26 GMT
Maybe... or we could implement  FS#15956  and allow the selection of which packages to build from a split package.
Comment by Allan McRae (Allan) - Saturday, 24 October 2009, 15:09 GMT
I was about to quickly implement this but adding the fallback is harder that I expected...
Comment by Allan McRae (Allan) - Sunday, 25 October 2009, 04:42 GMT Comment by Isaac G (IsaacG) - Sunday, 25 October 2009, 04:59 GMT
Thanks

Loading...