1
0
mirror of https://github.com/b4tman/armhf-alpine-qemu.git synced 2024-09-27 19:57:59 +00:00

Use static binaries instead of shebang scripts

With the latest version of qemu-arm-static using a shebang script with
the interpreter set to qemu-arm-static causes infinite recursion.

Fixes #2

Signed-off-by: Petros Angelatos <petrosagg@gmail.com>
This commit is contained in:
Petros Angelatos 2016-09-05 13:01:54 +01:00
parent 07e49260bf
commit 3f62d14109
6 changed files with 53 additions and 16 deletions

View File

@ -1,4 +1,7 @@
FROM resin/armv7hf-debian:jessie
ENV QEMU_EXECVE 1
COPY . /usr/bin
RUN [ "qemu-arm-static", "/bin/sh", "-c", "ln -s resin-xbuild /usr/bin/cross-build-start; ln -s resin-xbuild /usr/bin/cross-build-end; ln /bin/sh /bin/sh.real" ]

View File

@ -1,3 +0,0 @@
#!/usr/bin/qemu-arm-static /bin/sh.real
mv /bin/sh.real /bin/sh

View File

@ -1,4 +0,0 @@
#!/usr/bin/qemu-arm-static /bin/sh
mv /bin/sh /bin/sh.real
cp /usr/bin/sh-shim /bin/sh

BIN
resin-xbuild Executable file

Binary file not shown.

50
resin-xbuild.go Normal file
View File

@ -0,0 +1,50 @@
package main
import (
"log"
"os"
"os/exec"
)
func crossBuildStart() {
err := os.Remove("/bin/sh")
if err != nil {
log.Fatal(err)
}
err = os.Link("/usr/bin/resin-xbuild", "/bin/sh")
if err != nil {
log.Fatal(err)
}
}
func crossBuildEnd() {
err := os.Remove("/bin/sh")
if err != nil {
log.Fatal(err)
}
err = os.Link("/bin/sh.real", "/bin/sh")
if err != nil {
log.Fatal(err)
}
}
func runShell() {
cmd := exec.Command("/usr/bin/qemu-arm-static", append([]string{"-0", "/bin/sh", "/bin/sh"}, os.Args[1:]...)...)
cmd.Stdin = os.Stdin
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr
cmd.Run()
}
func main() {
switch os.Args[0] {
case "cross-build-start":
crossBuildStart()
case "cross-build-end":
crossBuildEnd()
case "/bin/sh":
crossBuildEnd()
runShell()
crossBuildStart()
}
}

View File

@ -1,9 +0,0 @@
#!/usr/bin/qemu-arm-static /bin/sh.real
set -o errexit
cp /bin/sh.real /bin/sh
/bin/sh "$@"
cp /usr/bin/sh-shim /bin/sh