From 72cff123221eea588793fd027453e0d334db69c6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emil=20Gardstr=C3=B6m?= Date: Fri, 3 Feb 2023 23:14:14 +0100 Subject: [PATCH 01/10] remove dev-version from release config --- Cargo.toml | 1 - 1 file changed, 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index 10eeeb09e..64e5d09ed 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -66,7 +66,6 @@ once_cell = "1" walkdir = "2" [package.metadata.release] -dev-version = false push = false publish = false tag = false From 3c5830e1fa908772048ed8bdfcb0adb9ff74d4c0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emil=20Gardstr=C3=B6m?= Date: Fri, 3 Feb 2023 23:35:48 +0100 Subject: [PATCH 02/10] allow advisory --- deny.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/deny.toml b/deny.toml index 3f7755317..b51d77327 100644 --- a/deny.toml +++ b/deny.toml @@ -12,7 +12,7 @@ vulnerability = "deny" unmaintained = "deny" notice = "deny" unsound = "deny" -ignore = [] +ignore = ["RUSTSEC-2021-0145"] [bans] multiple-versions = "deny" From 706637973d5da9c683d64a967d46822ef08affd9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emil=20Gardstr=C3=B6m?= Date: Sat, 4 Feb 2023 10:17:06 +0100 Subject: [PATCH 03/10] hack powerpc64, solaris and pc-windows-gnu and sparc64 --- Dockerfile.hack | 2 ++ xtask/src/build_docker_image.rs | 21 ++++++++++++++++++++- 2 files changed, 22 insertions(+), 1 deletion(-) create mode 100644 Dockerfile.hack diff --git a/Dockerfile.hack b/Dockerfile.hack new file mode 100644 index 000000000..664ab56dd --- /dev/null +++ b/Dockerfile.hack @@ -0,0 +1,2 @@ +ARG CROSS_IMAGE +FROM $CROSS_IMAGE \ No newline at end of file diff --git a/xtask/src/build_docker_image.rs b/xtask/src/build_docker_image.rs index fc00310ba..6feb367b2 100644 --- a/xtask/src/build_docker_image.rs +++ b/xtask/src/build_docker_image.rs @@ -84,7 +84,21 @@ fn locate_dockerfile( } else { eyre::bail!("unable to find dockerfile for target \"{target}\""); }; - let dockerfile = dockerfile_root.join(dockerfile_name).to_utf8()?.to_string(); + let dockerfile = if matches!( + target.triplet.as_str(), + "powerpc64-unknown-linux-gnu" + | "x86_64-sun-solaris" + | "i686-pc-windows-gnu" + | "x86_64-pc-windows-gnu" + | "sparc64-unknown-linux-gnu" + ) { + crate::util::project_dir(&mut <_>::default())? + .join("Dockerfile.hack") + .to_utf8()? + .to_string() + } else { + dockerfile_root.join(dockerfile_name).to_utf8()?.to_string() + }; Ok((target, dockerfile)) } @@ -243,6 +257,11 @@ pub fn build_docker_image( docker_build.args(&["--build-arg", "VERBOSE=1"]); } + docker_build.args(&[ + "--build-arg", + &format!("CROSS_IMAGE={}", target.image_name(&repository, "0.2.4")), + ]); + if target.needs_workspace_root_context() { docker_build.arg(&root); } else { From cf4c6bc51e81411ac403ca0ca2e62aba5a2e2050 Mon Sep 17 00:00:00 2001 From: Alex Huszagh Date: Mon, 18 Jul 2022 12:48:10 -0500 Subject: [PATCH 04/10] Fix SELinux labels to allow shared use. Ensure that the volumes are not mounted as private, unshared volumes since we might mount with the host filesystem. This also fixes permissions issues with reading data from a mounted volume using a rootless container engine. (cherry picked from commit ee3c9724582ee0201c61b3c3a5c83b0643ad26d4) --- src/docker/local.rs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/docker/local.rs b/src/docker/local.rs index 2d86d3d07..ed65f0b59 100644 --- a/src/docker/local.rs +++ b/src/docker/local.rs @@ -39,21 +39,21 @@ pub(crate) fn run( docker_user_id(&mut docker, engine.kind); docker - .args(&["-v", &format!("{}:/xargo:Z", dirs.xargo.to_utf8()?)]) - .args(&["-v", &format!("{}:/cargo:Z", dirs.cargo.to_utf8()?)]) + .args(&["-v", &format!("{}:/xargo:z", dirs.xargo.to_utf8()?)]) + .args(&["-v", &format!("{}:/cargo:z", dirs.cargo.to_utf8()?)]) // Prevent `bin` from being mounted inside the Docker container. .args(&["-v", "/cargo/bin"]); if mount_volumes { docker.args(&[ "-v", - &format!("{}:{}:Z", dirs.host_root.to_utf8()?, dirs.mount_root), + &format!("{}:{}:z", dirs.host_root.to_utf8()?, dirs.mount_root), ]); } else { - docker.args(&["-v", &format!("{}:/project:Z", dirs.host_root.to_utf8()?)]); + docker.args(&["-v", &format!("{}:/project:z", dirs.host_root.to_utf8()?)]); } docker - .args(&["-v", &format!("{}:/rust:Z,ro", dirs.sysroot.to_utf8()?)]) - .args(&["-v", &format!("{}:/target:Z", dirs.target.to_utf8()?)]); + .args(&["-v", &format!("{}:/rust:z,ro", dirs.sysroot.to_utf8()?)]) + .args(&["-v", &format!("{}:/target:z", dirs.target.to_utf8()?)]); docker_cwd(&mut docker, &paths, mount_volumes)?; // When running inside NixOS or using Nix packaging we need to add the Nix @@ -61,7 +61,7 @@ pub(crate) fn run( if let Some(ref nix_store) = dirs.nix_store { docker.args(&[ "-v", - &format!("{}:{}:Z", nix_store.to_utf8()?, nix_store.as_posix()?), + &format!("{}:{}:z", nix_store.to_utf8()?, nix_store.as_posix()?), ]); } From bbcc0cb21cee111cb5f9a38d95e5ba514c923e83 Mon Sep 17 00:00:00 2001 From: Taiki Endo Date: Sun, 4 Dec 2022 15:26:20 +0900 Subject: [PATCH 05/10] freebsd: include memstat in build image (cherry picked from commit fc3df661a701f8b502883555cab570c31479ac03) --- docker/freebsd.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/docker/freebsd.sh b/docker/freebsd.sh index e351bd3dc..2d1d01783 100755 --- a/docker/freebsd.sh +++ b/docker/freebsd.sh @@ -96,8 +96,9 @@ main() { cp "${td}/freebsd/lib/libdevstat.so.7" "${destdir}/lib" cp "${td}/freebsd/usr/lib/libc++.so.1" "${destdir}/lib" cp "${td}/freebsd/usr/lib/libc++.a" "${destdir}/lib" - cp "${td}/freebsd/usr/lib"/lib{c,util,m,ssp_nonshared}.a "${destdir}/lib" + cp "${td}/freebsd/usr/lib"/lib{c,util,m,ssp_nonshared,memstat}.a "${destdir}/lib" cp "${td}/freebsd/usr/lib"/lib{rt,execinfo,procstat}.so.1 "${destdir}/lib" + cp "${td}/freebsd/usr/lib"/libmemstat.so.3 "${destdir}/lib" cp "${td}/freebsd/usr/lib"/{crt1,Scrt1,crti,crtn}.o "${destdir}/lib" cp "${td}/freebsd/usr/lib"/libkvm.a "${destdir}/lib" From 47452d6be133d2a79baf0bf96819a76c0e13b302 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emil=20Gardstr=C3=B6m?= Date: Sat, 20 Aug 2022 19:27:24 +0200 Subject: [PATCH 06/10] copy kvm (cherry picked from commit 33ee9403c891417fdcd08110e094e2eb3581b61d) --- docker/dragonfly.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker/dragonfly.sh b/docker/dragonfly.sh index 167aff4ad..d53ac1a01 100755 --- a/docker/dragonfly.sh +++ b/docker/dragonfly.sh @@ -105,7 +105,7 @@ EOF cp "${td}/dragonfly/usr/lib/libexecinfo.so.1" "${destdir}/lib" cp "${td}/dragonfly/usr/lib/libpthread.so" "${destdir}/lib/libpthread.so" cp "${td}/dragonfly/usr/lib/librt.so.0" "${destdir}/lib" - cp "${td}"/dragonfly/usr/lib/lib{c,m,util}.a "${destdir}/lib" + cp "${td}"/dragonfly/usr/lib/lib{c,m,util,kvm}.a "${destdir}/lib" cp "${td}/dragonfly/usr/lib/thread/libthread_xu.so.2" "${destdir}/lib/libpthread.so.0" cp "${td}"/dragonfly/usr/lib/{crt1,Scrt1,crti,crtn}.o "${destdir}/lib/" From b6813bf23b7f036545393ad6112c9539a560d404 Mon Sep 17 00:00:00 2001 From: Alex Huszagh Date: Fri, 15 Jul 2022 10:41:54 -0500 Subject: [PATCH 07/10] Simplify FreeBSD package installs. (cherry picked from commit 81c1e59addeb17c7705187541547e3d392481e98) --- docker/Dockerfile.i686-unknown-freebsd | 6 ++- docker/Dockerfile.x86_64-unknown-freebsd | 6 ++- docker/freebsd-common.sh | 3 ++ docker/freebsd-extras.sh | 46 ++----------------- docker/freebsd-install.sh | 57 ++++++++++++++++++++++++ docker/freebsd.sh | 1 - 6 files changed, 72 insertions(+), 47 deletions(-) create mode 100755 docker/freebsd-install.sh diff --git a/docker/Dockerfile.i686-unknown-freebsd b/docker/Dockerfile.i686-unknown-freebsd index af4600a9c..37ea6e780 100644 --- a/docker/Dockerfile.i686-unknown-freebsd +++ b/docker/Dockerfile.i686-unknown-freebsd @@ -10,12 +10,14 @@ RUN /cmake.sh COPY xargo.sh / RUN /xargo.sh +RUN echo "export ARCH=i686" > /freebsd-arch.sh COPY freebsd-common.sh / COPY freebsd.sh / -RUN /freebsd.sh i686 +RUN /freebsd.sh +COPY freebsd-install.sh / COPY freebsd-extras.sh / -RUN /freebsd-extras.sh i686 +RUN /freebsd-extras.sh ENV CARGO_TARGET_I686_UNKNOWN_FREEBSD_LINKER=i686-unknown-freebsd12-gcc \ CC_i686_unknown_freebsd=i686-unknown-freebsd12-gcc \ diff --git a/docker/Dockerfile.x86_64-unknown-freebsd b/docker/Dockerfile.x86_64-unknown-freebsd index 4f53fb297..239628f80 100644 --- a/docker/Dockerfile.x86_64-unknown-freebsd +++ b/docker/Dockerfile.x86_64-unknown-freebsd @@ -10,12 +10,14 @@ RUN /cmake.sh COPY xargo.sh / RUN /xargo.sh +RUN echo "export ARCH=x86_64" > /freebsd-arch.sh COPY freebsd-common.sh / COPY freebsd.sh / -RUN /freebsd.sh x86_64 +RUN /freebsd.sh +COPY freebsd-install.sh / COPY freebsd-extras.sh / -RUN /freebsd-extras.sh x86_64 +RUN /freebsd-extras.sh ENV CARGO_TARGET_X86_64_UNKNOWN_FREEBSD_LINKER=x86_64-unknown-freebsd12-gcc \ CC_x86_64_unknown_freebsd=x86_64-unknown-freebsd12-gcc \ diff --git a/docker/freebsd-common.sh b/docker/freebsd-common.sh index 514ff524e..a5af3fa66 100755 --- a/docker/freebsd-common.sh +++ b/docker/freebsd-common.sh @@ -3,6 +3,9 @@ set -x set -euo pipefail +# shellcheck disable=SC1091 +. freebsd-arch.sh + export BSD_ARCH= case "${ARCH}" in x86_64) diff --git a/docker/freebsd-extras.sh b/docker/freebsd-extras.sh index c3f4f2348..e1d41462a 100755 --- a/docker/freebsd-extras.sh +++ b/docker/freebsd-extras.sh @@ -3,55 +3,17 @@ set -x set -euo pipefail -export ARCH="${1}" # shellcheck disable=SC1091 . lib.sh # shellcheck disable=SC1091 . freebsd-common.sh +# shellcheck disable=SC1091 +. freebsd-install.sh main() { - local pkg_source="https://pkg.freebsd.org/FreeBSD:${BSD_MAJOR}:${BSD_ARCH}/quarterly" - install_packages curl jq xz-utils - - local td - td="$(mktemp -d)" - - mkdir "${td}"/{openssl,sqlite,packagesite} - - pushd "${td}" - - curl --retry 3 -sSfL "${pkg_source}/packagesite.txz" -O - tar -C "${td}/packagesite" -xJf packagesite.txz - local openssl_ver - local sqlite_ver - openssl_ver=$(jq -c '. | select ( .name == "openssl" ) | .version' "${td}/packagesite/packagesite.yaml") - sqlite_ver=$(jq -c '. | select ( .name == "sqlite3" ) | .version' "${td}/packagesite/packagesite.yaml") - openssl_ver=${openssl_ver//'"'/} - sqlite_ver=${sqlite_ver//'"'/} - - local target="${ARCH}-unknown-freebsd${BSD_MAJOR}" - - # Adding openssl lib - curl --retry 3 -sSfL "${pkg_source}/All/openssl-${openssl_ver}.txz" -O - tar -C "${td}/openssl" -xJf "openssl-${openssl_ver}.txz" /usr/local/lib /usr/local/include/ - - # Adding sqlite3 - curl --retry 3 -sSfL "${pkg_source}/All/sqlite3-${sqlite_ver}.txz" -O - tar -C "${td}/sqlite" -xJf "sqlite3-${sqlite_ver}.txz" /usr/local/lib - - # Copy the linked library - local destdir="/usr/local/${target}" - cp -r "${td}/openssl/usr/local/include" "${destdir}" - cp "${td}/openssl/usr/local/lib"/lib{crypto,ssl}.a "${destdir}/lib" - cp "${td}/openssl/usr/local/lib"/lib{crypto,ssl}.so* "${destdir}/lib" - cp "${td}/sqlite/usr/local/lib"/libsqlite3.so* "${destdir}/lib" - - purge_packages - - # clean up - popd + setup_packagesite + install_freebsd_package openssl sqlite3 - rm -rf "${td}" rm "${0}" } diff --git a/docker/freebsd-install.sh b/docker/freebsd-install.sh new file mode 100755 index 000000000..dba0d1db7 --- /dev/null +++ b/docker/freebsd-install.sh @@ -0,0 +1,57 @@ +#!/usr/bin/env bash + +set -x +set -euo pipefail + +# shellcheck disable=SC1091 +. freebsd-common.sh + +export PACKAGESITE=/opt/freebsd-packagesite/packagesite.yaml +export PKG_SOURCE="https://pkg.freebsd.org/FreeBSD:${BSD_MAJOR}:${BSD_ARCH}/quarterly" +export TARGET="${ARCH}-unknown-freebsd${BSD_MAJOR}" + +setup_packagesite() { + apt-get update && apt-get install --assume-yes --no-install-recommends \ + curl \ + jq \ + xz-utils + + mkdir /opt/freebsd-packagesite + curl --retry 3 -sSfL "${PKG_SOURCE}/packagesite.txz" -O + tar -C /opt/freebsd-packagesite -xJf packagesite.txz + + rm packagesite.txz +} + +install_freebsd_package() { + local name + local path + local pkg + local td + local destdir="/usr/local/${TARGET}" + + td="$(mktemp -d)" + pushd "${td}" + + for name in "${@}"; do + path=$(jq -c '. | select ( .name == "'"${name}"'" ) | .repopath' "${PACKAGESITE}") + if [[ -z "${path}" ]]; then + echo "Unable to find package ${name}" >&2 + exit 1 + fi + path=${path//'"'/} + pkg=$(basename "${path}") + + mkdir "${td}"/package + curl --retry 3 -sSfL "${PKG_SOURCE}/${path}" -O + tar -C "${td}/package" -xJf "${pkg}" + cp -r "${td}/package/usr/local"/* "${destdir}"/ + + rm "${td:?}/${pkg}" + rm -rf "${td:?}/package" + done + + # clean up + popd + rm -rf "${td:?}" +} diff --git a/docker/freebsd.sh b/docker/freebsd.sh index 2d1d01783..94f023b31 100755 --- a/docker/freebsd.sh +++ b/docker/freebsd.sh @@ -3,7 +3,6 @@ set -x set -euo pipefail -export ARCH="${1}" # shellcheck disable=SC1091 . freebsd-common.sh # shellcheck disable=SC1091 From d719020e22c68a8677dd6659dc5bdd9582c86840 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emil=20Gardstr=C3=B6m?= Date: Fri, 6 Jan 2023 03:49:04 +0100 Subject: [PATCH 08/10] Fix error when using certain config values in Cargo.toml `pre-build = "file"` had a bad serialization (cherry picked from commit 6a57d01bea09dae71e30e1be9e31e37918417411) --- src/cross_toml.rs | 22 ++++++++++++++++++++++ src/docker/custom.rs | 17 ++++++++++++++++- src/tests/toml.rs | 11 +++++++---- 3 files changed, 45 insertions(+), 5 deletions(-) diff --git a/src/cross_toml.rs b/src/cross_toml.rs index 819143f05..3804622d3 100644 --- a/src/cross_toml.rs +++ b/src/cross_toml.rs @@ -680,6 +680,28 @@ mod tests { Ok(()) } + #[test] + pub fn fully_populated_roundtrip() -> Result<()> { + let cfg = r#" + [target.a] + xargo = false + build-std = true + image = "local" + dockerfile.file = "Dockerfile" + dockerfile.context = ".." + pre-build = ["sh"] + zig = true + + [target.b] + pre-build = "sh" + zig = "2.17" + "#; + + let (cfg, _) = CrossToml::parse_from_cross(cfg, &mut m!())?; + serde_json::from_value::(serde_json::to_value(cfg)?)?; + Ok(()) + } + #[test] pub fn merge() -> Result<()> { let cfg1_str = r#" diff --git a/src/docker/custom.rs b/src/docker/custom.rs index 31e2df6db..780247d88 100644 --- a/src/docker/custom.rs +++ b/src/docker/custom.rs @@ -23,7 +23,7 @@ pub enum Dockerfile<'a> { }, } -#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)] +#[derive(Debug, Clone, PartialEq, Eq, serde::Deserialize)] pub enum PreBuild { /// A path to a file to copy or a single line to `RUN` if line comes from env Single { line: String, env: bool }, @@ -31,6 +31,21 @@ pub enum PreBuild { Lines(Vec), } +impl serde::Serialize for PreBuild { + fn serialize(&self, serializer: S) -> Result { + match self { + PreBuild::Single { line, .. } => serializer.serialize_str(line), + PreBuild::Lines(lines) => { + use serde::ser::SerializeSeq; + let mut seq = serializer.serialize_seq(Some(lines.len()))?; + for line in lines { + seq.serialize_element(line)?; + } + seq.end() + } + } + } +} impl FromStr for PreBuild { type Err = std::convert::Infallible; diff --git a/src/tests/toml.rs b/src/tests/toml.rs index d917ea973..b7b7e75ab 100644 --- a/src/tests/toml.rs +++ b/src/tests/toml.rs @@ -60,14 +60,17 @@ fn toml_check() -> Result<(), Box> { text_line_no(&contents, fence.range().start), ); let mut msg_info = crate::shell::MessageInfo::default(); - assert!(if !cargo { + let toml = if !cargo { crate::cross_toml::CrossToml::parse_from_cross(&fence_content, &mut msg_info)? } else { crate::cross_toml::CrossToml::parse_from_cargo(&fence_content, &mut msg_info)? .unwrap_or_default() - } - .1 - .is_empty()); + }; + assert!(toml.1.is_empty()); + + // TODO: Add serde_path_to_error + // Check if roundtrip works, needed for merging Cross.toml and Cargo.toml + serde_json::from_value::(serde_json::to_value(toml.0)?)?; } } Ok(()) From b95898a6d24bc69f3d18ffa97744c7e5be30588e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emil=20Gardstr=C3=B6m?= Date: Sat, 4 Feb 2023 01:17:05 +0100 Subject: [PATCH 09/10] changelog --- CHANGELOG.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 55b47a683..2f5ec489f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,12 @@ This project adheres to [Semantic Versioning](http://semver.org/). ## [Unreleased] - ReleaseDate +## Fixed + +- #962 - fix SELinux labels to allow use in multiple containers and/or the host filesystem. +- #1166 - freebsd: include memstat in build image to fix build with libc 0.2.138 and up. +- #1183 - resolve issue when using `pre-build` in `Cargo.toml` + ## [v0.2.4] - 2022-07-10 ## Fixed From 8536aa8f33ebd7728c965841f3dd1fc5da34565d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emil=20Gardstr=C3=B6m?= Date: Fri, 3 Feb 2023 23:18:03 +0100 Subject: [PATCH 10/10] Release v0.2.5 --- CHANGELOG.md | 6 +++++- Cargo.lock | 2 +- Cargo.toml | 2 +- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2f5ec489f..aa0c4b01c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,8 @@ This project adheres to [Semantic Versioning](http://semver.org/). ## [Unreleased] - ReleaseDate +## [v0.2.5] - 2023-02-04 + ## Fixed - #962 - fix SELinux labels to allow use in multiple containers and/or the host filesystem. @@ -370,7 +372,9 @@ This project adheres to [Semantic Versioning](http://semver.org/). -[Unreleased]: https://github.com/cross-rs/cross/compare/v0.2.4...HEAD +[Unreleased]: https://github.com/cross-rs/cross/compare/v0.2.5...HEAD + +[v0.2.5]: https://github.com/cross-rs/cross/compare/v0.2.4...v0.2.5 [v0.2.4]: https://github.com/cross-rs/cross/compare/v0.2.3...v0.2.4 diff --git a/Cargo.lock b/Cargo.lock index 0ca6781d1..a95faa1ec 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -150,7 +150,7 @@ checksum = "fb58b6451e8c2a812ad979ed1d83378caa5e927eef2622017a45f251457c2c9d" [[package]] name = "cross" -version = "0.2.4" +version = "0.2.5" dependencies = [ "atty", "clap", diff --git a/Cargo.toml b/Cargo.toml index 64e5d09ed..d2c8f7b0d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -6,7 +6,7 @@ keywords = ["cross", "compilation", "testing", "tool"] license = "MIT OR Apache-2.0" name = "cross" repository = "https://github.com/cross-rs/cross" -version = "0.2.4" +version = "0.2.5" edition = "2021" include = [ "src/**/*",