Skip to content

Commit 8b99980

Browse files
fix get server bintar
1 parent 5f0c7cc commit 8b99980

1 file changed

Lines changed: 8 additions & 2 deletions

File tree

configuration/steps/commands/foundry.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,13 @@ def as_cmd_arg(self) -> list[str]:
9595
set -euo pipefail
9696
9797
base_url="https://ci.mariadb.org/%(prop:tarbuildnum)s/{self.ci_builder}"
98-
filename=$(curl -fsSL "$base_url/" | grep -oE 'href="mariadb-[^"]*-linux[^"]*\\.tar\\.gz"' | head -1 | sed -E 's/^href="(.*)"$/\\1/')
98+
# `... | head -1` here would let head close the pipe as soon as it has its
99+
# one line, which under pipefail can turn curl/tar's resulting SIGPIPE into
100+
# a hard failure of the whole step (seen in practice with tar -tzf listing a
101+
# whole bintar's contents). `awk 'NR==1'` picks the same first line but
102+
# still reads its input through to EOF, so the upstream command always
103+
# exits normally instead of getting killed by a broken pipe.
104+
filename=$(curl -fsSL "$base_url/" | grep -oE 'href="mariadb-[^"]*-linux[^"]*\\.tar\\.gz"' | sed -E 's/^href="(.*)"$/\\1/' | awk 'NR==1')
99105
if [ -z "$filename" ]; then
100106
echo "Could not find a server bintar under $base_url" >&2
101107
exit 1
@@ -105,7 +111,7 @@ def as_cmd_arg(self) -> list[str]:
105111
curl -fsSL "$base_url/$filename" -o "/home/buildbot/bintar/$filename"
106112
tar -xzf "/home/buildbot/bintar/$filename" -C /home/buildbot/bintar
107113
108-
dirname=$(tar -tzf "/home/buildbot/bintar/$filename" | head -1 | cut -d/ -f1)
114+
dirname=$(tar -tzf "/home/buildbot/bintar/$filename" | awk -F/ 'NR==1{{print $1}}')
109115
echo "/home/buildbot/bintar/$dirname"
110116
"""
111117
),

0 commit comments

Comments
 (0)