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

Obuilder_spec.run isn't translating to Dockerfile correctly #66

Open
dra27 opened this issue Mar 22, 2021 · 4 comments
Open

Obuilder_spec.run isn't translating to Dockerfile correctly #66

dra27 opened this issue Mar 22, 2021 · 4 comments

Comments

@dra27
Copy link
Contributor

dra27 commented Mar 22, 2021

Merely picking a recent build from opam-repo-ci.

This fragment from opam-repo-ci:

run ~cache ~network {|
        opam remove -y %s && opam %s%s %s
        res=$?
        test "$res" = 0 && exit 0
        if test "$res" = 60 && diff -q /usr/bin/opam /usr/bin/opam-2.0; then
          sudo ln -f /usr/bin/opam-2.1 /usr/bin/opam
          opam remove -y %s && opam install -vy%s %s%s
          exit 1
        fi
        test "$res" != 31 && exit 1
        export OPAMCLI=2.0
        build_dir=$(opam var prefix)/.opam-switch/build
        failed=$(ls "$build_dir")
        for pkg in $failed; do
          if opam show -f x-ci-accept-failures: "$pkg" | grep -qF "\"%s\""; then
            echo "A package failed and has been disabled for CI using the 'x-ci-accept-failures' field."
          fi
        done
        exit 1
      |}
      pkg (if upgrade_opam then "install -vy" else "depext -uivy") (if with_tests then "t" else "") pkg
      pkg (if with_tests then "t" else "") pkg (if with_tests then "" else " && opam reinstall -vyt "^pkg)
      (Variant.distribution variant)

is rendered:

RUN  \
    opam remove -y leveldb.1.3.0 && opam depext -uivy leveldb.1.3.0 \
    res=$? \
    test "$res" = 0 && exit 0 \
    if test "$res" = 60 && diff -q /usr/bin/opam /usr/bin/opam-2.0; then \
    sudo ln -f /usr/bin/opam-2.1 /usr/bin/opam \
    opam remove -y leveldb.1.3.0 && opam install -vy leveldb.1.3.0 && opam reinstall -vyt leveldb.1.3.0 \
    exit 1 \
    fi \
    test "$res" != 31 && exit 1 \
    export OPAMCLI=2.0 \
    build_dir=$(opam var prefix)/.opam-switch/build \
    failed=$(ls "$build_dir") \
    for pkg in $failed; do \
    if opam show -f x-ci-accept-failures: "$pkg" | grep -qF "\"alpine-3.12\""; then \
    echo "A package failed and has been disabled for CI using the 'x-ci-accept-failures' field." \
    fi \
    done \
    exit 1 \
    

but it needs semi-colons at the end of most lines. Not sure if escaping is the answer or possibly invoking via a HERE document?!

@dra27 dra27 changed the title Obuilder_spec.Docker.pp_run needs to escape backslashes Obuilder_spec.run isn't translating to Dockerfile correctly Mar 22, 2021
@talex5
Copy link
Contributor

talex5 commented Mar 22, 2021

I think the problem here is that the Dockerfile format just doesn't support this (see https://stackoverflow.com/questions/33439230/how-to-write-commands-with-multiple-lines-in-dockerfile-while-preserving-the-new).

Perhaps we should just reject attempts to convert to Dockerfile format in this case?

@dra27
Copy link
Contributor Author

dra27 commented Mar 22, 2021

Ouch, yes - if there isn't a workaround for here then we should just reject, I agree. I'll open an issue on opam-repo-ci to workaround it.

@dra27
Copy link
Contributor Author

dra27 commented Mar 22, 2021

Oh, there is a possible workaround, remembering horrid things we used to do in OCaml's testsuite - escaping newlines as :; \ certainly works here.

@talex5
Copy link
Contributor

talex5 commented Mar 22, 2021

Note that OBuilder allows you to use any shell, so shell-specific hacks won't work here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants