Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build: Restore backwards compatibility with existing containers #904

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 19 additions & 2 deletions src/go-build-wrapper
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,25 @@ if ! interpreter=$(patchelf --print-interpreter "$2/toolbox"); then
exit 1
fi

if ! patchelf --set-interpreter "/run/host$interpreter" "$2/toolbox"; then
echo "go-build-wrapper: failed to change PT_INTERP of $2/toolbox to /run/host$interpreter" >&2
if ! interpreter_canonical=$(readlink --canonicalize "$interpreter"); then
echo "go-build-wrapper: failed to canonicalize PT_INTERP" >&2
exit 1
fi

if ! interpreter_basename=$(basename "$interpreter"); then
echo "go-build-wrapper: failed to read the basename of PT_INTERP" >&2
exit 1
fi

if ! interpreter_canonical_dirname=$(dirname "$interpreter_canonical"); then
echo "go-build-wrapper: failed to read the dirname of the canonicalized PT_INTERP" >&2
exit 1
fi

interpreter="/run/host$interpreter_canonical_dirname/$interpreter_basename"

if ! patchelf --set-interpreter "$interpreter" "$2/toolbox"; then
echo "go-build-wrapper: failed to change PT_INTERP of $2/toolbox to $interpreter" >&2
exit 1
fi

Expand Down