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

2018-08-09 Thread Allan McRae
On 12/06/18 06:17, morganamilo wrote:
> When doing "pacman -Fs", show the "[installed: version]"
> message just like "pacman -Ss".
> 
> Signed-off-by: morganamilo 
> ---


Something not quite right here.   Note I have pacman-git installed.

allan@kamala ~/arch/code/pacman (patchqueue)
$ ./src/pacman/pacman -Fs pacman
core/pacman 5.1.1-1
usr/bin/pacman

usr/share/bash-completion/completions/pacman
extra/xscreensaver 5.39-1
usr/lib/xscreensaver/pacman

allan@kamala ~/arch/code/pacman (patchqueue)
$ pacman -Fs pacman
core/pacman 5.1.1-1
usr/bin/pacman
usr/share/bash-completion/completions/pacman
extra/xscreensaver 5.39-1
usr/lib/xscreensaver/pacman




>  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);
> 


[pacman-dev] [GIT] The official pacman repository branch, master, updated. v5.1.1-13-g7d05ffce

2018-08-09 Thread Allan McRae
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "The official pacman repository".

The branch, master has been updated
   via  7d05ffceaf9161a6572505d25b5017e1eb33bf0e (commit)
   via  e4be26b7327d8378735205ebedfc9718fb6fbba1 (commit)
   via  4e83abaae51c82ce6571450fb3ed9e2e71175b68 (commit)
   via  92bc0a474081c56d71605787d57ea2f6715a639c (commit)
   via  b0a8f44f105e0ac0f18279e3c25d570090ac9e70 (commit)
   via  885bbb504afbf014194c8c20a51fc862980da45b (commit)
   via  9e960d9d5a735bbc7d418f2ad81d3f3e92d99968 (commit)
   via  7f1f1355bbb3941a30798a295721e7f35077e116 (commit)
   via  0937d322ba67400cb2c5fd1a548ef6e843801ec6 (commit)
   via  7edbbd9a638ec864b42f14cb2dea631c383aebbb (commit)
   via  f2788244d322ca5ac45482d25747fe56176b72af (commit)
   via  0cbb128818726e4d41964ea8df8c42ee37697ef7 (commit)
   via  fd16da2ed68aa7f89ad37701bcf7674b7bb14b2d (commit)
  from  7e081d2adf8321f25165255fd21fab61d4055a53 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -
commit 7d05ffceaf9161a6572505d25b5017e1eb33bf0e
Author: Allan McRae 
Date:   Tue May 29 13:57:13 2018 +1000

Remove the last traces of the pacman --force option

Signed-off-by: Allan McRae 

commit e4be26b7327d8378735205ebedfc9718fb6fbba1
Author: Jan Alexander Steffens (heftig) 
Date:   Tue Jun 19 22:33:57 2018 +0200

scripts: Remove trailing semicolons

Signed-off-by: Allan McRae 

commit 4e83abaae51c82ce6571450fb3ed9e2e71175b68
Author: Jan Alexander Steffens (heftig) 
Date:   Tue Jun 19 22:33:56 2018 +0200

libmakepkg/util/option: Refactor checking to reduce code duplication

Pull out the expected=y/n check into a separate function and make use of
the fact we can just prepend the fallback arrays to get the same result.

Signed-off-by: Allan McRae 

commit 92bc0a474081c56d71605787d57ea2f6715a639c
Author: Eli Schwartz 
Date:   Tue Jun 19 16:26:35 2018 -0400

libmakepkg/util: use parameter transformation when checking variable type

Now that we require bash 4.4 this is "more correct" than analyzing the
output of declare -p to see if it compares favorably with -a.

Signed-off-by: Eli Schwartz 
Signed-off-by: Allan McRae 

commit b0a8f44f105e0ac0f18279e3c25d570090ac9e70
Author: Eli Schwartz 
Date:   Tue Jun 19 16:26:33 2018 -0400

