Re: [pacman-dev] [RFC v3 13/13] bacman: make gettext useful

2016-09-30 Thread Martin Kühne
Had to try this myself because I don't trust you on this for whatever reason:

$ set -- -a '1 2 3' -b; printf '<%s>\n' "$@"
<-a>
<1 2 3>
<-b>

$ set -- -a '1 2 3' -b; printf '<%s>\n' "$*"
<-a 1 2 3 -b>

Wow uh. So. My own expectation was that "1 2 3" would be split up too instead.
I'm not decided on which of these makepkg should do. I can submit the
implied makepkg patch and scan the project tree for other instances of
this.

cheers!
mar77i


Re: [pacman-dev] [RFC v3 06/13] paccache: streamline usage function

2016-09-30 Thread Gordian Edenhofer
On Fri, 2016-09-30 at 08:14 -0400, Dave Reisner wrote:
> On Fri, Sep 30, 2016 at 01:47:54PM +0200, Gordian Edenhofer wrote:
> > 
> > Signed-off-by: Gordian Edenhofer 
> > ---
> >  contrib/paccache.sh.in | 83 
> > --
> >  1 file changed, 53 insertions(+), 30 deletions(-)
> > 
> > diff --git a/contrib/paccache.sh.in b/contrib/paccache.sh.in
> > index 02fae52..78f566f 100644
> > --- a/contrib/paccache.sh.in
> > +++ b/contrib/paccache.sh.in
> > @@ -30,6 +30,17 @@ declaredelim=$'\n' keep=3 movedir= scanarch=
> >  QUIET=0
> >  USE_COLOR='y'
> >  
> > +# gettext initialization
> > +export TEXTDOMAIN='pacman'
> > +export TEXTDOMAINDIR='@localedir@'
> > +
> > +# Determine whether we have gettext; make it a no-op if we do not
> > +if ! type -p gettext >/dev/null; then
> > +   gettext() {
> > +   printf "%s\n" "$@"
> > +   }
> > +fi
> > +
> >  m4_include(../scripts/library/output_format.sh)
> >  m4_include(../scripts/library/parseopts.sh)
> >  
> > @@ -172,36 +183,48 @@ summarize() {
> >  }
> >  
> >  usage() {
> > -   cat < > -${myname} (pacman) v${myver}
> > -
> > -A flexible pacman cache cleaning utility.
> > -
> > -Usage: ${myname}  [options] [targets...]
> > -
> > -  Operations:
> > --d, --dryrun  perform a dry run, only finding
> > candidate packages.
> > --m, --move   move candidate packages to "dir".
> > --r, --remove  remove candidate packages.
> > -
> > -  Options:
> > --a, --arch  scan for "arch" (default: all
> > architectures).
> > --c, --cachedir   scan "dir" for packages. can be used
> > more than once.
> > -  (default: read from
> > @sysconfdir@/pacman.conf).
> > --f, --force   apply force to mv(1) and rm(1)
> > operations.
> > --h, --helpdisplay this help message and exit.
> > --i, --ignore    ignore "pkgs", comma-separated.
> > Alternatively, specify
> > -  "-" to read package names from stdin,
> > newline-
> > -  delimited.
> > --k, --keep   keep "num" of each package in the cache
> > (default: 3).
> > ---nocolor remove color from output.
> > --q, --quiet   minimize output
> > --u, --uninstalled target uninstalled packages.
> > --v, --verbose increase verbosity. specify up to 3
> > times.
> > --z, --nulluse null delimiters for candidate names
> > (only with -v
> > -  and -vv).
> > -
> > -EOF
> > +   printf "%s (pacman) %s\n" "$myname" "$myver"
> > +   echo
> > +   printf -- "$(gettext "A flexible pacman cache cleaning
> > utility")\n"
> > +   echo
> > +   printf -- "$(gettext "Usage: %s  [options]
> > [targets...]")\n" "$0"
> > +   echo
> > +   printf -- "$(gettext "Operations:")\n"
> > +   printf -- "  -d, --dryrun  "
> > +   printf -- "$(gettext "Perform a dry run, only finding
> > candidate packages")\n"
> > +   printf -- "  -m, --move   "
> > +   printf -- "$(gettext "Move candidate packages to
> > \"dir\"")\n"
> > +   printf -- "  -r, --remove  "
> > +   printf -- "$(gettext "Remove candidate packages")\n"
> > +   echo
> > +   printf -- "$(gettext "Options:")\n"
> > +   printf -- "  -a, --arch  "
> > +   printf -- "$(gettext "Scan for \"arch\" (default: all
> > architectures)")\n"
> > +   printf -- "  -c, --cachedir   "
> > +   printf -- "$(gettext "Scan \"dir\" for packages. Can be
> > used more than once.\n\
> > +   (default: read from %s).")\n"
> > "@sysconfdir@/pacman.conf"
> > +   printf -- "  -f, --force   "
> > +   printf -- "$(gettext "Apply force to mv(1) and rm(1)
> > operations")\n" "\$srcdir/"
> > +   printf -- "  -h, --help"
> > +   printf -- "$(gettext "Display this help message and
> > exit")\n"
> > +   printf -- "  -i, --ignore    "
> > +   printf -- "$(gettext "Ignore \"pkgs\", comma-separated.
> > Alternatively, specify\n\
> > +   \"-\" to read package names from
> > stdin, newline-\n\
> > +   delimited.")\n" "\$srcdir/"
> > +   printf -- "  -k, --keep   "
> > +   printf -- "$(gettext "Keep \"num\" of each package in the
> > cache (default: 3)")\n"
> > +   printf -- "  -q, --quiet   "
> > +   printf -- "$(gettext "Minimize output")\n"
> > +   printf -- "  -u, --uninstalled "
> > +   printf -- "$(gettext "Target uninstalled packages")\n"
> > +   printf -- "  -v, --verbose "
> > +   printf -- "$(gettext "Increase verbosity. specify up to 3
> > times.")\n"
> > +   printf -- "  -z, --null"
> > +   printf -- "$(gettext "Use null delimiters for candidate
> > names (only with -v\n\
> > +   and -vv)")\n"
> > +   printf -- "  --nocolor "
> > +   printf -- "$(gettext "Remove color from output")\n"
> > +   echo
> 
> I'm going to need convincing that this fits the definition of
> 

