Gilles Filippini a écrit le 31/10/2020 à 15:11 :
> Hi Josh,
> 
> Johannes 'josch' Schauer a écrit le 27/10/2020 à 18:45 :
>> Package: libhdf5-openmpi-dev
>> Version: 1.10.6+repack-2
>> Severity: wishlist
>>
>> Hi,
>>
>> when installing libhdf5-openmpi-dev in a chroot that doesn't have /proc
>> mounted, one will get the following error:
>>
>> Setting up libhdf5-openmpi-dev (1.10.6+repack-2) ...
>> /var/lib/dpkg/info/libhdf5-openmpi-dev.postinst: line 56: /dev/fd/63: No 
>> such file or directory
>> dpkg: error processing package libhdf5-openmpi-dev (--configure):
>>  installed libhdf5-openmpi-dev package post-installation script subprocess 
>> returned error exit status 1
>>
>> The problem is, that the postinst script uses the bash-feature to write:
>>
>>     while read x; do ... done < <(cmd2 args ...)
>>
>> Fortunately, these instances can easily be rewritten as:
>>
>>     cmd2 args | while read x; do ... done
>>
>> Please consider making this change.
> 
> Unfortunately it doesn't work this way. Consider this test script:
> 
> $ cat test.sh
> #!/bin/bash
> declare -A foo bar
> while read var; do
>   foo["$var"]="$var"
> done < <(seq 1 3)
> seq 1 3 | while read var; do
>   bar["$var"]="$var"
> done
> echo "foo=${foo[@]}"
> echo "bar=${bar[@]}"
> 
> $ ./test.sh
> foo=3 2 1
> bar=
> 
> Using a pipe makes variable assignments into the while loop inefficient.
> That's why I had to use the process substitution syntax.
> 
> Any other idea?

I've come up to this solution:

function read_alt_slaves () {
  local -n slaves=$1
  set -- $(echo "$2" | sed -n '/Slaves:/{: while;n;s/^ //;T end;p;b
while;: end;q}')  while [ -n "$1" ]; do
    slaves["$1"]="$2"
    shift 2
  done
}
...
  declare -A slave_links slave_targets
  read_alt_slaves slave_links "$mpi_alt_sig"
  read_alt_slaves slave_targets "$mpi_alt_impl"

Can you confirm it would work with no /proc?

_g.

Attachment: signature.asc
Description: OpenPGP digital signature

Reply via email to