From fc5bc75ba838a49b3184ff747d8c4ba824c1b969 Mon Sep 17 00:00:00 2001 From: Baptiste Augrain Date: Mon, 26 Feb 2024 14:35:38 +0100 Subject: [PATCH] build(linux): update snapcraft for insiders --- stores/snapcraft/build.sh | 70 ------------ .../{ => snap/local/bin}/electron-launch | 0 stores/snapcraft/insider/snap/snapcraft.yaml | 103 ++++++++++++++++++ stores/snapcraft/insider/snapcraft.yaml | 81 -------------- stores/snapcraft/stable/snap/snapcraft.yaml | 2 +- 5 files changed, 104 insertions(+), 152 deletions(-) delete mode 100755 stores/snapcraft/build.sh rename stores/snapcraft/insider/{ => snap/local/bin}/electron-launch (100%) create mode 100644 stores/snapcraft/insider/snap/snapcraft.yaml delete mode 100644 stores/snapcraft/insider/snapcraft.yaml diff --git a/stores/snapcraft/build.sh b/stores/snapcraft/build.sh deleted file mode 100755 index 44cbe1e..0000000 --- a/stores/snapcraft/build.sh +++ /dev/null @@ -1,70 +0,0 @@ -#!/usr/bin/env bash - -set -ex - -CALLER_DIR=$( pwd ) - -cd "$( dirname "${BASH_SOURCE[0]}" )" - -# Include utilities -. ../../utils.sh - -SNAP_VERSION=$( echo "${RELEASE_VERSION}" | sed 's|\-insider||' ) -ICON_NAME="$( echo "${APP_NAME}" | awk '{print tolower($0)}' )" - -if [[ "${VSCODE_QUALITY}" == "insider" ]]; then - ICON_NAME="${ICON_NAME}-insiders" -fi - -rm -rf build -mkdir -p build/snap/gui - -if [[ "${CI_BUILD}" == "no" ]]; then - DEB_ARCHIVE=$( ls ../../vscode/.build/linux/deb/amd64/deb/*.deb ) -else - # Get GitHub releases - wget --quiet "https://api.github.com/repos/${ASSETS_REPOSITORY}/releases" -O gh_latest.json - - DEB_URL=$( jq -r 'map(select(.tag_name == "'"${RELEASE_VERSION}"'"))|first.assets[].browser_download_url|select(endswith("'"_${ARCHITECTURE}.deb"'"))' gh_latest.json ) - DEB_ARCHIVE=$( basename "${DEB_URL}" ) - - # Downloading .deb - wget "${DEB_URL}" -O "${DEB_ARCHIVE}" - - rm gh_latest.json -fi - -# Unpacking .deb -dpkg -x "${DEB_ARCHIVE}" build/deb - -mkdir -p build/snap/local/usr/share -mv "build/deb/usr/share/${BINARY_NAME}" "build/snap/local/usr/share/${BINARY_NAME}" - -# Prepare snapcraft.yaml -cp ${VSCODE_QUALITY}/snapcraft.yaml build/snap/snapcraft.yaml - -replace "s|@@SNAP_NAME@@|${BINARY_NAME}|g" build/snap/snapcraft.yaml -replace "s|@@SNAP_VERSION@@|${SNAP_VERSION}|g" build/snap/snapcraft.yaml - -# Prepare electron-launch -cp ${VSCODE_QUALITY}/electron-launch build/electron-launch - -# Prepare GUI -cp "../../src/${VSCODE_QUALITY}/resources/linux/code.png" "build/snap/gui/${BINARY_NAME}.png" -cp build/deb/usr/share/applications/*.desktop build/snap/gui - -sed -i "s|Exec=/usr/share/${BINARY_NAME}/${BINARY_NAME}|Exec=${BINARY_NAME} --force-user-env|g" "build/snap/gui/${BINARY_NAME}.desktop" -sed -i "s|Exec=/usr/share/${BINARY_NAME}/${BINARY_NAME}|Exec=${BINARY_NAME} --force-user-env|g" "build/snap/gui/${BINARY_NAME}-url-handler.desktop" -sed -i "s|Icon=${ICON_NAME}|Icon=\${SNAP}/meta/gui/${BINARY_NAME}.png|g" "build/snap/gui/${BINARY_NAME}.desktop" -sed -i "s|Icon=${ICON_NAME}|Icon=\${SNAP}/meta/gui/${BINARY_NAME}.png|g" "build/snap/gui/${BINARY_NAME}-url-handler.desktop" - -# Clean up -rm -rf build/deb - -cd build - -if [[ "${CI_BUILD}" == "no" ]]; then - snapcraft --use-lxd --debug -fi - -cd "${CALLER_DIR}" diff --git a/stores/snapcraft/insider/electron-launch b/stores/snapcraft/insider/snap/local/bin/electron-launch similarity index 100% rename from stores/snapcraft/insider/electron-launch rename to stores/snapcraft/insider/snap/local/bin/electron-launch diff --git a/stores/snapcraft/insider/snap/snapcraft.yaml b/stores/snapcraft/insider/snap/snapcraft.yaml new file mode 100644 index 0000000..9a9ee78 --- /dev/null +++ b/stores/snapcraft/insider/snap/snapcraft.yaml @@ -0,0 +1,103 @@ +name: codium-insiders +adopt-info: codium-insiders +summary: Code editing. Redefined. +description: | + Binary releases of Visual Studio Code - Insiders without branding/telemetry/licensing + +base: core20 +grade: stable +confinement: classic +compression: lzo + +parts: + codium-insiders: + plugin: nil + override-build: | + set -eu + # Get .deb url + wget --quiet https://api.github.com/repos/VSCodium/vscodium-insiders/releases -O latest.json + VERSION=$( jq -r 'sort_by(.tag_name)|last.tag_name' latest.json ) + DEB_URL=$( jq -r 'map(select(.tag_name == "'"${VERSION}"'"))|first.assets[].browser_download_url|select(endswith("'"_${SNAPCRAFT_TARGET_ARCH}.deb"'"))' latest.json ) + DEB_NAME=$( basename "${DEB_URL}" ) + # Downloading .deb + wget "${DEB_URL}" -O "${SNAPCRAFT_PART_INSTALL}/${DEB_NAME}" + # Unpacking .deb + dpkg -x "${SNAPCRAFT_PART_INSTALL}/${DEB_NAME}" "${SNAPCRAFT_PART_INSTALL}" + # Clean up + rm -f latest.json + rm -f "${SNAPCRAFT_PART_INSTALL}/${DEB_NAME}" + # Set version + snapcraftctl set-version "${VERSION}" + # Prepare GUI + mkdir -p "${SNAPCRAFT_PART_INSTALL}/meta/gui" + cp "${SNAPCRAFT_PART_INSTALL}/usr/share/codium-insiders/resources/app/resources/linux/code.png" "${SNAPCRAFT_PART_INSTALL}/meta/gui/codium-insiders.png" + # Update paths + sed -i 's|Exec=/usr/share/codium/codium-insiders|Exec=codium-insiders --force-user-env|g' "${SNAPCRAFT_PART_INSTALL}/usr/share/applications/codium-insiders.desktop" + sed -i 's|Exec=/usr/share/codium/codium-insiders|Exec=codium-insiders --force-user-env|g' "${SNAPCRAFT_PART_INSTALL}/usr/share/applications/codium-insiders-url-handler.desktop" + sed -i 's|Icon=vscodium-insiders|Icon=${SNAP}/meta/gui/codium-insiders.png|g' "${SNAPCRAFT_PART_INSTALL}/usr/share/applications/codium-insiders.desktop" + sed -i 's|Icon=vscodium-insiders|Icon=${SNAP}/meta/gui/codium-insiders.png|g' "${SNAPCRAFT_PART_INSTALL}/usr/share/applications/codium-insiders-url-handler.desktop" + build-packages: + - wget + - jq + stage-packages: + - ca-certificates + - libasound2 + - libatk-bridge2.0-0 + - libatk1.0-0 + - libatspi2.0-0 + - libcairo2 + - libcanberra-gtk3-module + - libcurl3-gnutls + - libcurl3-nss + - libcurl4 + - libdrm2 + - libgbm1 + - libgl1 + - libglib2.0-0 + - libgtk-3-0 + - libibus-1.0-5 + - libnss3 + - libpango-1.0-0 + - libsecret-1-0 + - libxcomposite1 + - libxdamage1 + - libxfixes3 + - libxkbcommon0 + - libxkbfile1 + - libxrandr2 + - libxss1 + - locales-all + - packagekit-gtk3-module + - xdg-utils + prime: + - -usr/share/doc + - -usr/share/fonts + - -usr/share/icons + - -usr/share/lintian + - -usr/share/man + - -usr/share/codium/chrome-sandbox + build-attributes: + - enable-patchelf + override-prime: | + set -eux + snapcraftctl prime + for snap in "core20"; do + cd "/snap/${snap}/current/usr/lib/${SNAPCRAFT_ARCH_TRIPLET}" + find . -type f,l -name "*.so*" -exec bash -c "rm -f ${SNAPCRAFT_PRIME}/{}*" \; + done + + electron-launch: + after: + - codium-insiders + plugin: dump + source: snap/local/bin + +apps: + codium: + command: electron-launch $SNAP/usr/share/codium-insiders/bin/codium-insiders --no-sandbox + desktop: usr/share/applications/codium-insiders.desktop + common-id: codium-insiders.desktop + + url-handler: + command: electron-launch $SNAP/usr/share/codium-insiders/bin/codium-insiders --open-url --no-sandbox + desktop: usr/share/applications/codium-insiders-url-handler.desktop diff --git a/stores/snapcraft/insider/snapcraft.yaml b/stores/snapcraft/insider/snapcraft.yaml deleted file mode 100644 index cf59f80..0000000 --- a/stores/snapcraft/insider/snapcraft.yaml +++ /dev/null @@ -1,81 +0,0 @@ -name: @@SNAP_NAME@@ -version: '@@SNAP_VERSION@@' -summary: Code editing. Redefined. -description: | - Binary releases of Visual Studio Code - Insiders without branding/telemetry/licensing - -base: core20 -grade: stable -confinement: classic -compression: lzo - -parts: - @@SNAP_NAME@@: - plugin: dump - source: . - stage-packages: - - ca-certificates - - libasound2 - - libatk-bridge2.0-0 - - libatk1.0-0 - - libatspi2.0-0 - - libcairo2 - - libcanberra-gtk3-module - - libcurl3-gnutls - - libcurl3-nss - - libcurl4 - - libdrm2 - - libgbm1 - - libgl1 - - libglib2.0-0 - - libgtk-3-0 - - libibus-1.0-5 - - libnss3 - - libpango-1.0-0 - - libsecret-1-0 - - libxcomposite1 - - libxdamage1 - - libxfixes3 - - libxkbcommon0 - - libxkbfile1 - - libxrandr2 - - libxss1 - - locales-all - - packagekit-gtk3-module - - xdg-utils - prime: - - -usr/share/doc - - -usr/share/fonts - - -usr/share/icons - - -usr/share/lintian - - -usr/share/man - build-attributes: - - enable-patchelf - build-packages: - - patchelf - override-build: | - snapcraftctl build - patchelf --force-rpath --set-rpath '$ORIGIN/../../lib/x86_64-linux-gnu:$ORIGIN:/core20/current/lib/x86_64-linux-gnu' $SNAPCRAFT_PART_INSTALL/snap/usr/share/@@SNAP_NAME@@/chrome_crashpad_handler - - cleanup: - after: - - @@SNAP_NAME@@ - plugin: nil - build-snaps: - - core20 - build-packages: - - patchelf - override-prime: | - set -eux - for snap in "core20"; do - cd "/snap/$snap/current" && find . -type f,l -exec rm -f "$SNAPCRAFT_PRIME/{}" \; - done - patchelf --print-rpath $SNAPCRAFT_PRIME/snap/usr/share/@@SNAP_NAME@@/chrome_crashpad_handler - -apps: - @@SNAP_NAME@@: - command: electron-launch $SNAP/snap/usr/share/@@SNAP_NAME@@/bin/@@SNAP_NAME@@ --no-sandbox - common-id: @@SNAP_NAME@@.desktop - - url-handler: - command: electron-launch $SNAP/snap/usr/share/@@SNAP_NAME@@/bin/@@SNAP_NAME@@ --open-url --no-sandbox diff --git a/stores/snapcraft/stable/snap/snapcraft.yaml b/stores/snapcraft/stable/snap/snapcraft.yaml index 2ba6cf4..d19a74e 100644 --- a/stores/snapcraft/stable/snap/snapcraft.yaml +++ b/stores/snapcraft/stable/snap/snapcraft.yaml @@ -2,7 +2,7 @@ name: codium adopt-info: codium summary: Code editing. Redefined. description: | - Binary releases of Code without branding/telemetry/licensing + Binary releases of Visual Studio Code without branding/telemetry/licensing base: core20 grade: stable