Re: [pacman-dev] [RFC v3 13/13] bacman: make gettext useful

2016-09-30 Thread Gordian Edenhofer
On Fri, 2016-09-30 at 08:14 -0400, Dave Reisner wrote:
> On Fri, Sep 30, 2016 at 01:48:01PM +0200, Gordian Edenhofer wrote:
> > 
> > Export TEXTDOMAIN and TEXTDOMAINDIR in order for the strings to be
> > translatable with gettext.
> > ---
> >  contrib/bacman.sh.in | 28 ++--
> >  1 file changed, 22 insertions(+), 6 deletions(-)
> > 
> > diff --git a/contrib/bacman.sh.in b/contrib/bacman.sh.in
> > index 39fbe99..cc243c9 100644
> > --- a/contrib/bacman.sh.in
> > +++ b/contrib/bacman.sh.in
> > @@ -32,6 +32,17 @@ QUIET=0
> >  # Required for fakeroot because options are shifted off the array.
> >  ARGS=("$@")
> >  
> > +# gettext initialization
> > +export TEXTDOMAIN='pacman'
> > +export TEXTDOMAINDIR='@localedir@'
> > +
> > +# Determine whether we have gettext; make it a no-op if we do not
> > +if ! type -p gettext >/dev/null; then
> > +   gettext() {
> > +   printf "%s\n" "$@"
> 
> Not sure if this is copypasted from somewhere, but it's wrong.
> Consider
> the output of:
> 
>   printf '%s\n' 1 2 3
> 
> vs.
> 
>   printf '%s\n' '1 2 3'
> 
> You probably wanted this to be: printf '%s\n' "$*"

Yes, this is indeed copy-pasted from makepkg [1] since I though it
would be properly scripted there.

> > +   }
> > +fi
> > +
> >  m4_include(../scripts/library/output_format.sh)
> >  m4_include(../scripts/library/parseopts.sh)
> >  
> > @@ -54,13 +65,18 @@ usage() {
> >     printf -- "$(gettext "Usage: %s [options]
> > ")\n" "$0"
> >     echo
> >     printf -- "$(gettext "Options:")\n"
> > -   printf -- "$(gettext "  -h, --help   Show this help
> > message and exit")\n"
> > -   printf -- "$(gettext "  -q, --quiet  Silence most of
> > the status reporting")\n"
> > -   printf -- "$(gettext "  -m, --nocolorDisable colorized
> > output messages")\n"
> > -   printf -- "$(gettext "  -o, --out   Write output to
> > specified directory (instead of \$PKGDEST)")\n"
> > -   printf -- "$(gettext "  --pacnew Package .pacnew
> > files")\n"
> > +   printf -- "  -h, --help   "
> > +   printf -- "$(gettext "Show this help message and exit")\n"
> 
> This splitting/wrapping doesn't really make me think that this is an
> improvement. Other patches are subjectively worse IMO -- particularly
> cases where the usage wraps onto multiple lines and you're adding
> arbitrary amounts of whitespace wrapping. It's hard to get right and
> I
> suspect it'll be broken in the future. There's a reason I used a
> heredoc
> for paccache's usage function. It's natural, reads easily, and is
> easy
> to extend.
> 
> Still wondering if we actually care about translations for contrib,
> or
> if we care about contrib at all.

I really like heredocs and initially submitted my bacman patch using
them for the very same reasons you mentioned. However I was advised to
follow the style from scripts like makepkg, repo-add etc.

[1] https://git.archlinux.org/pacman.git/tree/scripts/makepkg.sh.in#n12
26

signature.asc
Description: This is a digitally signed message part


Re: [pacman-dev] [RFC v3 06/13] paccache: streamline usage function

2016-09-30 Thread Dave Reisner
On Fri, Sep 30, 2016 at 01:47:54PM +0200, Gordian Edenhofer wrote:
> Signed-off-by: Gordian Edenhofer 
> ---
>  contrib/paccache.sh.in | 83 
> --
>  1 file changed, 53 insertions(+), 30 deletions(-)
> 
> diff --git a/contrib/paccache.sh.in b/contrib/paccache.sh.in
> index 02fae52..78f566f 100644
> --- a/contrib/paccache.sh.in
> +++ b/contrib/paccache.sh.in
> @@ -30,6 +30,17 @@ declaredelim=$'\n' keep=3 movedir= scanarch=
>  QUIET=0
>  USE_COLOR='y'
>  
> +# gettext initialization
> +export TEXTDOMAIN='pacman'
> +export TEXTDOMAINDIR='@localedir@'
> +
> +# Determine whether we have gettext; make it a no-op if we do not
> +if ! type -p gettext >/dev/null; then
> + gettext() {
> + printf "%s\n" "$@"
> + }
> +fi
> +
>  m4_include(../scripts/library/output_format.sh)
>  m4_include(../scripts/library/parseopts.sh)
>  
> @@ -172,36 +183,48 @@ summarize() {
>  }
>  
>  usage() {
> - cat < -${myname} (pacman) v${myver}
> -
> -A flexible pacman cache cleaning utility.
> -
> -Usage: ${myname}  [options] [targets...]
> -
> -  Operations:
> --d, --dryrun  perform a dry run, only finding candidate packages.
> --m, --move   move candidate packages to "dir".
> --r, --remove  remove candidate packages.
> -
> -  Options:
> --a, --arch  scan for "arch" (default: all architectures).
> --c, --cachedir   scan "dir" for packages. can be used more than 
> once.
> -  (default: read from @sysconfdir@/pacman.conf).
> --f, --force   apply force to mv(1) and rm(1) operations.
> --h, --helpdisplay this help message and exit.
> --i, --ignoreignore "pkgs", comma-separated. Alternatively, 
> specify
> -  "-" to read package names from stdin, newline-
> -  delimited.
> --k, --keep   keep "num" of each package in the cache (default: 
> 3).
> ---nocolor remove color from output.
> --q, --quiet   minimize output
> --u, --uninstalled target uninstalled packages.
> --v, --verbose increase verbosity. specify up to 3 times.
> --z, --nulluse null delimiters for candidate names (only with 
> -v
> -  and -vv).
> -
> -EOF
> + printf "%s (pacman) %s\n" "$myname" "$myver"
> + echo
> + printf -- "$(gettext "A flexible pacman cache cleaning utility")\n"
> + echo
> + printf -- "$(gettext "Usage: %s  [options] [targets...]")\n" 
> "$0"
> + echo
> + printf -- "$(gettext "Operations:")\n"
> + printf -- "  -d, --dryrun  "
> + printf -- "$(gettext "Perform a dry run, only finding candidate 
> packages")\n"
> + printf -- "  -m, --move   "
> + printf -- "$(gettext "Move candidate packages to \"dir\"")\n"
> + printf -- "  -r, --remove  "
> + printf -- "$(gettext "Remove candidate packages")\n"
> + echo
> + printf -- "$(gettext "Options:")\n"
> + printf -- "  -a, --arch  "
> + printf -- "$(gettext "Scan for \"arch\" (default: all 
> architectures)")\n"
> + printf -- "  -c, --cachedir   "
> + printf -- "$(gettext "Scan \"dir\" for packages. Can be used more than 
> once.\n\
> + (default: read from %s).")\n" 
> "@sysconfdir@/pacman.conf"
> + printf -- "  -f, --force   "
> + printf -- "$(gettext "Apply force to mv(1) and rm(1) operations")\n" 
> "\$srcdir/"
> + printf -- "  -h, --help"
> + printf -- "$(gettext "Display this help message and exit")\n"
> + printf -- "  -i, --ignore"
> + printf -- "$(gettext "Ignore \"pkgs\", comma-separated. Alternatively, 
> specify\n\
> + \"-\" to read package names from stdin, 
> newline-\n\
> + delimited.")\n" "\$srcdir/"
> + printf -- "  -k, --keep   "
> + printf -- "$(gettext "Keep \"num\" of each package in the cache 
> (default: 3)")\n"
> + printf -- "  -q, --quiet   "
> + printf -- "$(gettext "Minimize output")\n"
> + printf -- "  -u, --uninstalled "
> + printf -- "$(gettext "Target uninstalled packages")\n"
> + printf -- "  -v, --verbose "
> + printf -- "$(gettext "Increase verbosity. specify up to 3 times.")\n"
> + printf -- "  -z, --null"
> + printf -- "$(gettext "Use null delimiters for candidate names (only 
> with -v\n\
> + and -vv)")\n"
> + printf -- "  --nocolor "
> + printf -- "$(gettext "Remove color from output")\n"
> + echo

