From 8319d9020fa83a34bd423283c5af7a1ef3dc1932 Mon Sep 17 00:00:00 2001 From: MedzikUser Date: Fri, 20 May 2022 16:23:00 +0200 Subject: [PATCH] addpkg: codium --- packages/codium/PKGBUILD | 140 +++++++++++++++++++++ packages/codium/built.conf | 1 + packages/codium/codium-uri-handler.desktop | 12 ++ packages/codium/codium.desktop | 18 +++ packages/codium/codium.js | 28 +++++ packages/codium/codium.sh | 4 + scripts/auto-update.sh | 15 ++- 7 files changed, 214 insertions(+), 4 deletions(-) create mode 100644 packages/codium/PKGBUILD create mode 100644 packages/codium/built.conf create mode 100644 packages/codium/codium-uri-handler.desktop create mode 100644 packages/codium/codium.desktop create mode 100644 packages/codium/codium.js create mode 100644 packages/codium/codium.sh diff --git a/packages/codium/PKGBUILD b/packages/codium/PKGBUILD new file mode 100644 index 00000000..81a6e337 --- /dev/null +++ b/packages/codium/PKGBUILD @@ -0,0 +1,140 @@ +# Maintainer: MedzikUser +pkgname='codium' +provides=('vscodium') +conflicts=('vscodium') +pkgdesc='Free/Libre Open Source Software Binaries of VSCode without MS branding/telemetry/licensing' +pkgver="1.67.2" +pkgrel=1 +arch=('x86_64') +microsofturl='https://github.com/microsoft/vscode' +url="https://github.com/VSCodium/vscodium" +license=('MIT') + +# Important: Remember to check https://github.com/microsoft/vscode/blob/master/.yarnrc (choose correct tag) for target electron version +_electron='electron17' +depends=("${_electron}" 'libsecret' 'libx11' 'libxkbfile' 'ripgrep') +makedepends=('nodejs-lts-gallium' 'npm' 'yarn' 'gulp' 'jq' 'libxdmcp' 'git' 'git-lfs' 'patch' 'python' 'pkg-config') + +optdepends=('gvfs: For move to trash functionality' + 'libdbusmenu-glib: For KDE global menu' + 'x11-ssh-askpass: SSH authentication' + 'org.freedesktop.secrets: Keyring password store support' + 'codium-features: Unblock some features in VSCodium' + 'codium-marketplace: Enable VS-Code marketplace in VSCodium') + +source=("vscodium::git+${url}#tag=${pkgver}" + "vscode::git+${microsofturl}#tag=${pkgver}" + "${pkgname}.desktop" + "${pkgname}-uri-handler.desktop" + "${pkgname}.js" + "${pkgname}.sh") +sha256sums=('SKIP' + 'SKIP' + 'c1339ef39bb4a3b4d79cedb0b5a9837b95259424677eb6483e38eb02fbf7a485' + 'cbbb81153ae784d08c20b450c172f6068501558487c6ea8d587506594d6828fe' + '8163558373e5093988717a5e576003718713a6aa97b62ef68f077badddbead03' + 'a23f31a316fa2965fab5333f748388854935fb9e23fa1a6ea0e88e323909aee4') + +# Even though we don't officially support other archs, let's allow the +# user to use this PKGBUILD to compile the package for their architecture. +case "${CARCH}" in + x86_64) + _vscode_arch=x64 + ;; + aarch64) + _vscode_arch=arm64 + ;; + armv7h) + _vscode_arch=arm + ;; + *) + # Needed for mksrcinfo + _vscode_arch=DUMMY + ;; +esac + +prepare() { + # Change electron binary name to the target electron + sed -i "s|exec electron |exec ${_electron} |" ${pkgname}.sh + sed -i "s|#!/usr/bin/electron|#!/usr/bin/${_electron}|" ${pkgname}.js + + # Move vscode repo + cd "vscodium" + + # Normally, we would execute get_repo.sh to clone the Microsoft repo here, but makepkg can't do this. + # So we rely on the clone that happened earlier, and move the git directory to the expected place. + rm -rf 'vscode' + mv '../vscode' 'vscode' +} + +_setup_nvm() { + # Set a temporary NVM directory to make sure the nvm in this script does not clash with a system-wide nvm install + export NVM_DIR="${srcdir}/.nvm" + source /usr/share/nvm/init-nvm.sh || [[ $? != 1 ]] + + # TODO: Remove this when VSCodium adds the .nvmrc file + if [ ! -f .nvmrc ] + then + echo "v14.19.0" > .nvmrc + fi + # TODO: End remove this + + # Install the correct version of NodeJS (read from .nvmrc) + nvm install $(cat .nvmrc) + nvm use + + # Check if the correct version of node is being used + if [[ "$(node --version)" != "$(cat .nvmrc)" ]] + then + echo "Using the wrong version of NodeJS! Expected ["$(cat .nvmrc)"] but using ["$(node --version)"]." + exit 1 + fi +} + +build() { + cd "vscodium" + + # Export some environment variables that would normally be set by Travis CI + export SHOULD_BUILD="yes" + export VSCODE_ARCH="${_vscode_arch}" + export OS_NAME="linux" + export LATEST_MS_COMMIT=$(git rev-list --tags --max-count=1) + export LATEST_MS_TAG=$(git describe --tags "${LATEST_MS_COMMIT}") + + # Disable building rpm, deb, and AppImage packages which are not needed in an AUR build + export SKIP_LINUX_PACKAGES="True" + + # Install Node.js (using nvm) + #_setup_nvm + + # Build + ./build.sh +} + +package() { + cd "vscodium/VSCode-linux-${_vscode_arch}" + + # Install resource files + install -d "${pkgdir}/usr/lib/${pkgname}" + cp -r --no-preserve=ownership --preserve=mode resources/app/* "${pkgdir}/usr/lib/${pkgname}/" + + # Replace statically included binary with system copy + ln -sf /usr/bin/rg "${pkgdir}/usr/lib/${pkgname}/node_modules.asar.unpacked/@vscode/ripgrep/bin/rg" + + # Install bash and zsh completions + install -Dm 644 "resources/completions/bash/${pkgname}" "${pkgdir}/usr/share/bash-completion/completions/${pkgname}" + install -Dm 644 "resources/completions/zsh/_${pkgname}" "${pkgdir}/usr/share/zsh/site-functions/_${pkgname}" + + install -Dm 644 "resources/app/resources/linux/code.png" "${pkgdir}/usr/share/pixmaps/${pkgname}.png" + + # Install start scripts + cd "${srcdir}" + + install -Dm 755 "${pkgname}.sh" "${pkgdir}/usr/bin/${pkgname}" + install -Dm 755 "${pkgname}.js" "${pkgdir}/usr/lib/${pkgname}/${pkgname}.js" + + # Install appdata and desktop files + install -d "${pkgdir}/usr/share/{${pkgname},applications,pixmaps}" + install -Dm 644 "${pkgname}.desktop" "${pkgdir}/usr/share/applications/${pkgname}.desktop" + install -Dm 644 "${pkgname}-uri-handler.desktop" "${pkgdir}/usr/share/applications/${pkgname}-uri-handler.desktop" +} diff --git a/packages/codium/built.conf b/packages/codium/built.conf new file mode 100644 index 00000000..a5095abe --- /dev/null +++ b/packages/codium/built.conf @@ -0,0 +1 @@ +GITHUB_REPO="VSCodium/vscodium" diff --git a/packages/codium/codium-uri-handler.desktop b/packages/codium/codium-uri-handler.desktop new file mode 100644 index 00000000..89ab70e5 --- /dev/null +++ b/packages/codium/codium-uri-handler.desktop @@ -0,0 +1,12 @@ +[Desktop Entry] +Name=VSCodium - URL Handler +Comment=Code Editing. Redefined. +GenericName=Text Editor +Exec=/usr/bin/codium --open-url %U +Icon=vscodium +Type=Application +NoDisplay=true +StartupNotify=true +Categories=Utility;TextEditor;Development;IDE; +MimeType=x-scheme-handler/vscode; +Keywords=vscode;codium; diff --git a/packages/codium/codium.desktop b/packages/codium/codium.desktop new file mode 100644 index 00000000..53994bac --- /dev/null +++ b/packages/codium/codium.desktop @@ -0,0 +1,18 @@ +[Desktop Entry] +Name=VSCodium +Comment=Code Editing. Redefined. +GenericName=Text Editor +Exec=/usr/bin/codium --no-sandbox --unity-launch %F +Icon=codium +Type=Application +StartupNotify=true +StartupWMClass=VSCodium +Categories=Utility;Development;IDE; +MimeType=text/plain;inode/directory; +Actions=new-empty-window; +Keywords=vscode;codium; + +[Desktop Action new-empty-window] +Name=New Empty Window +Exec=/usr/bin/codium --no-sandbox --new-window %F +Icon=codium diff --git a/packages/codium/codium.js b/packages/codium/codium.js new file mode 100644 index 00000000..7aead949 --- /dev/null +++ b/packages/codium/codium.js @@ -0,0 +1,28 @@ +#!/usr/bin/electron + +const name = 'codium' + +const app = require('electron').app +const path = require('path') +const fs = require("fs") + +// Change command name. +const fd = fs.openSync("/proc/self/comm", fs.constants.O_WRONLY) +fs.writeSync(fd, name) +fs.closeSync(fd) + +// Remove first command line argument (/usr/lib/codium/codium.js). - We call the CLI file first +process.argv.splice(0, 1) + +// Set application paths. +const appPath = __dirname +const packageJson = require(path.join(appPath, 'package.json')) +app.setAppPath(appPath) +app.setDesktopName(name + '.desktop') +app.setName(name) +app.setPath('userCache', path.join(app.getPath('cache'), name)) +app.setPath('userData', path.join(app.getPath('appData'), name)) +app.setVersion(packageJson.version) + +// Run the application. +require('module')._load(appPath, module, true) diff --git a/packages/codium/codium.sh b/packages/codium/codium.sh new file mode 100644 index 00000000..1a02ee34 --- /dev/null +++ b/packages/codium/codium.sh @@ -0,0 +1,4 @@ +#!/bin/sh +set -e + +ELECTRON_RUN_AS_NODE=1 exec electron /usr/lib/codium/out/cli.js /usr/lib/codium/codium.js "$@" diff --git a/scripts/auto-update.sh b/scripts/auto-update.sh index 88250165..e6258e1a 100755 --- a/scripts/auto-update.sh +++ b/scripts/auto-update.sh @@ -69,7 +69,13 @@ update-package() { then local latest_version="$(gh-tag-version ${GITHUB_REPO})" else - local latest_version="$(gh-version ${GITHUB_REPO})" + local latest_version="$(curl --silent --location -H "Authorization: token ${GITHUB_API_TOKEN}" "https://api.github.com/repos/${GITHUB_REPO}/releases/latest" | jq -r ".tag_name")" + fi + + if [ -z "${latest_version}" ] + then + echo "[!] Failed to get latest version of ${pkgname}" + return 1 fi custom_vars=$( @@ -81,13 +87,13 @@ update-package() { # Translate "_" into ".": some packages use underscores to seperate # version numbers, but we require them to be separated by dots. - version=${latest_tag//_/.} + latest_version=${latest_version//_/.} # Remove leading 'v' or 'r' - version=${version#[v,r]} + latest_version=${latest_version#[v,r]} # Translate "-" into ".": pacman does not support - in pkgver - version=${version//-/.} + latest_version=${latest_version//-/.} if [ "${version}" = "${latest_version}" ] then @@ -97,6 +103,7 @@ update-package() { sed -i "s|^\(pkgver=\)\(.*\)\$|\1\"${latest_version}\"|g" "${pkgdir}/PKGBUILD" # Update package checksums + cd "${pkgdir}" updpkgsums if [ "${GIT_COMMIT_PACKAGES}" = "true" ]