Need native support for VS Code through swupd

Being Optimised for CPU Clear Linux is a great choice for development but come on guys where is VS Code - Its an essential editor for developers, yeah I know it is available in flatpak but it doesn’t run in native terminal and there is a container overhead so please bring VS Code to swupd

2 Likes

not likely to ship this due to license issue.

There is an open source version, but I don’t know if we can call it “VScode” or whether we’d need to call it something else. Having someone try and autospec it would be helpful, too :).

I use https://github.com/VSCodium/vscodium , VSCode clone with disabled MS telemetry.

How to install:

# swupd bundle-add dnf
# rpm -ivh --nodeps https://github.com/VSCodium/vscodium/releases/download/1.36.1/codium-1.36.1-1562700284.el7.x86_64.rpm

It works, swupd shows no conflicts, system upgrade works too. Also easy update/remove with rpm.

4 Likes

As much as I’d like Intel to offer VSCode, it doesn’t appear to be possible with licensing? Until then, i just download and install. Works fine even though it’s outside of swupd.

Here is a shell script you can use to install the VSCode rpm.

#!/bin/bash

# delete previous version if needed
INSTALL_DIR=/usr/share/code
if [ -d "$INSTALL_DIR" ]; then
	echo "deleting: $INSTALL_DIR"
	sudo rm -rf $INSTALL_DIR
fi

# download the rpm from https://code.visualstudio.com/download

sudo swupd bundle-add cpio package-utils

sudo rpm2cpio code-*.rpm | ( cd /; cpio -idv)

# https://code.visualstudio.com/docs/setup/linux#_visual-studio-code-is-unable-to-watch-for-file-changes-in-this-large-workspace-error-enospc

sudo echo "fs.inotify.max_user_watches=524288" | sudo tee --append /etc/sysctl.conf

How do the solutions by @rana and @paulcarroty compare?
More generally, what should be checked before installing an RPM on CLR? What is the preferred place to get RPMs? Any preferred distro to get RPMs from?

Very dirty solution. After next release & next unpack old files will exists, and you get something like Slackware in your system. RPM provide cleanup and file conflicts resolver.

@EddyValiant maybe try each approach and see what works best for you. I like to get the latest full version from Microsoft. Its got the latest goodies and works fine. I added a delete previous version section to the script. You would have to manually download the latest VSCode version and re-run the script. Am not familiar enough with VSCodium to comment. I also use the rpm2cpio to install Google Chrome which works great too. It is a less than ideal solution until Intel or someone provides a better one. swupd would be the obviously desired choice.

@paulcarroty Thanks for pointing out that a new install would overwrite. I updated the install script to delete previous version. Any thoughts on a cleaner way?

Google Chrome install script.

#!/bin/bash

swupd bundle-add package-utils cpio wget
# wget https://dl.google.com/linux/direct/google-chrome-stable_current_x86_64.rpm
rpm2cpio google-chrome*.rpm | ( cd /; sudo cpio -idv)

ENV_FLE=/etc/environment
LN='export FONTCONFIG_PATH=/usr/share/defaults/fonts'
sudo touch $ENV_FLE
if ! grep -q "$LN" $ENV_FLE ; then 
	sudo echo $LN >> $ENV_FLE
fi
# https://github.com/clearlinux/distribution/issues/422

You can have these

[ -f google-chrome-stable_current_x86_64.rpm ] || wget https://dl.google.com/linux/direct/google-chrome-stable_current_x86_64.rpm
rpm2cpio google-chrome*.rpm | ( cd /; cpio -idv)

This will download the latest stable rpm if it’s not found.

1 Like

Thanks, nice addition

Here is another script to install using deb package. It will install the target at ~/ and auto-modify and create desktop links. To remove just delete ~/VisualStudioCode

#!/bin/bash

#PS4=’$LINENO: ’
#set -x

DEST=~/VisualStudioCode
VERSION_FILE=${DEST}/.version
REMOTE_VERSION=

echo Visual Studio Code updater

LOCAL_VERSION=“none” && [ -f VERSION_FILE ] && LOCAL_VERSION=(cat $VERSION_FILE)
echo -e “Local version\t: $LOCAL_VERSION”

#Check version on remote
#REMOTE_VERSION=1.36.0
REMOTE_VERSION=$(curl -s -L https://code.visualstudio.com/updates | grep -Po ‘(?<=strong>Update )[^:]+’ | grep -oP ‘[^]+’)
echo -e “Remote version\t: $REMOTE_VERSION”

if [ “$REMOTE_VERSION” == “$LOCAL_VERSION” ]; then
echo “No update available”
exit
fi

read -sp "Enter to update, Ctrl-C to abort… " && echo

echo Downloading …
TMPWORK=$(mktemp -d)
cd TMPWORK wget -q --show-progress https://update.code.visualstudio.com/{REMOTE_VERSION}/linux-deb-x64/stable -O code_${REMOTE_VERSION}_amd64.deb

echo Extracting …
ar x code_${REMOTE_VERSION}_amd64.deb data.tar.xz

rm -rf $DEST
mkdir $DEST
bsdtar -xf data.tar.xz -C $DEST

#adjust path
sed -e “s%/usr/share/code/code%{DEST}/usr/share/code/code%" -e "s%Icon=com.visualstudio.code%Icon={DEST}/usr/share/pixmaps/com.visualstudio.code.png%” ${DEST}/usr/share/applications/code.desktop > ~/.local/share/applications/code.desktop

#create a link at Desktop for easy access
ln -sf ~/.local/share/applications/code.desktop ~/Desktop/code.desktop

#Store version
echo $REMOTE_VERSION > $VERSION_FILE

cd
rm -rf $TMPWORK
echo Done.

[ (pgrep -c -f {DEST}/usr/share/code/code) -gt 0 ] && echo “Restart Visual Studio Code to use the latest version.”

2 Likes

swupd repair --picky will remove any files not shipped by Clear Linux

Please use /usr/local for any non-distro packages.

swupd won’t touch /usr/local.

2 Likes

I suggest to add sudo sysctl-p after modifying fs.inotify.max_user_watches value. So the new value is reloaded in current session.

1 Like

@doct0rHu @miguelinux @hong.wei.phang Thank you for the script improvements; much appreciated