vscodium/stores/snapcraft/build.sh

77 lines
2.3 KiB
Bash
Raw Normal View History

2024-02-06 18:51:19 -05:00
#!/usr/bin/env bash
set -ex
CALLER_DIR=$( pwd )
cd "$( dirname "${BASH_SOURCE[0]}" )"
# Include utilities
. ../../utils.sh
2024-02-07 06:15:01 -05:00
SNAP_VERSION=$( echo "${RELEASE_VERSION}" | sed 's|\-insider||' )
2024-02-06 18:51:19 -05:00
ICON_NAME="$( echo "${APP_NAME}" | awk '{print tolower($0)}' )"
if [[ "${VSCODE_QUALITY}" == "insider" ]]; then
ICON_NAME="${ICON_NAME}-insiders"
fi
2024-02-08 10:10:05 -05:00
rm -rf build
mkdir -p build/snap/gui
2024-02-06 18:51:19 -05:00
2024-02-08 10:10:05 -05:00
if [[ "${CI_BUILD}" == "no" ]]; then
DEB_ARCHIVE=$( ls ../../vscode/build/linux/deb/amd64/deb/*.deb )
else
2024-02-06 18:51:19 -05:00
# Get GitHub releases
2024-02-08 10:10:05 -05:00
wget --quiet "https://api.github.com/repos/${ASSETS_REPOSITORY}/releases" -O gh_latest.json
2024-02-06 18:51:19 -05:00
2024-02-08 10:10:05 -05:00
DEB_URL=$( jq -r 'map(select(.tag_name == "'"${RELEASE_VERSION}"'"))|first.assets[].browser_download_url|select(endswith("'"_${ARCHITECTURE}.deb"'"))' gh_latest.json )
2024-02-06 18:51:19 -05:00
DEB_ARCHIVE=$( basename "${DEB_URL}" )
# Downloading .deb
wget "${DEB_URL}" -O "${DEB_ARCHIVE}"
2024-02-08 10:10:05 -05:00
rm gh_latest.json
2024-02-06 18:51:19 -05:00
fi
# Unpacking .deb
2024-02-08 10:10:05 -05:00
dpkg -x "${DEB_ARCHIVE}" build/deb
2024-02-06 18:51:19 -05:00
2024-02-08 10:10:05 -05:00
mkdir -p build/snap/usr/share
mv "build/deb/usr/share/${BINARY_NAME}" "build/snap/usr/share/${BINARY_NAME}"
2024-02-06 18:51:19 -05:00
# Prepare snapcraft.yaml
2024-02-08 10:10:05 -05:00
cp ${VSCODE_QUALITY}/snapcraft.yaml build/snap/snapcraft.yaml
2024-02-06 18:51:19 -05:00
2024-02-08 10:10:05 -05:00
replace "s|@@SNAP_NAME@@|${BINARY_NAME}|g" build/snap/snapcraft.yaml
replace "s|@@SNAP_VERSION@@|${SNAP_VERSION}|g" build/snap/snapcraft.yaml
2024-02-06 18:51:19 -05:00
# Prepare electron-launch
2024-02-08 10:10:05 -05:00
cp ${VSCODE_QUALITY}/electron-launch build/snap/electron-launch
2024-02-06 18:51:19 -05:00
# Prepare GUI
2024-02-08 10:10:05 -05:00
cp "../../src/${VSCODE_QUALITY}/resources/linux/code.png" "build/snap/gui/${BINARY_NAME}.png"
cp build/deb/usr/share/applications/*.desktop build/snap/gui
2024-02-06 18:51:19 -05:00
2024-02-08 10:10:05 -05:00
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"
2024-02-06 18:51:19 -05:00
# Clean up
2024-02-08 10:10:05 -05:00
rm -rf build/deb
2024-02-06 18:51:19 -05:00
2024-02-08 10:10:05 -05:00
cd build
2024-02-06 18:51:19 -05:00
2024-02-08 10:10:05 -05:00
if [[ "${CI_BUILD}" == "no" ]]; then
2024-02-06 18:51:19 -05:00
snapcraft --use-lxd --debug
2024-02-08 10:10:05 -05:00
# else
# snapcraft
# SNAP_ARCHIVE=$( ls *.snap )
# echo "snap=$( pwd )/${SNAP_ARCHIVE}" >> "$GITHUB_OUTPUT"
2024-02-06 18:51:19 -05:00
fi
cd "${CALLER_DIR}"