Matrix : split buildctl into a function

This commit is contained in:
Gitouche 2022-03-05 23:34:52 +01:00
parent 141babe487
commit 71397466d0
2 changed files with 8 additions and 4 deletions

View file

@ -259,3 +259,10 @@ ensure_pod_not_running () {
get_podman_volume_path () { get_podman_volume_path () {
podman volume inspect --format '{{ .Mountpoint }}' ${1} 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)"
}

View file

@ -22,9 +22,7 @@ if ! podman image exists localhost/matrixdotorg/synapse:${synapse_version}; then
mkdir ${buildfolder} && mkdir ${buildfolder} &&
curl -sSfL -- "https://github.com/matrix-org/synapse/archive/refs/tags/${synapse_version}.tar.gz" | \tar xz --strip-components 1 -C ${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 && 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 | \ my_buildctl --addr=podman-container://buildkitd build \
tar xz -C ~/ bin/buildctl &&
~/bin/buildctl --addr=podman-container://buildkitd build \
--frontend dockerfile.v0 \ --frontend dockerfile.v0 \
--local context=${buildfolder}/ \ --local context=${buildfolder}/ \
--local dockerfile=${buildfolder}/docker/ \ --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 image rm localhost/synapse_${synapse_version}:latest &&
podman rm --force buildkitd && podman rm --force buildkitd &&
podman rmi docker.io/moby/buildkit:latest && podman rmi docker.io/moby/buildkit:latest &&
rm -f ~/bin/buildctl
} }
rm -rf ${buildfolder} rm -rf ${buildfolder}
fi fi