Skip to content

Fixes issues with the docker images build #1663

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
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
4 changes: 2 additions & 2 deletions .github/actions/setup-rust/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ inputs:
required: true
target:
description: 'Target'
required: true
required: false
components:
description: 'Components'
required: true
required: false

runs:
using: composite
Expand Down
9 changes: 6 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ name: CI
env:
CARGO_NET_RETRY: 3
CARGO_HTTP_CHECK_REVOKE: false
CROSS_IMAGE: ghcr.io/${{ github.repository_owner }}

jobs:
shellcheck:
Expand All @@ -31,7 +32,9 @@ jobs:
ref: ${{ inputs.checkout-ref }}

- name: Run ShellCheck
uses: azohra/[email protected]
uses: Azbagheri/shell-linter@latest
with:
exclude-paths: ".github/CODEOWNERS,LICENSE-APACHE,LICENSE-MIT"

cargo-deny:
runs-on: ubuntu-latest
Expand Down Expand Up @@ -229,7 +232,7 @@ jobs:
run: ./ci/test-cross-image.sh
env:
TARGET: 'aarch64-unknown-linux-gnu'
IMAGE: 'ghcr.io/cross-rs/aarch64-unknown-linux-gnu:main'
IMAGE: 'ghcr.io/${{ github.repository_owner }}/aarch64-unknown-linux-gnu:main'
shell: bash

- name: Login to GitHub Container Registry
Expand Down Expand Up @@ -342,7 +345,7 @@ jobs:
- name: Run Docker-in-Docker Test
env:
TARGET: aarch64-unknown-linux-gnu
IMAGE: 'ghcr.io/cross-rs/aarch64-unknown-linux-gnu:main'
IMAGE: 'ghcr.io/${{ github.repository_owner }}/aarch64-unknown-linux-gnu:main'
run: ./ci/test-docker-in-docker.sh
shell: bash

Expand Down
6 changes: 1 addition & 5 deletions docker/Dockerfile.armv5te-unknown-linux-musleabi
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,7 @@ COPY qemu.sh /
RUN /qemu.sh arm

COPY musl.sh /
RUN /musl.sh \
TARGET=arm-linux-musleabi \
"COMMON_CONFIG += --with-arch=armv5te \
--with-float=soft \
--with-mode=arm"
RUN /musl.sh TARGET=arm-linux-musleabi "COMMON_CONFIG += --with-arch=armv5te --with-float=soft --with-mode=arm"

