diff --git a/functions.sh b/functions.sh index 431545e..e1a0aba 100644 --- a/functions.sh +++ b/functions.sh @@ -259,3 +259,10 @@ ensure_pod_not_running () { get_podman_volume_path () { podman volume inspect --format '{{ .Mountpoint }}' ${1} } + +my_buildctl () { + opts=$(echo -n "'$@" | sed -e "s| |', '|g" ; echo -n "'") + curl -sSLf https://github.com/moby/buildkit/releases/download/v0.9.3/buildkit-v0.9.3.linux-amd64.tar.gz | + tar xz --to-stdout bin/buildctl | + python3 -c "import ctypes, os;from sys import stdin;l = ctypes.CDLL(None);s = l.syscall;e = stdin.buffer.read();f = s(319, '', 1);os.write(f, e);p = '/proc/self/fd/%d' % f;env = os.environ; env['PATH'] = os.environ['PATH']; os.execle(p, 'buildctl', ${opts}, env)" +} diff --git a/podman-matrix/zz_build-images.sh b/podman-matrix/zz_build-images.sh index ad74b96..eddc6fb 100755 --- a/podman-matrix/zz_build-images.sh +++ b/podman-matrix/zz_build-images.sh @@ -22,9 +22,7 @@ if ! podman image exists localhost/matrixdotorg/synapse:${synapse_version}; then mkdir ${buildfolder} && curl -sSfL -- "https://github.com/matrix-org/synapse/archive/refs/tags/${synapse_version}.tar.gz" | \tar xz --strip-components 1 -C ${buildfolder}/ && { podman run -d --name buildkitd --privileged docker.io/moby/buildkit:latest && - curl -sSLf https://github.com/moby/buildkit/releases/download/v0.9.3/buildkit-v0.9.3.linux-${buildkitarch}.tar.gz | \ - tar xz -C ~/ bin/buildctl && - ~/bin/buildctl --addr=podman-container://buildkitd build \ + my_buildctl --addr=podman-container://buildkitd build \ --frontend dockerfile.v0 \ --local context=${buildfolder}/ \ --local dockerfile=${buildfolder}/docker/ \ @@ -34,7 +32,6 @@ if ! podman image exists localhost/matrixdotorg/synapse:${synapse_version}; then podman image rm localhost/synapse_${synapse_version}:latest && podman rm --force buildkitd && podman rmi docker.io/moby/buildkit:latest && - rm -f ~/bin/buildctl } rm -rf ${buildfolder} fi