# Copyright 1999-2022 Gentoo Authors # Distributed under the terms of the GNU General Public License v2 # NOTE: this ebuild has been generated by ebuild-gen.py from the # electron overlay. If you would like to make changes, please # consider modifying the ebuild template and submitting a PR to # https://github.com/elprans/electron-overlay. EAPI=7 PYTHON_COMPAT=( python3_{10..13} ) inherit desktop multiprocessing python-any-r1 rpm xdg-utils DESCRIPTION="Visual Studio Code" HOMEPAGE="https://code.visualstudio.com/" if [[ ${PV} == *9999* ]]; then UPSTREAM_PV="latest" UPSTREAM_CHANNEL="insider" else UPSTREAM_PV="${PV}" UPSTREAM_CHANNEL="stable" fi ELECTRON_V=30.5.1 ELECTRON_SLOT=30 ASAR_V=0.14.3 # All binary packages depend on this NAN_V=2.19.0 NODE_ADDON_API_V=7.1.0 VSCODE__POLICY_WATCHER_V=1.1.6 VSCODE__SPDLOG_V=0.15.0 VSCODE__SQLITE3_V=5.1.6-vscode VSCODE__WINDOWS_MUTEX_V=0.5.0 VSCODE__WINDOWS_PROCESS_TREE_V=0.6.0 VSCODE__WINDOWS_REGISTRY_V=1.1.0 KERBEROS_V=2.1.1 NATIVE_IS_ELEVATED_V=0.7.0 NATIVE_KEYMAP_V=3.3.5 NATIVE_WATCHDOG_V=1.4.2 NODE_PTY_V=1.1.0-beta21 # The x86_64 arch below is irrelevant, as we will rebuild all binary packages. SRC_URI=" https://update.code.visualstudio.com/${UPSTREAM_PV}/linux-rpm-x64/${UPSTREAM_CHANNEL} -> vscode-x64-${PV}.rpm https://github.com/elprans/asar/releases/download/v${ASAR_V}-gentoo/asar-build.tar.gz -> asar-${ASAR_V}.tar.gz https://github.com/nodejs/nan/archive/v${NAN_V}.tar.gz -> nodejs-nan-${NAN_V}.tar.gz https://github.com/nodejs/node-addon-api/archive/v${NODE_ADDON_API_V}.tar.gz -> nodejs-node-addon-api-${NODE_ADDON_API_V}.tar.gz https://registry.npmjs.org/@vscode/policy-watcher/-/policy-watcher-1.1.6.tgz -> vscodedep-vscode--policy-watcher-${VSCODE__POLICY_WATCHER_V}.tar.gz https://registry.npmjs.org/@vscode/spdlog/-/spdlog-0.15.0.tgz -> vscodedep-vscode--spdlog-${VSCODE__SPDLOG_V}.tar.gz https://registry.npmjs.org/@vscode/sqlite3/-/sqlite3-5.1.6-vscode.tgz -> vscodedep-vscode--sqlite3-${VSCODE__SQLITE3_V}.tar.gz https://registry.npmjs.org/@vscode/windows-mutex/-/windows-mutex-0.5.0.tgz -> vscodedep-vscode--windows-mutex-${VSCODE__WINDOWS_MUTEX_V}.tar.gz https://registry.npmjs.org/@vscode/windows-process-tree/-/windows-process-tree-0.6.0.tgz -> vscodedep-vscode--windows-process-tree-${VSCODE__WINDOWS_PROCESS_TREE_V}.tar.gz https://registry.npmjs.org/@vscode/windows-registry/-/windows-registry-1.1.0.tgz -> vscodedep-vscode--windows-registry-${VSCODE__WINDOWS_REGISTRY_V}.tar.gz https://registry.npmjs.org/kerberos/-/kerberos-2.1.1.tgz -> vscodedep-kerberos-${KERBEROS_V}.tar.gz https://registry.npmjs.org/native-is-elevated/-/native-is-elevated-0.7.0.tgz -> vscodedep-native-is-elevated-${NATIVE_IS_ELEVATED_V}.tar.gz https://registry.npmjs.org/native-keymap/-/native-keymap-3.3.5.tgz -> vscodedep-native-keymap-${NATIVE_KEYMAP_V}.tar.gz https://registry.npmjs.org/native-watchdog/-/native-watchdog-1.4.2.tgz -> vscodedep-native-watchdog-${NATIVE_WATCHDOG_V}.tar.gz https://registry.npmjs.org/node-pty/-/node-pty-1.1.0-beta21.tgz -> vscodedep-node-pty-${NODE_PTY_V}.tar.gz " BINMODS=( vscode--policy-watcher vscode--spdlog vscode--sqlite3 vscode--windows-mutex vscode--windows-process-tree vscode--windows-registry kerberos native-is-elevated native-keymap native-watchdog node-pty ) RESTRICT="mirror bindist" LICENSE="MS-vscode" SLOT="0" KEYWORDS="~amd64" IUSE="" BDEPEND=" ${PYTHON_DEPS} >=dev-util/electron-${ELECTRON_V}:${ELECTRON_SLOT} " DEPEND=" >=app-crypt/libsecret-0.18.6:= >=app-text/hunspell-1.3.3:= >=dev-db/sqlite-3.24:= >=dev-libs/glib-2.52.0:= >=dev-libs/libgit2-0.23:=[ssh] >=dev-libs/libpcre2-10.22:=[jit,pcre16] x11-libs/libX11 x11-libs/libxkbfile " RDEPEND=" ${DEPEND} >=dev-util/ctags-5.8 >=dev-util/electron-${ELECTRON_V}:${ELECTRON_SLOT} dev-vcs/git sys-apps/ripgrep " S="${WORKDIR}/${PN}-${PV}" BIN_S="${WORKDIR}/${PN}-bin-${PV}" BUILD_DIR="${S}/out" src_unpack() { local a mkdir "${S}" || die mkdir "${BIN_S}" || die for a in ${A} ; do case "${a}" in *.rpm) pushd "${BIN_S}" >/dev/null || die srcrpm_unpack "${a}" popd >/dev/null || die ;; *.tar|*.tar.gz|*.tar.bz2|*.tar.xz) # Tarballs on registry.npmjs.org are wildly inconsistent, # and violate the convention of having ${P} as the top # directory name, so we strip the first component and # unpack into a correct directory explicitly. local basename=${a%.tar.*} local destdir=${WORKDIR}/${basename#vscodedep-} mkdir "${destdir}" || die tar -C "${destdir}" -x -o --strip-components 1 \ -f "${DISTDIR}/${a}" || die ;; *) # Fallback to the default unpacker. unpack "${a}" ;; esac done } src_prepare() { local suffix="$(get_install_suffix)" local vscode_rpmdir=$(get_vscode_rpmdir) local vscode_appname=$(get_vscode_appname) local install_dir="${EPREFIX}$(get_install_dir)" local electron_dir="${EPREFIX}$(get_electron_dir)" local electron_path="${electron_dir}/electron" local node_path="${electron_dir}/node" local node_includes="${EPREFIX}$(get_node_includedir)" local binmod local pkgdir local pyscript local wb_css_path="vs/workbench/workbench.desktop.main.css" local wb_css_local_path="vs/workbench/workbench.desktop.local.css" local wb_css_csum # Calling this here supports resumption via FEATURES=keepwork python_setup mkdir "${BUILD_DIR}" || die cp -a "${BIN_S}/${vscode_rpmdir}/resources/app" \ "${BUILD_DIR}/app" || die cp -a "${BIN_S}/${vscode_rpmdir}/bin/${vscode_appname}" \ "${BUILD_DIR}/app/code" || die # Unpack app.asar easar extract "${BIN_S}/${vscode_rpmdir}/resources/app/node_modules.asar" \ "${BUILD_DIR}/app/node_modules" cd "${BUILD_DIR}/app" || die rm -r "node_modules.asar.unpacked" || die if [[ "${PV}" == *9999* ]]; then eapply "${FILESDIR}/unbundle-electron-insiders.patch" else eapply "${FILESDIR}/unbundle-electron-r3.patch" fi eapply "${FILESDIR}/unbundle-ripgrep-r2.patch" sed -i -e "s|{{NPM_CONFIG_NODEDIR}}|${node_includes}|g" \ -e "s|{{ELECTRON_PATH}}|${electron_path}|g" \ -e "s|{{VSCODE_PATH}}|${install_dir}|g" \ -e "s|{{EPREFIX}}|${EPREFIX}|g" \ code \ || die sed -i -e "s|/${vscode_rpmdir}/${vscode_appname}|${EPREFIX}/usr/bin/code${suffix}|g" \ "${BIN_S}/usr/share/applications/$(get_vscode_appname).desktop" || die for binmod in "${BINMODS[@]}"; do pkgdir="${WORKDIR}/$(package_dir ${binmod})" cd "${pkgdir}" || die if have_patches_for "${binmod}"; then eapply "${FILESDIR}"/${binmod}-*.patch fi done cd "${BUILD_DIR}/app" || die # Unbundle bundled libs from modules for binmod in "${BINMODS[@]}"; do pkgdir="${WORKDIR}/$(package_dir ${binmod})" mkdir -p "${pkgdir}/node_modules" || die ln -s "${WORKDIR}/nodejs-nan-${NAN_V}" \ "${pkgdir}/node_modules/nan" || die ln -s "${WORKDIR}/nodejs-node-addon-api-${NODE_ADDON_API_V}" \ "${pkgdir}/node_modules/node-addon-api" || die done eapply_user cd "${BUILD_DIR}/app" || die if [ -e "out/${wb_css_local_path}" ]; then cat "out/${wb_css_local_path}" >> "out/${wb_css_path}" IFS= read -r -d '' pyscript <