chiark / gitweb /
bin/mdw-sbuild-server: Accept cross-build specs SUITE-TARGET/HOST.
authorMark Wooding <mdw@distorted.org.uk>
Wed, 9 Aug 2017 21:52:57 +0000 (22:52 +0100)
committerMark Wooding <mdw@distorted.org.uk>
Wed, 9 Aug 2017 22:34:37 +0000 (23:34 +0100)
That is, build for SUITE running on TARGET architecture, using a given
HOST.  This requires multiarch magic, and is unlikely to work well on
old SUITEs.

bin/mdw-sbuild-server

index 26043e6b9c41fefc44b2d807bc9db3b5909845da..d04f5a24de72d52a60c34887ffa6464431dc465f 100755 (executable)
@@ -176,6 +176,13 @@ case "$#,$1" in
     ## actually a little tricky.
     for t in $targets; do
 
+      ## Dissect the target name.
+      suite=${t%%-*} archs=${t#*-}
+      case $archs in
+       */*) target=${archs%/*} host=${archs#*/} ;;
+       *) target=$archs host=$archs; t=$suite-$target/$host ;;
+      esac
+
       ## Work through the architectures which we can build.
       for arch in $wantarchs; do
        case $arch in
@@ -199,7 +206,7 @@ case "$#,$1" in
            case $archp in nil) continue ;; esac
 
            ## If we can't build it then we shouldn't try.
-           if ! dpkg-architecture -a"$os-${t#*-}" -i"$arch"; then
+           if ! dpkg-architecture -a"$os-$target" -i"$arch"; then
              continue
            fi
 
@@ -237,18 +244,20 @@ FIRST = $first
 REST = $rest
 sbuild-wrap = \\
        t=\$@; \\
-       { echo started >build-status.\$\$t; \\
+       host=\$\${t\#\#*/} full=\$\${t%/*}; \\
+       suite=\$\${full%%-*} target=\$\${full\#*-}; \\
+       { echo started >build-status.\$\$full; \\
          sbuild \\
-               --dist=\$\${t%-*} --arch=\$\${t\#*-} \\
-               --chroot=\$@ --verbose \$1 \$(DSC); \\
+               --dist=\$\$suite --build=\$\$host --host=\$\$target \\
+               --chroot=\$\$suite-\$\$host --verbose \$1 \$(DSC); \\
          rc=\$\$?; case \$\$rc in \\
-           0) echo ok >build-status.\$\$t ;; \\
-           *) echo failed rc=\$\$rc >build-status.\$\$t ;; \\
+           0) echo ok >build-status.\$\$full ;; \\
+           *) echo failed rc=\$\$rc >build-status.\$\$full ;; \\
          esac; } | \\
        while IFS= read -r line; do \\
-         printf "%s: %s\n" "\$\$t" "\$\$line"; \\
+         printf "%s: %s\n" "\$\$full" "\$\$line"; \\
        done; \\
-       read st _ <build-status.\$\$t && \\
+       read st _ <build-status.\$\$full && \\
        case \$\$st in ok) exit 0 ;; *) exit 1 ;; esac
 all: \$(FIRST) \$(REST)
 \$(FIRST):; \$(call sbuild-wrap,$firstopt)
@@ -256,7 +265,7 @@ all: \$(FIRST) \$(REST)
 EOF
 
     ## Make some marker files to say things are in progress.
-    for i in $first $rest; do echo "starting" >build-status.$i; done
+    for i in $first $rest; do echo "starting" >build-status.${i%/*}; done
 
     ## And we're ready to go.
     mkfifo pipeout