I'm going to need convincing that this fits the definition of
"streamlined" compared to the current implementation.

  stream·line
  /ˈstrēmˌlīn/

  1.  design or provide with a form that presents very little resistance to a
  flow of air or water, increasing speed and ease of movement.
  2.  

[pacman-dev] [RFC v3 13/13] bacman: make gettext useful

2016-09-30 Thread Gordian Edenhofer
Export TEXTDOMAIN and TEXTDOMAINDIR in order for the strings to be
translatable with gettext.
---
 contrib/bacman.sh.in | 28 ++--
 1 file changed, 22 insertions(+), 6 deletions(-)

diff --git a/contrib/bacman.sh.in b/contrib/bacman.sh.in
index 39fbe99..cc243c9 100644
--- a/contrib/bacman.sh.in
+++ b/contrib/bacman.sh.in
@@ -32,6 +32,17 @@ QUIET=0
 # Required for fakeroot because options are shifted off the array.
 ARGS=("$@")
 
+# gettext initialization
+export TEXTDOMAIN='pacman'
+export TEXTDOMAINDIR='@localedir@'
+
+# Determine whether we have gettext; make it a no-op if we do not
+if ! type -p gettext >/dev/null; then
+   gettext() {
+   printf "%s\n" "$@"
+   }
+fi
+
 m4_include(../scripts/library/output_format.sh)
 m4_include(../scripts/library/parseopts.sh)
 
