[pacman-dev] [PATCH v3] libmakepkg: add optional argument support to parseopts

2019-10-23 Thread Ethan Sommer
Adds a "?" suffix that can be used to indicate that an option's argument is
optional.

This allows options to have a default behaviour when the user doesn't
specify one, e.g.: --color=[when] being able to behave like --color=auto
when only --color is passed

Options with optional arguments given on the command line will be returned
in the form "--opt=optarg" and "-o=optarg". Despite that not being the
syntax for passing an argument with a shortopt (trying to pass -o=foo
would make -o's argument "=foo"), this is done to allow the caller to split
the option and its optarg easily

Signed-off-by: Ethan Sommer 
---
 scripts/libmakepkg/util/parseopts.sh.in | 116 +++-
 test/scripts/parseopts_test.sh  |  12 ++-
 2 files changed, 83 insertions(+), 45 deletions(-)

diff --git a/scripts/libmakepkg/util/parseopts.sh.in 
b/scripts/libmakepkg/util/parseopts.sh.in
index c056cb1e..42540438 100644
--- a/scripts/libmakepkg/util/parseopts.sh.in
+++ b/scripts/libmakepkg/util/parseopts.sh.in
@@ -18,16 +18,23 @@
 #   along with this program.  If not, see .
 #
 # A getopt_long-like parser which portably supports longopts and
-# shortopts with some GNU extensions. It does not allow for options
-# with optional arguments. For both short and long opts, options
-# requiring an argument should be suffixed with a colon. After the
-# first argument containing the short opts, any number of valid long
-# opts may be be passed. The end of the options delimiter must then be
-# added, followed by the user arguments to the calling program.
+# shortopts with some GNU extensions. For both short and long opts,
+# options requiring an argument should be suffixed with a colon, and
+# options with optional arguments should be suffixed with a question
+# mark. After the first argument containing the short opts, any number
+# of valid long opts may be be passed. The end of the options delimiter
+# must then be added, followed by the user arguments to the calling
+# program.
+#
+# Options with optional arguments will be returned as "--longopt=optarg"
+# for longopts, or "-o=optarg" for shortopts. This isn't actually a valid
+# way to pass an optional argument with a shortopt on the command line,
+# but is done by parseopts to enable the caller script to split the option
+# and its optarg easily.
 #
 # Recommended Usage:
-#   OPT_SHORT='fb:z'
-#   OPT_LONG=('foo' 'bar:' 'baz')
+#   OPT_SHORT='fb:zq?'
+#   OPT_LONG=('foo' 'bar:' 'baz' 'qux?')
 #   if ! parseopts "$OPT_SHORT" "${OPT_LONG[@]}" -- "$@"; then
 # exit 1
 #   fi
@@ -49,29 +56,30 @@ parseopts() {
longoptmatch() {
local o longmatch=()
for o in "${longopts[@]}"; do
-   if [[ ${o%:} = "$1" ]]; then
+   if [[ ${o%[:?]} = "$1" ]]; then
longmatch=("$o")
break
fi
-   [[ ${o%:} = "$1"* ]] && longmatch+=("$o")
+   [[ ${o%[:?]} = "$1"* ]] && longmatch+=("$o")
done
 
case ${#longmatch[*]} in
1)
-   # success, override with opt and return arg req 
(0 == none, 1 == required)
-   opt=${longmatch%:}
-   if [[ $longmatch = *: ]]; then
-   return 1
-   else
-   return 0
-   fi ;;
+   # success, override with opt and return arg req 
(0 == none, 1 == required, 2 == optional)
+   opt=${longmatch%[:?]}
+   case $longmatch in
+   *:)  return 1 ;;
+   *\?) return 2 ;;
+   *)   return 0 ;;
+   esac
+   ;;
0)
# fail, no match found
return 255 ;;
*)
# fail, ambiguous match
printf "${0##*/}: $(gettext "option '%s' is 
ambiguous; possibilities:")" "--$1"
-   printf " '%s'" "${longmatch[@]%:}"
+   printf " '%s'" "${longmatch[@]%[:?]}"
printf '\n'
return 254 ;;
esac >&2
@@ -87,32 +95,47 @@ parseopts() {
for (( i = 1; i < ${#1}; i++ )); do
opt=${1:i:1}
 
-   # option doesn't exist
-   if [[ $shortopts != *$opt* ]]; then
-   printf "${0##*/}: $(gettext 
"invalid 

Re: [pacman-dev] Alternatives system brainstorm

2019-10-23 Thread Allan McRae
On 24/10/19 12:31 am, Daan van Rossum wrote:
> * on Wednesday, 2019-10-23 22:05 +1000, Allan McRae  
> wrote:
> 
>> Now, ignoring my comment about not commenting... My design principle for
>> additions to makepkg is an addition should be mostly straight forward to
>> a packager - i.e. if you can build the software manually, you can
>> package it.  Suggestions that look complex to package, are too complex.
>>  Looking at your suggestion (admittedly... bourbon), it did not pass my
>> "that seems obvious" threshold.
> 
> I think it looks less complex in a single-line summary:
> 
> Replace "virtual packages" (those specified with "provides=()" statements in 
> other packages) with actual packages that can make use of links prepared by 
> providers.
> 
> 
> The added complexity for a packager should be small:
> 1. packager will only work on provider packages, selector packages typically 
> don't change
> 2. his/her package being a provider is optional; it will still work the same 
> way as it does now without a provider() function
> 3. the provider() function can almost be copy-pasted (only paths need to be 
> adjusted) from other providers or from the selector PKGBUILD
> 


Compare that to the complexity of the original proposal example for python2:


In the PKGBUILD:

alternatives=('python')


And then provide a file python.alternative containing:

/usr/bin/python -> python2
/usr/bin/idle -> idle2


Yes - this potentially results in more complexity in the backend (I'm
not sure it will), but is dead simple for a packager.

Allan


Re: [pacman-dev] [PATCH v2] libmakepkg: add optional argument support to parseopts

2019-10-23 Thread Dave Reisner
On Wed, Oct 23, 2019 at 06:57:24PM -0400, Ethan Sommer wrote:
> Adds a "?" suffix that can be used to indicate that an option's argument is
> optional.
> 
> This allows options to have a default behaviour when the user doesn't
> specify one, e.g.: --color=[when] being able to behave like --color=auto
> when only --color is passed
> 
> Signed-off-by: Ethan Sommer 
> ---
>  scripts/libmakepkg/util/parseopts.sh.in | 110 +++-
>  test/scripts/parseopts_test.sh  |  12 ++-
>  2 files changed, 77 insertions(+), 45 deletions(-)
> 
> diff --git a/scripts/libmakepkg/util/parseopts.sh.in 
> b/scripts/libmakepkg/util/parseopts.sh.in
> index c056cb1e..9a215648 100644
> --- a/scripts/libmakepkg/util/parseopts.sh.in
> +++ b/scripts/libmakepkg/util/parseopts.sh.in
> @@ -18,16 +18,17 @@
>  #   along with this program.  If not, see .
>  #
>  # A getopt_long-like parser which portably supports longopts and
> -# shortopts with some GNU extensions. It does not allow for options
> -# with optional arguments. For both short and long opts, options
> -# requiring an argument should be suffixed with a colon. After the
> -# first argument containing the short opts, any number of valid long
> -# opts may be be passed. The end of the options delimiter must then be
> -# added, followed by the user arguments to the calling program.
> +# shortopts with some GNU extensions. For both short and long opts,
> +# options requiring an argument should be suffixed with a colon, and
> +# options with optional arguments should be suffixed with a question
> +# mark. After the first argument containing the short opts, any number
> +# of valid long opts may be be passed. The end of the options delimiter
> +# must then be added, followed by the user arguments to the calling
> +# program.
>  #
>  # Recommended Usage:
> -#   OPT_SHORT='fb:z'
> -#   OPT_LONG=('foo' 'bar:' 'baz')
> +#   OPT_SHORT='fb:zq?'
> +#   OPT_LONG=('foo' 'bar:' 'baz' 'qux?')
>  #   if ! parseopts "$OPT_SHORT" "${OPT_LONG[@]}" -- "$@"; then
>  # exit 1
>  #   fi
> @@ -49,29 +50,30 @@ parseopts() {
>   longoptmatch() {
>   local o longmatch=()
>   for o in "${longopts[@]}"; do
> - if [[ ${o%:} = "$1" ]]; then
> + if [[ ${o%[:?]} = "$1" ]]; then
>   longmatch=("$o")
>   break
>   fi
> - [[ ${o%:} = "$1"* ]] && longmatch+=("$o")
> + [[ ${o%[:?]} = "$1"* ]] && longmatch+=("$o")
>   done
>  
>   case ${#longmatch[*]} in
>   1)
> - # success, override with opt and return arg req 
> (0 == none, 1 == required)
> - opt=${longmatch%:}
> - if [[ $longmatch = *: ]]; then
> - return 1
> - else
> - return 0
> - fi ;;
> + # success, override with opt and return arg req 
> (0 == none, 1 == required, 2 == optional)
> + opt=${longmatch%[:?]}
> + case $longmatch in
> + *:)  return 1 ;;
> + *\?) return 2 ;;
> + *)   return 0 ;;
> + esac
> + ;;
>   0)
>   # fail, no match found
>   return 255 ;;
>   *)
>   # fail, ambiguous match
>   printf "${0##*/}: $(gettext "option '%s' is 
> ambiguous; possibilities:")" "--$1"
> - printf " '%s'" "${longmatch[@]%:}"
> + printf " '%s'" "${longmatch[@]%[:?]}"
>   printf '\n'
>   return 254 ;;
>   esac >&2
> @@ -87,32 +89,47 @@ parseopts() {
>   for (( i = 1; i < ${#1}; i++ )); do
>   opt=${1:i:1}
>  
> - # option doesn't exist
> - if [[ $shortopts != *$opt* ]]; then
> - printf "${0##*/}: $(gettext 
> "invalid option") -- '%s'\n" "$opt" >&2
> - OPTRET=(--)
> - return 1
> - fi
> -
> - OPTRET+=("-$opt")
> - # option requires optarg
> - if [[ $shortopts = *$opt:* ]]; then
> - # if we're not at the end of 
> the option 

[pacman-dev] [PATCH v2] libmakepkg: add optional argument support to parseopts

2019-10-23 Thread Ethan Sommer
Adds a "?" suffix that can be used to indicate that an option's argument is
optional.

This allows options to have a default behaviour when the user doesn't
specify one, e.g.: --color=[when] being able to behave like --color=auto
when only --color is passed

Signed-off-by: Ethan Sommer 
---
 scripts/libmakepkg/util/parseopts.sh.in | 110 +++-
 test/scripts/parseopts_test.sh  |  12 ++-
 2 files changed, 77 insertions(+), 45 deletions(-)

diff --git a/scripts/libmakepkg/util/parseopts.sh.in 
b/scripts/libmakepkg/util/parseopts.sh.in
index c056cb1e..9a215648 100644
--- a/scripts/libmakepkg/util/parseopts.sh.in
+++ b/scripts/libmakepkg/util/parseopts.sh.in
@@ -18,16 +18,17 @@
 #   along with this program.  If not, see .
 #
 # A getopt_long-like parser which portably supports longopts and
-# shortopts with some GNU extensions. It does not allow for options
-# with optional arguments. For both short and long opts, options
-# requiring an argument should be suffixed with a colon. After the
-# first argument containing the short opts, any number of valid long
-# opts may be be passed. The end of the options delimiter must then be
-# added, followed by the user arguments to the calling program.
+# shortopts with some GNU extensions. For both short and long opts,
+# options requiring an argument should be suffixed with a colon, and
+# options with optional arguments should be suffixed with a question
+# mark. After the first argument containing the short opts, any number
+# of valid long opts may be be passed. The end of the options delimiter
+# must then be added, followed by the user arguments to the calling
+# program.
 #
 # Recommended Usage:
-#   OPT_SHORT='fb:z'
-#   OPT_LONG=('foo' 'bar:' 'baz')
+#   OPT_SHORT='fb:zq?'
+#   OPT_LONG=('foo' 'bar:' 'baz' 'qux?')
 #   if ! parseopts "$OPT_SHORT" "${OPT_LONG[@]}" -- "$@"; then
 # exit 1
 #   fi
@@ -49,29 +50,30 @@ parseopts() {
longoptmatch() {
local o longmatch=()
for o in "${longopts[@]}"; do
-   if [[ ${o%:} = "$1" ]]; then
+   if [[ ${o%[:?]} = "$1" ]]; then
longmatch=("$o")
break
fi
-   [[ ${o%:} = "$1"* ]] && longmatch+=("$o")
+   [[ ${o%[:?]} = "$1"* ]] && longmatch+=("$o")
done
 
case ${#longmatch[*]} in
1)
-   # success, override with opt and return arg req 
(0 == none, 1 == required)
-   opt=${longmatch%:}
-   if [[ $longmatch = *: ]]; then
-   return 1
-   else
-   return 0
-   fi ;;
+   # success, override with opt and return arg req 
(0 == none, 1 == required, 2 == optional)
+   opt=${longmatch%[:?]}
+   case $longmatch in
+   *:)  return 1 ;;
+   *\?) return 2 ;;
+   *)   return 0 ;;
+   esac
+   ;;
0)
# fail, no match found
return 255 ;;
*)
# fail, ambiguous match
printf "${0##*/}: $(gettext "option '%s' is 
ambiguous; possibilities:")" "--$1"
-   printf " '%s'" "${longmatch[@]%:}"
+   printf " '%s'" "${longmatch[@]%[:?]}"
printf '\n'
return 254 ;;
esac >&2
@@ -87,32 +89,47 @@ parseopts() {
for (( i = 1; i < ${#1}; i++ )); do
opt=${1:i:1}
 
-   # option doesn't exist
-   if [[ $shortopts != *$opt* ]]; then
-   printf "${0##*/}: $(gettext 
"invalid option") -- '%s'\n" "$opt" >&2
-   OPTRET=(--)
-   return 1
-   fi
-
-   OPTRET+=("-$opt")
-   # option requires optarg
-   if [[ $shortopts = *$opt:* ]]; then
-   # if we're not at the end of 
the option chunk, the rest is the optarg
-   if (( i < ${#1} - 1 )); then
-   

Re: [pacman-dev] [PATCH] libmakepkg: add optional argument support to parseopts

2019-10-23 Thread Allan McRae
It is right...

On 24/10/19 7:53 am, Ethan Sommer wrote:

<- HERE

> Signed-off-by: Ethan Sommer 

... where you provide context for what the patch is implementing.  What
does it do and why?

Allan


[pacman-dev] [PATCH] libmakepkg: add optional argument support to parseopts

2019-10-23 Thread Ethan Sommer
Signed-off-by: Ethan Sommer 
---
 scripts/libmakepkg/util/parseopts.sh.in | 110 +++-
 test/scripts/parseopts_test.sh  |  12 ++-
 2 files changed, 77 insertions(+), 45 deletions(-)

diff --git a/scripts/libmakepkg/util/parseopts.sh.in 
b/scripts/libmakepkg/util/parseopts.sh.in
index c056cb1e..9a215648 100644
--- a/scripts/libmakepkg/util/parseopts.sh.in
+++ b/scripts/libmakepkg/util/parseopts.sh.in
@@ -18,16 +18,17 @@
 #   along with this program.  If not, see .
 #
 # A getopt_long-like parser which portably supports longopts and
-# shortopts with some GNU extensions. It does not allow for options
-# with optional arguments. For both short and long opts, options
-# requiring an argument should be suffixed with a colon. After the
-# first argument containing the short opts, any number of valid long
-# opts may be be passed. The end of the options delimiter must then be
-# added, followed by the user arguments to the calling program.
+# shortopts with some GNU extensions. For both short and long opts,
+# options requiring an argument should be suffixed with a colon, and
+# options with optional arguments should be suffixed with a question
+# mark. After the first argument containing the short opts, any number
+# of valid long opts may be be passed. The end of the options delimiter
+# must then be added, followed by the user arguments to the calling
+# program.
 #
 # Recommended Usage:
-#   OPT_SHORT='fb:z'
-#   OPT_LONG=('foo' 'bar:' 'baz')
+#   OPT_SHORT='fb:zq?'
+#   OPT_LONG=('foo' 'bar:' 'baz' 'qux?')
 #   if ! parseopts "$OPT_SHORT" "${OPT_LONG[@]}" -- "$@"; then
 # exit 1
 #   fi
@@ -49,29 +50,30 @@ parseopts() {
longoptmatch() {
local o longmatch=()
for o in "${longopts[@]}"; do
-   if [[ ${o%:} = "$1" ]]; then
+   if [[ ${o%[:?]} = "$1" ]]; then
longmatch=("$o")
break
fi
-   [[ ${o%:} = "$1"* ]] && longmatch+=("$o")
+   [[ ${o%[:?]} = "$1"* ]] && longmatch+=("$o")
done
 
case ${#longmatch[*]} in
1)
-   # success, override with opt and return arg req 
(0 == none, 1 == required)
-   opt=${longmatch%:}
-   if [[ $longmatch = *: ]]; then
-   return 1
-   else
-   return 0
-   fi ;;
+   # success, override with opt and return arg req 
(0 == none, 1 == required, 2 == optional)
+   opt=${longmatch%[:?]}
+   case $longmatch in
+   *:)  return 1 ;;
+   *\?) return 2 ;;
+   *)   return 0 ;;
+   esac
+   ;;
0)
# fail, no match found
return 255 ;;
*)
# fail, ambiguous match
printf "${0##*/}: $(gettext "option '%s' is 
ambiguous; possibilities:")" "--$1"
-   printf " '%s'" "${longmatch[@]%:}"
+   printf " '%s'" "${longmatch[@]%[:?]}"
printf '\n'
return 254 ;;
esac >&2
@@ -87,32 +89,47 @@ parseopts() {
for (( i = 1; i < ${#1}; i++ )); do
opt=${1:i:1}
 
-   # option doesn't exist
-   if [[ $shortopts != *$opt* ]]; then
-   printf "${0##*/}: $(gettext 
"invalid option") -- '%s'\n" "$opt" >&2
-   OPTRET=(--)
-   return 1
-   fi
-
-   OPTRET+=("-$opt")
-   # option requires optarg
-   if [[ $shortopts = *$opt:* ]]; then
-   # if we're not at the end of 
the option chunk, the rest is the optarg
-   if (( i < ${#1} - 1 )); then
-   OPTRET+=("${1:i+1}")
-   break
-   # if we're at the end, grab the 
the next positional, if it exists
-   elif (( i == ${#1} - 

[pacman-dev] [PATCH] Update copyright years

2019-10-23 Thread Allan McRae
make update-copyright OLD=2018 NEW=2019

Signed-off-by: Allan McRae 
---
 doc/index.asciidoc| 2 +-
 lib/libalpm/add.c | 2 +-
 lib/libalpm/add.h | 2 +-
 lib/libalpm/alpm.c| 2 +-
 lib/libalpm/alpm.h| 2 +-
 lib/libalpm/alpm_list.c   | 2 +-
 lib/libalpm/alpm_list.h   | 2 +-
 lib/libalpm/backup.c  | 2 +-
 lib/libalpm/backup.h  | 2 +-
 lib/libalpm/be_local.c| 2 +-
 lib/libalpm/be_package.c  | 2 +-
 lib/libalpm/be_sync.c | 2 +-
 lib/libalpm/conflict.c| 2 +-
 lib/libalpm/conflict.h| 2 +-
 lib/libalpm/db.c  | 2 +-
 lib/libalpm/db.h  | 2 +-
 lib/libalpm/deps.c| 2 +-
 lib/libalpm/deps.h| 2 +-
 lib/libalpm/diskspace.c   | 2 +-
 lib/libalpm/diskspace.h   | 2 +-
 lib/libalpm/dload.c   | 2 +-
 lib/libalpm/dload.h   | 2 +-
 lib/libalpm/error.c   | 2 +-
 lib/libalpm/filelist.c| 2 +-
 lib/libalpm/filelist.h| 2 +-
 lib/libalpm/graph.c   | 2 +-
 lib/libalpm/graph.h   | 2 +-
 lib/libalpm/group.c   | 2 +-
 lib/libalpm/group.h   | 2 +-
 lib/libalpm/handle.c  | 2 +-
 lib/libalpm/handle.h  | 2 +-
 lib/libalpm/hook.c| 2 +-
 lib/libalpm/hook.h| 2 +-
 lib/libalpm/libarchive-compat.h   | 2 +-
 lib/libalpm/log.c | 2 +-
 lib/libalpm/log.h | 2 +-
 lib/libalpm/package.c | 2 +-
 lib/libalpm/package.h | 2 +-
 lib/libalpm/pkghash.c | 2 +-
 lib/libalpm/pkghash.h | 2 +-
 lib/libalpm/remove.c  | 2 +-
 lib/libalpm/remove.h  | 2 +-
 lib/libalpm/signing.c | 2 +-
 lib/libalpm/signing.h | 2 +-
 lib/libalpm/sync.c| 2 +-
 lib/libalpm/sync.h| 2 +-
 lib/libalpm/trans.c   | 2 +-
 lib/libalpm/trans.h   | 2 +-
 lib/libalpm/util.c| 2 +-
 lib/libalpm/util.h| 2 +-
 lib/libalpm/version.c | 2 +-
 scripts/libmakepkg/buildenv.sh.in | 2 +-
 scripts/libmakepkg/buildenv/buildflags.sh.in  | 2 +-
 scripts/libmakepkg/buildenv/compiler.sh.in| 2 +-
 scripts/libmakepkg/buildenv/debugflags.sh.in  | 2 +-
 scripts/libmakepkg/buildenv/makeflags.sh.in   | 2 +-
 scripts/libmakepkg/executable.sh.in   | 2 +-
 scripts/libmakepkg/executable/ccache.sh.in| 2 +-
 scripts/libmakepkg/executable/checksum.sh.in  | 2 +-
 scripts/libmakepkg/executable/distcc.sh.in| 2 +-
 scripts/libmakepkg/executable/fakeroot.sh.in  | 2 +-
 scripts/libmakepkg/executable/gpg.sh.in   | 2 +-
 scripts/libmakepkg/executable/gzip.sh.in  | 2 +-
 scripts/libmakepkg/executable/pacman.sh.in| 2 +-
 scripts/libmakepkg/executable/strip.sh.in | 2 +-
 scripts/libmakepkg/executable/sudo.sh.in  | 2 +-
 scripts/libmakepkg/executable/vcs.sh.in   | 2 +-
 scripts/libmakepkg/integrity.sh.in| 2 +-
 scripts/libmakepkg/integrity/generate_checksum.sh.in  | 2 +-
 scripts/libmakepkg/integrity/generate_signature.sh.in | 2 +-
 

Re: [pacman-dev] Alternatives system brainstorm

2019-10-23 Thread Daan van Rossum
* on Wednesday, 2019-10-23 22:05 +1000, Allan McRae  wrote:

> Now, ignoring my comment about not commenting... My design principle for
> additions to makepkg is an addition should be mostly straight forward to
> a packager - i.e. if you can build the software manually, you can
> package it.  Suggestions that look complex to package, are too complex.
>  Looking at your suggestion (admittedly... bourbon), it did not pass my
> "that seems obvious" threshold.

I think it looks less complex in a single-line summary:

Replace "virtual packages" (those specified with "provides=()" statements in 
other packages) with actual packages that can make use of links prepared by 
providers.


The added complexity for a packager should be small:
1. packager will only work on provider packages, selector packages typically 
don't change
2. his/her package being a provider is optional; it will still work the same 
way as it does now without a provider() function
3. the provider() function can almost be copy-pasted (only paths need to be 
adjusted) from other providers or from the selector PKGBUILD

There ain't no such thing as a free lunch...

Daan


signature.asc
Description: PGP signature


Re: [pacman-dev] [PATCH 1/2] Update completion for -F changes

2019-10-23 Thread Allan McRae
On 23/10/19 9:56 pm, Bruno Pagani wrote:
> Le 23/10/2019 à 11:41, Allan McRae a écrit :
>> -  files=('list machinereadable owns search refresh regex' 'l o s x y')
>> +  files=('list machinereadablerefresh regex' 'l x y')
> 
> Missing white space?
> .
> 

Thanks - fixed.

A


Re: [pacman-dev] Alternatives system brainstorm

2019-10-23 Thread Allan McRae
On 23/10/19 9:35 pm, Daan van Rossum wrote:
> * on Sunday, 2019-10-20 21:05 +1000, Allan McRae  wrote:
> 
>> It is constructive, but I don't think is necessarily relevant.  Pacman
>> is a system package manager, not a userspace software manager.
>>
>> The HPC use case is quite different.  It allows pieces of software to be
>> made available to individual users, but not system-wide.
> 
> I was under the impression that Arch Linux had gotten around well without both



> What if Arch offered alternatives through sets of

Without actually commenting on your idea (because bourbon), I will point
out that pacman is distro independent.  It just happens that Arch hosts
our infrastructure.  So our decisions are based around what is best for
a package manager, but not Arch.


Now, ignoring my comment about not commenting... My design principle for
additions to makepkg is an addition should be mostly straight forward to
a packager - i.e. if you can build the software manually, you can
package it.  Suggestions that look complex to package, are too complex.
 Looking at your suggestion (admittedly... bourbon), it did not pass my
"that seems obvious" threshold.


> [*] IMHO it is one of Arch's strengths to follow upstream as much as possible 
> and settle on a single current version of e.g. Python.  Older versions can be 
> installed but the '/usr/bin/python' is always what upstream deems 'current'.  

Upstream python specifically states that /usr/bin/python should always
point to /usr/bin/python2.  So Arch does not follow upstream in that
regard.  Just some idiot decided it was time to point to python3 about
10 years before upstream will...

Allan


Re: [pacman-dev] Alternatives system brainstorm

2019-10-23 Thread Daniel M. Capella
Quoting Daan van Rossum (2019-10-23 07:35:45)

> Installing or reinstalling a selector package will detect:
>  0 providers exist: abort suggesting providers from 
> 'alternative_providers'

> # pacman -S awk
> -> failed: selector package 'awk' is missing a provider package.  Potential 
> providers are: gawk, nawk

Seems to me it would be more streamlined to prompt to install a provider
here.

--
Best,
Daniel 


signature.asc
Description: signature


Re: [pacman-dev] [PATCH 1/2] Update completion for -F changes

2019-10-23 Thread Bruno Pagani
Le 23/10/2019 à 11:41, Allan McRae a écrit :
> -  files=('list machinereadable owns search refresh regex' 'l o s x y')
> +  files=('list machinereadablerefresh regex' 'l x y')

Missing white space?


Re: [pacman-dev] Alternatives system brainstorm

2019-10-23 Thread Daan van Rossum
* on Sunday, 2019-10-20 21:05 +1000, Allan McRae  wrote:

> It is constructive, but I don't think is necessarily relevant.  Pacman
> is a system package manager, not a userspace software manager.
> 
> The HPC use case is quite different.  It allows pieces of software to be
> made available to individual users, but not system-wide.

I was under the impression that Arch Linux had gotten around well without both
1. alternatives
2. env-modules
and that when talking about support for alternatives it may be helpful to 
clearly differentiate between these two[*], like Fedora does as well[1].


* on Saturday, 2019-10-19 18:15 +1000, Allan McRae  wrote:
> The setting of /usr/bin/python is more for interactive use.
The distinction appeared a bit vague to me here.  Sorry if misinterpreted!


Back to brainstorming - continuing thoughts shared by Allan, Eli, Andrew, 
Levente, and others - let me share an idea for a not fully fledged alternatives 
system (such as Fedora has it) but something more simple that maybe fits nicely 
in pacman's approach and maybe a bit less obtuse than link packages:


What if Arch offered alternatives through sets of
1. selector package
2. provider packages


Selector package 'awk' owns links in e.g. /usr/bin/ and /usr/share/man that it 
copied from a fakeroot provided by a provider package under 
/var/lib/pacman/alternatives/awk/.  In addition, it specifies:
requires=('awk-provider')
alternative_providers=('gawk' 'nawk')  # for hinting only, may be 
incomplete!


Provider package 'gawk' specifies
selector=('awk')
provides=('awk-provider')
and a "provide()" function that links the files and directories that it 
provides to a fakeroot under /var/lib/pacman/alternatives/awk/.


Installing or reinstalling a selector package will detect:
 0 providers exist: abort suggesting providers from 
'alternative_providers'
 1 provider exists: continue silently
>1 providers exist: ask the user to select a provider and continue
Once a provider is selected, its "provide()" function is executed (setting up 
the fakeroot), and then the selector package is (re-)installed (copying the 
links from the fakeroot into the system).


Providers that get newly installed on a system trigger reinstalling the 
selector package, offering the user to switch to the new provider.

Alternatives can be reconfigured at any time by reinstalling the selector 
package.  (But I think this action would be rare on most systems?)


Here are two examples:
# pacman -S awk
-> failed: selector package 'awk' is missing a provider package.  Potential 
providers are: gawk, nawk

# pacman -S netcat gnu-netcat openbsd-netcat
-> select a provider for netcat: [1] gnu-netcat, [2] openbsd-netcat.


Best, Daan


[*] IMHO it is one of Arch's strengths to follow upstream as much as possible 
and settle on a single current version of e.g. Python.  Older versions can be 
installed but the '/usr/bin/python' is always what upstream deems 'current'.  
This implies that old versions are never an "alternative" for new versions in 
arch's sense.  A user can always still depart from this KISS approach in 
his/her environment.

[1] https://docs.fedoraproject.org/en-US/packaging-guidelines/Alternatives/


signature.asc
Description: PGP signature


[pacman-dev] [PATCH 2/2] Remove --force from completion

2019-10-23 Thread Allan McRae
Signed-off-by: Allan McRae 
---
 scripts/completion/bash_completion.in | 4 ++--
 scripts/completion/zsh_completion.in  | 2 --
 2 files changed, 2 insertions(+), 4 deletions(-)

diff --git a/scripts/completion/bash_completion.in 
b/scripts/completion/bash_completion.in
index 129a87aa..4e63aef9 100644
--- a/scripts/completion/bash_completion.in
+++ b/scripts/completion/bash_completion.in
@@ -113,10 +113,10 @@ _pacman() {
   query=('changelog check deps explicit file foreign groups info list native 
owns
   search unrequired upgrades' 'c e g i k l m n o p s t u')
   remove=('cascade dbonly nodeps assume-installed nosave print recursive 
unneeded' 'c n p s u')
-  sync=('asdeps asexplicit clean dbonly downloadonly force groups ignore 
ignoregroup
+  sync=('asdeps asexplicit clean dbonly downloadonly groups ignore ignoregroup
  info list needed nodeps assume-installed print refresh recursive 
search sysupgrade'
 'c g i l p s u w y')
-  upgrade=('asdeps asexplicit force needed nodeps assume-installed print 
recursive' 'p')
+  upgrade=('asdeps asexplicit needed nodeps assume-installed print recursive' 
'p')
   common=('arch cachedir color config confirm dbpath debug gpgdir help hookdir 
logfile
noconfirm noprogressbar noscriptlet quiet root verbose' 'b d h q r 
v')
   core=('database files help query remove sync upgrade version' 'D F Q R S U V 
h')
diff --git a/scripts/completion/zsh_completion.in 
b/scripts/completion/zsh_completion.in
index 82868344..92fc2382 100644
--- a/scripts/completion/zsh_completion.in
+++ b/scripts/completion/zsh_completion.in
@@ -44,7 +44,6 @@ _pacman_opts_pkgfile=(
'*--nodeps[Skip dependency checks]'
'*--assume-installed[Add virtual package to satisfy dependencies]'
'--dbonly[Only remove database entry, do not remove files]'
-   '--force[Overwrite conflicting files]'
'--needed[Do not reinstall up to date packages]'
'--asdeps[mark packages as non-explicitly installed]'
'--asexplicit[mark packages as explicitly installed]'
@@ -133,7 +132,6 @@ _pacman_opts_sync_modifiers=(
'*--ignoregroup[Ignore a group upgrade]:package 
group:_pacman_completions_all_groups'
'--asdeps[Install packages as non-explicitly installed]'
'--asexplicit[Install packages as explicitly installed]'
-   '--force[Overwrite conflicting files]'
'--print-format[Specify how the targets should be printed]'
 )
 
-- 
2.23.0


[pacman-dev] [PATCH 1/2] Update completion for -F changes

2019-10-23 Thread Allan McRae
Signed-off-by: Allan McRae 
---
 scripts/completion/bash_completion.in | 3 +--
 scripts/completion/zsh_completion.in  | 2 --
 2 files changed, 1 insertion(+), 4 deletions(-)

diff --git a/scripts/completion/bash_completion.in 
b/scripts/completion/bash_completion.in
index 915004e2..129a87aa 100644
--- a/scripts/completion/bash_completion.in
+++ b/scripts/completion/bash_completion.in
@@ -109,7 +109,7 @@ _pacman() {
   local cur prev words cword
   _init_completion || return
   database=('asdeps asexplicit')
-  files=('list machinereadable owns search refresh regex' 'l o s x y')
+  files=('list machinereadablerefresh regex' 'l x y')
   query=('changelog check deps explicit file foreign groups info list native 
owns
   search unrequired upgrades' 'c e g i k l m n o p s t u')
   remove=('cascade dbonly nodeps assume-installed nosave print recursive 
unneeded' 'c n p s u')
@@ -136,7 +136,6 @@ _pacman() {
   _pacman_pkg Qq;;
   F)
 { _arch_incomp 'l list'   && _pacman_pkg Slq ; }   ||
-  _arch_incomp 'o owns'   ||
   compopt +o default;;
   Q)
 { _arch_incomp 'g groups' && _pacman_pkg Qg sort; }||
diff --git a/scripts/completion/zsh_completion.in 
b/scripts/completion/zsh_completion.in
index c114ae02..82868344 100644
--- a/scripts/completion/zsh_completion.in
+++ b/scripts/completion/zsh_completion.in
@@ -101,8 +101,6 @@ _pacman_opts_database=(
 
 _pacman_opts_files=(
{-l,--list}'[List the files owned by the queried 
package]:package:_pacman_completions_all_packages'
-   {-o,--owns}'[Query the package that owns]:files:_files'
-   {-s,--search}'[Search package file names for matching 
strings]:files:_files'
{-x,--regex}'[Enable searching using regular expressions]:regex:'
{-y,--refresh}'[Download fresh files databases from the server]'
'--machinereadable[Produce machine-readable output]'
-- 
2.23.0