configure: bump the minimum version of bash to 4.4

This is required in order to use declare -g and ${var@a}

Signed-off-by: Eli Schwartz 
Signed-off-by: Allan McRae 

commit 885bbb504afbf014194c8c20a51fc862980da45b
Author: Eli Schwartz 
Date:   Tue Jun 12 10:00:29 2018 -0400

makepkg: when signing packages, report package filename on failure

In commit c6b04c04653ba9933fe978829148312e412a9ea7 the signing function
was moved out of fakeroot, and thus out of the create_package loop. This
meant that if package signing failed, it was no longer possible to tell
which package it failed on by checking which package creation is
currently running. Successful signing attempts do not have this problem
as we already printed the name of the signature file.

Signed-off-by: Eli Schwartz 
Signed-off-by: Allan McRae 

commit 9e960d9d5a735bbc7d418f2ad81d3f3e92d99968
Author: Michael Straube 
Date:   Sun Jun 10 18:58:34 2018 +0200

libalpm/dload.c: add case for CURLE_COULDNT_RESOLVE_HOST

Add a case for curl error 'Could not resolve host'.
An attempt to fix FS#48285.

Signed-off-by: Michael Straube 
Signed-off-by: Allan McRae 

commit 7f1f1355bbb3941a30798a295721e7f35077e116
Author: Jouke Witteveen 
Date:   Sat Jun 9 19:45:59 2018 +0200

libalpm: ignore .hook suffix when sorting hooks

It is desirable to have 'a-post.hook' ordered after 'a.hook'. For this,
it is needed to ignore the suffix when sorting.

Signed-off-by: Allan McRae 

commit 0937d322ba67400cb2c5fd1a548ef6e843801ec6
Author: morganamilo 
Date:   Fri Jun 8 19:18:58 2018 +0100

libmakepkg: add pkgbase to linted variables

Signed-off-by: morganamilo 
Signed-off-by: Allan McRae 

commit 7edbbd9a638ec864b42f14cb2dea631c383aebbb
Author: Jan Alexander Steffens (heftig) 
Date:   Tue May 8 15:31:58 2018 +0200

makepkg: Simplify run_package

Signed-off-by: Allan McRae 

commit f2788244d322ca5ac45482d25747fe56176b72af
Author: Jan Alexander Steffens (heftig) 
Date:   Thu May 31 18:24:47 2018 +0200

makepkg: Simplify SPLITPKG check

This causes package_$pkgname() to be preferred over package() in the
non-split case, but the behavior if both functions exist was
undocumented anyway.

Signed-off-by: Allan 

[pacman-dev] [PATCH] makepkg: Handle errors when canonicalizing paths

2018-08-09 Thread Luke Shumaker
From: Luke Shumaker 

If you don't have adequate permission to `cd` to one of the DEST
directories, it's clear that that something's not doing error handling
right:

$ install -d -m srcdest
$ SRCDEST=$PWD/srcdest makepkg
/usr/share/makepkg/util/util.sh: line 75: cd: /.../srcdest: Permission 
denied
==> ERROR: Failed to change to directory /.../srcdest
Aborting...
==> ERROR: Failed to create the directory $SRCDEST ().
Aborting...

The first error comes from cd_safe() inside of canonicalize_path().
Because that bit runs in a subshell, it doesn't actually abort right there.
Then, makepkg.sh doesn't check for failures from canonicalize_path.  So
then the variable gets set to an empty string (which makes the next error
message from ensure_writable_dir() look funny), and keeps going.

As an additional "fun" quirk, canonicalize_path doesn't canonicalize it if
ensure_writable_dir has any work to do.  That's probably not intended, but
I'm not sure it is wrong either (see below).

 1. Combine canonicalize_path() and ensure_writable_dir() in to
