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

2018-06-11 Thread Morgan Adamiec
On Mon, 11 Jun 2018 at 22:27, Eli Schwartz  wrote:
>
> On 06/11/2018 04:53 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 | 7 ++-
> >  1 file changed, 6 insertions(+), 1 deletion(-)
> >
> > diff --git a/scripts/libmakepkg/lint_pkgbuild/arch.sh.in 
> > b/scripts/libmakepkg/lint_pkgbuild/arch.sh.in
> > index f2c80c73..8a1d2c11 100644
> > --- a/scripts/libmakepkg/lint_pkgbuild/arch.sh.in
> > +++ b/scripts/libmakepkg/lint_pkgbuild/arch.sh.in
> > @@ -38,11 +38,16 @@ lint_arch() {
> >   return 1
> >   fi
> >
> > - if [[ $arch == 'any' ]]; then
> > + if [[ $arch == 'any' && ${#arch[@]} == 1 ]]; then
>
>
> [[ ${#arch[@]} = 1 ]] is a string comparison (the test keyword or
> builtin uses -eq to handle numeric values).
>
> (( ${#arch[@]} == 1 )) is an integer comparison (shell arithmetic is
> generally superior when available).
>
> I specifically mentioned the latter in my previous email.
>
> --
> Eli Schwartz
> Bug Wrangler and Trusted User
>

Yeah I see that now. Bash Isn't really my thing so I didn't really
take note of the (( ))

Just to be sure before I send another patch it would be
if [[ $arch == 'any' && (( ${#arch[@]} == 1 )) ]];
right? With the (( )) nested in the [[ ]].

Thanks for the feedback by the way, It helps a lot.


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

2018-06-11 Thread Eli Schwartz
On 06/11/2018 04:53 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 | 7 ++-
>  1 file changed, 6 insertions(+), 1 deletion(-)
> 
> diff --git a/scripts/libmakepkg/lint_pkgbuild/arch.sh.in 
> b/scripts/libmakepkg/lint_pkgbuild/arch.sh.in
> index f2c80c73..8a1d2c11 100644
> --- a/scripts/libmakepkg/lint_pkgbuild/arch.sh.in
> +++ b/scripts/libmakepkg/lint_pkgbuild/arch.sh.in
> @@ -38,11 +38,16 @@ lint_arch() {
>   return 1
>   fi
>  
> - if [[ $arch == 'any' ]]; then
> + if [[ $arch == 'any' && ${#arch[@]} == 1 ]]; then


[[ ${#arch[@]} = 1 ]] is a string comparison (the test keyword or
builtin uses -eq to handle numeric values).

(( ${#arch[@]} == 1 )) is an integer comparison (shell arithmetic is
generally superior when available).

I specifically mentioned the latter in my previous email.

-- 
Eli Schwartz
Bug Wrangler and Trusted User



signature.asc
Description: OpenPGP digital signature


[pacman-dev] [PATCH] Show install status during file search

2018-06-11 Thread morganamilo
When doing "pacman -Fs", show the "[installed: version]"
message just like "pacman -Ss".

Signed-off-by: morganamilo 
---
 src/pacman/files.c | 7 +--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/src/pacman/files.c b/src/pacman/files.c
index d7fc5446..65e6ad26 100644
--- a/src/pacman/files.c
+++ b/src/pacman/files.c
@@ -101,6 +101,7 @@ static int files_fileowner(alpm_list_t *syncs, alpm_list_t 
*targets) {
 
 static int files_search(alpm_list_t *syncs, alpm_list_t *targets, int regex) {
int ret = 0;
+   alpm_db_t *db_local = alpm_get_localdb(config->handle);
alpm_list_t *t;
const colstr_t *colstr = >colstr;
 
@@ -157,13 +158,15 @@ static int files_search(alpm_list_t *syncs, alpm_list_t 
*targets, int regex) {
printf("%s/%s\n", 
alpm_db_get_name(repo), alpm_pkg_get_name(pkg));
} else {
alpm_list_t *ml;
-   printf("%s%s/%s%s %s%s%s\n", 
colstr->repo, alpm_db_get_name(repo),
+   printf("%s%s/%s%s %s%s%s", 
colstr->repo, alpm_db_get_name(repo),
colstr->title, 
alpm_pkg_get_name(pkg),
colstr->version, 
alpm_pkg_get_version(pkg), colstr->nocolor);
 
+   print_installed(db_local, pkg);
+
for(ml = match; ml; ml = 
alpm_list_next(ml)) {
c = ml->data;
-   printf("%s\n", c);
+   printf("\n%s\n", c);
}
}
alpm_list_free(match);
-- 
2.17.1


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

2018-06-11 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 | 7 ++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/scripts/libmakepkg/lint_pkgbuild/arch.sh.in 
b/scripts/libmakepkg/lint_pkgbuild/arch.sh.in
index f2c80c73..8a1d2c11 100644
--- a/scripts/libmakepkg/lint_pkgbuild/arch.sh.in
+++ b/scripts/libmakepkg/lint_pkgbuild/arch.sh.in
@@ -38,11 +38,16 @@ lint_arch() {
return 1
fi
 
-   if [[ $arch == 'any' ]]; then
+   if [[ $arch == 'any' && ${#arch[@]} == 1 ]]; 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:]_]}"
-- 
2.17.1