@@ -54,13 +65,18 @@ usage() {
printf -- "$(gettext "Usage: %s [options] ")\n" "$0"
echo
printf -- "$(gettext "Options:")\n"
-   printf -- "$(gettext "  -h, --help   Show this help message and 
exit")\n"
-   printf -- "$(gettext "  -q, --quiet  Silence most of the status 
reporting")\n"
-   printf -- "$(gettext "  -m, --nocolorDisable colorized output 
messages")\n"
-   printf -- "$(gettext "  -o, --out   Write output to specified 
directory (instead of \$PKGDEST)")\n"
-   printf -- "$(gettext "  --pacnew Package .pacnew files")\n"
+   printf -- "  -h, --help   "
+   printf -- "$(gettext "Show this help message and exit")\n"
+   printf -- "  -q, --quiet  "
+   printf -- "$(gettext "Silence most of the status reporting")\n"
+   printf -- "  -m, --nocolor"
+   printf -- "$(gettext "Disable colorized output messages")\n"
+   printf -- "  -o, --out   "
+   printf -- "$(gettext "Write output to specified directory (instead of 
%s)")\n" "\$PKGDEST"
+   printf -- "  --pacnew "
+   printf -- "$(gettext "Package .pacnew files")\n"
echo
-   printf -- "$(gettext "Examples:")" 
+   printf -- "$(gettext "Examples:")"
printf -- "%s linux-headers\n" "$myname"
printf -- "%s -o ~/packages libarchive\n" "$myname"
printf -- "%s --nocolor --pacnew gzip make binutils\n" "$myname"
-- 
2.10.0


[pacman-dev] [RFC v3 12/13] rankmirrors: streamline usage function

2016-09-30 Thread Gordian Edenhofer
Signed-off-by: Gordian Edenhofer 
---
 contrib/rankmirrors.sh.in | 48 ++-
 1 file changed, 35 insertions(+), 13 deletions(-)

diff --git a/contrib/rankmirrors.sh.in b/contrib/rankmirrors.sh.in
index 0988fe9..e1e0503 100644
--- a/contrib/rankmirrors.sh.in
+++ b/contrib/rankmirrors.sh.in
@@ -24,23 +24,45 @@ trap finaloutput INT
 declare -r myname='rankmirrors'
 declare -r myver='@PACKAGE_VERSION@'
 
+# gettext initialization
+export TEXTDOMAIN='pacman'
+export TEXTDOMAINDIR='@localedir@'
+
+# Determine whether we have gettext; make it a no-op if we do not
+if ! type -p gettext >/dev/null; then
+   gettext() {
+   printf "%s\n" "$@"
+   }
+fi
+
+m4_include(../scripts/library/parseopts.sh)
+
 usage() {
-   echo "${myname} (pacman) v${myver}"
+   printf "%s (pacman) %s\n" "$myname" "$myver"
+   echo
+   printf -- "$(gettext "\
+Ranks pacman mirrors by their connection and opening speed. Pacman mirror\n\
+files are located in %s. It can also rank one mirror if the URL is\n\
+provided")\n" "@sysconfdir@/pacman.d/"
echo
-   echo "Ranks pacman mirrors by their connection and opening speed. 
Pacman mirror"
-   echo "files are located in @sysconfdir@/pacman.d/. It can also rank one 
mirror if the URL is"
-   echo "provided."
+   printf -- "$(gettext "Usage: %s [options] ")\n" "$0"
echo
-   echo "Usage: ${myname} [options] MIRRORFILE | URL"
+   printf -- "$(gettext "Options:")\n"
+   printf -- "  -h, --help "
+   printf -- "$(gettext "Show this help message and exit")\n"
+   printf -- "  -n  "
+   printf -- "$(gettext "Number of servers to output, 0 for all")\n"
+   printf -- "  -t, --times"
+   printf -- "$(gettext "Only output mirrors and their response times")\n"
+   printf -- "  -u, --url  "
+   printf -- "$(gettext "Test a specific URL")\n"
+   printf -- "  -v, --verbose  "
+   printf -- "$(gettext "Be verbose in ouptut")\n"
+   printf -- "  -r, --repo   "
+   printf -- "$(gettext "Specify a repository name instead of guessing")\n"
+   printf -- "  --version  "
+   printf -- "$(gettext "Show program's version number and exit")\n"
echo
-   echo "Options:"
-   echo "  --version  show program's version number and exit"
-   echo "  -h, --help show this help message and exit"
-   echo "  -n NUM number of servers to output, 0 for all"
-   echo "  -t, --timesonly output mirrors and their response times"
-   echo "  -u, --url  test a specific URL"
-   echo "  -v, --verbose  be verbose in ouptut"
-   echo "  -r, --repo specify a repository name instead of guessing"
 }
 
 version() {
-- 
2.10.0


[pacman-dev] [RFC v3 09/13] paclog-pkglist: streamline usage function

2016-09-30 Thread Gordian Edenhofer
Signed-off-by: Gordian Edenhofer 
---
 contrib/paclog-pkglist.sh.in | 25 ++---
 1 file changed, 18 insertions(+), 7 deletions(-)

diff --git a/contrib/paclog-pkglist.sh.in b/contrib/paclog-pkglist.sh.in
index 847b389..065210c 100644
--- a/contrib/paclog-pkglist.sh.in
+++ b/contrib/paclog-pkglist.sh.in
@@ -20,20 +20,31 @@
 declare -r myname='paclog-pkglist'
 declare -r myver='@PACKAGE_VERSION@'
 
-export TEXTDOMAIN='pacman'
-export TEXTDOMAINDIR='/usr/share/locale'
 declare logfile=${1:-@localstatedir@/log/pacman.log}
 
+# gettext initialization
+export TEXTDOMAIN='pacman'
+export TEXTDOMAINDIR='@localedir@'
+
+# Determine whether we have gettext; make it a no-op if we do not
+if ! type -p gettext >/dev/null; then
+   gettext() {
+   printf "%s\n" "$@"
+   }
+fi
+
 usage() {
-   printf "%s (pacman) v%s\n" "${myname}" "${myver}"
+   printf "%s (pacman) %s\n" "$myname" "$myver"
+   echo
+   printf -- "$(gettext "Parse a log file into a list of currently 
installed packages")\n"
echo
-   echo "Parse a log file into a list of currently installed packages"
+   printf -- "$(gettext "Usage: %s [path to pacman log]")\n" "$0"
echo
-   printf "Usage: %s [path to pacman log]\n" "${myname}"
+   printf -- "$(gettext "Examples:")"
+   printf -- "%s @localstatedir@/log/pacman.log\n" "$myname"
echo
-   printf "Example: %s @localstatedir@/log/pacman.log\n" "${myname}"
+   printf -- "$(gettext "Defaults to: %s")\n" 
"@localstatedir@/log/pacman.log"
echo
-   echo 'Defaults to: @localstatedir@/log/pacman.log'
 }
 
 version() {
-- 
2.10.0


[pacman-dev] [RFC v3 02/13] pacdiff: streamline option syntax with makepkg

2016-09-30 Thread Gordian Edenhofer
Allow for '-m' as abbreviation for '--nocolor'.

Signed-off-by: Gordian Edenhofer 
---
 contrib/pacdiff.sh.in | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/contrib/pacdiff.sh.in b/contrib/pacdiff.sh.in
index cd93164..3394993 100644
--- a/contrib/pacdiff.sh.in
+++ b/contrib/pacdiff.sh.in
@@ -47,7 +47,7 @@ Search Options: select one (default: --pacmandb)
 
 General Options:
   -o/--output   print files instead of merging them
-  --nocolor remove colors from output
+  -m/--nocolor  remove colors from output
 
 Environment Variables:
   DIFFPROG  override the merge program: (default: 'vim -d')
@@ -96,7 +96,7 @@ cmd() {
 }
 
 # Parse arguments
-OPT_SHORT='lfpoVh'
+OPT_SHORT='lfpomVh'
 OPT_LONG=('locate' 'find' 'pacmandb' 'output' 'nocolor' 'version' 'help')
 if ! parseopts "$OPT_SHORT" "${OPT_LONG[@]}" -- "$@"; then
usage
@@ -115,7 +115,7 @@ while :; do
USE_PACDB=1;;
-o|--output)
OUTPUTONLY=1;;
-   --nocolor)
+   -m|--nocolor)
USE_COLOR='n';;
-V|--version)
version
-- 
2.10.0


