From eb7d54bd62bed1bd539845c851598af3f64a3f58 Mon Sep 17 00:00:00 2001 From: Baptiste Augrain Date: Mon, 26 Feb 2024 01:17:26 +0100 Subject: [PATCH] build(linux): build snap with core20 [skip ci] --- .gitignore | 4 +- stores/snapcraft/stable/snap/snapcraft.yaml | 41 ++++++++++++--------- 2 files changed, 26 insertions(+), 19 deletions(-) diff --git a/.gitignore b/.gitignore index 7c9e2803485..55ba9370f9b 100644 --- a/.gitignore +++ b/.gitignore @@ -14,5 +14,5 @@ build/linux/appimage/VSCodium build/windows/msi/releasedir build/windows/msi/Files*.wxs build/windows/msi/Files*.wixobj -remote-dependencies.tar -stores/snapcraft/build +stores/snapcraft/insider/*.snap +stores/snapcraft/stable/*.snap diff --git a/stores/snapcraft/stable/snap/snapcraft.yaml b/stores/snapcraft/stable/snap/snapcraft.yaml index 45ebb2f713a..2ba6cf4f4ea 100644 --- a/stores/snapcraft/stable/snap/snapcraft.yaml +++ b/stores/snapcraft/stable/snap/snapcraft.yaml @@ -14,23 +14,28 @@ parts: plugin: nil override-build: | set -eu - # Get GitHub releases + # Get .deb url wget --quiet https://api.github.com/repos/VSCodium/vscodium/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=$(basename "${DEB_URL}") - # Downloading .deb" - wget "${DEB_URL}" -O "${SNAPCRAFT_PART_INSTALL}/${DEB}" - # Unpacking .deb" - dpkg -x "${SNAPCRAFT_PART_INSTALL}/${DEB}" ${SNAPCRAFT_PART_INSTALL} + 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}" + rm -f "${SNAPCRAFT_PART_INSTALL}/${DEB_NAME}" # Set version - snapcraftctl set-version "$VERSION" - # Correct path to icon. - sed -i 's|Icon=vscodium|Icon=${SNAP}/usr/share/pixmaps/vscodium.png|g' ${SNAPCRAFT_PART_INSTALL}/usr/share/applications/codium.desktop - #sed -i 's|Exec=/usr/share/codium/codium|Exec=codium|g' ${SNAPCRAFT_PART_INSTALL}/usr/share/applications/codium.desktop - sed -i 's|Icon=vscodium|Icon=/usr/share/pixmaps/vscodium.png|g' ${SNAPCRAFT_PART_INSTALL}/usr/share/applications/codium-url-handler.desktop + snapcraftctl set-version "${VERSION}" + # Prepare GUI + mkdir -p "${SNAPCRAFT_PART_INSTALL}/meta/gui" + cp "${SNAPCRAFT_PART_INSTALL}/usr/share/codium/resources/app/resources/linux/code.png" "${SNAPCRAFT_PART_INSTALL}/meta/gui/codium.png" + # Update paths + sed -i 's|Exec=/usr/share/codium/codium|Exec=codium --force-user-env|g' "${SNAPCRAFT_PART_INSTALL}/usr/share/applications/codium.desktop" + sed -i 's|Exec=/usr/share/codium/codium|Exec=codium --force-user-env|g' "${SNAPCRAFT_PART_INSTALL}/usr/share/applications/codium-url-handler.desktop" + sed -i 's|Icon=vscodium|Icon=${SNAP}/meta/gui/codium.png|g' "${SNAPCRAFT_PART_INSTALL}/usr/share/applications/codium.desktop" + sed -i 's|Icon=vscodium|Icon=${SNAP}/meta/gui/codium.png|g' "${SNAPCRAFT_PART_INSTALL}/usr/share/applications/codium-url-handler.desktop" build-packages: - wget - jq @@ -75,10 +80,10 @@ parts: - enable-patchelf override-prime: | set -eux - craftctl default + 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_PART_INSTALL/usr/lib/$SNAPCRAFT_ARCH_TRIPLET/{}*" \; + 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: @@ -90,7 +95,9 @@ parts: apps: codium: command: electron-launch $SNAP/usr/share/codium/bin/codium --no-sandbox + desktop: usr/share/applications/codium.desktop common-id: codium.desktop url-handler: command: electron-launch $SNAP/usr/share/codium/bin/codium --open-url --no-sandbox + desktop: usr/share/applications/codium-url-handler.desktop