# vscodium - VS Code without Microsoft's telemetry or branding.
#
# This repackages the upstream build rather than compiling one. VS Code is an
# Electron application: building it from source means a full Node toolchain, a
# Chromium checkout and several hours, and the result would be the same binary
# VSCodium already publishes and signs. Nothing else in ScrapLinux is packaged this
# way, and that is worth being explicit about - it is a binary repackage, in
# extra, and it is not part of any profile.
#
# It brings its own Electron, so it needs the graphical stack at runtime but
# nothing at build time.
name=vscodium
version=1.126.04524
release=1
desc="VS Code without Microsoft's telemetry or branding"
url="https://vscodium.com/"
license="MIT"
depend="glibc gtk3 nss libx11 libxcb libxkbcommon alsa-lib libdrm mesa"
makedepend=""
source="VSCodium-linux-x64-$version.tar.gz::https://github.com/VSCodium/vscodium/releases/download/$version/VSCodium-linux-x64-$version.tar.gz"
sha256="SKIP"
options="!strip"

package() {
	# The tarball has no top-level directory: it unpacks the application
	# straight into the extraction root.
	install -d "$pkgdir/usr/lib/vscodium"
	cp -a ./* "$pkgdir/usr/lib/vscodium/"
	rm -rf "$pkgdir/usr/lib/vscodium/.PKGINFO" 2>/dev/null || :

	install -d "$pkgdir/usr/bin"
	ln -sf ../lib/vscodium/bin/codium "$pkgdir/usr/bin/codium"
	ln -sf ../lib/vscodium/bin/codium "$pkgdir/usr/bin/vscodium"

	install -Dm644 /dev/stdin "$pkgdir/usr/share/applications/codium.desktop" <<'EOF'
[Desktop Entry]
Name=VSCodium
Comment=Code editing. Redefined.
Exec=/usr/bin/codium %F
Icon=vscodium
Type=Application
StartupNotify=false
StartupWMClass=VSCodium
Categories=TextEditor;Development;IDE;
MimeType=text/plain;inode/directory;
EOF

	if [ -f resources/app/resources/linux/code.png ]; then
		install -Dm644 resources/app/resources/linux/code.png \
			"$pkgdir/usr/share/icons/hicolor/512x512/apps/vscodium.png"
	fi
}