[pacman-dev] [RFC v3 11/13] updpkgsums: streamline usage function

2016-09-30 Thread Gordian Edenhofer
Signed-off-by: Gordian Edenhofer 
---
 contrib/updpkgsums.sh.in | 35 ++-
 1 file changed, 26 insertions(+), 9 deletions(-)

diff --git a/contrib/updpkgsums.sh.in b/contrib/updpkgsums.sh.in
index c571d29..132c192 100644
--- a/contrib/updpkgsums.sh.in
+++ b/contrib/updpkgsums.sh.in
@@ -22,20 +22,37 @@ shopt -s extglob
 declare -r myname='updpkgsums'
 declare -r myver='@PACKAGE_VERSION@'
 
+# gettext initialization
+export TEXTDOMAIN='pacman'
+export TEXTDOMAINDIR='@localedir@'
+
+# Determine whether we have gettext; make it a no-op if we do not
+if ! type -p gettext >/dev/null; then
+   gettext() {
+   printf "%s\n" "$@"
+   }
+fi
+
 usage() {
-   printf "%s (pacman) v%s\n" "${myname}" "${myver}"
+   printf "%s (pacman) %s\n" "$myname" "$myver"
+   echo
+   printf -- "$(gettext "\
+%s will perform an in place update of the checksums in the\n\
+path specified by [build file], defaulting to PKGBUILD in the current\n\
+working directory")\n" "$myname"
echo
-   printf "%s will perform an in place update of the checksums in the\n" 
"${myname}"
-   echo "path specified by [build file], defaulting to PKGBUILD in the 
current"
-   echo "working directory."
+   printf -- "$(gettext "Usage: %s [options] [build file]")\n" "$0"
echo
-   printf "Usage: %s [options] [build file]\n" "${myname}"
+   printf -- "$(gettext "Options:")\n"
+   printf -- "  -h, --help"
+   printf -- "$(gettext "Display this help message and exit")\n"
+   printf -- "  -V, --version "
+   printf -- "$(gettext "Display version information and exit")\n"
echo
-   echo "-h, --helpdisplay this help message and exit"
-   echo "-V, --version display version information and exit"
+   printf -- "$(gettext "These options can be passed to makepkg:")\n"
+   printf -- "  -m, --nocolor "
+   printf -- "$(gettext "Disable colorized output messages")\n"
echo
-   echo "These options can be passed to makepkg:"
-   echo "-m, --nocolor disable colorized output messages"
 }
 
 version() {
-- 
2.10.0


[pacman-dev] [RFC v3 10/13] pacscripts: streamline usage function

2016-09-30 Thread Gordian Edenhofer
Signed-off-by: Gordian Edenhofer 
---
 contrib/pacscripts.sh.in | 31 +++
 1 file changed, 23 insertions(+), 8 deletions(-)

diff --git a/contrib/pacscripts.sh.in b/contrib/pacscripts.sh.in
index 4a1e0c5..0c5e926 100644
--- a/contrib/pacscripts.sh.in
+++ b/contrib/pacscripts.sh.in
@@ -27,6 +27,17 @@ set -o errexit
 declare -r myname='pacscripts'
 declare -r myver='@PACKAGE_VERSION@'
 
+# gettext initialization
+export TEXTDOMAIN='pacman'
+export TEXTDOMAINDIR='@localedir@'
+
+# Determine whether we have gettext; make it a no-op if we do not
+if ! type -p gettext >/dev/null; then
+   gettext() {
+   printf "%s\n" "$@"
+   }
+fi
+
 conf="@sysconfdir@/pacman.conf"
 
 if [ ! -r "$conf" ]; then
@@ -45,18 +56,22 @@ error() {
 }
 
 usage() {
-   echo "${myname} (pacman) v${myver}"
+   printf "%s (pacman) %s\n" "$myname" "$myver"
+   echo
+   printf -- "$(gettext "Prints the {pre,post}_{install,remove,upgrade} 
scripts of a given package")\n"
echo
-   echo "Prints the {pre,post}_{install,remove,upgrade} scripts of a given 
package."
+   printf -- "$(gettext "Usage: %s ")\n" "$0"
echo
-   echo "Usage: ${myname} "
+   printf -- "$(gettext "Options:")\n"
+   printf -- "  -h, --help "
+   printf -- "$(gettext "Print this help message")\n"
+   printf -- "  -v, --version  "
+   printf -- "$(gettext "Print program name and version")\n"
echo
-   echo " Options:"
-   echo "  -h, --help Print this help message"
-   echo "  -v, --version  Print program name and version"
+   printf -- "$(gettext "Examples:")"
+   printf -- "  %s gconf-editor\n" "$myname"
+   printf -- "  %s gconf-editor-3.0.1-3-x86_64.pkg.tar.xz\n" "$myname"
echo
-   echo "Example: ${myname} gconf-editor"
-   echo "Example: ${myname} gconf-editor-3.0.1-3-x86_64.pkg.tar.xz"
 }
 
 version() {
-- 
2.10.0


[pacman-dev] [RFC v3 06/13] paccache: streamline usage function

2016-09-30 Thread Gordian Edenhofer
Signed-off-by: Gordian Edenhofer 
---
 contrib/paccache.sh.in | 83 --
 1 file changed, 53 insertions(+), 30 deletions(-)

diff --git a/contrib/paccache.sh.in b/contrib/paccache.sh.in
index 02fae52..78f566f 100644
--- a/contrib/paccache.sh.in
+++ b/contrib/paccache.sh.in
@@ -30,6 +30,17 @@ declaredelim=$'\n' keep=3 movedir= scanarch=
 QUIET=0
 USE_COLOR='y'
 
+# gettext initialization
+export TEXTDOMAIN='pacman'
+export TEXTDOMAINDIR='@localedir@'
+
+# Determine whether we have gettext; make it a no-op if we do not
+if ! type -p gettext >/dev/null; then
+   gettext() {
+   printf "%s\n" "$@"
+   }
+fi
+
 m4_include(../scripts/library/output_format.sh)
 m4_include(../scripts/library/parseopts.sh)
 
@@ -172,36 +183,48 @@ summarize() {
 }
 
 usage() {
-   cat < [options] [targets...]
-
-  Operations:
--d, --dryrun  perform a dry run, only finding candidate packages.
--m, --move   move candidate packages to "dir".
--r, --remove  remove candidate packages.
-
-  Options:
--a, --arch  scan for "arch" (default: all architectures).
--c, --cachedir   scan "dir" for packages. can be used more than once.
-  (default: read from @sysconfdir@/pacman.conf).
--f, --force   apply force to mv(1) and rm(1) operations.
--h, --helpdisplay this help message and exit.
--i, --ignoreignore "pkgs", comma-separated. Alternatively, 
specify
-  "-" to read package names from stdin, newline-
-  delimited.
--k, --keep   keep "num" of each package in the cache (default: 3).
---nocolor remove color from output.
--q, --quiet   minimize output
--u, --uninstalled target uninstalled packages.
--v, --verbose increase verbosity. specify up to 3 times.
--z, --nulluse null delimiters for candidate names (only with -v
-  and -vv).
-
-EOF
+   printf "%s (pacman) %s\n" "$myname" "$myver"
+   echo
+   printf -- "$(gettext "A flexible pacman cache cleaning utility")\n"
+   echo
+   printf -- "$(gettext "Usage: %s  [options] [targets...]")\n" 
"$0"
+   echo
+   printf -- "$(gettext "Operations:")\n"
+   printf -- "  -d, --dryrun  "
+   printf -- "$(gettext "Perform a dry run, only finding candidate 
packages")\n"
+   printf -- "  -m, --move   "
+   printf -- "$(gettext "Move candidate packages to \"dir\"")\n"
+   printf -- "  -r, --remove  "
+   printf -- "$(gettext "Remove candidate packages")\n"
+   echo
+   printf -- "$(gettext "Options:")\n"
+   printf -- "  -a, --arch  "
+   printf -- "$(gettext "Scan for \"arch\" (default: all 
architectures)")\n"
+   printf -- "  -c, --cachedir   "
+   printf -- "$(gettext "Scan \"dir\" for packages. Can be used more than 
once.\n\
+   (default: read from %s).")\n" 
"@sysconfdir@/pacman.conf"
+   printf -- "  -f, --force   "
+   printf -- "$(gettext "Apply force to mv(1) and rm(1) operations")\n" 
"\$srcdir/"
+   printf -- "  -h, --help"
+   printf -- "$(gettext "Display this help message and exit")\n"
+   printf -- "  -i, --ignore"
+   printf -- "$(gettext "Ignore \"pkgs\", comma-separated. Alternatively, 
specify\n\
+   \"-\" to read package names from stdin, 
newline-\n\
+   delimited.")\n" "\$srcdir/"
+   printf -- "  -k, --keep   "
+   printf -- "$(gettext "Keep \"num\" of each package in the cache 
(default: 3)")\n"
+   printf -- "  -q, --quiet   "
+   printf -- "$(gettext "Minimize output")\n"
+   printf -- "  -u, --uninstalled "
+   printf -- "$(gettext "Target uninstalled packages")\n"
+   printf -- "  -v, --verbose "
+   printf -- "$(gettext "Increase verbosity. specify up to 3 times.")\n"
+   printf -- "  -z, --null"
+   printf -- "$(gettext "Use null delimiters for candidate names (only 
with -v\n\
+   and -vv)")\n"
+   printf -- "  --nocolor "
+   printf -- "$(gettext "Remove color from output")\n"
+   echo
 }
 
 version() {
-- 
2.10.0


[pacman-dev] [RFC v3 05/13] checkupdates: streamline usage function

2016-09-30 Thread Gordian Edenhofer
Signed-off-by: Gordian Edenhofer 
---
 contrib/checkupdates.sh.in | 20 
 1 file changed, 16 insertions(+), 4 deletions(-)

diff --git a/contrib/checkupdates.sh.in b/contrib/checkupdates.sh.in
index ff62891..40a13ec 100644
--- a/contrib/checkupdates.sh.in
+++ b/contrib/checkupdates.sh.in
@@ -21,17 +21,29 @@
 declare -r myname='checkupdates'
 declare -r myver='@PACKAGE_VERSION@'
 
+# gettext initialization
+export TEXTDOMAIN='pacman'
+export TEXTDOMAINDIR='@localedir@'
+
+# Determine whether we have gettext; make it a no-op if we do not
+if ! type -p gettext >/dev/null; then
+   gettext() {
+   printf "%s\n" "$@"
+   }
+fi
+
 m4_include(../scripts/library/output_format.sh)
 m4_include(../scripts/library/term_colors.sh)
 
 if (( $# > 0 )); then
-   echo "${myname} (pacman) v${myver}"
+   printf "%s (pacman) %s\n" "$myname" "$myver"
+   echo
+   printf -- "$(gettext "Safely print a list of pending updates")\n"
echo
-   echo "Safely print a list of pending updates"
+   printf -- "$(gettext "Usage: %s")\n" "$0"
echo
-   echo "Usage: ${myname}"
+   printf -- "$(gettext "Note: Export the "%s" variable to change the path 
of the temporary database.")\n" "CHECKUPDATES_DB"
echo
-   echo 'Note: Export the "CHECKUPDATES_DB" variable to change the path of 
the temporary database.'
exit 0
 fi
 
-- 
2.10.0


[pacman-dev] [RFC v3 04/13] contrib: support localedir config in Makefile

2016-09-30 Thread Gordian Edenhofer
Signed-off-by: Gordian Edenhofer 
---
 contrib/Makefile.am | 1 +
 1 file changed, 1 insertion(+)

diff --git a/contrib/Makefile.am b/contrib/Makefile.am
index 897cd85..0754c0d 100644
--- a/contrib/Makefile.am
+++ b/contrib/Makefile.am
@@ -60,6 +60,7 @@ REAL_PACKAGE_VERSION = $(PACKAGE_VERSION)
 endif
 
 edit = sed \
+   -e 's|@localedir[@]|$(localedir)|g' \
-e 's|@sysconfdir[@]|$(sysconfdir)|g' \
-e 's|@localstatedir[@]|$(localstatedir)|g' \
-e 's|@PACKAGE_VERSION[@]|$(REAL_PACKAGE_VERSION)|g' \
-- 
2.10.0


[pacman-dev] [RFC v3 07/13] pacdiff: streamline usage function

2016-09-30 Thread Gordian Edenhofer
Signed-off-by: Gordian Edenhofer 
---
 contrib/pacdiff.sh.in | 67 ---
 1 file changed, 42 insertions(+), 25 deletions(-)

diff --git a/contrib/pacdiff.sh.in b/contrib/pacdiff.sh.in
index 3394993..b9b15b8 100644
--- a/contrib/pacdiff.sh.in
+++ b/contrib/pacdiff.sh.in
@@ -29,35 +29,52 @@ USE_COLOR='y'
 declare -a oldsaves
 declare -i USE_FIND=0 USE_LOCATE=0 USE_PACDB=0 OUTPUTONLY=0
 
+# gettext initialization
+export TEXTDOMAIN='pacman'
+export TEXTDOMAINDIR='@localedir@'
+
+# Determine whether we have gettext; make it a no-op if we do not
+if ! type -p gettext >/dev/null; then
+   gettext() {
+   printf "%s\n" "$@"
+   }
+fi
+
 m4_include(../scripts/library/output_format.sh)
 m4_include(../scripts/library/parseopts.sh)
 
 usage() {
-   cat < [options]")\n" "$0"
+   echo
+   printf -- "$(gettext "Search Options:")\n"
+   printf -- "  -l, --locate  "
+   printf -- "$(gettext "Scan using locate")\n"
+   printf -- "  -f, --find"
+   printf -- "$(gettext "Scan using find")\n"
+   printf -- "  -p, --pacmandb"
+   printf -- "$(gettext "Scan active config files from pacman database")\n"
+   echo
+   printf -- "$(gettext "Options:")\n"
+   printf -- "  -o, --output  "
+   printf -- "$(gettext "Print files instead of merging them")\n"
+   printf -- "  -m, --nocolor "
+   printf -- "$(gettext "Remove colors from output")\n"
+   echo
+   printf -- "$(gettext "Environment Variables:")\n"
+   printf -- "  DIFFPROG  "
+   printf -- "$(gettext "Override the merge program: (default: '%s')")\n" 
"vim -d"
+   printf -- "  DIFFSEARCHPATH"
+   printf -- "$(gettext "Override the search path. (only when using 
find)\n\
+   (default: %s)")\n" "/etc"
+   echo
+   printf -- "$(gettext "Examples:")"
+   printf -- "DIFFPROG=meld DIFFSEARCHPATH=\"/boot /etc /usr\" %s\n" 
"$myname"
+   printf -- "%s --output --locate\n" "$myname"
+   echo
 }
 
 version() {
-- 
2.10.0


[pacman-dev] [RFC v3 08/13] paclist: streamline usage function

2016-09-30 Thread Gordian Edenhofer
Signed-off-by: Gordian Edenhofer 
---
 contrib/paclist.sh.in | 17 ++---
 1 file changed, 10 insertions(+), 7 deletions(-)

diff --git a/contrib/paclist.sh.in b/contrib/paclist.sh.in
index f4fd540..47589f7 100644
--- a/contrib/paclist.sh.in
+++ b/contrib/paclist.sh.in
@@ -20,24 +20,27 @@
 declare -r myname='paclist'
 declare -r myver='@PACKAGE_VERSION@'
 
+# gettext initialization
 export TEXTDOMAIN='pacman'
-export TEXTDOMAINDIR='/usr/share/locale'
+export TEXTDOMAINDIR='@localedir@'
 
 # determine whether we have gettext; make it a no-op if we do not
-if ! type gettext &>/dev/null; then
+if ! type -p gettext >/dev/null; then
gettext() {
-   echo "$@"
+   printf "%s\n" "$@"
}
 fi
 
 usage() {
-   printf "%s (pacman) v%s\n" "${myname}" "${myver}"
+   printf "%s (pacman) %s\n" "$myname" "$myver"
echo
-   printf "List all packages installed from a given repository\n" 
"${myname}"
+   printf -- "$(gettext "List all packages installed from a given 
repository")\n"
echo
-   printf "Usage: %s \n" "${myname}"
+   printf -- "$(gettext "Usage: %s ")\n" "$0"
+   echo
+   printf -- "$(gettext "Examples:")"
+   printf -- "%s testing\n" "$myname"
echo
-   printf "Example: %s testing\n" "${myname}"
 }
 
 version() {
-- 
2.10.0


Re: [pacman-dev] [PATCH 00/11] Streamline syntax of contrib scripts

2016-09-30 Thread Gordian Edenhofer
On Thu, 2016-09-29 at 09:56 -0400, Dave Reisner wrote:
> On Thu, Sep 29, 2016 at 03:30:30PM +0200, Gordian Edenhofer wrote:
> > 
> > On Thu, 2016-09-29 at 09:04 -0400, Dave Reisner wrote:
> > > 
> > > On Thu, Sep 29, 2016 at 12:23:00PM +0200, Gordian Edenhofer
> > > wrote:
> > > > 
> > > > 
> > > > Reorganize scripts in contrib to fit the syntax and style of
> > > > makepkg.
> > > > Unify multiple different approaches to e.g. write a usage
> > > > function,
> > > > handle
> > > > options and differences in naming schemas for options.
> > > 
> > > Again, you're still putting flag names in the translatable
> > > strings.
> > > This
> > > will only ever end badly.
> > 
> > It has worked great for makepkg, see the git repo for dozens of
> > examples [1].
> > 
> > [1] https://git.archlinux.org/pacman.git/tree/scripts/makepkg.sh.in
> > #n11
> > 66
> 
> Has it worked great?
> 
> - id.po contains --noprapare instead of --noprepare
> - da.po contains --finer instead of --finger
> - sv.po contains --inout instead of --input
> 
> Repeating this mistake of allowing flags to be translated is purely
> cargo-cult nonsense. Please don't do it.

Ok, I will resubmit a new version with non-translatable flags.

signature.asc
Description: This is a digitally signed message part


Re: [pacman-dev] [PATCH] Give a "success!" message on database check

2016-09-30 Thread Johannes Löthberg

On 29/09, Allan McRae wrote:

On 29/09/16 05:29, Patrick Eigensatz wrote:

Ps:  Is it possible to tell git send-email to reply to the message with
this ID?



--in-reply-to=

(although I am fairly sure no-one does that...)


Lots of people use it, and quite a few patches recently sent to this ML 
has a proper reply-to header.


--
Sincerely,
 Johannes Löthberg
 PGP Key ID: 0x50FB9B273A9D0BB5
 https://theos.kyriasis.com/~kyrias/


signature.asc
Description: PGP signature