From efc9f0d44c9c6522ea11ff7e22ef852d762615ab Mon Sep 17 00:00:00 2001 From: Michael Baudino Date: Mon, 14 Dec 2020 16:26:50 +0100 Subject: [PATCH 1/2] feat(ipfs): add IPFS on Pi3, Pi4, XU4 and PC (disabled by default) --- CHANGELOG.md | 3 + Config.in | 1 + RELEASE-NOTES.md | 5 ++ configs/recalbox-odroidxu4_defconfig | 3 +- configs/recalbox-rpi3_defconfig | 1 + configs/recalbox-rpi4_defconfig | 1 + configs/recalbox-x86_64_defconfig | 1 + package/go-ipfs/Config.in | 11 ++++ package/go-ipfs/S10ipfs | 55 +++++++++++++++++++ package/go-ipfs/go-ipfs.hash | 1 + package/go-ipfs/go-ipfs.mk | 23 ++++++++ .../recalbox-system/odroidgo2/recalbox.conf | 5 ++ .../recalbox-system/odroidxu4/recalbox.conf | 5 ++ package/recalbox-system/rpi3/recalbox.conf | 5 ++ package/recalbox-system/rpi4/recalbox.conf | 5 ++ package/recalbox-system/x86_64/recalbox.conf | 5 ++ 16 files changed, 129 insertions(+), 1 deletion(-) create mode 100644 package/go-ipfs/Config.in create mode 100644 package/go-ipfs/S10ipfs create mode 100644 package/go-ipfs/go-ipfs.hash create mode 100644 package/go-ipfs/go-ipfs.mk diff --git a/CHANGELOG.md b/CHANGELOG.md index 965de1d086..e9725ee970 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,9 @@ # Change Log All notable changes to this project will be documented in this file. +## [NEXT] +- Add IPFS on Pi3, Pi4, XU4 and PC (disabled by default) + ## [8.0-Electron] - Remove non-working shaders - Fix rotation on pifba for Rpizero2 (#2032) diff --git a/Config.in b/Config.in index 2cf6826305..b88e765ea2 100644 --- a/Config.in +++ b/Config.in @@ -284,6 +284,7 @@ menu "Utils" source "$BR2_EXTERNAL_RECALBOX_PATH/package/xxd/Config.in" source "$BR2_EXTERNAL_RECALBOX_PATH/package/kmsgrab/Config.in" source "$BR2_EXTERNAL_RECALBOX_PATH/package/eepromutils/Config.in" + source "$BR2_EXTERNAL_RECALBOX_PATH/package/go-ipfs/Config.in" endmenu menu "Small TFT Screen" source "$BR2_EXTERNAL_RECALBOX_PATH/package/rpi-fbcp/Config.in" diff --git a/RELEASE-NOTES.md b/RELEASE-NOTES.md index 9b67896841..e72e9d3a9d 100644 --- a/RELEASE-NOTES.md +++ b/RELEASE-NOTES.md @@ -5,6 +5,11 @@ The text, located between the first `## Version XXX` and the second one, will ap as release notes for end user on a Recalbox upgrade. +## Version NEXT + +### News +- Add IPFS on Pi3, Pi4, XU4 and PC (disabled by default) + ## Version 8.0-Electron ### News diff --git a/configs/recalbox-odroidxu4_defconfig b/configs/recalbox-odroidxu4_defconfig index 31b7e0f485..4276b45449 100644 --- a/configs/recalbox-odroidxu4_defconfig +++ b/configs/recalbox-odroidxu4_defconfig @@ -352,4 +352,5 @@ BR2_PACKAGE_FLUIDSYNTH_PULSEAUDIO=y BR2_PACKAGE_KODI_PULSEAUDIO=y BR2_PACKAGE_PAMIX=y BR2_PACKAGE_XOW=y -BR2_PACKAGE_KMSGRAB=y \ No newline at end of file +BR2_PACKAGE_KMSGRAB=y +BR2_PACKAGE_GO_IPFS=y diff --git a/configs/recalbox-rpi3_defconfig b/configs/recalbox-rpi3_defconfig index 8ee9c797e2..67f1c47e62 100644 --- a/configs/recalbox-rpi3_defconfig +++ b/configs/recalbox-rpi3_defconfig @@ -366,3 +366,4 @@ BR2_PACKAGE_RECALBOX_VOLUMED=y BR2_PACKAGE_KMSGRAB=y BR2_PACKAGE_RECALBOX_CRT=y BR2_PACKAGE_SWITCHRES=y +BR2_PACKAGE_GO_IPFS=y diff --git a/configs/recalbox-rpi4_defconfig b/configs/recalbox-rpi4_defconfig index 79a6439a6e..d976a3ca03 100644 --- a/configs/recalbox-rpi4_defconfig +++ b/configs/recalbox-rpi4_defconfig @@ -358,3 +358,4 @@ BR2_PACKAGE_RECALBOX_VOLUMED=y BR2_PACKAGE_KMSGRAB=y BR2_PACKAGE_RECALBOX_CRT=y BR2_PACKAGE_SWITCHRES=y +BR2_PACKAGE_GO_IPFS=y diff --git a/configs/recalbox-x86_64_defconfig b/configs/recalbox-x86_64_defconfig index 51a62b9564..9e76081329 100644 --- a/configs/recalbox-x86_64_defconfig +++ b/configs/recalbox-x86_64_defconfig @@ -440,3 +440,4 @@ BR2_PACKAGE_FLUIDSYNTH_PULSEAUDIO=y BR2_PACKAGE_KODI_PULSEAUDIO=y BR2_PACKAGE_PAMIX=y BR2_PACKAGE_XOW=y +BR2_PACKAGE_GO_IPFS=y diff --git a/package/go-ipfs/Config.in b/package/go-ipfs/Config.in new file mode 100644 index 0000000000..fca4883d49 --- /dev/null +++ b/package/go-ipfs/Config.in @@ -0,0 +1,11 @@ +config BR2_PACKAGE_GO_IPFS + bool "go-ipfs" + depends on BR2_PACKAGE_HOST_GO_TARGET_ARCH_SUPPORTS + + help + IPFS is a global, versioned, peer-to-peer filesystem. + IPFS provides an interface as simple as the HTTP web, + but with permanence built-in. + You can also mount the world at /ipfs. + + https://ipfs.io diff --git a/package/go-ipfs/S10ipfs b/package/go-ipfs/S10ipfs new file mode 100644 index 0000000000..dcadcae2b9 --- /dev/null +++ b/package/go-ipfs/S10ipfs @@ -0,0 +1,55 @@ +#!/bin/ash + +if [ "$(recalbox_settings -command load -key system.ipfs.enabled)" != "1" ]; then + exit 0 +fi + +PIDFILE=/var/run/ipfs.pid + +do_init() { + if ipfs config show &> /dev/null; then + return 0 + fi + + recallog "Initializing IPFS" + + hostname="$(recalbox_settings -command load -key system.hostname)" + hostname=${hostname:-RECALBOX} + storageMax="$(recalbox_settings -command load -key system.ipfs.storage-max)" + storageMax=${storageMax:-8GB} + + ipfs init --empty-repo + ipfs config Addresses.Gateway /ip4/0.0.0.0/tcp/9001 # default is 8080 but it's used by + ipfs config Addresses.API /ip4/0.0.0.0/tcp/5001 + ipfs config --json API.HTTPHeaders.Access-Control-Allow-Origin "[\"http://${hostname}:5001\", \"http://${hostname}.local:5001\", \"http://localhost:5001\", \"http://127.0.0.1:5001\"]" + ipfs config --json API.HTTPHeaders.Access-Control-Allow-Methods '["PUT", "POST"]' + ipfs config Datastore.StorageMax "${storageMax}" +} + +do_start() { + recallog "Starting IPFS" + start-stop-daemon --start --quiet --background --make-pidfile --pidfile $PIDFILE --exec ipfs -- daemon +} + +do_stop() { + recallog "Stopping IPFS" + start-stop-daemon --stop --quiet --pidfile $PIDFILE +} + +case "$1" in + start) + do_init + do_start + ;; + stop) + do_stop + ;; + restart) + do_stop + sleep 1 + do_start + ;; + *) + echo "Usage: $0 {start|stop|restart}" + exit 1 +esac diff --git a/package/go-ipfs/go-ipfs.hash b/package/go-ipfs/go-ipfs.hash new file mode 100644 index 0000000000..8a1829ca07 --- /dev/null +++ b/package/go-ipfs/go-ipfs.hash @@ -0,0 +1 @@ +md5 711b7e9e117d0d4a4c77ba6c8bb235fd go-ipfs-source.tar.gz diff --git a/package/go-ipfs/go-ipfs.mk b/package/go-ipfs/go-ipfs.mk new file mode 100644 index 0000000000..c345afe9ff --- /dev/null +++ b/package/go-ipfs/go-ipfs.mk @@ -0,0 +1,23 @@ +################################################################################ +# +# go-ipfs +# +################################################################################ + +GO_IPFS_VERSION = 0.7.0 +GO_IPFS_SITE = https://github.com/ipfs/go-ipfs/releases/download/v$(GO_IPFS_VERSION) +GO_IPFS_SOURCE = go-ipfs-source.tar.gz + +GO_IPFS_LICENSE = MIT or Apache-2.0 +GO_IPFS_LICENSE_FILES = LICENSE LICENSE-MIT LICENSE-APACHE + +GO_IPFS_GO_ENV = CGO_ENABLED=0 +GO_IPFS_BUILD_TARGETS = cmd/ipfs + +GO_IPFS_INSTALL_BINS = $(notdir $(GO_IPFS_BUILD_TARGETS)) + +define GO_IPFS_INSTALL_INIT_SYSV + $(INSTALL) -D -m 0755 $(GO_IPFS_PKGDIR)/S10ipfs $(TARGET_DIR)/etc/init.d/S10ipfs +endef + +$(eval $(golang-package)) diff --git a/package/recalbox-system/odroidgo2/recalbox.conf b/package/recalbox-system/odroidgo2/recalbox.conf index 78c1b01a7f..b4b1e6a9f6 100644 --- a/package/recalbox-system/odroidgo2/recalbox.conf +++ b/package/recalbox-system/odroidgo2/recalbox.conf @@ -178,6 +178,11 @@ wifi.region=JP ## Samba share system.samba.enabled=1 + +## IPFS share +;system.ipfs.enabled=0 +;system.ipfs.storage-max=8GB + ### Virtual Gamepads system.virtual-gamepads.enabled=1 ### SSH diff --git a/package/recalbox-system/odroidxu4/recalbox.conf b/package/recalbox-system/odroidxu4/recalbox.conf index 7a711803a8..1c2fa46255 100644 --- a/package/recalbox-system/odroidxu4/recalbox.conf +++ b/package/recalbox-system/odroidxu4/recalbox.conf @@ -180,6 +180,11 @@ wifi.region=JP ## Samba share system.samba.enabled=1 + +## IPFS share +;system.ipfs.enabled=0 +;system.ipfs.storage-max=8GB + ### Virtual Gamepads system.virtual-gamepads.enabled=1 ### SSH diff --git a/package/recalbox-system/rpi3/recalbox.conf b/package/recalbox-system/rpi3/recalbox.conf index 658a21c53c..8a318214fd 100644 --- a/package/recalbox-system/rpi3/recalbox.conf +++ b/package/recalbox-system/rpi3/recalbox.conf @@ -198,6 +198,11 @@ wifi.region=JP ## Samba share system.samba.enabled=1 + +## IPFS share +;system.ipfs.enabled=0 +;system.ipfs.storage-max=8GB + ### Virtual Gamepads system.virtual-gamepads.enabled=1 ### SSH diff --git a/package/recalbox-system/rpi4/recalbox.conf b/package/recalbox-system/rpi4/recalbox.conf index f8d807d978..9e9dc3655b 100644 --- a/package/recalbox-system/rpi4/recalbox.conf +++ b/package/recalbox-system/rpi4/recalbox.conf @@ -190,6 +190,11 @@ wifi.region=JP ## Samba share system.samba.enabled=1 + +## IPFS share +;system.ipfs.enabled=0 +;system.ipfs.storage-max=8GB + ### Virtual Gamepads system.virtual-gamepads.enabled=1 ### SSH diff --git a/package/recalbox-system/x86_64/recalbox.conf b/package/recalbox-system/x86_64/recalbox.conf index f5eab96a29..f81e9cf5f7 100644 --- a/package/recalbox-system/x86_64/recalbox.conf +++ b/package/recalbox-system/x86_64/recalbox.conf @@ -175,6 +175,11 @@ wifi.region=JP ## Samba share system.samba.enabled=1 + +## IPFS share +;system.ipfs.enabled=0 +;system.ipfs.storage-max=8GB + ### Virtual Gamepads system.virtual-gamepads.enabled=1 ### SSH -- GitLab From 9f118d5f08ae2c83569462f540b002b1367ad8db Mon Sep 17 00:00:00 2001 From: Michael Baudino Date: Wed, 16 Dec 2020 10:21:19 +0100 Subject: [PATCH 2/2] feat(ipfs): compile IPFS with OpenSSL (via CGOs) According to go-ipfs README file: > Building with OpenSSL should significantly reduce the background > CPU usage on nodes that frequently make or receive new connections. --- package/go-ipfs/Config.in | 8 ++++++++ package/go-ipfs/go-ipfs.mk | 8 +++++++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/package/go-ipfs/Config.in b/package/go-ipfs/Config.in index fca4883d49..3d7e89c399 100644 --- a/package/go-ipfs/Config.in +++ b/package/go-ipfs/Config.in @@ -1,6 +1,9 @@ config BR2_PACKAGE_GO_IPFS bool "go-ipfs" depends on BR2_PACKAGE_HOST_GO_TARGET_ARCH_SUPPORTS + depends on BR2_PACKAGE_HOST_GO_TARGET_CGO_LINKING_SUPPORTS + depends on BR2_TOOLCHAIN_HAS_THREADS + select BR2_PACKAGE_OPENSSL help IPFS is a global, versioned, peer-to-peer filesystem. @@ -9,3 +12,8 @@ config BR2_PACKAGE_GO_IPFS You can also mount the world at /ipfs. https://ipfs.io + +comment "go-ipfs needs a toolchain w/ threads" + depends on BR2_PACKAGE_HOST_GO_TARGET_ARCH_SUPPORTS + depends on BR2_PACKAGE_HOST_GO_TARGET_CGO_LINKING_SUPPORTS + depends on !BR2_TOOLCHAIN_HAS_THREADS diff --git a/package/go-ipfs/go-ipfs.mk b/package/go-ipfs/go-ipfs.mk index c345afe9ff..2f8b9ae6e5 100644 --- a/package/go-ipfs/go-ipfs.mk +++ b/package/go-ipfs/go-ipfs.mk @@ -11,9 +11,15 @@ GO_IPFS_SOURCE = go-ipfs-source.tar.gz GO_IPFS_LICENSE = MIT or Apache-2.0 GO_IPFS_LICENSE_FILES = LICENSE LICENSE-MIT LICENSE-APACHE -GO_IPFS_GO_ENV = CGO_ENABLED=0 GO_IPFS_BUILD_TARGETS = cmd/ipfs +GO_IPFS_DEPENDENCIES = openssl +GO_IPFS_TAGS = openssl +GO_IPFS_LDFLAGS = \ + -X $(GO_IPFS_GOMOD)/cli/version.GitCommit=$(GO_IPFS_VERSION) \ + -X $(GO_IPFS_GOMOD)/cli/version.Version=$(GO_IPFS_VERSION) \ + -linkmode internal + GO_IPFS_INSTALL_BINS = $(notdir $(GO_IPFS_BUILD_TARGETS)) define GO_IPFS_INSTALL_INIT_SYSV -- GitLab