template

5.5 KB · 159 lines
GITHUB
# Template file for 'visual-studio-code-insiders'
pkgname=visual-studio-code-insiders
version=1.144.0.20261022
revision=1
_commit=76fae85ac19c965c60b10618426469bfd93a6d03
archs="x86_64 aarch64 armv7l"
depends="
 alsa-lib
 at-spi2-core
 cairo
 cups
 dbus
 expat
 glib
 gnupg
 gtk+3
 libsecret
 libX11
 libXcomposite
 libXdamage
 libXext
 libXfixes
 libXrandr
 libXScrnSaver
 libdrm
 libxcb
 libxkbcommon
 libxkbfile
 libxshmfence
 lsof
 mesa
 nspr
 nss
 pango
 shared-mime-info
 xdg-utils
"
short_desc="Visual Studio Code Insiders: Editor for building and debugging modern web and cloud applications (Insiders build)"
maintainer="AmarBego <[email protected]>"
license="custom:commercial"
homepage="https://code.visualstudio.com/insiders/"
restricted=yes
nopie=yes
nostrip=yes
noshlibprovides=yes
create_wrksrc=yes

case "$XBPS_TARGET_MACHINE" in
	x86_64)
		skiprdeps="/opt/${pkgname}/resources/app/node_modules/@github/copilot-linuxmusl-x64/copilot
		 /opt/${pkgname}/resources/app/node_modules/@github/copilot-linuxmusl-arm64/copilot
		 /opt/${pkgname}/resources/app/node_modules/@microsoft/mxc-sdk/bin/arm64/lxc-exec
		 /opt/${pkgname}/resources/app/node_modules/@microsoft/mxc-sdk/bin/arm64/linux-test-proxy"
		;;
	aarch64)
		skiprdeps="/opt/${pkgname}/resources/app/node_modules/@github/copilot-linuxmusl-x64/copilot
		 /opt/${pkgname}/resources/app/node_modules/@github/copilot-linuxmusl-arm64/copilot
		 /opt/${pkgname}/resources/app/node_modules/@microsoft/mxc-sdk/bin/x64/lxc-exec
		 /opt/${pkgname}/resources/app/node_modules/@microsoft/mxc-sdk/bin/x64/linux-test-proxy"
		;;
	armv7l)
		skiprdeps="/opt/${pkgname}/resources/app/node_modules/@github/copilot-linuxmusl-x64/copilot
		 /opt/${pkgname}/resources/app/node_modules/@github/copilot-linuxmusl-arm64/copilot
		 /opt/${pkgname}/resources/app/node_modules/@microsoft/mxc-sdk/bin/arm64/lxc-exec
		 /opt/${pkgname}/resources/app/node_modules/@microsoft/mxc-sdk/bin/arm64/linux-test-proxy
		 /opt/${pkgname}/resources/app/node_modules/@microsoft/mxc-sdk/bin/x64/lxc-exec
		 /opt/${pkgname}/resources/app/node_modules/@microsoft/mxc-sdk/bin/x64/linux-test-proxy"
		;;
esac

_baseurl="https://raw.githubusercontent.com/microsoft/vscode/main/resources/linux"
distfiles="${_baseurl}/code.desktop>code-insiders.desktop.in
 ${_baseurl}/code-url-handler.desktop>code-insiders-url-handler.desktop.in
 ${_baseurl}/code-workspace.xml>code-insiders-workspace.xml.in"
checksum="2b36d3a8c70fcead5258dd0855be0782305b23a00448f0eef11ee4ea462193a0
 c361efa7e02fcad759ed80d2fbab67877f33219b981578af6fffaf18aeb12d9b
 3af748dd6578a1775e8eb7248ba397b7e11840df2ea6ee234ff76fee3dc306cf"

skip_extraction="code-insiders.desktop.in code-insiders-url-handler.desktop.in code-insiders-workspace.xml.in"

_dlbase="https://vscode.download.prss.microsoft.com/dbazure/download/insider/${_commit}"

