Re: [pacman-dev] [PATCH] makepkg: install all dependencies simultanously, if possible when using rmdeps but not install, runtime dependencies do not need special handling for (non)removal, and can be

2018-06-08 Thread Eli Schwartz
On 06/08/2018 11:56 AM, Florian Pritz via pacman-dev wrote:
> That subject is way too long. Please keep it around 50 chars if at all
> possible and put the more detailed explanation in the commit body. In
> this case it's probably best to simply end the subject at the first comma.

This was supposed to be:

"""
makepkg: install all dependencies simultanously, if possible

when using rmdeps but not install, runtime dependencies do not need
special handling for (non)removal, and can be installed in the same
transaction. This allows pacman to intelligently resolve some things
which would otherwise be conflicts.
"""

...

I was shown the patch on #archlinux32, and proposed a more detailed
commit message body. Erich says it was supposed to have been multiple
succeeding lines in the original commit message...

I guess Allan can reflow it this once. ;)

-- 
Eli Schwartz
Bug Wrangler and Trusted User



signature.asc
Description: OpenPGP digital signature


Re: [pacman-dev] [PATCH] makepkg: install all dependencies simultanously, if possible when using rmdeps but not install, runtime dependencies do not need special handling for (non)removal, and can be

2018-06-08 Thread Florian Pritz via pacman-dev
That subject is way too long. Please keep it around 50 chars if at all
possible and put the more detailed explanation in the commit body. In
this case it's probably best to simply end the subject at the first comma.

Florian



signature.asc
Description: OpenPGP digital signature


[pacman-dev] [PATCH] makepkg: install all dependencies simultanously, if possible when using rmdeps but not install, runtime dependencies do not need special handling for (non)removal, and can be inst

2018-06-08 Thread arch
From: Erich Eckner 

Signed-off-by: Erich Eckner 
---
 scripts/makepkg.sh.in | 10 +-
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/scripts/makepkg.sh.in b/scripts/makepkg.sh.in
index e9080a70..625b89a2 100644
--- a/scripts/makepkg.sh.in
+++ b/scripts/makepkg.sh.in
@@ -1607,18 +1607,18 @@ else
fi
deperr=0
 
-   msg "$(gettext "Checking runtime dependencies...")"
-   resolve_deps ${depends[@]} || deperr=1
-
if (( RMDEPS && INSTALL )); then
+   msg "$(gettext "Checking runtime dependencies...")"
+   resolve_deps ${depends[@]} || deperr=1
+
original_pkglist=($(run_pacman -Qq))# required by remove_dep
fi
 
msg "$(gettext "Checking buildtime dependencies...")"
if (( CHECKFUNC )); then
-   resolve_deps "${makedepends[@]}" "${checkdepends[@]}" || 
deperr=1
+   resolve_deps "${depends[@]}" "${makedepends[@]}" 
"${checkdepends[@]}" || deperr=1
else
-   resolve_deps "${makedepends[@]}" || deperr=1
+   resolve_deps "${depends[@]}" "${makedepends[@]}" || deperr=1
fi
 
if (( RMDEPS )); then
-- 
2.17.1


Re: [pacman-dev] [PATCH 7/7] libmakepkg: disallow using 'any' with other arches

