Re: [pacman-dev] [PATCH] libmakepkg: fix linting arrays of empty strings
On Sun, 21 Oct 2018 at 13:10, Allan McRae wrote: > > On 21/10/18 9:56 pm, Morgan Adamiec wrote: > > On Sun, 21 Oct 2018 at 10:16, Allan McRae wrote: > >> The error this gives is: > >> ==> ERROR: depends is not allowed to be empty. > > > > Where so you get this error? > > > > pkgname=foo > > pkgver=1 > > pkgrel=1 > > arch=(any) > > depends=('') > > > > This pkgbuild manages to pass linting for me without this patch. > > > > (resend, accidentally sent off list) > > . > > I meant that is the error you get after this patch. And you can get it > without the patch using: > > depends=('glibc' '' 'gcc') > > It is not correct to say depends is empty, or that it can't be empty. > It can have an empty entry. As I said, existing issue, not caused by > your patch - I just noticed it while testing. > > A Ah right, sorry misunderstood. How about we change the type we pass to lint_one_pkgname() from depends/provides/... to a depend/a provide/...? This gives "==> ERROR: a depend is not allowed to be empty."
Re: [pacman-dev] [PATCH] libmakepkg: fix linting arrays of empty strings
On Sun, 21 Oct 2018 at 10:16, Allan McRae wrote: > The error this gives is: > ==> ERROR: depends is not allowed to be empty. Where so you get this error? pkgname=foo pkgver=1 pkgrel=1 arch=(any) depends=('') This pkgbuild manages to pass linting for me without this patch. (resend, accidentally sent off list)
Re: [pacman-dev] [PATCH] libmakepkg: fix linting arrays of empty strings
On 17/10/18 3:49 am, morganamilo wrote: > [[ ${array[@]} ]] will resolve to false if array only contains empty > strings. This means that values such as "depends=('')" can be inserted > into a pkgbuild and bypass the linting. > > This causes makepkg to successfully build the package while pacman > refuses to install it because of the unmet dependency on ''. > > Instead check the length of the array. > > Signed-off-by: morganamilo > The error this gives is: ==> ERROR: depends is not allowed to be empty. but this also gives this error: depends=('glibc' '' 'gcc') so this is not a regression... just a poorly worked error message. Allan > diff --git a/scripts/libmakepkg/util/pkgbuild.sh.in > b/scripts/libmakepkg/util/pkgbuild.sh.in > index c6f8a82d..b29229a3 100644 > --- a/scripts/libmakepkg/util/pkgbuild.sh.in > +++ b/scripts/libmakepkg/util/pkgbuild.sh.in > @@ -60,7 +60,7 @@ extract_global_variable() { > > if (( isarray )); then > array_build ref "$attr" > - [[ ${ref[@]} ]] && array_build "$outputvar" "$attr" > + (( ${#ref[@]} )) && array_build "$outputvar" "$attr" > else > [[ ${!attr} ]] && printf -v "$outputvar" %s "${!attr}" > fi > @@ -144,7 +144,7 @@ get_pkgbuild_all_split_attributes() { > done > done > > - [[ ${all_list[@]} ]] && array_build "$outputvar" all_list > + (( ${#all_list[@]} )) && array_build "$outputvar" all_list > } > > ## >
[pacman-dev] [PATCH] libmakepkg: fix linting arrays of empty strings
[[ ${array[@]} ]] will resolve to false if array only contains empty strings. This means that values such as "depends=('')" can be inserted into a pkgbuild and bypass the linting. This causes makepkg to successfully build the package while pacman refuses to install it because of the unmet dependency on ''. Instead check the length of the array. Signed-off-by: morganamilo diff --git a/scripts/libmakepkg/util/pkgbuild.sh.in b/scripts/libmakepkg/util/pkgbuild.sh.in index c6f8a82d..b29229a3 100644 --- a/scripts/libmakepkg/util/pkgbuild.sh.in +++ b/scripts/libmakepkg/util/pkgbuild.sh.in @@ -60,7 +60,7 @@ extract_global_variable() { if (( isarray )); then array_build ref "$attr" - [[ ${ref[@]} ]] && array_build "$outputvar" "$attr" + (( ${#ref[@]} )) && array_build "$outputvar" "$attr" else [[ ${!attr} ]] && printf -v "$outputvar" %s "${!attr}" fi @@ -144,7 +144,7 @@ get_pkgbuild_all_split_attributes() { done done - [[ ${all_list[@]} ]] && array_build "$outputvar" all_list + (( ${#all_list[@]} )) && array_build "$outputvar" all_list } ## -- 2.19.1