builder: Add the functionality to pull the prebuilt dependencies

This commit is contained in:
Sameer Rahmani 2023-02-03 00:05:21 +00:00
parent e0e0a1dea1
commit 2347b06ab4
Signed by: lxsameer
GPG Key ID: B0A4AF28AB9FD90B
2 changed files with 86 additions and 3 deletions

View File

@ -90,12 +90,34 @@ function push_toolchain() { ## Push the toolchain to the package repository
info "Pushing the toolchain version '$version'..."
_push "$DEPS_BUILD_DIR"
http "$LLVM_DIR_NAME" "$version"
http_push "$LLVM_DIR_NAME" "$version"
echo ""
info "Done"
_pop
}
function pull_toolchain() {
local version
version=$(get_version "$LLVM_DIR")
info "Pulling the toolchain version '$version'..."
if [ -f "$LLVM_INSTALL_DIR.zstd" ]; then
error "The package is already in the cache at: '$LLVM_INSTALL_DIR.zstd'"
return
fi
_push "$DEPS_BUILD_DIR"
if http_pull "$LLVM_DIR_NAME" "$version" "$LLVM_INSTALL_DIR.zstd"; then
echo ""
info "Done"
else
echo ""
error "Can't find the package."
fi
_pop
}
function build_bdwgc() { ## Builds the BDW GC
local version
version=$(get_version "$BDWGC_SOURCE_DIR")
@ -167,12 +189,35 @@ function push_bdwgc() { ## Push the BDWGC package to the package repository
info "Pushing the BDWGC package version '$version'..."
_push "$DEPS_BUILD_DIR"
http "$BDWGC_DIR_NAME" "$version"
http_push "$BDWGC_DIR_NAME" "$version"
echo ""
info "Done"
_pop
}
function pull_bdwgc() {
local version
version=$(get_version "$BDWGC_SOURCE_DIR")
info "Pulling the BDWGC version '$version'..."
if [ -f "$BDWGC_INSTALL_DIR.zstd" ]; then
error "The package is already in the cache at: '$BDWGC_INSTALL_DIR.zstd'"
return
fi
_push "$DEPS_BUILD_DIR"
if http_pull "$BDWGC_DIR_NAME" "$version" "$BDWGC_INSTALL_DIR.zstd"; then
echo ""
info "Done"
else
echo ""
error "Can't find the package."
fi
_pop
}
function manage_dependencies() {
if [ ! "$1" ]; then
error "The action is missing."
@ -192,6 +237,10 @@ function manage_dependencies() {
"pull")
pull_dep "${@:2}"
;;
"install")
install_dependencies "${@:2}"
;;
*)
error "Don't know about '$1' action"
exit 1
@ -199,6 +248,14 @@ function manage_dependencies() {
esac
}
function pull_dep() {
if [ ! "$1" ]; then
error "The dependency name is missing."
exit 1
fi
pull_"$1" "${@:2}"
}
function build_dep() {
if [ ! "$1" ]; then
@ -235,3 +292,9 @@ function pull_dep() {
pull_"$1" "${@:2}"
}
function install_dependencies() {
info "Looking up the dependencies in the remote repository"
pull_toolchain || true
pull_bdwgc || true
}

View File

@ -70,7 +70,7 @@ function get_version() {
_pop
}
function http() {
function http_push() {
if [[ -z "$DEV_HEROES_TOKEN" ]]; then
error '"$DEV_HEROES_TOKEN" is not set.'
exit 1
@ -89,3 +89,23 @@ function http() {
-H "Authorization: token $DEV_HEROES_TOKEN" \
-H "Content-Type: application/json"
}
function http_pull() {
local pkg_name
local version
local output
local url
pkg_name="$1"
version="$2"
output="$3"
url="$DEV_HEROES/api/packages/serene/generic/$pkg_name/$version/$pkg_name.$version.zstd"
info "Fetching '$url'..."
if curl "$url" --fail --progress-bar -o "$output" 2> /dev/null; then
return 0
else
return 4
fi
}