Fix support of inline scripts in prepare/shell#4875
Conversation
There was a problem hiding this comment.
Code Review
This pull request enables support for multiline shell scripts in Containerfiles by utilizing heredocs for command collection. A bug was identified in the test suite where the assertion string does not match the actual output of the multiline test script.
An inline script in `prepare/shell` can break easily the RUN directive. We run into this when working on profiles where we had a script with a function: https://gitlab.com/testing-farm/profiles/-/merge_requests/85/diffs To fix this use RUN heredoc to properly support any scripts user can throw on us. Signed-off-by: Miroslav Vadkerti <mvadkert@redhat.com>
214b848 to
b3e7329
Compare
|
/packit build |
|
@thrix is there an issue? I recall several issues filed today related to continerfiles, namely #4868 and #4867, plus one extra PR, #4871. I'd like to be sure you and @lukaszachy are aligned, you seem to be touching same code. |
From what I tried this PR seems to fix #4868 (multiline problem) but not #4867 (variable expansion) |
| ) | ||
| self.guest.execute( | ||
| ShellScript(f'cat <<EOF > {containerfile_path!s} \n{containerfile} \nEOF') | ||
| ShellScript(f'cat <<EOF > {containerfile_path!s}\n{containerfile}\nEOF') |
There was a problem hiding this comment.
Iiuc what you want here is textwrap.deindent? Will look at it again when I have a fresh mind
There was a problem hiding this comment.
not sure, I will take a look
There was a problem hiding this comment.
Ok, new day fresh mind. Why not guest.push these? There are so many other edge cases, e.g. what if the containerfile_directives contains
RUN cat <<EOF > /etc/profile.d/mpi.sh
module load mpi
EOFlooks like it will clash and end in a fun state.
There was a problem hiding this comment.
I will try, not originally my code, it was just causing me trouble due to the used spurious spaces.
I did not file an issue, we found this on Thursday while working on Image Mode in profiles |
This should fix #4868. The #4867 & #4871 I would keep as separate, it is another separate problem |
An inline script in
prepare/shellcan break easily the RUN directive. We run into this when working on profiles where we had a script with a function:https://gitlab.com/testing-farm/profiles/-/merge_requests/85/diffs
To fix this use RUN heredoc to properly support any scripts user can throw on us.
Resolves #4868
Pull Request Checklist