addpkg: codium

This commit is contained in:
MedzikUser 2022-05-20 16:23:00 +02:00
parent d87dd0c233
commit 8319d9020f
No known key found for this signature in database
GPG Key ID: A5FAC1E185C112DB
7 changed files with 214 additions and 4 deletions

140
packages/codium/PKGBUILD Normal file
View File

@ -0,0 +1,140 @@
# Maintainer: MedzikUser <nivua1fn@duck.com>
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"
}

View File

@ -0,0 +1 @@
GITHUB_REPO="VSCodium/vscodium"

View File

@ -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;

View File

@ -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

28
packages/codium/codium.js Normal file
View File

@ -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)

View File

@ -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 "$@"

View File

@ -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" ]