On Sun, Nov 29, 2009, Junichi Uekawa wrote:
> I was thinking along the lines of running something inside the chroot
> as part of build process, and passing the output back to pdebuild, and
> using that to get the correct value.
> 
> However, that's a bit of work to implement, so I have so far deferred
> doing this.

 Yeah it's not trivial; especially since there are two code pathes in
 pdebuild (use-internal versus regular) and multiple builders.  Probably
 a nicer design would be to start some kind of pbuilder server in the
 build env and feed commands to it so that we could send a
 "get_architecture" command independently of running the build.

 In the mean time, I came up with this proof of concept code:
#!/bin/bash

run() {
    echo Regular output
    echo arch=somearch >&3
    echo More output
}

# fd 3 is used for IPC output from guest to host
exec 3>&1

# output goes to a copy of stdout by default and writes to fd 3 are captured by
# the backticks
ipc_output=`exec 4>&1- 1>&3- 3>&4-; run`

for var in $ipc_output; do
    case $var in
      arch=*)
        export $var
      ;;
    esac
done

echo arch=$arch

 (it's possible to have a similar construct for sending stuff to run
 over another fd)

 If we can find an unused fd which doesn't get closed by the builders, I
 think this should work, even if it's not too pretty.

 I'm attaching a more complete example, albeit I didn't yet find a way
 -- without two real FIFO files -- to send commands and process their
 results sequentially.

-- 
Loïc Minier

Attachment: foo.sh
Description: Bourne shell script

Reply via email to