55ROOT=" ${GITHUB_WORKSPACE:- $(git rev-parse --show-toplevel)} "
66
77latest_release=0
8+ cleanup=0
89for arg in " $@ " ; do
910 if [ " $arg " = " --latest-release" ]; then
1011 latest_release=1
1112 fi
13+ if [ " $arg " = " --cleanup" ]; then
14+ cleanup=1
15+ fi
1216done
1317
1418CLEANUP_ON_EXIT=()
1519
1620function cleanup() {
21+ if [ " $cleanup " -eq 0 ]; then
22+ echo " You can delete the following directories:"
23+ echo " ${CLEANUP_ON_EXIT[@]} "
24+ else
1725 for x in " ${CLEANUP_ON_EXIT[@]} " ; do
18- rm -rf " ${x} "
26+ echo " Deleting: ${x} "
27+ rm -rf " ${x} "
1928 done
29+ fi
2030}
2131
2232trap cleanup EXIT
@@ -27,11 +37,7 @@ function sed_replace {
2737 shift
2838 while [[ $# -gt 0 ]]; do
2939 local pattern=" ${1} " ;
30- if [[ " $( uname) " == " Darwin" ]]; then
31- sed -i ' ' -e " ${pattern} " " ${filepath} "
32- else
33- sed -i -e " ${pattern} " " ${filepath} "
34- fi
40+ perl -0777 -pi -e " ${pattern} " " ${filepath} "
3541 shift
3642 done
3743}
@@ -44,24 +50,46 @@ popd &>/dev/null # "${ROOT}/aws-lc-rs"
4450
4551RUSTLS_RCGEN_DIR=" $( mktemp -d) "
4652CLEANUP_ON_EXIT+=(" ${RUSTLS_RCGEN_DIR} " )
47- cargo download -o " ${RUSTLS_RCGEN_DIR} " /rcgen.tar.gz rcgen
48- tar xvzf " ${RUSTLS_RCGEN_DIR} " /rcgen.tar.gz -C " ${RUSTLS_RCGEN_DIR} " --strip-components=1
49- rm " ${RUSTLS_RCGEN_DIR} " /rcgen.tar.gz
50- RUSTLS_RCGEN_COMMIT=" $( jq -r ' .git.sha1' ${RUSTLS_RCGEN_DIR} /.cargo_vcs_info.json) "
51- rm -rf " ${RUSTLS_RCGEN_DIR} " # Cleanup before we clone
53+ if [[ $latest_release == " 1" ]]; then
54+ RUSTLS_RCGEN_STABLE_VERSION=" $( cargo show --json rcgen | jq -r '
55+ [.versions[] |
56+ select(.yanked == false and (.num | test("alpha|beta|rc") | not))
57+ ][0].num
58+ ' ) "
59+
60+ cargo download -o " ${RUSTLS_RCGEN_DIR} " /rcgen.tar.gz " rcgen=${RUSTLS_RCGEN_STABLE_VERSION} "
61+ tar xvzf " ${RUSTLS_RCGEN_DIR} " /rcgen.tar.gz -C " ${RUSTLS_RCGEN_DIR} " --strip-components=1
62+ rm " ${RUSTLS_RCGEN_DIR} " /rcgen.tar.gz
63+ RUSTLS_RCGEN_COMMIT=" $( jq -r ' .git.sha1' ${RUSTLS_RCGEN_DIR} /.cargo_vcs_info.json) "
64+ rm -rf " ${RUSTLS_RCGEN_DIR} " # Cleanup before we clone
65+ fi
5266
5367RUSTLS_WEBPKI_DIR=" $( mktemp -d) "
5468CLEANUP_ON_EXIT+=(" ${RUSTLS_WEBPKI_DIR} " )
55- cargo download -o " ${RUSTLS_WEBPKI_DIR} " /rustls-webpki.tar.gz rustls-webpki
56- tar xvzf " ${RUSTLS_WEBPKI_DIR} " /rustls-webpki.tar.gz -C " ${RUSTLS_WEBPKI_DIR} " --strip-components=1
57- rm " ${RUSTLS_WEBPKI_DIR} " /rustls-webpki.tar.gz
58- RUSTLS_WEBPKI_COMMIT=" $( jq -r ' .git.sha1' ${RUSTLS_WEBPKI_DIR} /.cargo_vcs_info.json) "
59- rm -rf " ${RUSTLS_WEBPKI_DIR} " # Cleanup before we clone
69+ if [[ $latest_release == " 1" ]]; then
70+ RUSTLS_WEBPKI_STABLE_VERSION=" $( cargo show --json rustls-webpki | jq -r '
71+ [.versions[] |
72+ select(.yanked == false and (.num | test("alpha|beta|rc") | not))
73+ ][0].num
74+ ' ) "
75+
76+ cargo download -o " ${RUSTLS_WEBPKI_DIR} " /rustls-webpki.tar.gz " rustls-webpki=${RUSTLS_WEBPKI_STABLE_VERSION} "
77+ tar xvzf " ${RUSTLS_WEBPKI_DIR} " /rustls-webpki.tar.gz -C " ${RUSTLS_WEBPKI_DIR} " --strip-components=1
78+ rm " ${RUSTLS_WEBPKI_DIR} " /rustls-webpki.tar.gz
79+ RUSTLS_WEBPKI_COMMIT=" $( jq -r ' .git.sha1' ${RUSTLS_WEBPKI_DIR} /.cargo_vcs_info.json) "
80+ rm -rf " ${RUSTLS_WEBPKI_DIR} " # Cleanup before we clone
81+ fi
6082
6183RUSTLS_DIR=" $( mktemp -d) "
6284CLEANUP_ON_EXIT+=(" ${RUSTLS_DIR} " )
6385if [[ $latest_release == " 1" ]]; then
64- cargo download -o " ${RUSTLS_DIR} " /rustls.tar.gz rustls
86+ RUSTLS_STABLE_VERSION=" $( cargo show --json rustls | jq -r '
87+ [.versions[] |
88+ select(.yanked == false and (.num | test("alpha|beta|rc") | not))
89+ ][0].num
90+ ' ) "
91+
92+ cargo download -o " ${RUSTLS_DIR} " /rustls.tar.gz " rustls=${RUSTLS_STABLE_VERSION} "
6593 tar xvzf " ${RUSTLS_DIR} " /rustls.tar.gz -C " ${RUSTLS_DIR} " --strip-components=1
6694 rm " ${RUSTLS_DIR} " /rustls.tar.gz
6795 RUSTLS_COMMIT=" $( jq -r ' .git.sha1' ${RUSTLS_DIR} /.cargo_vcs_info.json) "
@@ -74,7 +102,9 @@ git clone https://github.com/rustls/rustls.git "${RUSTLS_DIR}"
74102
75103# Update rcgen to use the GitHub repository reference under test.
76104pushd " ${RUSTLS_RCGEN_DIR} "
77- git checkout " ${RUSTLS_RCGEN_COMMIT} "
105+ if [[ $latest_release == " 1" ]]; then
106+ git checkout " ${RUSTLS_RCGEN_COMMIT} "
107+ fi
78108rm Cargo.lock
79109RCGEN_AWS_LC_RS_STRING=" ^aws-lc-rs = .*"
80110RCGEN_AWS_LC_RS_PATH_STRING=" aws-lc-rs = { path = \" ${ROOT} /aws-lc-rs\" , default-features = false, features = [\" aws-lc-sys\" ] }"
@@ -87,17 +117,16 @@ popd &>/dev/null # "${RUSTLS_RCGEN_DIR}"
87117
88118# Update rustls-webpki to use the GitHub repository reference under test.
89119pushd " ${RUSTLS_WEBPKI_DIR} "
90- git checkout " ${RUSTLS_WEBPKI_COMMIT} "
120+ if [[ $latest_release == " 1" ]]; then
121+ git checkout " ${RUSTLS_WEBPKI_COMMIT} "
122+ fi
91123rm Cargo.lock
92124WEBPKI_RCGEN_STRING=" ^rcgen = { .* }"
93125WEBPKI_RCGEN_PATH_STRING=" rcgen = { path = \" ${RUSTLS_RCGEN_DIR} /rcgen\" , default-features = false, features = [\" aws_lc_rs\" ] }"
94126WEBPKI_AWS_LC_RS_STRING=" ^aws-lc-rs = { version.* }"
95127WEBPKI_AWS_LC_RS_PATH_STRING=" aws-lc-rs = { path = \" ${ROOT} /aws-lc-rs\" , optional = true, default-features = false, features = [\" aws-lc-sys\" ] }"
96- if [[ " $( uname) " == " Darwin" ]]; then
97- find ./ -type f -name " Cargo.toml" | xargs sed -i ' ' -e " s|${WEBPKI_RCGEN_STRING} |${WEBPKI_RCGEN_PATH_STRING} |g" -e " s|${WEBPKI_AWS_LC_RS_STRING} |${WEBPKI_AWS_LC_RS_PATH_STRING} |g"
98- else
99- find ./ -type f -name " Cargo.toml" | xargs sed -i -e " s|${WEBPKI_RCGEN_STRING} |${WEBPKI_RCGEN_PATH_STRING} |g" -e " s|${WEBPKI_AWS_LC_RS_STRING} |${WEBPKI_AWS_LC_RS_PATH_STRING} |g"
100- fi
128+ find ./ -type f -name " Cargo.toml" | xargs perl -0777 -pi -e ' s|' " ${WEBPKI_RCGEN_STRING} " ' |' " ${WEBPKI_RCGEN_PATH_STRING} " ' |g; s|' " ${WEBPKI_AWS_LC_RS_STRING} " ' |' " ${WEBPKI_AWS_LC_RS_PATH_STRING} " ' |g'
129+
101130# Trigger Cargo to generate the lock file
102131cargo update
103132cargo update " aws-lc-rs@${AWS_LC_RS_VERSION} "
@@ -116,14 +145,11 @@ RUSTLS_RCGEN_PATH_STRING="rcgen = { path = \"${RUSTLS_RCGEN_DIR}/rcgen\" , defau
116145RUSTLS_AWS_LC_RS_STRING=" ^aws-lc-rs = { version.* }"
117146RUSTLS_AWS_LC_RS_PATH_STRING=" aws-lc-rs = { path = \" ${ROOT} /aws-lc-rs\" , default-features = false, features = [\" aws-lc-sys\" ] }"
118147RUSTLS_AWS_LC_RS_NON_OPTIONAL_PATH_STRING=" aws-lc-rs = { path = \" ${ROOT} /aws-lc-rs\" , default-features = false, features = [\" unstable\" , \" aws-lc-sys\" ] }"
119- RUSTLS_WEBPKI_STRING=" ^webpki = { package.* }"
148+ RUSTLS_WEBPKI_STRING=" ^webpki = { package = \" rustls-webpki \" ,.* }"
120149RUSTLS_WEBPKI_PATH_STRING=" webpki = { package = \" rustls-webpki\" , path = \" ${RUSTLS_WEBPKI_DIR} \" , features = [\" alloc\" ], default-features = false }"
121150sed_replace ./rustls-post-quantum/Cargo.toml " s|${RUSTLS_AWS_LC_RS_STRING} |${RUSTLS_AWS_LC_RS_NON_OPTIONAL_PATH_STRING} |g"
122- if [[ " $( uname) " == " Darwin" ]]; then
123- find ./ -type f -name " Cargo.toml" | xargs sed -i ' ' -e " s|${RUSTLS_RCGEN_STRING} |${RUSTLS_RCGEN_PATH_STRING} |g" -e " s|${RUSTLS_AWS_LC_RS_STRING} |${RUSTLS_AWS_LC_RS_PATH_STRING} |g" -e " s|${RUSTLS_WEBPKI_STRING} |${RUSTLS_WEBPKI_PATH_STRING} |g"
124- else
125- find ./ -type f -name " Cargo.toml" | xargs sed -i -e " s|${RUSTLS_RCGEN_STRING} |${RUSTLS_RCGEN_PATH_STRING} |g" -e " s|${RUSTLS_AWS_LC_RS_STRING} |${RUSTLS_AWS_LC_RS_PATH_STRING} |g" -e " s|${RUSTLS_WEBPKI_STRING} |${RUSTLS_WEBPKI_PATH_STRING} |g"
126- fi
151+ find ./ -type f -name " Cargo.toml" | xargs perl -0777 -pi -e ' s|' " ${RUSTLS_RCGEN_STRING} " ' |' " ${RUSTLS_RCGEN_PATH_STRING} " ' |g; s|' " ${RUSTLS_AWS_LC_RS_STRING} " ' |' " ${RUSTLS_AWS_LC_RS_PATH_STRING} " ' |g; s|' " ${RUSTLS_WEBPKI_STRING} " ' |' " ${RUSTLS_WEBPKI_PATH_STRING} " ' |g'
152+
127153# Trigger Cargo to generate the lock file
128154cargo update
129155cargo update " aws-lc-rs@${AWS_LC_RS_VERSION} "
0 commit comments