mirror of
https://github.com/GreptimeTeam/greptimedb.git
synced 2025-12-26 08:00:01 +00:00
build: Download assets to cargo output dir (#1476)
* build: Download assets to cargo output dir Also remove the output from the build script and only print the output on failure * chore: Update src/servers/build.rs Co-authored-by: Ruihang Xia <waynestxia@gmail.com> * build: replace pushd by cd --------- Co-authored-by: Ruihang Xia <waynestxia@gmail.com>
This commit is contained in:
@@ -7,9 +7,12 @@ set -e
|
|||||||
declare -r SCRIPT_DIR=$(cd $(dirname ${0}) >/dev/null 2>&1 && pwd)
|
declare -r SCRIPT_DIR=$(cd $(dirname ${0}) >/dev/null 2>&1 && pwd)
|
||||||
declare -r ROOT_DIR=$(dirname ${SCRIPT_DIR})
|
declare -r ROOT_DIR=$(dirname ${SCRIPT_DIR})
|
||||||
declare -r STATIC_DIR="$ROOT_DIR/src/servers/dashboard"
|
declare -r STATIC_DIR="$ROOT_DIR/src/servers/dashboard"
|
||||||
|
OUT_DIR="${1:-$SCRIPT_DIR}"
|
||||||
|
|
||||||
RELEASE_VERSION="$(cat $STATIC_DIR/VERSION)"
|
RELEASE_VERSION="$(cat $STATIC_DIR/VERSION)"
|
||||||
|
|
||||||
|
echo "Downloading assets to dir: $OUT_DIR"
|
||||||
|
cd $OUT_DIR
|
||||||
# Download the SHA256 checksum attached to the release. To verify the integrity
|
# Download the SHA256 checksum attached to the release. To verify the integrity
|
||||||
# of the download, this checksum will be used to check the download tar file
|
# of the download, this checksum will be used to check the download tar file
|
||||||
# containing the built dashboard assets.
|
# containing the built dashboard assets.
|
||||||
|
|||||||
@@ -21,33 +21,28 @@ fn main() {
|
|||||||
fn fetch_dashboard_assets() {
|
fn fetch_dashboard_assets() {
|
||||||
use std::process::{Command, Stdio};
|
use std::process::{Command, Stdio};
|
||||||
|
|
||||||
macro_rules! p {
|
let message = "Failed to fetch dashboard assets";
|
||||||
($($tokens: tt)*) => {
|
let help = r#"
|
||||||
println!("cargo:warning={}", format!($($tokens)*))
|
You can manually execute './scripts/fetch-dashboard-assets.sh' to see why,
|
||||||
}
|
or it's a network error, just try again or enable/disable some proxy."#;
|
||||||
}
|
let out_dir = std::env::var("OUT_DIR").unwrap();
|
||||||
|
|
||||||
let output = Command::new("./fetch-dashboard-assets.sh")
|
let output = Command::new("./fetch-dashboard-assets.sh")
|
||||||
|
.arg(&out_dir)
|
||||||
.current_dir("../../scripts")
|
.current_dir("../../scripts")
|
||||||
.stdout(Stdio::piped())
|
.stdout(Stdio::piped())
|
||||||
.spawn()
|
.spawn()
|
||||||
.and_then(|p| p.wait_with_output());
|
.and_then(|p| p.wait_with_output());
|
||||||
match output {
|
match output {
|
||||||
Ok(output) => {
|
Ok(output) => {
|
||||||
String::from_utf8_lossy(&output.stdout)
|
let script_output = String::from_utf8_lossy(&output.stdout);
|
||||||
.lines()
|
|
||||||
.for_each(|x| p!("{}", x));
|
|
||||||
|
|
||||||
assert!(output.status.success());
|
assert!(
|
||||||
|
output.status.success(),
|
||||||
|
"{message}.\n{script_output}\n{help}"
|
||||||
|
);
|
||||||
}
|
}
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
let e = format!(
|
let e = format!("{message}: {e}.\n{help}");
|
||||||
r#"
|
|
||||||
Failed to fetch dashboard assets: {}.
|
|
||||||
You can manually execute './scripts/fetch-dashboard-assets.sh' to see why,
|
|
||||||
or it's a network error, just try again or enable/disable some proxy."#,
|
|
||||||
e
|
|
||||||
);
|
|
||||||
panic!("{}", e);
|
panic!("{}", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user