case "$XBPS_TARGET_MACHINE" in
	x86_64)
		distfiles+=" ${_dlbase}/code-insider-x64-1792604446.tar.gz"
		checksum+=" 42a141bda84f05d4842b16b3e2e6adfb4ec46d2bb96f750c3f9430ec58295806"
		_app_dir="VSCode-linux-x64"
		;;
	aarch64)
		distfiles+=" ${_dlbase}/code-insider-arm64-1792603970.tar.gz"
		checksum+=" 1f35435e516ccfe7b436f4a0ffd2dc38357c2fd353645dae9f2b48fa04b2066c"
		_app_dir="VSCode-linux-arm64"
		;;
	armv7l)
		distfiles+=" ${_dlbase}/code-insider-armhf-1792603695.tar.gz"
		checksum+=" d0719a77efbc9b9a90b7f5cc8ffc1ba42648ab8bf814f6b4dc145ded19cf9c88"
		_app_dir="VSCode-linux-armhf"
		;;
esac

do_install() {
	# Extract and install app
	vmkdir opt/${pkgname}
	vcopy "${_app_dir}/*" opt/${pkgname}

	# Helper script
	# We create it dynamically to handle strict paths
	cat > code-insiders.sh <<EOF
#!/bin/bash
XDG_CONFIG_HOME=\${XDG_CONFIG_HOME:-~/.config}

# Allow users to override command-line options
if [[ -f \$XDG_CONFIG_HOME/code-insiders-flags.conf ]]; then
   CODE_USER_FLAGS="\$(sed 's/#.*//' \$XDG_CONFIG_HOME/code-insiders-flags.conf | tr '\n' ' ')"
fi

# Launch
exec /opt/${pkgname}/bin/code-insiders "\$@" \$CODE_USER_FLAGS
EOF
	vbin code-insiders.sh code-insiders

	# Desktop files and icons
	cp "${XBPS_SRCDISTDIR}/${pkgname}-${version}/code-insiders.desktop.in" code-insiders.desktop
	cp "${XBPS_SRCDISTDIR}/${pkgname}-${version}/code-insiders-url-handler.desktop.in" code-insiders-url-handler.desktop
	cp "${XBPS_SRCDISTDIR}/${pkgname}-${version}/code-insiders-workspace.xml.in" ${pkgname}-workspace.xml

	# Process desktop files
	vsed -i "code-insiders.desktop" \
		-e "s/@@NAME_LONG@@/Visual Studio Code - Insiders/g" \
		-e "s/@@NAME_SHORT@@/Code - Insiders/g" \
		-e "s/@@NAME@@/code-insiders/g" \
		-e "s#@@EXEC@@#/usr/bin/code-insiders#g" \
		-e "s/@@ICON@@/visual-studio-code-insiders/g"

	vsed -i "code-insiders-url-handler.desktop" \
		-e "s/@@NAME_LONG@@/Visual Studio Code - Insiders/g" \
		-e "s#@@EXEC@@#/usr/bin/code-insiders#g" \
		-e "s/@@ICON@@/visual-studio-code-insiders/g" \
		-e "s/@@URLPROTOCOL@@/vscode-insiders/g"

	# Process workspace xml
	vsed -i "${pkgname}-workspace.xml" \
		-e "s/@@NAME_LONG@@/Visual Studio Code - Insiders/g" \
		-e "s/@@NAME@@/code-insiders/g"

	vinstall code-insiders.desktop 644 usr/share/applications
	vinstall code-insiders-url-handler.desktop 644 usr/share/applications
	vinstall ${pkgname}-workspace.xml 644 usr/share/mime/packages

	vinstall "${_app_dir}/resources/app/resources/linux/code.png" 644 usr/share/pixmaps ${pkgname}.png
	
	# License
	vlicense "${_app_dir}/resources/app/LICENSE.rtf"
	
	# Shell completions
	vcompletion "${_app_dir}/resources/completions/bash/code-insiders" bash code-insiders
	vcompletion "${_app_dir}/resources/completions/zsh/_code-insiders" zsh code-insiders
}