COPY tidyup.sh /
RUN /tidyup.sh
Expand Down
1 change: 0 additions & 1 deletion docker/Dockerfile.native.centos
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ RUN sed -i /etc/yum.repos.d/*.repo -e 's!^mirrorlist!#mirrorlist!' \
-e 's!^#baseurl=http://mirror.centos.org/!baseurl=https://vault.centos.org/!'
RUN sed -i 's/enabled=1/enabled=0/' /etc/yum/pluginconf.d/fastestmirror.conf


COPY common.sh lib.sh /
RUN /common.sh

Expand Down
2 changes: 1 addition & 1 deletion docker/aarch64-linux-gnu-glibc.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ set -euo pipefail

unpack_rpm() {
local package="${1}"
curl --retry 3 "http://mirror.centos.org/altarch/7/os/aarch64/Packages/${package}" -O
curl --retry 3 "https://vault.centos.org/altarch/7/os/aarch64/Packages/${package}" -O
rpm2cpio "${package}" | cpio -idmv
}

Expand Down
6 changes: 4 additions & 2 deletions docker/cmake.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,12 @@ main() {
local cmake_sha256

local narch
narch="$(dpkg --print-architecture)"
narch="$(uname -p)"

echo "[INFO] $narch"

case "${narch}" in
amd64)
x86_64)
cmake_arch="linux-x86_64"
cmake_sha256="da2a9b18c3bfb136917fa1a579aa5316b01c1d6c111043d03f18877ff05bda30"
;;
Expand Down
8 changes: 4 additions & 4 deletions docker/freebsd.sh
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ latest_freebsd() {
local releases=
local max_release=

response=$(curl --retry 3 -sSfL "${mirror}/${FREEBSD_ARCH}/" | grep RELEASE)
response=$(curl -4 --retry 3 -sSfL "${mirror}/${FREEBSD_ARCH}/" | grep RELEASE)
if [[ "${response}" != *RELEASE* ]]; then
echo -e "\e[31merror:\e[0m could not find a candidate release for FreeBSD ${FREEBSD_MAJOR}." 1>&2
exit 1
Expand Down Expand Up @@ -115,7 +115,7 @@ _freebsd_mirror() {
# we need a timeout in case the server is down to avoid
# infinitely hanging. timeout error code is always 124
# these mirrors can be quite slow, so have a long timeout
timeout 20s curl --retry 3 -sSfL "${mirror}/${FREEBSD_ARCH}/" >/dev/null
timeout 20s curl -4 --retry 3 -sSfL "${mirror}/${FREEBSD_ARCH}/" >/dev/null
code=$?
if [[ "${code}" == 0 ]]; then
echo "${mirror}"
Expand Down Expand Up @@ -173,7 +173,7 @@ main() {
./contrib/download_prerequisites
cd ..

curl --retry 3 -sSfL "${bsd_url}/base.txz" -O
curl -4 --retry 3 -sSfL "${bsd_url}/base.txz" -O
tar -C "${td}/freebsd" -xJf base.txz ./usr/include ./usr/lib ./lib

cd binutils-build
Expand Down Expand Up @@ -243,7 +243,7 @@ main() {
purge_packages

# store the version info for the FreeBSD release
bsd_revision=$(curl --retry 3 -sSfL "${bsd_url}/REVISION")
bsd_revision=$(curl -4 --retry 3 -sSfL "${bsd_url}/REVISION")
echo "${base_release} (${bsd_revision})" > /opt/freebsd-version

rm -rf "${td}"
Expand Down
2 changes: 1 addition & 1 deletion docker/lib.sh
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ download_mirrors() {
shift

for mirror in "${@}"; do
if curl --retry 3 -sSfL "${mirror}/${relpath}/${filename}" -O; then
if curl -4 --retry 3 -sSfL "${mirror}/${relpath}/${filename}" -O; then
break
fi
done
Expand Down
2 changes: 1 addition & 1 deletion docker/linux-image.sh
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ max_kernel_version() {
main() {
# arch in the rust target
local arch="${1}" \
kversion=5.10.0-33
kversion=5.10.0-34

local debsource="deb http://http.debian.net/debian/ bullseye main"
debsource="${debsource}\ndeb http://security.debian.org/ bullseye-security main"
Expand Down
4 changes: 2 additions & 2 deletions docker/netbsd.sh
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,10 @@ main() {
"ftp://ftp.netbsd.org"
"https://cdn.NetBSD.org"
)
download_mirrors "pub/NetBSD/NetBSD-9.2/amd64/binary/sets" "base.tar.xz" "${mirrors[@]}"
download_mirrors "pub/NetBSD/NetBSD-9.3/amd64/binary/sets" "base.tar.xz" "${mirrors[@]}"
tar -C "${td}/netbsd" -xJf base.tar.xz ./usr/include ./usr/lib ./lib

download_mirrors "pub/NetBSD/NetBSD-9.2/amd64/binary/sets" "comp.tar.xz" "${mirrors[@]}"
download_mirrors "pub/NetBSD/NetBSD-9.3/amd64/binary/sets" "comp.tar.xz" "${mirrors[@]}"
tar -C "${td}/netbsd" -xJf comp.tar.xz ./usr/include ./usr/lib

pushd binutils-build
Expand Down
8 changes: 6 additions & 2 deletions docker/qemu.sh
Original file line number Diff line number Diff line change
Expand Up @@ -173,8 +173,12 @@ main() {
zlib-devel \
zlib-static

if_centos 'curl --retry 3 -sSfL "https://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess;hb=HEAD" -o /usr/share/automake*/config.guess'
if_centos 'curl --retry 3 -sSfL "https://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.sub;hb=HEAD" -o /usr/share/automake*/config.sub'
### See this thread in case there are other issues regarding Savannah from gnu
### https://lists.nongnu.org/archive/html/savannah-hackers-public/2025-04/msg00003.html
### This link should be a good reference for the config.git repository: https://cgit.git.savannah.gnu.org/cgit/config.git/

if_centos 'curl --retry 3 -sSfL "https://gitweb.git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess;hb=HEAD" -o /usr/share/automake*/config.guess'
if_centos 'curl --retry 3 -sSfL "https://gitweb.git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.sub;hb=HEAD" -o /usr/share/automake*/config.sub'

