diff mbox

[pacman-dev] makepkg: reject PKGBUILDs with both split and non-split package functions

Message ID 20180612145602.32242-1-eschwartz@archlinux.org
State Changes Requested, archived
Headers show

Commit Message

Eli Schwartz June 12, 2018, 2:56 p.m. UTC
We accept package_foo() in non-split packages, because it's easier to
switch to/from a split package just by removing a pkgname element. But
it makes no sense to have both in one PKGBUILD.

Signed-off-by: Eli Schwartz <eschwartz@archlinux.org>
---
 scripts/libmakepkg/lint_pkgbuild/package_function.sh.in | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

Comments

Allan McRae June 19, 2018, 2:34 p.m. UTC | #1
On 13/06/18 00:56, Eli Schwartz wrote:
> We accept package_foo() in non-split packages, because it's easier to
> switch to/from a split package just by removing a pkgname element. But
> it makes no sense to have both in one PKGBUILD.
> 
> Signed-off-by: Eli Schwartz <eschwartz@archlinux.org>
> ---
>  scripts/libmakepkg/lint_pkgbuild/package_function.sh.in | 9 ++++++++-
>  1 file changed, 8 insertions(+), 1 deletion(-)
> 
> diff --git a/scripts/libmakepkg/lint_pkgbuild/package_function.sh.in b/scripts/libmakepkg/lint_pkgbuild/package_function.sh.in
> index e52f1325..457b8f67 100644
> --- a/scripts/libmakepkg/lint_pkgbuild/package_function.sh.in
> +++ b/scripts/libmakepkg/lint_pkgbuild/package_function.sh.in
> @@ -34,11 +34,18 @@ lint_package_function() {
>  	local i ret=0
>  
>  	if (( ${#pkgname[@]} == 1 )); then
> -		if have_function 'build' && ! { have_function 'package' || have_function "package_$pkgname"; }; then
> +		if have_function 'package' && have_function "package_$pkgname"; then
> +			error "$(gettext "Duplicate %s and %s functions in %s")" "package()" "package_$pkgname()" "$BUILDFILE"

I don't think duplicate is the right word here.

Conflicting?

> +			ret=1
> +		elif have_function 'build' && ! { have_function 'package' || have_function "package_$pkgname"; }; then
>  			error "$(gettext "Missing %s function in %s")" "package()" "$BUILDFILE"
>  			ret=1
>  		fi
>  	else
> +		if have_function "package"; then
> +			error "$(gettext "Extra %s function for split package '%s'")" "package()" "$pkgbase"
> +			ret=1
> +		fi
>  		for i in "${pkgname[@]}"; do
>  			if ! have_function "package_$i"; then
>  				error "$(gettext "Missing %s function for split package '%s'")" "package_$i()" "$i"
>
diff mbox

Patch

diff --git a/scripts/libmakepkg/lint_pkgbuild/package_function.sh.in b/scripts/libmakepkg/lint_pkgbuild/package_function.sh.in
index e52f1325..457b8f67 100644
--- a/scripts/libmakepkg/lint_pkgbuild/package_function.sh.in
+++ b/scripts/libmakepkg/lint_pkgbuild/package_function.sh.in
@@ -34,11 +34,18 @@  lint_package_function() {
 	local i ret=0
 
 	if (( ${#pkgname[@]} == 1 )); then
-		if have_function 'build' && ! { have_function 'package' || have_function "package_$pkgname"; }; then
+		if have_function 'package' && have_function "package_$pkgname"; then
+			error "$(gettext "Duplicate %s and %s functions in %s")" "package()" "package_$pkgname()" "$BUILDFILE"
+			ret=1
+		elif have_function 'build' && ! { have_function 'package' || have_function "package_$pkgname"; }; then
 			error "$(gettext "Missing %s function in %s")" "package()" "$BUILDFILE"
 			ret=1
 		fi
 	else
+		if have_function "package"; then
+			error "$(gettext "Extra %s function for split package '%s'")" "package()" "$pkgbase"
+			ret=1
+		fi
 		for i in "${pkgname[@]}"; do
 			if ! have_function "package_$i"; then
 				error "$(gettext "Missing %s function for split package '%s'")" "package_$i()" "$i"