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

feat: add snap package configuration #7529

Merged
merged 4 commits into from
Jul 24, 2020
Merged
Show file tree
Hide file tree
Changes from 3 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
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,9 @@ vendor
go-ipfs-source.tar.gz
docs/examples/go-ipfs-as-a-library/example-folder/Qm*
/test/sharness/t0054-dag-car-import-export-data/*.car

# ignore build output from snapcraft
/ipfs_*.snap
/parts
/stage
/prime
3 changes: 2 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
FROM golang:1.14.4-buster
# Note: when updating the go minor version here, also update the go-channel in snap/snapcraft.yml
FROM golang:1.14.4-buster
olizilla marked this conversation as resolved.
Show resolved Hide resolved
LABEL maintainer="Steven Allen <[email protected]>"

# Install deps
Expand Down
46 changes: 46 additions & 0 deletions snap/snapcraft.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# This snap will build go-ipfs from source.
name: ipfs
summary: global, versioned, peer-to-peer filesystem # 79 char long summary
description: |
IPFS combines good ideas from Git, BitTorrent, Kademlia, SFS, and the Web.
It is like a single bittorrent swarm, exchanging git objects. IPFS provides
an interface as simple as the HTTP web, but with permanence built in. You
can also mount the world at /ipfs.

# fetch the version number in the `ipfs` part rather than hardcode it here
# see: https://snapcraft.io/docs/using-external-metadata#heading--scriptlet
adopt-info: ipfs
base: core18
grade: stable
confinement: strict

apps:
ipfs:
command: ipfs
# the home plug is included so the user can `ipfs add` files from their home dir without a permission error.
plugs: [home, network, network-bind, removable-media]
environment:
# Snaps versions are isolated by default. This keeps the same ipfs repo across upgrades.
IPFS_PATH: "$SNAP_USER_COMMON"

parts:
ipfs:
source: '.'
# TODO: set this to master when porting this file to ipfs/go-ipfs.
olizilla marked this conversation as resolved.
Show resolved Hide resolved
# Setting it explicitly lets us build the missing versions 0.5 and 0.6
source-tag: master
plugin: go
# keep me up to date with the go version that go-ipfs expects to be built with.
go-channel: 1.14/stable
go-importpath: github.com/ipfs/go-ipfs
build-packages:
- build-essential

# use `make` to build and set the snap version from `ipfs version` output
override-build: |
export GOPATH=$SNAPCRAFT_PART_BUILD/go
make install
cp $SNAPCRAFT_PART_BUILD/go/bin/ipfs $SNAPCRAFT_PART_INSTALL
export IPFS_VERSION=$($SNAPCRAFT_PART_BUILD/go/bin/ipfs version --commit | cut -c 14-)
echo "found version $IPFS_VERSION"
snapcraftctl set-version $IPFS_VERSION