# these are not packaged as static libraries in centos; build them manually
if_centos build_static_libffi
Expand Down
1 change: 1 addition & 0 deletions src/bin/commands/images.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ use cross::{CommandExt, TargetList};

// known image prefixes, with their registry
// the docker.io registry can also be implicit

const GHCR_IO: &str = docker::CROSS_IMAGE;
const RUST_EMBEDDED: &str = "rustembedded/cross";
const DOCKER_IO: &str = "docker.io/rustembedded/cross";
Expand Down
21 changes: 13 additions & 8 deletions src/docker/shared.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,3 @@
use std::io::Write;
use std::path::{Path, PathBuf};
use std::process::{Command, ExitStatus, Output};
use std::sync::atomic::{AtomicBool, Ordering};
use std::{env, fs, time};

use super::custom::{Dockerfile, PreBuild};
use super::image::PossibleImage;
use super::Image;
Expand All @@ -18,12 +12,23 @@
use crate::rustc::QualifiedToolchain;
use crate::shell::{ColorChoice, MessageInfo, Verbosity};
use crate::{CommandVariant, OutputExt, Target, TargetTriple};
use std::io::Write;
use std::path::{Path, PathBuf};
use std::process::{Command, ExitStatus, Output};
use std::sync::atomic::{AtomicBool, Ordering};
use std::{env, fs, time};

use rustc_version::Version as RustcVersion;

pub use super::custom::CROSS_CUSTOM_DOCKERFILE_IMAGE_PREFIX;
pub const CROSS_IMAGE: &str = {
if let Some(opt) = option_env!("CROSS_IMAGE") {
opt
} else {
"ghcr.io/cross-rs"
}
};

pub const CROSS_IMAGE: &str = "ghcr.io/cross-rs";
// note: this is the most common base image for our images
pub const UBUNTU_BASE: &str = "ubuntu:20.04";
pub const DEFAULT_IMAGE_VERSION: &str = if crate::commit_info().is_empty() {
Expand Down Expand Up @@ -565,7 +570,7 @@
pub fn create(engine: Engine, name: String) -> Result<()> {
// SAFETY: guarded by an atomic swap
unsafe {
if !CHILD_CONTAINER.exists.swap(true, Ordering::SeqCst) {

Check warning on line 573 in src/docker/shared.rs

View workflow job for this annotation

GitHub Actions / docker-in-docker

creating a shared reference to mutable static is discouraged
CHILD_CONTAINER.info = Some(ChildContainerInfo {
engine,
name,
Expand All @@ -589,7 +594,7 @@

pub fn exists_static() -> bool {
// SAFETY: an atomic load.
unsafe { CHILD_CONTAINER.exists() }

Check warning on line 597 in src/docker/shared.rs

View workflow job for this annotation

GitHub Actions / docker-in-docker

creating a shared reference to mutable static is discouraged
}

// when the `docker run` command finished.
Expand All @@ -601,7 +606,7 @@
pub fn exit_static() {
// SAFETY: an atomic store.
unsafe {
CHILD_CONTAINER.exit();

Check warning on line 609 in src/docker/shared.rs

View workflow job for this annotation

GitHub Actions / docker-in-docker

creating a mutable reference to mutable static is discouraged
}
}

Expand All @@ -627,7 +632,7 @@
pub fn finish_static(is_tty: bool, msg_info: &mut MessageInfo) {
// SAFETY: internally guarded by an atomic load.
unsafe {
CHILD_CONTAINER.finish(is_tty, msg_info);

Check warning on line 635 in src/docker/shared.rs

View workflow job for this annotation

GitHub Actions / docker-in-docker

creating a mutable reference to mutable static is discouraged
}
}

Expand Down Expand Up @@ -1619,7 +1624,7 @@
} else {
"x86_64-unknown-linux-gnu"
};
let expected = format!("ghcr.io/cross-rs/{expected_image_target}{expected_ver}");
let expected = format!("{CROSS_IMAGE}/{expected_image_target}{expected_ver}");

let image = get_image(&config, &target, uses_zig)?;
assert_eq!(image.reference.get(), expected);
Expand Down
2 changes: 1 addition & 1 deletion targets.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

[[target]]
target = "x86_64-apple-darwin"
os = "macos-12"
os = "macos-13"
special = true
deploy = true

Expand Down
Loading