mirror of
https://github.com/b4tman/armhf-alpine-qemu.git
synced 2024-12-12 21:06:54 +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:
parent
07e49260bf
commit
3f62d14109
@ -1,4 +1,7 @@
|
|||||||
FROM resin/armv7hf-debian:jessie
|
FROM resin/armv7hf-debian:jessie
|
||||||
|
|
||||||
ENV QEMU_EXECVE 1
|
ENV QEMU_EXECVE 1
|
||||||
|
|
||||||
COPY . /usr/bin
|
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" ]
|
||||||
|
@ -1,3 +0,0 @@
|
|||||||
#!/usr/bin/qemu-arm-static /bin/sh.real
|
|
||||||
|
|
||||||
mv /bin/sh.real /bin/sh
|
|
@ -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
BIN
resin-xbuild
Executable file
Binary file not shown.
50
resin-xbuild.go
Normal file
50
resin-xbuild.go
Normal 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()
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user