Skip to content

Commit d76a471

Browse files
authored
Merge pull request #14 from rust-lang/build-manifest-component
Use a prebuilt copy of build-manifest
2 parents 66ac5c1 + 32e731a commit d76a471

File tree

10 files changed

+388
-106
lines changed

10 files changed

+388
-106
lines changed

Cargo.lock

Lines changed: 138 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ authors = ["Alex Crichton <alex@alexcrichton.com>"]
55
license = "MIT OR Apache-2.0"
66
edition = "2018"
77

8+
build = "build.rs"
9+
810
[dependencies]
911
curl = "0.4"
1012
flate2 = "1"
@@ -21,3 +23,5 @@ sha2 = "0.9.1"
2123
hex = "0.4.2"
2224
pgp = "0.7.1"
2325
chrono = "0.4.19"
26+
git2 = "0.13.11"
27+
tempfile = "3.1.0"

README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,13 @@ environment variable while calling `rustup`:
3131
RUSTUP_DIST_SERVER="http://localhost:9000/static"
3232
```
3333

34+
You can also release a specific commit by providing its full hash as the second
35+
argument of `./run.sh`:
36+
37+
```
38+
./run.sh nightly 0000000000000000000000000000000000000000
39+
```
40+
3441
### Adding additional files to the local release
3542

3643
To save on time and bandwidth, when running a release locally the tooling won't

build.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
fn main() {
2+
// Prevent a rebuild every time a non-Rust file is changed.
3+
println!("cargo:rerun-if-changed=build.rs");
4+
5+
// Provide the current target as environment variable.
6+
println!(
7+
"cargo:rustc-env=TARGET={}",
8+
std::env::var("TARGET").unwrap()
9+
);
10+
}

local/run.sh

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ RUSTC_DEFAULT_BRANCH="master"
1313
DOWNLOAD_BASE="https://ci-artifacts.rust-lang.org/rustc-builds"
1414
# Rustup components to download for each target we want to release.
1515
DOWNLOAD_COMPONENTS=(
16+
"build-manifest"
1617
"cargo"
1718
"rust"
1819
"rust-docs"
@@ -35,6 +36,7 @@ DOWNLOAD_STANDALONE=(
3536
)
3637

3738
channel="$1"
39+
override_commit="$2"
3840

3941
# Nightly is on the default branch
4042
if [[ "${channel}" = "nightly" ]]; then
@@ -46,8 +48,13 @@ fi
4648
echo "==> overriding files to force promote-release to run"
4749
mc cp "/src/local/channel-rust-${channel}.toml" "local/static/dist/channel-rust-${channel}.toml" >/dev/null
4850

49-
echo "==> detecting the last rustc commit on branch ${branch}"
50-
commit="$(git ls-remote "${RUSTC_REPO}" | grep "refs/heads/${branch}" | awk '{print($1)}')"
51+
if [[ "${override_commit}" = "" ]]; then
52+
echo "==> detecting the last rustc commit on branch ${branch}"
53+
commit="$(git ls-remote "${RUSTC_REPO}" | grep "refs/heads/${branch}" | awk '{print($1)}')"
54+
else
55+
echo "=>> using overridden commit ${override_commit}"
56+
commit="${override_commit}"
57+
fi
5158

5259
# While the nightly and beta channels have the channel name as the "release" in
5360
# the archive names, the stable channel uses the actual Rust and Cargo version
@@ -86,8 +93,9 @@ download() {
8693
file="$1"
8794
if ! mc stat "local/artifacts/builds/${commit}/${file}" >/dev/null 2>&1; then
8895
echo "==> copying ${file} from ci-artifacts.rust-lang.org"
89-
curl -Lo /tmp/component "${DOWNLOAD_BASE}/${commit}/${file}" --fail
90-
mc cp /tmp/component "local/artifacts/builds/${commit}/${file}" >/dev/null
96+
if curl -Lo /tmp/component "${DOWNLOAD_BASE}/${commit}/${file}" --fail; then
97+
mc cp /tmp/component "local/artifacts/builds/${commit}/${file}" >/dev/null
98+
fi
9199
else
92100
echo "==> reusing cached ${file}"
93101
fi
@@ -129,6 +137,10 @@ export PROMOTE_RELEASE_GZIP_COMPRESSION_LEVEL="1" # Faster recompressions
129137
export PROMOTE_RELEASE_S3_ENDPOINT_URL="http://minio:9000"
130138
export PROMOTE_RELEASE_SKIP_CLOUDFRONT_INVALIDATIONS="yes"
131139
export PROMOTE_RELEASE_SKIP_DELETE_BUILD_DIR="yes"
140+
# Conditional environment variables
141+
if [[ "${override_commit}" != "" ]]; then
142+
export PROMOTE_RELEASE_OVERRIDE_COMMIT="${override_commit}"
143+
fi
132144

133145
echo "==> starting promote-release"
134146
/src/target/release/promote-release /persistent/release "${channel}"

prod/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ ENV PATH=/root/.cargo/bin:$PATH
2222
# caching, and it works by copying the Cargo.{toml,lock} with dummy source code
2323
# and doing a full build with it.
2424
WORKDIR /tmp/source
25-
COPY Cargo.lock Cargo.toml /tmp/source/
25+
COPY Cargo.lock Cargo.toml build.rs /tmp/source/
2626
RUN mkdir -p /tmp/source/src && \
2727
echo "fn main() {}" > /tmp/source/src/main.rs
2828
RUN cargo fetch

run.sh

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,12 @@
55
set -euo pipefail
66
IFS=$'\n\t'
77

8-
if [[ "$#" -ne 1 ]]; then
9-
echo "Usage: $0 <channel>"
8+
if [[ "$#" -lt 1 ]] || [[ "$#" -gt 2 ]]; then
9+
echo "Usage: $0 <channel> [commit]"
1010
exit 1
1111
fi
1212
channel="$1"
13+
override_commit="${2-}"
1314

1415
container_id="$(docker-compose ps -q local)"
1516
if [[ "${container_id}" == "" ]]; then
@@ -30,4 +31,4 @@ fi
3031
cargo build --release
3132

3233
# Run the command inside the docker environment.
33-
docker-compose exec -T local /src/local/run.sh "${channel}"
34+
docker-compose exec -T local /src/local/run.sh "${channel}" "${override_commit}"

0 commit comments

Comments
 (0)