-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(installation): download lib binaries (#191)
- Loading branch information
Showing
14 changed files
with
317 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,4 +15,5 @@ | |
^\.task$ | ||
^src/\.cargo$ | ||
^src/rust/vendor$ | ||
^src/Makevars$ | ||
^tools/libprqlr\.a$ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,4 +6,5 @@ docs | |
|
||
src/rust/vendor | ||
src/rust/vendor.tar.xz | ||
src/Makevars | ||
tools/libprqlr.a |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#!/usr/bin/env sh | ||
|
||
rm -f src/Makevars |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,69 @@ | ||
#!/usr/bin/env sh | ||
|
||
NOT_CRAN=${NOT_CRAN:-"false"} | ||
LIBPRQLR_BUILD=${LIBPRQLR_BUILD:-""} | ||
|
||
LIBNAME="libprqlr.a" | ||
LIBPRQLR_PATH="tools/${LIBNAME}" | ||
|
||
export PATH="$PATH:$HOME/.cargo/bin" | ||
|
||
check_cargo() { | ||
if [ ! "$(command -v cargo)" ]; then | ||
echo "----------------------- [RUST NOT FOUND]---------------------------" | ||
echo "" | ||
echo "------------------------- [RUST NOT FOUND] -------------------------" | ||
echo "The 'cargo' command was not found on the PATH. Please install rustc" | ||
echo "from: https://www.rust-lang.org/tools/install" | ||
echo "" | ||
echo "Alternatively, you may install cargo from your OS package manager:" | ||
echo " - Debian/Ubuntu: apt-get install cargo" | ||
echo " - Fedora/CentOS: dnf install cargo" | ||
echo " - macOS: brew install rustc" | ||
echo "-------------------------------------------------------------------" | ||
echo "--------------------------------------------------------------------" | ||
echo "" | ||
exit 1 | ||
else | ||
echo "" | ||
echo "--------------------------- [RUST FOUND] ---------------------------" | ||
"$(cargo -V)" | ||
echo "" | ||
"$(rustc -vV)" | ||
echo "--------------------------------------------------------------------" | ||
echo "" | ||
fi | ||
} | ||
|
||
check_bin_lib() { | ||
if [ "${NOT_CRAN}" = "true" ] && [ -z "${LIBPRQLR_BUILD}" ]; then | ||
LIBPRQLR_BUILD="false" | ||
fi | ||
|
||
if [ "${LIBPRQLR_BUILD}" = "false" ] && [ -f "tools/lib-sums.tsv" ] && [ ! -f "${LIBPRQLR_PATH}" ] ; then | ||
echo "Try to download pre-built binary..." | ||
LIBPRQLR_PATH="tools/${LIBNAME}" | ||
Rscript "tools/prep-lib.R" || echo "Failed to download pre-built binary..." | ||
fi | ||
|
||
if [ "${LIBPRQLR_BUILD}" = "false" ] && [ -f "${LIBPRQLR_PATH}" ]; then | ||
echo "" | ||
echo "------------------------- [LIBRARY FOUND] -------------------------" | ||
echo "The library was found at <${LIBPRQLR_PATH}>. No need to build it." | ||
echo "-------------------------------------------------------------------" | ||
echo "" | ||
sed -e "s|@RUST_TARGET@||" src/Makevars.in >src/Makevars | ||
exit 0 | ||
elif [ "${LIBPRQLR_BUILD}" = "false" ]; then | ||
echo "" | ||
echo "----------------------- [LIBRARY NOT FOUND] -----------------------" | ||
echo "The library was not found at <${LIBPRQLR_PATH}>." | ||
echo "-------------------------------------------------------------------" | ||
echo "" | ||
fi | ||
} | ||
|
||
check_bin_lib | ||
check_cargo | ||
|
||
sed -e "s|@RUST_TARGET@|$(rustc -vV | grep host | cut -d' ' -f2)|" src/Makevars.in >src/Makevars | ||
|
||
exit 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,62 @@ | ||
#!/bin/sh | ||
|
||
NOT_CRAN=${NOT_CRAN:-"false"} | ||
LIBPRQLR_BUILD=${LIBPRQLR_BUILD:-""} | ||
|
||
LIBNAME="libprqlr.a" | ||
LIBPRQLR_PATH="tools/${LIBNAME}" | ||
|
||
export PATH="$PATH:$HOME/.cargo/bin" | ||
|
||
check_cargo() { | ||
if [ ! "$(command -v cargo)" ]; then | ||
echo "----------------------- [RUST NOT FOUND]---------------------------" | ||
echo "" | ||
echo "------------------------- [RUST NOT FOUND] -------------------------" | ||
echo "The 'cargo' command was not found on the PATH. Please install rustc" | ||
echo "from: https://www.rust-lang.org/tools/install" | ||
echo "-------------------------------------------------------------------" | ||
echo "--------------------------------------------------------------------" | ||
echo "" | ||
exit 1 | ||
else | ||
echo "" | ||
echo "--------------------------- [RUST FOUND] ---------------------------" | ||
"$(cargo -V)" | ||
echo "" | ||
"$(rustc -vV)" | ||
echo "--------------------------------------------------------------------" | ||
echo "" | ||
fi | ||
} | ||
|
||
check_bin_lib() { | ||
if [ "${NOT_CRAN}" = "true" ] && [ -z "${LIBPRQLR_BUILD}" ]; then | ||
LIBPRQLR_BUILD="false" | ||
fi | ||
|
||
if [ "${LIBPRQLR_BUILD}" = "false" ] && [ -f "tools/lib-sums.tsv" ] && [ ! -f "${LIBPRQLR_PATH}" ] ; then | ||
echo "Try to download pre-built binary..." | ||
LIBPRQLR_PATH="tools/${LIBNAME}" | ||
Rscript "tools/prep-lib.R" || echo "Failed to download pre-built binary..." | ||
fi | ||
|
||
if [ "${LIBPRQLR_BUILD}" = "false" ] && [ -f "${LIBPRQLR_PATH}" ]; then | ||
echo "" | ||
echo "------------------------- [LIBRARY FOUND] -------------------------" | ||
echo "The library was found at <${LIBPRQLR_PATH}>. No need to build it." | ||
echo "-------------------------------------------------------------------" | ||
echo "" | ||
sed -e "s|@RUST_TARGET@||" src/Makevars.in >src/Makevars | ||
exit 0 | ||
elif [ "${LIBPRQLR_BUILD}" = "false" ]; then | ||
echo "" | ||
echo "----------------------- [LIBRARY NOT FOUND] -----------------------" | ||
echo "The library was not found at <${LIBPRQLR_PATH}>." | ||
echo "-------------------------------------------------------------------" | ||
echo "" | ||
fi | ||
} | ||
|
||
check_bin_lib | ||
check_cargo | ||
|
||
exit 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
base_url <- "https://github.com/eitsupi/prqlr/releases/download/" | ||
|
||
tag_prefix <- "lib-v" | ||
|
||
lib_data_file_path <- file.path("tools", "lib-sums.tsv") | ||
|
||
package_name <- desc::desc_get("Package") | ||
current_lib_version <- RcppTOML::parseTOML("src/rust/Cargo.toml")$package$version | ||
|
||
latest_released_lib_version <- gert::git_remote_ls(remote = "https://github.com/eitsupi/prqlr/") |> | ||
dplyr::pull(ref) |> | ||
stringr::str_subset(stringr::str_c(r"(^refs/tags/)", tag_prefix)) |> | ||
stringr::str_remove(stringr::str_c(".*", tag_prefix)) |> | ||
sort(decreasing = TRUE) |> | ||
_[1] | ||
|
||
write_bin_lib_data <- function(path, sums_url, libs_base_url) { | ||
df <- readr::read_table(sums_url, col_names = FALSE, show_col_types = FALSE) |> | ||
dplyr::mutate( | ||
url = glue::glue("{libs_base_url}{X2}"), | ||
sha256sum = X1, | ||
.keep = "none" | ||
) | ||
|
||
readr::write_tsv(df, path) | ||
} | ||
|
||
desc::desc_set(paste0("Config/", package_name, "/LibVersion"), current_lib_version) | ||
|
||
if (identical(current_lib_version, latest_released_lib_version)) { | ||
message("Current lib version is available via the binary release.") | ||
write_bin_lib_data( | ||
lib_data_file_path, | ||
glue::glue("{base_url}{tag_prefix }{latest_released_lib_version}/sha256sums.txt"), | ||
glue::glue("{base_url}{tag_prefix }{latest_released_lib_version}/") | ||
) | ||
} else { | ||
message("Current lib version is not available via binary releases.") | ||
if (fs::file_exists(lib_data_file_path)) fs::file_delete(lib_data_file_path) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
url sha256sum | ||
https://github.com/eitsupi/prqlr/releases/download/lib-v0.9.0/libprqlr-0.9.0-aarch64-apple-darwin.tar.gz 882ffcc187e225d44d17c1c3bdcac3c27e7fa3b9577a26a4ab2f74677e87f0e8 | ||
https://github.com/eitsupi/prqlr/releases/download/lib-v0.9.0/libprqlr-0.9.0-aarch64-unknown-linux-musl.tar.gz e91a0e3db7a60e8b6b61f55dd061ec1d0429e82e749e0ce16a8af8830fa55eec | ||
https://github.com/eitsupi/prqlr/releases/download/lib-v0.9.0/libprqlr-0.9.0-x86_64-apple-darwin.tar.gz de46cb2e1a68dfca1a6a40116d176cdb850b0c63de0d8495b4453a1099dfcde1 | ||
https://github.com/eitsupi/prqlr/releases/download/lib-v0.9.0/libprqlr-0.9.0-x86_64-pc-windows-gnu.tar.gz 4170bd99c98bc1b39610bdadeccc60a69e5aeaf00f348d2e760da19cb188dbe8 | ||
https://github.com/eitsupi/prqlr/releases/download/lib-v0.9.0/libprqlr-0.9.0-x86_64-unknown-linux-musl.tar.gz 3a9fcdae0b4fdd42bc2e12476b44471c1704a6702770d0dd4e85dee7df38972f |
Oops, something went wrong.