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

Improper multi-line templating of pre-build configuration #1554

Open
4 of 11 tasks
arthuro555 opened this issue Sep 4, 2024 · 1 comment
Open
4 of 11 tasks

Improper multi-line templating of pre-build configuration #1554

arthuro555 opened this issue Sep 4, 2024 · 1 comment
Labels
Milestone

Comments

@arthuro555
Copy link

Checklist

Describe your issue

Using a multi-line string in Cross.toml's pre-build field causes $CROSS_DEB_ARCH to not be properly replaced with the current architecture.

What target(s) are you cross-compiling for?

armv7-unknown-linux-gnueabihf

Which operating system is the host (e.g computer cross is on) running?

  • macOS
  • Windows
  • Linux / BSD
  • other OS (specify in description)

What architecture is the host?

  • x86_64 / AMD64
  • arm32
  • arm64 (including Mac M1)

What container engine is cross using?

  • docker
  • podman
  • other container engine (specify in description)

cross version

cross 0.2.5

Example

Here are two failing configurations:

[build]
pre-build = [
    "dpkg --add-architecture $CROSS_DEB_ARCH",
    "apt-get update",
    """apt-get --assume-yes --no-install-recommends install
    libssl-dev:$CROSS_DEB_ARCH
    libcairo2-dev:$CROSS_DEB_ARCH
    """,
]
[build]
pre-build = [
    "dpkg --add-architecture $CROSS_DEB_ARCH",
    "apt-get update",
    """apt-get --assume-yes --no-install-recommends install \
    libssl-dev:$CROSS_DEB_ARCH \
    libcairo2-dev:$CROSS_DEB_ARCH \
    """,
]

Here is an equivalent, working configuration using a simple string:

[build]
pre-build = [
    "dpkg --add-architecture $CROSS_DEB_ARCH",
    "apt-get update",
    "apt-get --assume-yes --no-install-recommends install libssl-dev:$CROSS_DEB_ARCH libcairo2-dev:$CROSS_DEB_ARCH",
]

Expected behavior:

# Functional
apt-get --assume-yes --no-install-recommends install
    libssl-dev:armhf
    libcairo2-dev:armhf

Current behavior:

# Errors: Unknown architecture
apt-get --assume-yes --no-install-recommends install
    libssl-dev:$CROSS_DEB_ARCH
    libcairo2-dev:$CROSS_DEB_ARCH

Additional information / notes

No response

@Emilgardis
Copy link
Member

Interesting, this is how it's put into the Dockerfile

cross/src/docker/shared.rs

Lines 169 to 172 in d8631fe

FROM {image}
ARG CROSS_DEB_ARCH=
ARG CROSS_CMD
RUN eval "${{CROSS_CMD}}""#

and I think the problem is a combination of how it's expanded in quotemarks and

Some(("CROSS_CMD", pre_build.join("\n"))),

will have to investigate

@Emilgardis Emilgardis added the bug label Sep 4, 2024
@Emilgardis Emilgardis added this to the v0.3.0 milestone Sep 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants