From 883ad0d1d2145502f220cc962cda4fb30dd79e83 Mon Sep 17 00:00:00 2001 From: Oli Evans Date: Thu, 9 Jul 2020 11:07:14 +0100 Subject: [PATCH 1/4] feat: add snap package configuration Simplify keeping the snap package up to date by including the snapcraft.yaml in the repo. We can then wire up the snapstore to autobuild the package for amd64,i386,arm* etc. Many thanks to @elopio for the work of getting ipfs into the snap store in the first place, and to @bertrandfalguiere and @mkg20001 for pushing it forwards. See: https://github.com/ipfs-shipyard/ipfs-snap for more info. Fixes #7250 WIP #3595 License: MIT Signed-off-by: Oli Evans --- .gitignore | 6 ++++++ Dockerfile | 3 ++- snap/snapcraft.yaml | 46 +++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 54 insertions(+), 1 deletion(-) create mode 100644 snap/snapcraft.yaml diff --git a/.gitignore b/.gitignore index 90109ade45a..cb147456b11 100644 --- a/.gitignore +++ b/.gitignore @@ -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 diff --git a/Dockerfile b/Dockerfile index ea28fbf8cb5..7e10ea753b1 100644 --- a/Dockerfile +++ b/Dockerfile @@ -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 " # Install deps diff --git a/snap/snapcraft.yaml b/snap/snapcraft.yaml new file mode 100644 index 00000000000..c0ff8d2c317 --- /dev/null +++ b/snap/snapcraft.yaml @@ -0,0 +1,46 @@ +# This snap will build go-ipfs from source. +# See: https://github.com/ipfs-shipyard/ipfs-snap for more details +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 + plugs: [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. + # 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 From ba0b4154083032d243115f8e2e67317f184cab53 Mon Sep 17 00:00:00 2001 From: Oli Evans Date: Fri, 10 Jul 2020 16:30:54 +0100 Subject: [PATCH 2/4] chore: enable snap home interface Without the home interface the user is unable to add files to ipfs from their home dir. Also explicitly sets the build architectures, to skip some esoteric ones and save some cpu cycles. License: MIT Signed-off-by: Oli Evans --- snap/snapcraft.yaml | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/snap/snapcraft.yaml b/snap/snapcraft.yaml index c0ff8d2c317..05ad832f865 100644 --- a/snap/snapcraft.yaml +++ b/snap/snapcraft.yaml @@ -1,5 +1,4 @@ # This snap will build go-ipfs from source. -# See: https://github.com/ipfs-shipyard/ipfs-snap for more details name: ipfs summary: global, versioned, peer-to-peer filesystem # 79 char long summary description: | @@ -15,10 +14,15 @@ base: core18 grade: stable confinement: strict +# skip building on `ppc64el` and `s390x` to save some cpu cycles. +architectures: + - build-on: [amd64, arm64, armhf, i386] + apps: ipfs: command: ipfs - plugs: [network, network-bind, removable-media] + # 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" From 812ee63d1856cecbc7bcfd0161b65e152465764f Mon Sep 17 00:00:00 2001 From: Oli Evans Date: Fri, 10 Jul 2020 18:05:36 +0100 Subject: [PATCH 3/4] chore: remove explicit architectures remvoing as specifying the subset of architectures you want to build on has side-effects, like the resulting snap is labeled as "multi" arch, and the snapstore UI lists it as building on i386 the whole time. License: MIT Signed-off-by: Oli Evans --- snap/snapcraft.yaml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/snap/snapcraft.yaml b/snap/snapcraft.yaml index 05ad832f865..3602a2fcb9b 100644 --- a/snap/snapcraft.yaml +++ b/snap/snapcraft.yaml @@ -14,10 +14,6 @@ base: core18 grade: stable confinement: strict -# skip building on `ppc64el` and `s390x` to save some cpu cycles. -architectures: - - build-on: [amd64, arm64, armhf, i386] - apps: ipfs: command: ipfs From bb6a42dd080e5d50e14d55a2031d4fb6b9778f64 Mon Sep 17 00:00:00 2001 From: Oli Evans Date: Tue, 21 Jul 2020 10:31:55 +0100 Subject: [PATCH 4/4] chore: remove stale comment License: MIT Signed-off-by: Oli Evans --- snap/snapcraft.yaml | 2 -- 1 file changed, 2 deletions(-) diff --git a/snap/snapcraft.yaml b/snap/snapcraft.yaml index 3602a2fcb9b..1c4da1a2157 100644 --- a/snap/snapcraft.yaml +++ b/snap/snapcraft.yaml @@ -26,8 +26,6 @@ apps: parts: ipfs: source: '.' - # TODO: set this to master when porting this file to ipfs/go-ipfs. - # 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.