my_buildctl : split into 2 functions

This commit is contained in:
Gitouche 2022-03-06 00:40:36 +01:00
parent 9d64a47bc9
commit b4a445ada7

View file

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