Skip to content

Commit bfc6edc

Browse files
bors[bot]EmilgardisAlexhuszaghtaiki-e
authored
Merge #1201
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]>
2 parents 4645d93 + 8536aa8 commit bfc6edc

17 files changed

+163
-67
lines changed

CHANGELOG.md

+11-1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,14 @@ This project adheres to [Semantic Versioning](http://semver.org/).
77

88
## [Unreleased] - ReleaseDate
99

10+
## [v0.2.5] - 2023-02-04
11+
12+
## Fixed
13+
14+
- #962 - fix SELinux labels to allow use in multiple containers and/or the host filesystem.
15+
- #1166 - freebsd: include memstat in build image to fix build with libc 0.2.138 and up.
16+
- #1183 - resolve issue when using `pre-build` in `Cargo.toml`
17+
1018
## [v0.2.4] - 2022-07-10
1119

1220
## Fixed
@@ -364,7 +372,9 @@ This project adheres to [Semantic Versioning](http://semver.org/).
364372
<!-- prettier-ignore-start -->
365373
<!-- next-url -->
366374

367-
[Unreleased]: https://github.com/cross-rs/cross/compare/v0.2.4...HEAD
375+
[Unreleased]: https://github.com/cross-rs/cross/compare/v0.2.5...HEAD
376+
377+
[v0.2.5]: https://github.com/cross-rs/cross/compare/v0.2.4...v0.2.5
368378

369379
[v0.2.4]: https://github.com/cross-rs/cross/compare/v0.2.3...v0.2.4
370380

Cargo.lock

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

+1-2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ keywords = ["cross", "compilation", "testing", "tool"]
66
license = "MIT OR Apache-2.0"
77
name = "cross"
88
repository = "https://github.com/cross-rs/cross"
9-
version = "0.2.4"
9+
version = "0.2.5"
1010
edition = "2021"
1111
include = [
1212
"src/**/*",
@@ -66,7 +66,6 @@ once_cell = "1"
6666
walkdir = "2"
6767

6868
[package.metadata.release]
69-
dev-version = false
7069
push = false
7170
publish = false
7271
tag = false

Dockerfile.hack

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
ARG CROSS_IMAGE
2+
FROM $CROSS_IMAGE

deny.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ vulnerability = "deny"
1212
unmaintained = "deny"
1313
notice = "deny"
1414
unsound = "deny"
15-
ignore = []
15+
ignore = ["RUSTSEC-2021-0145"]
1616

1717
[bans]
1818
multiple-versions = "deny"

docker/Dockerfile.i686-unknown-freebsd

+4-2
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,14 @@ RUN /cmake.sh
1010
COPY xargo.sh /
1111
RUN /xargo.sh
1212

13+
RUN echo "export ARCH=i686" > /freebsd-arch.sh
1314
COPY freebsd-common.sh /
1415
COPY freebsd.sh /
15-
RUN /freebsd.sh i686
16+
RUN /freebsd.sh
1617

18+
COPY freebsd-install.sh /
1719
COPY freebsd-extras.sh /
18-
RUN /freebsd-extras.sh i686
20+
RUN /freebsd-extras.sh
1921

2022
ENV CARGO_TARGET_I686_UNKNOWN_FREEBSD_LINKER=i686-unknown-freebsd12-gcc \
2123
CC_i686_unknown_freebsd=i686-unknown-freebsd12-gcc \

docker/Dockerfile.x86_64-unknown-freebsd

+4-2
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,14 @@ RUN /cmake.sh
1010
COPY xargo.sh /
1111
RUN /xargo.sh
1212

13+
RUN echo "export ARCH=x86_64" > /freebsd-arch.sh
1314
COPY freebsd-common.sh /
1415
COPY freebsd.sh /
15-
RUN /freebsd.sh x86_64
16+
RUN /freebsd.sh
1617

18+
COPY freebsd-install.sh /
1719
COPY freebsd-extras.sh /
18-
RUN /freebsd-extras.sh x86_64
20+
RUN /freebsd-extras.sh
1921

2022
ENV CARGO_TARGET_X86_64_UNKNOWN_FREEBSD_LINKER=x86_64-unknown-freebsd12-gcc \
2123
CC_x86_64_unknown_freebsd=x86_64-unknown-freebsd12-gcc \

docker/dragonfly.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ EOF
105105
cp "${td}/dragonfly/usr/lib/libexecinfo.so.1" "${destdir}/lib"
106106
cp "${td}/dragonfly/usr/lib/libpthread.so" "${destdir}/lib/libpthread.so"
107107
cp "${td}/dragonfly/usr/lib/librt.so.0" "${destdir}/lib"
108-
cp "${td}"/dragonfly/usr/lib/lib{c,m,util}.a "${destdir}/lib"
108+
cp "${td}"/dragonfly/usr/lib/lib{c,m,util,kvm}.a "${destdir}/lib"
109109
cp "${td}/dragonfly/usr/lib/thread/libthread_xu.so.2" "${destdir}/lib/libpthread.so.0"
110110
cp "${td}"/dragonfly/usr/lib/{crt1,Scrt1,crti,crtn}.o "${destdir}/lib/"
111111

docker/freebsd-common.sh

+3
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33
set -x
44
set -euo pipefail
55

6+
# shellcheck disable=SC1091
7+
. freebsd-arch.sh
8+
69
export BSD_ARCH=
710
case "${ARCH}" in
811
x86_64)

docker/freebsd-extras.sh

+4-42
Original file line numberDiff line numberDiff line change
@@ -3,55 +3,17 @@
33
set -x
44
set -euo pipefail
55

6-
export ARCH="${1}"
76
# shellcheck disable=SC1091
87
. lib.sh
98
# shellcheck disable=SC1091
109
. freebsd-common.sh
10+
# shellcheck disable=SC1091
11+
. freebsd-install.sh
1112

1213
main() {
13-
local pkg_source="https://pkg.freebsd.org/FreeBSD:${BSD_MAJOR}:${BSD_ARCH}/quarterly"
14-
install_packages curl jq xz-utils
15-
16-
local td
17-
td="$(mktemp -d)"
18-
19-
mkdir "${td}"/{openssl,sqlite,packagesite}
20-
21-
pushd "${td}"
22-
23-
curl --retry 3 -sSfL "${pkg_source}/packagesite.txz" -O
24-
tar -C "${td}/packagesite" -xJf packagesite.txz
25-
local openssl_ver
26-
local sqlite_ver
27-
openssl_ver=$(jq -c '. | select ( .name == "openssl" ) | .version' "${td}/packagesite/packagesite.yaml")
28-
sqlite_ver=$(jq -c '. | select ( .name == "sqlite3" ) | .version' "${td}/packagesite/packagesite.yaml")
29-
openssl_ver=${openssl_ver//'"'/}
30-
sqlite_ver=${sqlite_ver//'"'/}
31-
32-
local target="${ARCH}-unknown-freebsd${BSD_MAJOR}"
33-
34-
# Adding openssl lib
35-
curl --retry 3 -sSfL "${pkg_source}/All/openssl-${openssl_ver}.txz" -O
36-
tar -C "${td}/openssl" -xJf "openssl-${openssl_ver}.txz" /usr/local/lib /usr/local/include/
37-
38-
# Adding sqlite3
39-
curl --retry 3 -sSfL "${pkg_source}/All/sqlite3-${sqlite_ver}.txz" -O
40-
tar -C "${td}/sqlite" -xJf "sqlite3-${sqlite_ver}.txz" /usr/local/lib
41-
42-
# Copy the linked library
43-
local destdir="/usr/local/${target}"
44-
cp -r "${td}/openssl/usr/local/include" "${destdir}"
45-
cp "${td}/openssl/usr/local/lib"/lib{crypto,ssl}.a "${destdir}/lib"
46-
cp "${td}/openssl/usr/local/lib"/lib{crypto,ssl}.so* "${destdir}/lib"
47-
cp "${td}/sqlite/usr/local/lib"/libsqlite3.so* "${destdir}/lib"
48-
49-
purge_packages
50-
51-
# clean up
52-
popd
14+
setup_packagesite
15+
install_freebsd_package openssl sqlite3
5316

54-
rm -rf "${td}"
5517
rm "${0}"
5618
}
5719

docker/freebsd-install.sh

+57
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
#!/usr/bin/env bash
2+
3+
set -x
4+
set -euo pipefail
5+
6+
# shellcheck disable=SC1091
7+
. freebsd-common.sh
8+
9+
export PACKAGESITE=/opt/freebsd-packagesite/packagesite.yaml
10+
export PKG_SOURCE="https://pkg.freebsd.org/FreeBSD:${BSD_MAJOR}:${BSD_ARCH}/quarterly"
11+
export TARGET="${ARCH}-unknown-freebsd${BSD_MAJOR}"
12+
13+
setup_packagesite() {
14+
apt-get update && apt-get install --assume-yes --no-install-recommends \
15+
curl \
16+
jq \
17+
xz-utils
18+
19+
mkdir /opt/freebsd-packagesite
20+
curl --retry 3 -sSfL "${PKG_SOURCE}/packagesite.txz" -O
21+
tar -C /opt/freebsd-packagesite -xJf packagesite.txz
22+
23+
rm packagesite.txz
24+
}
25+
26+
install_freebsd_package() {
27+
local name
28+
local path
29+
local pkg
30+
local td
31+
local destdir="/usr/local/${TARGET}"
32+
33+
td="$(mktemp -d)"
34+
pushd "${td}"
35+
36+
for name in "${@}"; do
37+
path=$(jq -c '. | select ( .name == "'"${name}"'" ) | .repopath' "${PACKAGESITE}")
38+
if [[ -z "${path}" ]]; then
39+
echo "Unable to find package ${name}" >&2
40+
exit 1
41+
fi
42+
path=${path//'"'/}
43+
pkg=$(basename "${path}")
44+
45+
mkdir "${td}"/package
46+
curl --retry 3 -sSfL "${PKG_SOURCE}/${path}" -O
47+
tar -C "${td}/package" -xJf "${pkg}"
48+
cp -r "${td}/package/usr/local"/* "${destdir}"/
49+
50+
rm "${td:?}/${pkg}"
51+
rm -rf "${td:?}/package"
52+
done
53+
54+
# clean up
55+
popd
56+
rm -rf "${td:?}"
57+
}

docker/freebsd.sh

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
set -x
44
set -euo pipefail
55

6-
export ARCH="${1}"
76
# shellcheck disable=SC1091
87
. freebsd-common.sh
98
# shellcheck disable=SC1091
@@ -96,8 +95,9 @@ main() {
9695
cp "${td}/freebsd/lib/libdevstat.so.7" "${destdir}/lib"
9796
cp "${td}/freebsd/usr/lib/libc++.so.1" "${destdir}/lib"
9897
cp "${td}/freebsd/usr/lib/libc++.a" "${destdir}/lib"
99-
cp "${td}/freebsd/usr/lib"/lib{c,util,m,ssp_nonshared}.a "${destdir}/lib"
98+
cp "${td}/freebsd/usr/lib"/lib{c,util,m,ssp_nonshared,memstat}.a "${destdir}/lib"
10099
cp "${td}/freebsd/usr/lib"/lib{rt,execinfo,procstat}.so.1 "${destdir}/lib"
100+
cp "${td}/freebsd/usr/lib"/libmemstat.so.3 "${destdir}/lib"
101101
cp "${td}/freebsd/usr/lib"/{crt1,Scrt1,crti,crtn}.o "${destdir}/lib"
102102
cp "${td}/freebsd/usr/lib"/libkvm.a "${destdir}/lib"
103103

src/cross_toml.rs

+22
Original file line numberDiff line numberDiff line change
@@ -680,6 +680,28 @@ mod tests {
680680
Ok(())
681681
}
682682

683+
#[test]
684+
pub fn fully_populated_roundtrip() -> Result<()> {
685+
let cfg = r#"
686+
[target.a]
687+
xargo = false
688+
build-std = true
689+
image = "local"
690+
dockerfile.file = "Dockerfile"
691+
dockerfile.context = ".."
692+
pre-build = ["sh"]
693+
zig = true
694+
695+
[target.b]
696+
pre-build = "sh"
697+
zig = "2.17"
698+
"#;
699+
700+
let (cfg, _) = CrossToml::parse_from_cross(cfg, &mut m!())?;
701+
serde_json::from_value::<CrossToml>(serde_json::to_value(cfg)?)?;
702+
Ok(())
703+
}
704+
683705
#[test]
684706
pub fn merge() -> Result<()> {
685707
let cfg1_str = r#"

src/docker/custom.rs

+16-1
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,29 @@ pub enum Dockerfile<'a> {
2323
},
2424
}
2525

26-
#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
26+
#[derive(Debug, Clone, PartialEq, Eq, serde::Deserialize)]
2727
pub enum PreBuild {
2828
/// A path to a file to copy or a single line to `RUN` if line comes from env
2929
Single { line: String, env: bool },
3030
/// Lines to execute in a single `RUN`
3131
Lines(Vec<String>),
3232
}
3333

34+
impl serde::Serialize for PreBuild {
35+
fn serialize<S: serde::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
36+
match self {
37+
PreBuild::Single { line, .. } => serializer.serialize_str(line),
38+
PreBuild::Lines(lines) => {
39+
use serde::ser::SerializeSeq;
40+
let mut seq = serializer.serialize_seq(Some(lines.len()))?;
41+
for line in lines {
42+
seq.serialize_element(line)?;
43+
}
44+
seq.end()
45+
}
46+
}
47+
}
48+
}
3449
impl FromStr for PreBuild {
3550
type Err = std::convert::Infallible;
3651

src/docker/local.rs

+7-7
Original file line numberDiff line numberDiff line change
@@ -39,29 +39,29 @@ pub(crate) fn run(
3939
docker_user_id(&mut docker, engine.kind);
4040

4141
docker
42-
.args(&["-v", &format!("{}:/xargo:Z", dirs.xargo.to_utf8()?)])
43-
.args(&["-v", &format!("{}:/cargo:Z", dirs.cargo.to_utf8()?)])
42+
.args(&["-v", &format!("{}:/xargo:z", dirs.xargo.to_utf8()?)])
43+
.args(&["-v", &format!("{}:/cargo:z", dirs.cargo.to_utf8()?)])
4444
// Prevent `bin` from being mounted inside the Docker container.
4545
.args(&["-v", "/cargo/bin"]);
4646
if mount_volumes {
4747
docker.args(&[
4848
"-v",
49-
&format!("{}:{}:Z", dirs.host_root.to_utf8()?, dirs.mount_root),
49+
&format!("{}:{}:z", dirs.host_root.to_utf8()?, dirs.mount_root),
5050
]);
5151
} else {
52-
docker.args(&["-v", &format!("{}:/project:Z", dirs.host_root.to_utf8()?)]);
52+
docker.args(&["-v", &format!("{}:/project:z", dirs.host_root.to_utf8()?)]);
5353
}
5454
docker
55-
.args(&["-v", &format!("{}:/rust:Z,ro", dirs.sysroot.to_utf8()?)])
56-
.args(&["-v", &format!("{}:/target:Z", dirs.target.to_utf8()?)]);
55+
.args(&["-v", &format!("{}:/rust:z,ro", dirs.sysroot.to_utf8()?)])
56+
.args(&["-v", &format!("{}:/target:z", dirs.target.to_utf8()?)]);
5757
docker_cwd(&mut docker, &paths, mount_volumes)?;
5858

5959
// When running inside NixOS or using Nix packaging we need to add the Nix
6060
// Store to the running container so it can load the needed binaries.
6161
if let Some(ref nix_store) = dirs.nix_store {
6262
docker.args(&[
6363
"-v",
64-
&format!("{}:{}:Z", nix_store.to_utf8()?, nix_store.as_posix()?),
64+
&format!("{}:{}:z", nix_store.to_utf8()?, nix_store.as_posix()?),
6565
]);
6666
}
6767

src/tests/toml.rs

+7-4
Original file line numberDiff line numberDiff line change
@@ -60,14 +60,17 @@ fn toml_check() -> Result<(), Box<dyn std::error::Error>> {
6060
text_line_no(&contents, fence.range().start),
6161
);
6262
let mut msg_info = crate::shell::MessageInfo::default();
63-
assert!(if !cargo {
63+
let toml = if !cargo {
6464
crate::cross_toml::CrossToml::parse_from_cross(&fence_content, &mut msg_info)?
6565
} else {
6666
crate::cross_toml::CrossToml::parse_from_cargo(&fence_content, &mut msg_info)?
6767
.unwrap_or_default()
68-
}
69-
.1
70-
.is_empty());
68+
};
69+
assert!(toml.1.is_empty());
70+
71+
// TODO: Add serde_path_to_error
72+
// Check if roundtrip works, needed for merging Cross.toml and Cargo.toml
73+
serde_json::from_value::<crate::cross_toml::CrossToml>(serde_json::to_value(toml.0)?)?;
7174
}
7275
}
7376
Ok(())

0 commit comments

Comments
 (0)