2018-06-08 Thread Eli Schwartz
On 06/08/2018 02:18 PM, morganamilo wrote:
> Error if the arch array contains any and any other values. This also
> fixes a bug where the check for `$arch == 'any'` which only evaluated
> the first value in the array, meaning the rest of the values would not
> be linted.
> 
> Signed-off-by: morganamilo 
> ---
>  scripts/libmakepkg/lint_pkgbuild/arch.sh.in | 13 +
>  1 file changed, 9 insertions(+), 4 deletions(-)
> 
> diff --git a/scripts/libmakepkg/lint_pkgbuild/arch.sh.in 
> b/scripts/libmakepkg/lint_pkgbuild/arch.sh.in
> index f2c80c73..98ae70af 100644
> --- a/scripts/libmakepkg/lint_pkgbuild/arch.sh.in
> +++ b/scripts/libmakepkg/lint_pkgbuild/arch.sh.in
> @@ -38,11 +38,12 @@ lint_arch() {
>   return 1
>   fi
>  
> - if [[ $arch == 'any' ]]; then
> - return 0
> - fi
> -
>   for a in "${arch[@]}"; do
> + if [[ $a == 'any' ]]; then
> + error "$(gettext "any can not be used with other 
> architectures")"
> + ret=1
> + fi

Um, how is this supposed to work? If arch=('any') then this for loop
will run once, discover [[ $a = any ]] and error out. The proper check
would be to *not* move the previous return 0, but instead tell it to &&
(( ${#arch[@]} == 1 ))

>   if [[ $a = *[![:alnum:]_]* ]]; then
>   error "$(gettext "%s contains invalid characters: 
> '%s'")" \
>   'arch' "${a//[[:alnum:]_]}"
> @@ -50,6 +51,10 @@ lint_arch() {
>   fi
>   done
>  
> + if [[ $arch == 'any' ]]; then
> + return $ret
> + fi
> +
>   if (( ! IGNOREARCH )) && ! in_array "$CARCH" "${arch[@]}"; then
>   error "$(gettext "%s is not available for the '%s' 
> architecture.")" "$pkgbase" "$CARCH"
>   return 1
> 


-- 
Eli Schwartz
Bug Wrangler and Trusted User



signature.asc
Description: OpenPGP digital signature


Re: [pacman-dev] [PATCH 2/7] libmakepkg: stop printsrcinfo generating empty values

2018-06-08 Thread Eli Schwartz
On 06/08/2018 02:18 PM, morganamilo wrote:
> When a split package overriddes an array using += and the array does not
> exist globally, makepkg --printsrcinfo will print the field with an
> empty vlaue before printing the acual values.
> 
> For exampple: having `depends+=(foo bar)` will generate:
>   depends =
>   depends = foo
>   depends = bar
> 
> Explicity check for empty array values and only print the values that
> are not empty.
> 
> Signed-off-by: morganamilo 
> ---
>  scripts/libmakepkg/srcinfo.sh.in | 6 +-
>  1 file changed, 5 insertions(+), 1 deletion(-)
> 
> diff --git a/scripts/libmakepkg/srcinfo.sh.in 
> b/scripts/libmakepkg/srcinfo.sh.in
> index 509c4860..6a49be37 100644
> --- a/scripts/libmakepkg/srcinfo.sh.in
> +++ b/scripts/libmakepkg/srcinfo.sh.in
> @@ -44,7 +44,11 @@ srcinfo_write_attr() {
>   attrvalues=("${attrvalues[@]#[[:space:]]}")
>   attrvalues=("${attrvalues[@]%[[:space:]]}")
>  
> - printf "\t$attrname = %s\n" "${attrvalues[@]}"
> + for val in "${attrvalues[@]}"; do
> + if [[ ! -z ${val// /} ]]; then
> + printf "\t$attrname = %s\n" "$val"
> + fi
> + done

This is odd, I wonder why get_pkgbuild_attribute is returning an
array=('' foo bar) in this case? We should probably fix it more directly.

-- 
Eli Schwartz
Bug Wrangler and Trusted User



signature.asc
Description: OpenPGP digital signature


Re: [pacman-dev] [PATCH 1/7] libmakepkg: disallow empty arch

2018-06-08 Thread Eli Schwartz
On 06/08/2018 02:18 PM, morganamilo wrote:
> We already ensure arch is an array but if arch is never defined
> this error never triggers. Add an explicit check for a missing arch.

Good catch! We'd usually abort with
==> ERROR: foo is not available for the 'x86_64' architecture.

but not if we're doing some IGNOREARCH operation that doesn't check
this, e.g. --source or --printsrcinfo or --packagelist

Or, makepkg --ignorearch.

-- 
Eli Schwartz
Bug Wrangler and Trusted User



signature.asc
Description: OpenPGP digital signature


Re: [pacman-dev] [PATCH 2/7] libmakepkg: stop printsrcinfo generating empty values

2018-06-08 Thread Morgan Adamiec
On Fri, 8 Jun 2018 at 20:33, Eli Schwartz  wrote:
>
> On 06/08/2018 02:18 PM, morganamilo wrote:
> > When a split package overriddes an array using += and the array does not
> > exist globally, makepkg --printsrcinfo will print the field with an
> > empty vlaue before printing the acual values.
> >
> > For exampple: having `depends+=(foo bar)` will generate:
> >   depends =
> >   depends = foo
> >   depends = bar
> >
> > Explicity check for empty array values and only print the values that
> > are not empty.
> >
> > Signed-off-by: morganamilo 
> > ---
> >  scripts/libmakepkg/srcinfo.sh.in | 6 +-
> >  1 file changed, 5 insertions(+), 1 deletion(-)
> >
> > diff --git a/scripts/libmakepkg/srcinfo.sh.in 
> > b/scripts/libmakepkg/srcinfo.sh.in
> > index 509c4860..6a49be37 100644
> > --- a/scripts/libmakepkg/srcinfo.sh.in
> > +++ b/scripts/libmakepkg/srcinfo.sh.in
> > @@ -44,7 +44,11 @@ srcinfo_write_attr() {
> >   attrvalues=("${attrvalues[@]#[[:space:]]}")
> >   attrvalues=("${attrvalues[@]%[[:space:]]}")
> >
> > - printf "\t$attrname = %s\n" "${attrvalues[@]}"
> > + for val in "${attrvalues[@]}"; do
> > + if [[ ! -z ${val// /} ]]; then
> > + printf "\t$attrname = %s\n" "$val"
> > + fi
> > + done
>
> This is odd, I wonder why get_pkgbuild_attribute is returning an
> array=('' foo bar) in this case? We should probably fix it more directly.
>
> --
> Eli Schwartz
> Bug Wrangler and Trusted User
>

In my investigation it came down to lines like this
https://git.archlinux.org/pacman.git/tree/scripts/libmakepkg/srcinfo.sh.in#n55

It seems appending an array to a non array value generates an array
with the first value being an empty string then the values appended.

You can reproduce it with:
foo=
foo+=(bar)
echo "${#foo[@]}"

I did think about fixing it there, but that function is used all over
and I didn't want to break something.


[pacman-dev] [PATCH 2/7] libmakepkg: stop printsrcinfo generating empty values

2018-06-08 Thread morganamilo
When a split package overriddes an array using += and the array does not
exist globally, makepkg --printsrcinfo will print the field with an
empty vlaue before printing the acual values.

For exampple: having `depends+=(foo bar)` will generate:
depends =
depends = foo
depends = bar

Explicity check for empty array values and only print the values that
are not empty.

Signed-off-by: morganamilo 
---
 scripts/libmakepkg/srcinfo.sh.in | 6 +-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/scripts/libmakepkg/srcinfo.sh.in b/scripts/libmakepkg/srcinfo.sh.in
index 509c4860..6a49be37 100644
--- a/scripts/libmakepkg/srcinfo.sh.in
+++ b/scripts/libmakepkg/srcinfo.sh.in
@@ -44,7 +44,11 @@ srcinfo_write_attr() {
attrvalues=("${attrvalues[@]#[[:space:]]}")
attrvalues=("${attrvalues[@]%[[:space:]]}")
 
-   printf "\t$attrname = %s\n" "${attrvalues[@]}"
+   for val in "${attrvalues[@]}"; do
+   if [[ ! -z ${val// /} ]]; then
+   printf "\t$attrname = %s\n" "$val"
+   fi
+   done
 }
 
 pkgbuild_extract_to_srcinfo() {
-- 
2.17.1


[pacman-dev] [PATCH 6/7] libmakepkg: add pkgbase to linted variables

2018-06-08 Thread morganamilo
Signed-off-by: morganamilo 
---
 scripts/libmakepkg/lint_pkgbuild/variable.sh.in | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/scripts/libmakepkg/lint_pkgbuild/variable.sh.in 
b/scripts/libmakepkg/lint_pkgbuild/variable.sh.in
index 6b7da4a2..bdb70774 100644
--- a/scripts/libmakepkg/lint_pkgbuild/variable.sh.in
+++ b/scripts/libmakepkg/lint_pkgbuild/variable.sh.in
@@ -35,7 +35,7 @@ lint_variable() {
 validpgpkeys)
local arch_array=(conflicts depends makedepends md5sums optdepends 
provides
  replaces sha1sums sha256sums sha384sums sha512sums 
source)
-   local string=(changelog epoch install pkgdesc pkgrel pkgver url)
+   local string=(changelog epoch install pkgbase pkgdesc pkgrel pkgver url)
 
local no_overide_string=(pkgbase pkgver pkgrel epoch)
 
-- 
2.17.1


[pacman-dev] [PATCH 7/7] libmakepkg: disallow using 'any' with other arches

2018-06-08 Thread morganamilo
Error if the arch array contains any and any other values. This also
fixes a bug where the check for `$arch == 'any'` which only evaluated
the first value in the array, meaning the rest of the values would not
be linted.

Signed-off-by: morganamilo 
---
 scripts/libmakepkg/lint_pkgbuild/arch.sh.in | 13 +
 1 file changed, 9 insertions(+), 4 deletions(-)

diff --git a/scripts/libmakepkg/lint_pkgbuild/arch.sh.in 
b/scripts/libmakepkg/lint_pkgbuild/arch.sh.in
index f2c80c73..98ae70af 100644
--- a/scripts/libmakepkg/lint_pkgbuild/arch.sh.in
+++ b/scripts/libmakepkg/lint_pkgbuild/arch.sh.in
@@ -38,11 +38,12 @@ lint_arch() {
return 1
fi
 
-   if [[ $arch == 'any' ]]; then
-   return 0
-   fi
-
for a in "${arch[@]}"; do
+   if [[ $a == 'any' ]]; then
+   error "$(gettext "any can not be used with other 
architectures")"
+   ret=1
+   fi
+
if [[ $a = *[![:alnum:]_]* ]]; then
error "$(gettext "%s contains invalid characters: 
'%s'")" \
'arch' "${a//[[:alnum:]_]}"
@@ -50,6 +51,10 @@ lint_arch() {
fi
done
 
+   if [[ $arch == 'any' ]]; then
+   return $ret
+   fi
+
if (( ! IGNOREARCH )) && ! in_array "$CARCH" "${arch[@]}"; then
error "$(gettext "%s is not available for the '%s' 
architecture.")" "$pkgbase" "$CARCH"
return 1
-- 
2.17.1


[pacman-dev] [PATCH 4/7] libmakepkg: lint disallowed architecture specific variables

2018-06-08 Thread morganamilo
Variables such as 'pkgdesc_x86_64' are invalid, instead of ignoring them
raise an error.

Signed-off-by: morganamilo 
---
 .../libmakepkg/lint_pkgbuild/variable.sh.in   | 24 ++-
 1 file changed, 23 insertions(+), 1 deletion(-)

diff --git a/scripts/libmakepkg/lint_pkgbuild/variable.sh.in 
b/scripts/libmakepkg/lint_pkgbuild/variable.sh.in
index 68512a62..b9264768 100644
--- a/scripts/libmakepkg/lint_pkgbuild/variable.sh.in
+++ b/scripts/libmakepkg/lint_pkgbuild/variable.sh.in
@@ -69,6 +69,15 @@ lint_variable() {
fi
fi
done
+
+   for i in ${array[@]} ${string[@]}; do
+   v="${i}_${a}"
+   eval "keys=(\"\${!${v}[@]}\")"
+   if (( ${#keys[*]} > 0 )); then
+   error "$(gettext "%s_%s can not be architecture 
specific")" "$i" "$a"
+   ret=1
+   fi
+   done
done
 
for i in ${string[@]}; do
@@ -93,6 +102,20 @@ lint_variable() {
for a in ${arch[@]}; do
[[ $a == "any" ]] && continue
 
+   for i in ${string[@]}; do
+   if extract_function_variable "package_$pkg" 
"${i}_${a}" 0 out; then
+   error "$(gettext "%s_%s can not be 
architecture specific")" "$i" "$a"
+   ret=1
+   fi
+   done
+
+   for i in ${array[@]}; do
+   if extract_function_variable "package_$pkg" 
"${i}_${a}" 1 out; then
+   error "$(gettext "%s_%s can not be 
architecture specific")" "$i" "$a"
+   ret=1
+   fi
+   done
+
for i in ${no_overide_string[@]}; do
if extract_function_variable "package_$pkg" 
"${i}_${a}" 0 out; then
error "$(gettext "%s_%s can not be 
overridden in package function")" "$i" "$a"
@@ -108,7 +131,6 @@ lint_variable() {
 
done
 
-
for i in ${arch_array[@]}; do
if extract_function_variable "package_$pkg" 
"${i}_${a}" 0 out; then
error "$(gettext "%s_%s should be an 
array")" "$i" "$a"
-- 
2.17.1


[pacman-dev] [PATCH 5/7] libmakepkg: disallow using any as an architecture specific variable

2018-06-08 Thread morganamilo
Signed-off-by: morganamilo 
---
 scripts/libmakepkg/lint_pkgbuild/variable.sh.in | 12 ++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/scripts/libmakepkg/lint_pkgbuild/variable.sh.in 
b/scripts/libmakepkg/lint_pkgbuild/variable.sh.in
index b9264768..6b7da4a2 100644
--- a/scripts/libmakepkg/lint_pkgbuild/variable.sh.in
+++ b/scripts/libmakepkg/lint_pkgbuild/variable.sh.in
@@ -57,12 +57,15 @@ lint_variable() {
done
 
for a in ${arch[@]}; do
-   [[ $a == "any" ]] && continue
-
for i in ${arch_array[@]}; do
v="${i}_${a}"
eval "keys=(\"\${!${v}[@]}\")"
if (( ${#keys[*]} > 0 )); then
+   if [[ $a == "any" ]]; then
+   error "$(gettext "%s_%s any can not be 
used for an architecture specific variable")" "$i" "$a"
+   ret=1
+   fi
+
if ! is_array $v; then
error "$(gettext "%s_%s should be an 
array")" "$i" "$a"
ret=1
@@ -111,6 +114,11 @@ lint_variable() {
 
for i in ${array[@]}; do
if extract_function_variable "package_$pkg" 
"${i}_${a}" 1 out; then
+   if [[ $a == "any" ]]; then
+   error "$(gettext "%s_%s any can 
not be used for an architecture specific variable")" "$i" "$a"
+   ret=1
+   fi
+
error "$(gettext "%s_%s can not be 
architecture specific")" "$i" "$a"
ret=1
fi
-- 
2.17.1


[pacman-dev] [PATCH 3/7] libmakepkg: lint disallowed variables in package()

2018-06-08 Thread morganamilo
makepkpg will now error if disallowed variables are overridden inside of
the package function.

Signed-off-by: morganamilo 
---
 .../libmakepkg/lint_pkgbuild/variable.sh.in   | 36 +++
 1 file changed, 36 insertions(+)

diff --git a/scripts/libmakepkg/lint_pkgbuild/variable.sh.in 
b/scripts/libmakepkg/lint_pkgbuild/variable.sh.in
index 3266cb5e..68512a62 100644
--- a/scripts/libmakepkg/lint_pkgbuild/variable.sh.in
+++ b/scripts/libmakepkg/lint_pkgbuild/variable.sh.in
@@ -37,6 +37,12 @@ lint_variable() {
  replaces sha1sums sha256sums sha384sums sha512sums 
source)
local string=(changelog epoch install pkgdesc pkgrel pkgver url)
 
+   local no_overide_string=(pkgbase pkgver pkgrel epoch)
+
+   local no_overide_array=(checkdepends makedepends
+   noextract source validpgpkeys md5suns sha1sums
+   sha224sums sha256sums sha384sums sha512sums)
+
local i a v pkg keys out bad ret=0
 
# global variables
@@ -87,6 +93,22 @@ lint_variable() {
for a in ${arch[@]}; do
[[ $a == "any" ]] && continue
 
+   for i in ${no_overide_string[@]}; do
+   if extract_function_variable "package_$pkg" 
"${i}_${a}" 0 out; then
+   error "$(gettext "%s_%s can not be 
overridden in package function")" "$i" "$a"
+   ret=1
+   fi
+   done
+
+   for i in ${no_overide_array[@]}; do
+   if extract_function_variable "package_$pkg" 
"${i}_${a}" 1 out; then
+   error "$(gettext "%s_%s can not be 
overridden in package function")" "$i" "$a"
+   ret=1
+   fi
+
+   done
+
+
for i in ${arch_array[@]}; do
if extract_function_variable "package_$pkg" 
"${i}_${a}" 0 out; then
error "$(gettext "%s_%s should be an 
array")" "$i" "$a"
@@ -95,6 +117,20 @@ lint_variable() {
done
done
 
+   for i in ${no_overide_string[@]}; do
+   if extract_function_variable "package_$pkg" "$i" 0 out; 
then
+   error "$(gettext "%s can not be overridden in 
package function")" "$i"
+   ret=1
+   fi
+   done
+
+   for i in ${no_overide_string[@]}; do
+   if extract_function_variable "package_$pkg" "$i" 1 out; 
then
+   error "$(gettext "%s can not be overridden in 
package function")" "$i"
+   ret=1
+   fi
+   done
+
for i in ${string[@]}; do
if extract_function_variable "package_$pkg" $i 1 out; 
then
error "$(gettext "%s should not be an array")" 
"$i"
-- 
2.17.1


[pacman-dev] [PATCH 0/7] Improve linting for makepkg

2018-06-08 Thread morganamilo
I recently did some data crunshing on AUR packages, trying to find ones that
are formatted incorrectly, catching mistakes makepkg did not.

I wrote up on the results here
https://github.com/Morganamilo/go-srcinfo/issues/1.

This patch should cover all the mistakes found and make is so that makepkg
bails out duing the linting phase and users are forced to make more correct
pkgbuilds.

morganamilo (7):
  libmakepkg: disallow empty arch
  libmakepkg: stop printsrcinfo generating empty values
  libmakepkg: lint disallowed variables in package()
  libmakepkg: lint disallowed architecture specific variables
  libmakepkg: disallow using any as an architecture specific variable
  libmakepkg: add pkgbase to linted variables
  libmakepkg: disallow using 'any' with other arches

 scripts/libmakepkg/lint_pkgbuild/arch.sh.in   | 14 +++-
 .../libmakepkg/lint_pkgbuild/variable.sh.in   | 72 ++-
 scripts/libmakepkg/srcinfo.sh.in  |  6 +-
 3 files changed, 86 insertions(+), 6 deletions(-)

-- 
2.17.1


[pacman-dev] [PATCH 1/7] libmakepkg: disallow empty arch

2018-06-08 Thread morganamilo
We already ensure arch is an array but if arch is never defined
this error never triggers. Add an explicit check for a missing arch.

Signed-off-by: morganamilo 
---
 scripts/libmakepkg/lint_pkgbuild/arch.sh.in | 5 +
 1 file changed, 5 insertions(+)

diff --git a/scripts/libmakepkg/lint_pkgbuild/arch.sh.in 
b/scripts/libmakepkg/lint_pkgbuild/arch.sh.in
index ef1aac46..f2c80c73 100644
--- a/scripts/libmakepkg/lint_pkgbuild/arch.sh.in
+++ b/scripts/libmakepkg/lint_pkgbuild/arch.sh.in
@@ -33,6 +33,11 @@ lint_pkgbuild_functions+=('lint_arch')
 lint_arch() {
local a name list ret=0
 
+   if [[ -z $arch ]]; then
+   error "$(gettext "%s is not allowed to be empty.")" "arch"
+   return 1
+   fi
+
if [[ $arch == 'any' ]]; then
return 0
fi
-- 
2.17.1


Re: [pacman-dev] [PATCH 7/7] libmakepkg: disallow using 'any' with other arches

2018-06-08 Thread Morgan Adamiec
On Fri, 8 Jun 2018 at 20:33, Eli Schwartz  wrote:
>
> On 06/08/2018 02:18 PM, morganamilo wrote:
> > Error if the arch array contains any and any other values. This also
> > fixes a bug where the check for `$arch == 'any'` which only evaluated
> > the first value in the array, meaning the rest of the values would not
> > be linted.
> >
> > Signed-off-by: morganamilo 
> > ---
> >  scripts/libmakepkg/lint_pkgbuild/arch.sh.in | 13 +
> >  1 file changed, 9 insertions(+), 4 deletions(-)
> >
> > diff --git a/scripts/libmakepkg/lint_pkgbuild/arch.sh.in 
> > b/scripts/libmakepkg/lint_pkgbuild/arch.sh.in
> > index f2c80c73..98ae70af 100644
> > --- a/scripts/libmakepkg/lint_pkgbuild/arch.sh.in
> > +++ b/scripts/libmakepkg/lint_pkgbuild/arch.sh.in
> > @@ -38,11 +38,12 @@ lint_arch() {
> >   return 1
> >   fi
> >
> > - if [[ $arch == 'any' ]]; then
> > - return 0
> > - fi
> > -
> >   for a in "${arch[@]}"; do
> > + if [[ $a == 'any' ]]; then
> > + error "$(gettext "any can not be used with other 
> > architectures")"
> > + ret=1
> > + fi
>
> Um, how is this supposed to work? If arch=('any') then this for loop
> will run once, discover [[ $a = any ]] and error out. The proper check
> would be to *not* move the previous return 0, but instead tell it to &&
> (( ${#arch[@]} == 1 ))
>
> >   if [[ $a = *[![:alnum:]_]* ]]; then
> >   error "$(gettext "%s contains invalid characters: 
> > '%s'")" \
> >   'arch' "${a//[[:alnum:]_]}"
> > @@ -50,6 +51,10 @@ lint_arch() {
> >   fi
> >   done
> >
> > + if [[ $arch == 'any' ]]; then
> > + return $ret
> > + fi
> > +
> >   if (( ! IGNOREARCH )) && ! in_array "$CARCH" "${arch[@]}"; then
> >   error "$(gettext "%s is not available for the '%s' 
> > architecture.")" "$pkgbase" "$CARCH"
> >   return 1
> >
>
>
> --
> Eli Schwartz
> Bug Wrangler and Trusted User
>

Yeah slipped my mind, that would be a better way to do it.


Re: [pacman-dev] [PATCH 2/7] libmakepkg: stop printsrcinfo generating empty values

2018-06-08 Thread Dave Reisner
On Fri, Jun 08, 2018 at 08:42:11PM +0100, Morgan Adamiec wrote:
> On Fri, 8 Jun 2018 at 20:33, Eli Schwartz  wrote:
> >
> > On 06/08/2018 02:18 PM, morganamilo wrote:
> > > When a split package overriddes an array using += and the array does not
> > > exist globally, makepkg --printsrcinfo will print the field with an
> > > empty vlaue before printing the acual values.
> > >
> > > For exampple: having `depends+=(foo bar)` will generate:
> > >   depends =
> > >   depends = foo
> > >   depends = bar
> > >
> > > Explicity check for empty array values and only print the values that
> > > are not empty.
> > >
> > > Signed-off-by: morganamilo 
> > > ---
> > >  scripts/libmakepkg/srcinfo.sh.in | 6 +-
> > >  1 file changed, 5 insertions(+), 1 deletion(-)
> > >
> > > diff --git a/scripts/libmakepkg/srcinfo.sh.in 
> > > b/scripts/libmakepkg/srcinfo.sh.in
> > > index 509c4860..6a49be37 100644
> > > --- a/scripts/libmakepkg/srcinfo.sh.in
> > > +++ b/scripts/libmakepkg/srcinfo.sh.in
> > > @@ -44,7 +44,11 @@ srcinfo_write_attr() {
> > >   attrvalues=("${attrvalues[@]#[[:space:]]}")
> > >   attrvalues=("${attrvalues[@]%[[:space:]]}")
> > >
> > > - printf "\t$attrname = %s\n" "${attrvalues[@]}"
> > > + for val in "${attrvalues[@]}"; do
> > > + if [[ ! -z ${val// /} ]]; then
> > > + printf "\t$attrname = %s\n" "$val"
> > > + fi
> > > + done
> >
> > This is odd, I wonder why get_pkgbuild_attribute is returning an
> > array=('' foo bar) in this case? We should probably fix it more directly.
> >
> > --
> > Eli Schwartz
> > Bug Wrangler and Trusted User
> >
> 
> In my investigation it came down to lines like this
> https://git.archlinux.org/pacman.git/tree/scripts/libmakepkg/srcinfo.sh.in#n55
> 
> It seems appending an array to a non array value generates an array
> with the first value being an empty string then the values appended.
> 
> You can reproduce it with:
> foo=
> foo+=(bar)
> echo "${#foo[@]}"
> 
> I did think about fixing it there, but that function is used all over
> and I didn't want to break something.

That's just bad shell code. Using foo= to declare an array is the same
as writing foo=('').

Please don't change this to paper over bad PKGBUILDs. If anything, the
fix here is to leverage bash 4.4 in our lint rules when it's available
and use @a expansion to detect if something is an array or a string,
e.g.

$ licenses='MIT'
$ [[ ${licenses@a} = *a* ]] || echo "licenses must be an array"


Re: [pacman-dev] [PATCH 2/7] libmakepkg: stop printsrcinfo generating empty values

2018-06-08 Thread Morgan Adamiec
> Please don't change this to paper over bad PKGBUILDs.

the thing is foo= is never declared in the pkgbuild

A pkgbuild like this:

pkgname=foo
pkgver=1
pkgrel=1
arch=('any')

package() {
depends+=("bar")
}

Generates a srcinfo like this:

pkgbase = foo
pkgver = 1
pkgrel = 1
arch = any

pkgname = foo
depends =
depends = bar

When you perform foo+=(bar) when foo is unset the array will only
contain foo. So no I wouldn't put the blame on bad pkgbuilds here.

Infact the same thing happens if you do declare depends globally like such:

pkgname=foo
pkgver=1
pkgrel=1
arch=('any')
depends=()

package() {
depends+=("bar")
}