mirror of
https://codeberg.org/cunicu/cunicu.git
synced 2025-10-06 01:06:59 +08:00
scripts: adapt get_cunicu script to work with archives
Signed-off-by: Steffen Vogel <post@steffenvogel.de>
This commit is contained in:
@@ -27,6 +27,7 @@
|
|||||||
HAS_WGET="$(type "wget" &> /dev/null && echo true || echo false)"
|
HAS_WGET="$(type "wget" &> /dev/null && echo true || echo false)"
|
||||||
HAS_SHA256SUM="$(type "sha256sum" &> /dev/null && echo true || echo false)"
|
HAS_SHA256SUM="$(type "sha256sum" &> /dev/null && echo true || echo false)"
|
||||||
HAS_GPG="$(type "gpg" &> /dev/null && echo true || echo false)"
|
HAS_GPG="$(type "gpg" &> /dev/null && echo true || echo false)"
|
||||||
|
HAS_TAR="$(type "tar" &> /dev/null && echo true || echo false)"
|
||||||
|
|
||||||
# Settings
|
# Settings
|
||||||
GITHUB_URL="https://github.com/stv0g/cunicu"
|
GITHUB_URL="https://github.com/stv0g/cunicu"
|
||||||
@@ -86,6 +87,11 @@ function verifySupported() {
|
|||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [[ "${HAS_TAR}" != "true" ]]; then
|
||||||
|
echo -e "tar is required"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
if [[ "${VERIFY_CHECKSUM}" == "true" && "${HAS_SHA256SUM}" != "true" ]]; then
|
if [[ "${VERIFY_CHECKSUM}" == "true" && "${HAS_SHA256SUM}" != "true" ]]; then
|
||||||
echo -e "In order to verify checksum, sha256sum must first be installed."
|
echo -e "In order to verify checksum, sha256sum must first be installed."
|
||||||
echo -e "Please install sha256sum or set VERIFY_CHECKSUM=false in your environment."
|
echo -e "Please install sha256sum or set VERIFY_CHECKSUM=false in your environment."
|
||||||
@@ -138,24 +144,23 @@ function checkInstalledVersion() {
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
# downloadBinary downloads the latest binary package and also the checksum
|
# downloadArchive downloads the latest binary package and also the checksum
|
||||||
# for that binary.
|
# for that binary.
|
||||||
function downloadBinary() {
|
function downloadArchive() {
|
||||||
local suffix="gz"
|
local suffix="tar.gz"
|
||||||
if [[ ${OS} == "windows" ]]; then
|
if [[ ${OS} == "windows" ]]; then
|
||||||
suffix="zip"
|
suffix="zip"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
TMP_ROOT="$(mktemp -dt cunicu-installer-XXXXXX)"
|
|
||||||
DIST_FILE="cunicu_${VERSION}_${OS}_${ARCH}.${suffix}"
|
DIST_FILE="cunicu_${VERSION}_${OS}_${ARCH}.${suffix}"
|
||||||
|
|
||||||
downloadFile "${DIST_FILE}"
|
downloadFile "${DIST_FILE}"
|
||||||
}
|
}
|
||||||
|
|
||||||
# verifyBinary verifies the SHA256 checksum of the binary package
|
# verifyArchive verifies the SHA256 checksum of the binary package
|
||||||
# and the GPG signatures for both the package and checksum file
|
# and the GPG signatures for both the package and checksum file
|
||||||
# (depending on settings in environment).
|
# (depending on settings in environment).
|
||||||
function verifyBinary() {
|
function verifyArchive() {
|
||||||
if [[ "${VERIFY_CHECKSUM}" == "true" ]]; then
|
if [[ "${VERIFY_CHECKSUM}" == "true" ]]; then
|
||||||
verifyChecksum
|
verifyChecksum
|
||||||
fi
|
fi
|
||||||
@@ -168,7 +173,7 @@ function verifyBinary() {
|
|||||||
|
|
||||||
# installBinary installs the cunicu binary.
|
# installBinary installs the cunicu binary.
|
||||||
function installBinary() {
|
function installBinary() {
|
||||||
gunzip -c "${TMP_ROOT}/${DIST_FILE}" > "${TMP_ROOT}/${BINARY_NAME}"
|
tar -xzf "${TMP_ROOT}/${DIST_FILE}" -C "${TMP_ROOT}"
|
||||||
|
|
||||||
runAsRoot cp "${TMP_ROOT}/${BINARY_NAME}" "${INSTALL_DIR}"
|
runAsRoot cp "${TMP_ROOT}/${BINARY_NAME}" "${INSTALL_DIR}"
|
||||||
|
|
||||||
@@ -320,14 +325,16 @@ done
|
|||||||
|
|
||||||
set +u
|
set +u
|
||||||
|
|
||||||
|
TMP_ROOT="$(mktemp -dt cunicu-installer-XXXXXX)"
|
||||||
|
|
||||||
detectArch
|
detectArch
|
||||||
detectOS
|
detectOS
|
||||||
verifySupported
|
verifySupported
|
||||||
checkDesiredVersion
|
checkDesiredVersion
|
||||||
|
|
||||||
if ! checkInstalledVersion; then
|
if ! checkInstalledVersion; then
|
||||||
downloadBinary
|
downloadArchive
|
||||||
verifyBinary
|
verifyArchive
|
||||||
installBinary
|
installBinary
|
||||||
testVersion
|
testVersion
|
||||||
fi
|
fi
|
||||||
|
Reference in New Issue
Block a user