canonicalize_and_ensure_writable_dir().  Both are only ever called on
exactly the same variables (except that ensure_writable_dir() might
skip PKGDEST, SRCPKGDEST, or LOGDEST; depending on the flags).
 2. Use plain `cd` and check the status ourselves, rather than `cd_safe`.
We can come up with a better (context-aware) error message than
`cd_safe`, and we avoid duplicating the "Aborting..." message.

This has a few consequences:

 a. We no longer canonicalize dirpaths that we don't ensure are writable.
That's probably safe.  This means that makepkg might now error in fewer
cases; for example:

$ install -d -m pkgdest
$ PKGDEST=$PWD/pkgdest makepkg -g

There's no reason for it to care that it can't `cd` to PKGDEST; it
won't be using it.

 b. We now canonicalize paths that we create that didn't exist before.

That said, I'm not sure why we ever need to canonicalize the paths; I'm not
sure why c0f58ea was necessary even after 960c2cd was already applied.
---
 scripts/libmakepkg/util/util.sh.in | 31 +++---
 scripts/makepkg.sh.in  | 14 +++---
 2 files changed, 18 insertions(+), 27 deletions(-)

diff --git a/scripts/libmakepkg/util/util.sh.in 
b/scripts/libmakepkg/util/util.sh.in
index e1ca5cb7..1dfe6da9 100644
--- a/scripts/libmakepkg/util/util.sh.in
+++ b/scripts/libmakepkg/util/util.sh.in
@@ -49,20 +49,6 @@ is_array() {
return $ret
 }
 
