Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

snap: modernise snapcraft.yaml #62

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 17 additions & 19 deletions snapcraft.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,37 +21,35 @@ apps:
command: bin/yarn.js

parts:
gcc-10:
plugin: nil
override-pull: 'true'
override-build: |
sudo apt --yes install software-properties-common
sudo add-apt-repository --yes ppa:ubuntu-toolchain-r/test
sudo apt --yes install gcc-10 g++-10 python3-distutils
override-stage: 'true'
override-prime: 'true'
node:
plugin: make
source-type: tar
source: https://nodejs.org/download/nightly/v23.0.0-nightly202405092863c54257/node-v23.0.0-nightly202405092863c54257.tar.gz
build-packages:
# Ensure these and the build environment below match the minimum GCC and G++ versions for this Node release.
# https://github.com/nodejs/node/blob/main/BUILDING.md#building-nodejs-on-supported-platforms
- gcc-10
- g++-10
- python3-distutils
build-environment:
- CC: gcc-10
- CXX: g++-10
- LINK: g++-10
- V: ""
make-parameters:
- V=
override-build: |
export CC="gcc-10"
export CXX="g++-10"
export LINK="g++-10"
export V=
./configure --verbose --prefix=/ --release-urlbase=https://nodejs.org/download/nightly/ --tag=nightly202405092863c54257
snapcraftctl build
mkdir -p $SNAPCRAFT_PART_INSTALL/etc
echo "prefix = /usr/local" >> $SNAPCRAFT_PART_INSTALL/etc/npmrc
craftctl default
mkdir -p $CRAFT_PART_INSTALL/etc
echo "prefix = /usr/local" >> $CRAFT_PART_INSTALL/etc/npmrc
yarn:
source-type: tar
source: https://yarnpkg.com/latest.tar.gz
plugin: dump
# Yarn has a problem with lifecycle scripts when used inside snap, they don't complete properly, with exit code !=0.
# Replacing the spinner with proper stdio appears to fix it.
override-build: |
snapcraftctl build
chmod -R g-s $SNAPCRAFT_PART_INSTALL
sed -i "s/var stdio = spinner ? undefined : 'inherit';/var stdio = 'inherit';/" $SNAPCRAFT_PART_INSTALL/lib/cli.js
craftctl default
chmod -R g-s $CRAFT_PART_INSTALL
sed -i "s/var stdio = spinner ? undefined : 'inherit';/var stdio = 'inherit';/" $CRAFT_PART_INSTALL/lib/cli.js
37 changes: 18 additions & 19 deletions snapcraft.yaml.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
set -euxo pipefail

__dirname="$(CDPATH="" cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
UPDATE_GIT=no

while getopts "r:g:" opt; do
case $opt in
Expand Down Expand Up @@ -75,40 +76,38 @@ apps:
command: bin/yarn.js

parts:
gcc-10:
plugin: nil
override-pull: 'true'
override-build: |
sudo apt --yes install software-properties-common
sudo add-apt-repository --yes ppa:ubuntu-toolchain-r/test
sudo apt --yes install gcc-10 g++-10 python3-distutils
override-stage: 'true'
override-prime: 'true'
node:
plugin: make
source-type: tar
source: https://nodejs.org/download/${NODE_DISTTYPE}/v${NODE_VERSION}/node-v${NODE_VERSION}.tar.gz
build-packages:
# Ensure these and the build environment below match the minimum GCC and G++ versions for this Node release.
# https://github.com/nodejs/node/blob/main/BUILDING.md#building-nodejs-on-supported-platforms
- gcc-10
- g++-10
- python3-distutils
build-environment:
- CC: gcc-10
- CXX: g++-10
- LINK: g++-10
- V: ""
make-parameters:
- V=
override-build: |
export CC="gcc-10"
export CXX="g++-10"
export LINK="g++-10"
export V=
./configure --verbose --prefix=/ --release-urlbase=https://nodejs.org/download/${NODE_DISTTYPE}/ --tag=${NODE_TAG}
snapcraftctl build
mkdir -p \$SNAPCRAFT_PART_INSTALL/etc
echo "prefix = /usr/local" >> \$SNAPCRAFT_PART_INSTALL/etc/npmrc
craftctl default
mkdir -p \$CRAFT_PART_INSTALL/etc
echo "prefix = /usr/local" >> \$CRAFT_PART_INSTALL/etc/npmrc
yarn:
source-type: tar
source: https://yarnpkg.com/latest.tar.gz
plugin: dump
# Yarn has a problem with lifecycle scripts when used inside snap, they don't complete properly, with exit code !=0.
# Replacing the spinner with proper stdio appears to fix it.
override-build: |
snapcraftctl build
chmod -R g-s \$SNAPCRAFT_PART_INSTALL
sed -i "s/var stdio = spinner ? undefined : 'inherit';/var stdio = 'inherit';/" \$SNAPCRAFT_PART_INSTALL/lib/cli.js
craftctl default
chmod -R g-s \$CRAFT_PART_INSTALL
sed -i "s/var stdio = spinner ? undefined : 'inherit';/var stdio = 'inherit';/" \$CRAFT_PART_INSTALL/lib/cli.js
EOF

if [ "X${UPDATE_GIT}" = "Xyes" ] && [ -n "$(git status --porcelain "$__dirname")" ]; then
Expand Down