build(linux): build snap with core20 [skip ci]

This commit is contained in:
Baptiste Augrain 2024-02-26 01:17:26 +01:00
parent ad280d74db
commit eb7d54bd62
2 changed files with 26 additions and 19 deletions

4
.gitignore vendored
View File

@ -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

View File

@ -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