Skip to content

Commit

Permalink
Merge pull request #7529 from ipfs/feat/add-snap-package
Browse files Browse the repository at this point in the history
feat: add snap package configuration
  • Loading branch information
aschmahmann authored Jul 24, 2020
2 parents e3905e1 + bb6a42d commit 5b28704
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 1 deletion.
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
LABEL maintainer="Steven Allen <steven@stebalien.com>"

# Install deps
Expand Down
44 changes: 44 additions & 0 deletions snap/snapcraft.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# 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: '.'
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

0 comments on commit 5b28704

Please sign in to comment.