Skip to content

Commit

Permalink
Merge #1201
Browse files Browse the repository at this point in the history
1201: Release v0.2.5 r=Emilgardis a=Emilgardis

See #962 (comment)

includes

ee3c972 #962
fc3df66 #1166
33ee940 in #997
81c1e59 #950
6a57d01 #1183

Co-authored-by: Emil Gardström <[email protected]>
Co-authored-by: Alex Huszagh <[email protected]>
Co-authored-by: Taiki Endo <[email protected]>
  • Loading branch information
4 people authored Feb 4, 2023
2 parents 4645d93 + 8536aa8 commit bfc6edc
Show file tree
Hide file tree
Showing 17 changed files with 163 additions and 67 deletions.
12 changes: 11 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,14 @@ 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.
- #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
Expand Down Expand Up @@ -364,7 +372,9 @@ This project adheres to [Semantic Versioning](http://semver.org/).
<!-- prettier-ignore-start -->
<!-- next-url -->

[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

Expand Down
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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/**/*",
Expand Down Expand Up @@ -66,7 +66,6 @@ once_cell = "1"
walkdir = "2"

[package.metadata.release]
dev-version = false
push = false
publish = false
tag = false
Expand Down
2 changes: 2 additions & 0 deletions Dockerfile.hack
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
ARG CROSS_IMAGE
FROM $CROSS_IMAGE
2 changes: 1 addition & 1 deletion deny.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ vulnerability = "deny"
unmaintained = "deny"
notice = "deny"
unsound = "deny"
ignore = []
ignore = ["RUSTSEC-2021-0145"]

[bans]
multiple-versions = "deny"
Expand Down
6 changes: 4 additions & 2 deletions docker/Dockerfile.i686-unknown-freebsd
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand Down
6 changes: 4 additions & 2 deletions docker/Dockerfile.x86_64-unknown-freebsd
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand Down
2 changes: 1 addition & 1 deletion docker/dragonfly.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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/"

Expand Down
3 changes: 3 additions & 0 deletions docker/freebsd-common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
set -x
set -euo pipefail

# shellcheck disable=SC1091
. freebsd-arch.sh

export BSD_ARCH=
case "${ARCH}" in
x86_64)
Expand Down
46 changes: 4 additions & 42 deletions docker/freebsd-extras.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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}"
}

Expand Down
57 changes: 57 additions & 0 deletions docker/freebsd-install.sh
Original file line number Diff line number Diff line change
@@ -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:?}"
}
4 changes: 2 additions & 2 deletions docker/freebsd.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
set -x
set -euo pipefail

export ARCH="${1}"
# shellcheck disable=SC1091
. freebsd-common.sh
# shellcheck disable=SC1091
Expand Down Expand Up @@ -96,8 +95,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"

Expand Down
22 changes: 22 additions & 0 deletions src/cross_toml.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::<CrossToml>(serde_json::to_value(cfg)?)?;
Ok(())
}

#[test]
pub fn merge() -> Result<()> {
let cfg1_str = r#"
Expand Down
17 changes: 16 additions & 1 deletion src/docker/custom.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,29 @@ 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 },
/// Lines to execute in a single `RUN`
Lines(Vec<String>),
}

impl serde::Serialize for PreBuild {
fn serialize<S: serde::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
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;

Expand Down
14 changes: 7 additions & 7 deletions src/docker/local.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,29 +39,29 @@ 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
// Store to the running container so it can load the needed binaries.
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()?),
]);
}

Expand Down
11 changes: 7 additions & 4 deletions src/tests/toml.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,14 +60,17 @@ fn toml_check() -> Result<(), Box<dyn std::error::Error>> {
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::<crate::cross_toml::CrossToml>(serde_json::to_value(toml.0)?)?;
}
}
Ok(())
Expand Down
Loading

0 comments on commit bfc6edc

Please sign in to comment.