Skip to content

Instantly share code, notes, and snippets.

@cyfrost
Last active November 8, 2019 04:01
Show Gist options
  • Select an option

  • Save cyfrost/1f9169eebee8dbed9962d4e3800edf38 to your computer and use it in GitHub Desktop.

Select an option

Save cyfrost/1f9169eebee8dbed9962d4e3800edf38 to your computer and use it in GitHub Desktop.
[Fedora] Simple shell script to install (or update to) the latest version of VSCodium
#!/bin/bash
# This script will check if VSCodium is installed in your machine, if yes, then tries to update it to the latest version
# else, installs whichever the latest version is.
#
# NOTE: There's already this repo (https://gitlab.com/paulcarroty/vscodium-deb-rpm-repo) that provides
# the codium package for RPM based distros but for some reason the download was extremely slow.
# This script pulls the download from github directly (which is hopefully a tad bit faster).
# Thanks to https://stackoverflow.com/a/4024263/2631023
function verlte() {
[ "$1" = "`echo -e "$1\n$2" | sort -V | head -n1`" ]
}
# Thanks to https://stackoverflow.com/a/4024263/2631023
function verlt() {
[ "$1" = "$2" ] && return 1 || verlte $1 $2
}
# Checks if Codium is installed, if yes, tries to update it to latest version, else installs latest version.
function install_or_update_latest_codium() {
rpm -q codium | grep -q "not installed" && INSTALLED_VERSION="NOT_INSTALLED" || INSTALLED_VERSION="$(rpm -q --queryformat "%{VERSION}" codium)"
LATEST_VERSION="$(curl -sL https://api.github.com/repos/vscodium/vscodium/releases/latest | grep -Po '"tag_name": "\K.*?(?=")')" && \
verlt "$INSTALLED_VERSION" "$LATEST_VERSION" && IS_UPDATE_AVAILABLE="yes" || IS_UPDATE_AVAILABLE="no"
if [ "$IS_UPDATE_AVAILABLE" = "yes" ] || [ "$INSTALLED_VERSION" = "NOT_INSTALLED" ]; then
[ "$INSTALLED_VERSION" = "NOT_INSTALLED" ] && MSG="Downloading and installing latest VSCodium v$LATEST_VERSION..." || MSG="Updating VSCodium from $INSTALLED_VERSION to $LATEST_VERSION..."
printf "\n$MSG\n\n"
RPM_DOWNLOAD="$(curl -sL https://api.github.com/repos/vscodium/vscodium/releases/latest | grep "https.*x86_64.rpm" | head -1 | cut -d '"' -f 4)"
FILENAME="/tmp/vscodium.rpm"
[ -f $FILENAME ] && rm -f $FILENAME
wget -O $FILENAME $RPM_DOWNLOAD -q --show-progress
sudo dnf install -y "$FILENAME" && rm -f $FILENAME; printf "\nFinished\n\n" || printf "\nError: failed to install VSCodium version $LATEST_VERSION.\n\n"
else
printf "\nVSCodium is already up-to-date (Installed: "$INSTALLED_VERSION", Latest: "$LATEST_VERSION").\n\n"
fi
}
install_or_update_latest_codium
@cyfrost
Copy link
Copy Markdown
Author

cyfrost commented Oct 8, 2019

Usage:

bash <(curl -s https://gist.githubusercontent.com/cyfrost/1f9169eebee8dbed9962d4e3800edf38/raw/install-latest-vscodium-fedora.sh)

@cyfrost
Copy link
Copy Markdown
Author

cyfrost commented Nov 8, 2019

Screenshot

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment