Re: [pacman-dev] [PATCH v2] makepkg: print filenames and line numbers of references to $srcdir & $pkgdir in built package

2016-10-14 Thread Ivy Foster
On 14 Oct 2016, at 10:07 pm -0400, Andrew Gregory wrote:
> We're not very strict about this, but please try to keep the first
> line of the commit message fairly short, ideally around 50 characters.

Noted, thanks.

> On 10/14/16 at 08:21pm, ivy.fos...@gmail.com wrote:
> > From: Ivy Foster 
 > +mapfile -t refs < <(find "$pkgdir" -type f -exec grep -n 
 > "${!var}" {} +)

> For packages with just a single file this won't print the name of the
> matching file.  GNU grep has -H for this, but it's not POSIX.  What
> about including /dev/null as an argument to grep so that it always has
> more than one file?

Ah, you're quite right. I'll fiddle with that and resubmit tomorrow, then.

Ivy


Re: [pacman-dev] [PATCH v2] makepkg: print filenames and line numbers of references to $srcdir & $pkgdir in built package

2016-10-14 Thread Andrew Gregory
We're not very strict about this, but please try to keep the first
line of the commit message fairly short, ideally around 50 characters.

On 10/14/16 at 08:21pm, ivy.fos...@gmail.com wrote:
> From: Ivy Foster 
> 
> grep -n output is used to match format of compiler warnings.
> Since rewriting build_references() anyway, tweaked quoting.
> Implements FS#31558.
> 
> Signed-off-by: Ivy Foster 
> ---
>  scripts/libmakepkg/lint_package/build_references.sh.in | 16 +---
>  1 file changed, 9 insertions(+), 7 deletions(-)
> 
> diff --git a/scripts/libmakepkg/lint_package/build_references.sh.in 
> b/scripts/libmakepkg/lint_package/build_references.sh.in
> index 67c14e6..62f705c 100644
> --- a/scripts/libmakepkg/lint_package/build_references.sh.in
> +++ b/scripts/libmakepkg/lint_package/build_references.sh.in
> @@ -25,14 +25,16 @@ LIBRARY=${LIBRARY:-'@libmakepkgdir@'}
>  
>  source "$LIBRARY/util/message.sh"
>  
> -
>  lint_package_functions+=('warn_build_references')
>  
>  warn_build_references() {
> - if find "${pkgdir}" -type f -print0 | xargs -0 grep -q -I "${srcdir}" ; 
> then
> - warning "$(gettext "Package contains reference to %s")" 
> "\$srcdir"
> - fi
> - if find "${pkgdir}" -type f -print0 | xargs -0 grep -q -I 
> "${pkgdirbase}" ; then
> - warning "$(gettext "Package contains reference to %s")" 
> "\$pkgdir"
> - fi
> + local refs
> +
> + for var in srcdir pkgdir; do
> + mapfile -t refs < <(find "$pkgdir" -type f -exec grep -n 
> "${!var}" {} +)

For packages with just a single file this won't print the name of the
matching file.  GNU grep has -H for this, but it's not POSIX.  What
about including /dev/null as an argument to grep so that it always has
more than one file?

Also, unrelated to this patch, but we should be using grep -F since
paths can contain regular expression metacharacters.

> + if  [[ ${#refs} -gt 0 ]]; then
> + warning "$(gettext 'Package contains reference to %s')" 
> "\$$var"
> + printf '%s\n' "${refs[@]}" >&2
> + fi
> + done
>  }
> -- 
> 2.10.0


[pacman-dev] [PATCH v2] makepkg: print filenames and line numbers of references to $srcdir & $pkgdir in built package

2016-10-14 Thread ivy . foster
From: Ivy Foster 

grep -n output is used to match format of compiler warnings.
Since rewriting build_references() anyway, tweaked quoting.
Implements FS#31558.

Signed-off-by: Ivy Foster 
---
 scripts/libmakepkg/lint_package/build_references.sh.in | 16 +---
 1 file changed, 9 insertions(+), 7 deletions(-)

diff --git a/scripts/libmakepkg/lint_package/build_references.sh.in 
b/scripts/libmakepkg/lint_package/build_references.sh.in
index 67c14e6..62f705c 100644
--- a/scripts/libmakepkg/lint_package/build_references.sh.in
+++ b/scripts/libmakepkg/lint_package/build_references.sh.in
@@ -25,14 +25,16 @@ LIBRARY=${LIBRARY:-'@libmakepkgdir@'}
 
 source "$LIBRARY/util/message.sh"
 
-
 lint_package_functions+=('warn_build_references')
 
 warn_build_references() {
-   if find "${pkgdir}" -type f -print0 | xargs -0 grep -q -I "${srcdir}" ; 
then
-   warning "$(gettext "Package contains reference to %s")" 
"\$srcdir"
-   fi
-   if find "${pkgdir}" -type f -print0 | xargs -0 grep -q -I 
"${pkgdirbase}" ; then
-   warning "$(gettext "Package contains reference to %s")" 
"\$pkgdir"
-   fi
+   local refs
+
+   for var in srcdir pkgdir; do
+   mapfile -t refs < <(find "$pkgdir" -type f -exec grep -n 
"${!var}" {} +)
+   if  [[ ${#refs} -gt 0 ]]; then
+   warning "$(gettext 'Package contains reference to %s')" 
"\$$var"
+   printf '%s\n' "${refs[@]}" >&2
+   fi
+   done
 }
-- 
2.10.0


[pacman-dev] [PATCH] makepkg: print filenames and line numbers of references to $srcdir & $pkgdir in built package

2016-10-14 Thread ivy . foster
From: Ivy Foster 

grep -n output is used to match format of compiler warnings.
Since rewriting build_references() anyway, tweaked quoting.
Implements FS#31558.

Signed-off-by: Ivy Foster 
---
 scripts/libmakepkg/lint_package/build_references.sh.in | 15 +++
 1 file changed, 11 insertions(+), 4 deletions(-)

diff --git a/scripts/libmakepkg/lint_package/build_references.sh.in 
b/scripts/libmakepkg/lint_package/build_references.sh.in
index 67c14e6..32554b2 100644
--- a/scripts/libmakepkg/lint_package/build_references.sh.in
+++ b/scripts/libmakepkg/lint_package/build_references.sh.in
@@ -29,10 +29,17 @@ source "$LIBRARY/util/message.sh"
 lint_package_functions+=('warn_build_references')
 
 warn_build_references() {
-   if find "${pkgdir}" -type f -print0 | xargs -0 grep -q -I "${srcdir}" ; 
then
-   warning "$(gettext "Package contains reference to %s")" 
"\$srcdir"
+   local srcdir_refs pkgdir_refs
+
+   mapfile -t srcdir_refs < <(find "$pkgdir" -type f -print0 | xargs -0 
grep -n "$srcdir")
+   mapfile -t pkgdir_refs < <(find "$pkgdir" -type f -print0 | xargs -0 
grep -n "$pkgdirbase")
+
+   if  [[ ${#srcdir_refs} -gt 0 ]]; then
+   warning "$(gettext 'Package contains reference to %s')" 
'$srcdir'
+   printf '%s\n' "${srcdir_refs[@]}" >&2
fi
-   if find "${pkgdir}" -type f -print0 | xargs -0 grep -q -I 
"${pkgdirbase}" ; then
-   warning "$(gettext "Package contains reference to %s")" 
"\$pkgdir"
+   if [[ ${#pkgdir_refs} -gt 0 ]]; then
+   warning "$(gettext 'Package contains reference to %s')" 
'$pkgdir'
+   printf '%s\n' "${pkgdir_refs[@]}" >&2
fi
 }
-- 
2.10.0


[pacman-dev] [PATCH] doc/pacman.8.txt: improve description of -Qt

2016-10-14 Thread ivy . foster
From: Ivy Foster 

Though correct, the wording of the description of Query's
-t/--unrequired option was confusing. Closes FS#48144.

Signed-off-by: Ivy Foster 
---
 doc/pacman.8.txt | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/doc/pacman.8.txt b/doc/pacman.8.txt
index 2bafa41..0fa727e 100644
--- a/doc/pacman.8.txt
+++ b/doc/pacman.8.txt
@@ -338,10 +338,10 @@ Query Options (apply to '-Q')[[QO]]
with descriptions matching ALL of those terms are returned.
 
 *-t, \--unrequired*::
-   Restrict or filter output to packages not required or optionally 
required by
-   any currently installed package. Specify this option twice to only 
filter
-   packages that are direct dependencies (i.e. do not filter optional
-   dependencies).
+   Restrict or filter output to print only packages neither required nor
+   optionally required by any currently installed package. Specify this
+   option twice to include packages which are optionally, but not directly,
+   required by another package.
 
 *-u, \--upgrades*::
Restrict or filter output to packages that are out-of-date on the local
-- 
2.10.0


[pacman-dev] [PATCH v2] Parametrise the different ways in which the payload is reset

2016-10-14 Thread mar77i
In FS#43434, Downloads which fail and are restarted on a different server
will resume and may display a negative download speed. The payload's progress
in libalpm was not properly reset which ultimately caused terminal noise
because the line width calculation assumes positive download speeds.

This patch fixes the incomplete reset of the payload by mimicing what
be_sync.c:alpm_db_update() does over in sync.c:download_single_file().
dload.c:_alpm_dload_payload_reset() bundles and extends over the current
behavior by updating initial_size and prevprogress for this case.
This makes pacman reset the progress properly in the next invocation of the
callback and display positive download speeds.

Fixes FS#43434.

Signed-off-by: Martin Kühne 
---
 lib/libalpm/be_sync.c |  4 ++--
 lib/libalpm/dload.c   | 15 +++
 lib/libalpm/dload.h   |  2 +-
 lib/libalpm/sync.c|  4 +---
 4 files changed, 15 insertions(+), 10 deletions(-)

diff --git a/lib/libalpm/be_sync.c b/lib/libalpm/be_sync.c
index a836277..2425359 100644
--- a/lib/libalpm/be_sync.c
+++ b/lib/libalpm/be_sync.c
@@ -244,7 +244,7 @@ int SYMEXPORT alpm_db_update(int force, alpm_db_t *db)
payload.unlink_on_fail = 1;
 
ret = _alpm_download(, syncpath, NULL, _db_url);
-   _alpm_dload_payload_reset();
+   _alpm_dload_payload_reset(, 0);
updated = (updated || ret == 0);
 
if(ret != -1 && updated && (level & ALPM_SIG_DATABASE)) {
@@ -300,7 +300,7 @@ int SYMEXPORT alpm_db_update(int force, alpm_db_t *db)
sig_ret = _alpm_download(, syncpath, NULL, 
NULL);
/* errors_ok suppresses error messages, but not the 
return code */
sig_ret = payload.errors_ok ? 0 : sig_ret;
-   _alpm_dload_payload_reset();
+   _alpm_dload_payload_reset(, 0);
}
 
if(ret != -1 && sig_ret != -1) {
diff --git a/lib/libalpm/dload.c b/lib/libalpm/dload.c
index dc57c92..55ff41f 100644
--- a/lib/libalpm/dload.c
+++ b/lib/libalpm/dload.c
@@ -697,7 +697,7 @@ char SYMEXPORT *alpm_fetch_pkgurl(alpm_handle_t *handle, 
const char *url)
 
/* download the file */
ret = _alpm_download(, cachedir, _file, 
_pkg_url);
-   _alpm_dload_payload_reset();
+   _alpm_dload_payload_reset(, 0);
if(ret == -1) {
_alpm_log(handle, ALPM_LOG_WARNING, _("failed to 
download %s\n"), url);
free(final_file);
@@ -738,7 +738,7 @@ char SYMEXPORT *alpm_fetch_pkgurl(alpm_handle_t *handle, 
const char *url)
FREE(sig_final_file);
}
free(sig_filepath);
-   _alpm_dload_payload_reset();
+   _alpm_dload_payload_reset(, 0);
}
 
/* we should be able to find the file the second time around */
@@ -750,15 +750,22 @@ char SYMEXPORT *alpm_fetch_pkgurl(alpm_handle_t *handle, 
const char *url)
return filepath;
 }
 
-void _alpm_dload_payload_reset(struct dload_payload *payload)
+void _alpm_dload_payload_reset(struct dload_payload *payload, int allow_resume)
 {
ASSERT(payload, return);
 
+   FREE(payload->fileurl);
+   if(allow_resume) {
+   payload->initial_size += payload->prevprogress;
+   payload->prevprogress = 0;
+   payload->unlink_on_fail = 0;
+   return;
+   }
+
FREE(payload->remote_name);
FREE(payload->tempfile_name);
FREE(payload->destfile_name);
FREE(payload->content_disp_name);
-   FREE(payload->fileurl);
memset(payload, '\0', sizeof(*payload));
 }
 
diff --git a/lib/libalpm/dload.h b/lib/libalpm/dload.h
index 427c486..c9c94b8 100644
--- a/lib/libalpm/dload.h
+++ b/lib/libalpm/dload.h
@@ -46,7 +46,7 @@ struct dload_payload {
 #endif
 };
 
-void _alpm_dload_payload_reset(struct dload_payload *payload);
+void _alpm_dload_payload_reset(struct dload_payload *payload, int 
allow_resume);
 
 int _alpm_download(struct dload_payload *payload, const char *localpath,
char **final_file, const char **final_url);
diff --git a/lib/libalpm/sync.c b/lib/libalpm/sync.c
index 00b68d0..81900df 100644
--- a/lib/libalpm/sync.c
+++ b/lib/libalpm/sync.c
@@ -946,9 +946,7 @@ static int download_single_file(alpm_handle_t *handle, 
struct dload_payload *pay
EVENT(handle, );
return 0;
}
-
-   FREE(payload->fileurl);
-   payload->unlink_on_fail = 0;
+   _alpm_dload_payload_reset(payload, 1);
}
 
event.type = ALPM_EVENT_PKGDOWNLOAD_FAILED;
-- 
2.10.0