diff --git a/functions.sh b/functions.sh index 26e7ce0..50c1011 100644 --- a/functions.sh +++ b/functions.sh @@ -260,25 +260,19 @@ get_podman_volume_path () { podman volume inspect --format '{{ .Mountpoint }}' ${1} } -# Execute buildctl directly from the web -my_buildctl () { - opts=$(echo -n "$@") - +# Execute elf binary from stdin +elfexec () { + opts=$(echo "$@") if [[ $(uname -i) == 'aarch64' ]]; then - buildkitarch='arm64' memfd_create='279' elif [[ $(uname -i) == 'x86_64' ]]; then - buildkitarch='amd64' memfd_create='319' else # defaults to amd64 - buildkitarch='amd64' memfd_create='319' fi - curl -sSLf https://github.com/moby/buildkit/releases/download/v0.9.3/buildkit-v0.9.3.linux-${buildkitarch}.tar.gz | - tar xOz bin/buildctl | - python3 -c " + python3 -c " import ctypes, os; from sys import stdin; l = ctypes.CDLL(None); @@ -290,3 +284,17 @@ p = '/proc/self/fd/%d' % f; myargs='${opts}'; os.execve(p, ['buildctl'] + myargs.split(), {'PATH': '${PATH}'})" } + +# Execute buildctl directly from the web +my_buildctl () { + if [[ $(uname -i) == 'aarch64' ]]; then + buildkitarch='arm64' + elif [[ $(uname -i) == 'x86_64' ]]; then + buildkitarch='amd64' + else + # defaults to amd64 + buildkitarch='amd64' + fi + curl -sSLf https://github.com/moby/buildkit/releases/download/v0.9.3/buildkit-v0.9.3.linux-${buildkitarch}.tar.gz | + tar xOz bin/buildctl | elfexec "${@}" +}