#!/bin/bash set -e MIRROR="https://packages.0xinfinity.dev" if [ -z "${FS_ROOT}" ] then FS_ROOT="/" fi if [[ "${FS_ROOT}" == "/" ]]; then if [[ "$(whoami)" != "root" ]]; then echo -e "You must run '${0}' as root." exit 1 fi fi if [ -z "${TMP_DIR}" ] then TMP_DIR="/tmp" fi mkdir -p "${TMP_DIR}/downloads" if [ -z "${IBPS_DB}" ] then IBPS_DB="${FS_ROOT}/var/ibps/" fi mkdir -p "${IBPS_DB}" function download_from_mirror { file="$1" version="$2" build_no="$3" curl --output-dir="$TMP_DIR/downloads" "${MIRROR}/${file}/${file}-${version}-${build_no}.ibps" -O echo "Downloaded ${file}:${version}:${build_no}" } function extract { file="$1" currdir="$(pwd)" mkdir -p "${TMP_DIR}/${file}" cp "${TMP_DIR}/downloads/${file}.ibps" "${TMP_DIR}/${file}" cd "${TMP_DIR}/${file}" tar -xf "${file}.ibps" rm "${file}.ibps" cd "${currdir}" } ## Temporarily broken for testing purposes function get_latest_version { local file="$1" echo -e "$resp" echo -e "VERSION SPEC:" echo -e "$version" echo -e "BUILD SPEC:" echo -e "$build_no" } if [ $# -eq 0 ] then echo -e "You must supply a package name!" echo -e "Example:" echo -e " $0 vim" fi PKG_NAME=$1 resp=$(curl "${MIRROR}/${PKG_NAME}/" -o -) if [[ "$(echo "$resp" | grep "^