-# Canonicalize a directory path if it exists
-canonicalize_path() {
-   local path="$1";
-
-   if [[ -d $path ]]; then
-   (
-   cd_safe "$path"
-   pwd -P
-   )
-   else
-   printf "%s\n" "$path"
-   fi
-}
-
 dir_is_empty() {
(
shopt -s dotglob nullglob
@@ -79,10 +65,10 @@ cd_safe() {
fi
 }
 
-# Try to create directory if one does not yet exist. Fails if the directory
-# exists but has no write permissions, or if there is an existing file with
-# the same name.
-ensure_writable_dir() {
+# Try to create directory if one does not yet exist, and prints the
+# canonical path to the directory. Fails if the directory exists but has no
+# write permissions, or if there is an existing file with the same name.
+canonicalize_and_ensure_writable_dir() {
local dirtype="$1" dirpath="$2"
 
if ! mkdir -p "$dirpath" 2>/dev/null; then
@@ -92,6 +78,11 @@ ensure_writable_dir() {
error "$(gettext "You do not have write permission for the 
directory \$%s (%s).")" "$dirtype" "$dirpath"
return 1
fi
-
-   return 0
+   (
+   if ! cd "$dirpath"; then
+   error "$(gettext "Could not canonicalize the directory 
\$%s (%s).")" "$dirtype" "$dirpath"
+   return 1
+   fi
+   pwd -P
+   )
 }
diff --git a/scripts/makepkg.sh.in b/scripts/makepkg.sh.in
index 8ee0f5c5..62c2db80 100644
--- a/scripts/makepkg.sh.in
+++ b/scripts/makepkg.sh.in
@@ -1353,9 +1353,9 @@ if (( ${#extra_environment[*]} )); then
export "${extra_environment[@]}"
 fi
 
-# canonicalize paths and provide defaults if anything is still undefined
+# provide defaults if anything is still undefined
 for var in PKGDEST SRCDEST SRCPKGDEST LOGDEST BUILDDIR; do
-   printf -v "$var" "$(canonicalize_path "${!var:-$startdir}")"
+   printf -v "$var" "${!var:-$startdir}"
 done
 unset var
 PACKAGER=${PACKAGER:-"Unknown Packager"}
@@ -1378,23 +1378,23 @@ lint_config || exit $E_CONFIG_ERROR
 
 
 # check that all settings directories are user-writable
-if ! ensure_writable_dir "BUILDDIR" "$BUILDDIR"; then
+if ! BUILDDIR=$(canonicalize_and_ensure_writable_dir "BUILDDIR" "$BUILDDIR"); 
then
plain "$(gettext "Aborting...")"
exit $E_FS_PERMISSIONS
 fi
 
-if (( ! (NOBUILD || GENINTEG) )) && ! 

[pacman-dev] [PATCH v2 2/3] makepkg: check_pkgrel: Don't say "decimal" in the error message

2018-08-09 Thread Luke Shumaker
From: Luke Shumaker 

If you have a malformed pkgrel, the error message says that it must be a
"decimal".  That isn't quite true, as that would mean that `1.1 == 1.10`.
---
 scripts/libmakepkg/lint_pkgbuild/pkgrel.sh.in | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/scripts/libmakepkg/lint_pkgbuild/pkgrel.sh.in 
b/scripts/libmakepkg/lint_pkgbuild/pkgrel.sh.in
index 5dc9d3a7..cc2c0f40 100644
--- a/scripts/libmakepkg/lint_pkgbuild/pkgrel.sh.in
+++ b/scripts/libmakepkg/lint_pkgbuild/pkgrel.sh.in
@@ -37,7 +37,7 @@ check_pkgrel() {
fi
 
if [[ $rel != +([0-9])?(.+([0-9])) ]]; then
-   error "$(gettext "%s must be a decimal, not %s.")" 
"pkgrel${type:+ in $type}" "$rel"
+   error "$(gettext "%s must be of the form 'integer[.integer]', 
not %s.")" "pkgrel${type:+ in $type}" "$rel"
return 1
fi
 }
-- 
2.18.0


[pacman-dev] [PATCH v2 3/3] makepkg: check_pkgver: Report what the bad pkgver is

2018-08-09 Thread Luke Shumaker
From: Luke Shumaker 

For consistency with check_epoch and check_pkgrel.

I think that this is important because if there are multiple
provides/depends/whatever that include a version, and one of them is
malformed, including the bad version in the error message identified
which one is the problem.
---
 scripts/libmakepkg/lint_pkgbuild/pkgver.sh.in | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/scripts/libmakepkg/lint_pkgbuild/pkgver.sh.in 
b/scripts/libmakepkg/lint_pkgbuild/pkgver.sh.in
index c105212b..65216b64 100644
--- a/scripts/libmakepkg/lint_pkgbuild/pkgver.sh.in
+++ b/scripts/libmakepkg/lint_pkgbuild/pkgver.sh.in
@@ -38,7 +38,7 @@ check_pkgver() {
fi
 
if [[ $ver = *[[:space:]/:-]* ]]; then
-   error "$(gettext "%s is not allowed to contain colons, forward 
slashes, hyphens or whitespace.")" "pkgver${type:+ in $type}"
+   error "$(gettext "%s is not allowed to contain colons, forward 
slashes, hyphens or whitespace; got %s.")" "pkgver${type:+ in $type}" "$ver"
return 1
fi
 }
-- 
2.18.0


[pacman-dev] [PATCH v2 1/3] makepkg: Better error messages for versions in (check, make, opt)depends/provides/conflicts

2018-08-09 Thread Luke Shumaker
From: Luke Shumaker 

Given the depends

depends=('foo>=1.2-1.par2')

and the error message

==> ERROR: pkgver in depends is not allowed to contain colons, forward 
slashes, hyphens or whitespace.

One would be lead to believe that the problem is that they gave a pkgrel in
depends at all, not that the pkgrel contains letters.

Each of the (check,make,opt)depends, conflicts, and provides linters use a
glob to trim off properly formed epoch an rel from the full version string,
and pass the remainder to check_pkgver().  This does a good job of
accepting/rejecting full versions, but doesn't do a good job of generating
good error messages when rejecting if it's because of the epoch or rel.

1. Factor out check_epoch() and check_pkgrel() from lint_epoch() and
   lint_pkgrel(), similarly to check_pkgver().
2. Add a check_fullpkgver() that takes a full [epoch:]ver[-rel] string and
   splits it in to epoch/ver/rel, and calls the appropriate check_ function
   on each.
3. Use check_fullpkgver() in the {,check,make,opt}depends, conflicts, and
   provides linters.
---
v2:
 - Don't skip lint_pkgrel if (( PKGVERFUNC ))
 - check_fullpkgver: Don't let rel strip ver down to nothing

 scripts/Makefile.am   |  1 +
 .../lint_pkgbuild/checkdepends.sh.in  | 10 ++--
 .../libmakepkg/lint_pkgbuild/conflicts.sh.in  | 10 ++--
 .../libmakepkg/lint_pkgbuild/depends.sh.in| 14 ++---
 scripts/libmakepkg/lint_pkgbuild/epoch.sh.in  | 10 +++-
 .../libmakepkg/lint_pkgbuild/fullpkgver.sh.in | 58 +++
 .../lint_pkgbuild/makedepends.sh.in   | 10 ++--
 .../libmakepkg/lint_pkgbuild/optdepends.sh.in | 10 ++--
 scripts/libmakepkg/lint_pkgbuild/pkgrel.sh.in | 15 +++--
 .../libmakepkg/lint_pkgbuild/provides.sh.in   | 10 ++--
 10 files changed, 105 insertions(+), 43 deletions(-)
 create mode 100644 scripts/libmakepkg/lint_pkgbuild/fullpkgver.sh.in

diff --git a/scripts/Makefile.am b/scripts/Makefile.am
index f759e149..7cf8bed0 100644
--- a/scripts/Makefile.am
+++ b/scripts/Makefile.am
@@ -73,6 +73,7 @@ LIBMAKEPKG_IN = \
libmakepkg/lint_pkgbuild/conflicts.sh \
libmakepkg/lint_pkgbuild/depends.sh \
libmakepkg/lint_pkgbuild/epoch.sh \
+   libmakepkg/lint_pkgbuild/fullpkgver.sh \
libmakepkg/lint_pkgbuild/install.sh \
libmakepkg/lint_pkgbuild/makedepends.sh \
libmakepkg/lint_pkgbuild/optdepends.sh \
diff --git a/scripts/libmakepkg/lint_pkgbuild/checkdepends.sh.in 
b/scripts/libmakepkg/lint_pkgbuild/checkdepends.sh.in
index d5648bd4..0a9ddf67 100644
--- a/scripts/libmakepkg/lint_pkgbuild/checkdepends.sh.in
+++ b/scripts/libmakepkg/lint_pkgbuild/checkdepends.sh.in
@@ -23,8 +23,8 @@ LIBMAKEPKG_LINT_PKGBUILD_CHECKDEPENDS_SH=1

 LIBRARY=${LIBRARY:-'@libmakepkgdir@'}

+source "$LIBRARY/lint_pkgbuild/fullpkgver.sh"
 source "$LIBRARY/lint_pkgbuild/pkgname.sh"
-source "$LIBRARY/lint_pkgbuild/pkgver.sh"
 source "$LIBRARY/util/message.sh"
 source "$LIBRARY/util/pkgbuild.sh"

@@ -43,12 +43,10 @@ lint_checkdepends() {

for checkdepend in "${checkdepends_list[@]}"; do
name=${checkdepend%%@(<|>|=|>=|<=)*}
-   # remove optional epoch in version specifier
-   ver=${checkdepend##$name@(<|>|=|>=|<=)?(+([0-9]):)}
lint_one_pkgname checkdepends "$name" || ret=1
-   if [[ $ver != $checkdepend ]]; then
-   # remove optional pkgrel in version specifier
-   check_pkgver "${ver%-+([0-9])?(.+([0-9]))}" 
checkdepends || ret=1
+   if [[ $name != $checkdepend ]]; then
+   ver=${checkdepend##$name@(<|>|=|>=|<=)}
+   check_fullpkgver "$ver" checkdepends || ret=1
fi
done

diff --git a/scripts/libmakepkg/lint_pkgbuild/conflicts.sh.in 
b/scripts/libmakepkg/lint_pkgbuild/conflicts.sh.in
index a18c25fa..b61459e1 100644
--- a/scripts/libmakepkg/lint_pkgbuild/conflicts.sh.in
+++ b/scripts/libmakepkg/lint_pkgbuild/conflicts.sh.in
@@ -23,8 +23,8 @@ LIBMAKEPKG_LINT_PKGBUILD_CONFLICTS_SH=1

 LIBRARY=${LIBRARY:-'@libmakepkgdir@'}

+source "$LIBRARY/lint_pkgbuild/fullpkgver.sh"
 source "$LIBRARY/lint_pkgbuild/pkgname.sh"
-source "$LIBRARY/lint_pkgbuild/pkgver.sh"
 source "$LIBRARY/util/message.sh"
 source "$LIBRARY/util/pkgbuild.sh"

@@ -43,12 +43,10 @@ lint_conflicts() {

for conflict in "${conflicts_list[@]}"; do
name=${conflict%%@(<|>|=|>=|<=)*}
-   # remove optional epoch in version specifier
-   ver=${conflict##$name@(<|>|=|>=|<=)?(+([0-9]):)}
lint_one_pkgname conflicts "$name" || ret=1
-   if [[ $ver != $conflict ]]; then
-   # remove optional pkgrel in version specifier
-   check_pkgver "${ver%-+([0-9])?(.+([0-9]))}" conflicts 
|| ret=1
+   if [[ $name != $conflict ]]; then
+   ver=${conflict##$name@(<|>|=|>=|<=)}
+   

[pacman-dev] [PATCH v2 0/3] makepkg: Improve lint_pkgbuild error messages for epoch/ver/rel

2018-08-09 Thread Luke Shumaker
From: Luke Shumaker 

The error messages that makepkg prints when encountering a bad
epoch/pkgver/pkgrel are often somewhat misleading.  These patchset
tries to improve that.  The behavior is intended to be unchanged,
other than what the messages say.

v2:
 - Don't skip lint_pkgrel if (( PKGVERFUNC )), I should have never
   included that bit in v1.
 - check_fullpkgver: Don't let rel strip ver down to nothing

Luke Shumaker (3):
  makepkg: Better error messages for versions in
(check,make,opt)depends/provides/conflicts
  makepkg: check_pkgrel: Don't say "decimal" in the error message
  makepkg: check_pkgver: Report what the bad pkgver is

 scripts/Makefile.am   |  1 +
 .../lint_pkgbuild/checkdepends.sh.in  | 10 ++--
 .../libmakepkg/lint_pkgbuild/conflicts.sh.in  | 10 ++--
 .../libmakepkg/lint_pkgbuild/depends.sh.in| 14 ++---
 scripts/libmakepkg/lint_pkgbuild/epoch.sh.in  | 10 +++-
 .../libmakepkg/lint_pkgbuild/fullpkgver.sh.in | 58 +++
 .../lint_pkgbuild/makedepends.sh.in   | 10 ++--
 .../libmakepkg/lint_pkgbuild/optdepends.sh.in | 10 ++--
 scripts/libmakepkg/lint_pkgbuild/pkgrel.sh.in | 15 +++--
 scripts/libmakepkg/lint_pkgbuild/pkgver.sh.in |  2 +-
 .../libmakepkg/lint_pkgbuild/provides.sh.in   | 10 ++--
 11 files changed, 106 insertions(+), 44 deletions(-)
 create mode 100644 scripts/libmakepkg/lint_pkgbuild/fullpkgver.sh.in

--
Happy hacking,
~ Luke Shumaker

2.18.0