diff --git a/GIDs b/GIDs index 5832815be271..253a0748730e 100644 --- a/GIDs +++ b/GIDs @@ -675,7 +675,7 @@ bopm:*:717: # free: 732 # free: 733 # free: 734 -# free: 735 +c-lightning:*:735: # free: 736 # free: 737 # free: 738 diff --git a/UIDs b/UIDs index 0c25862e93a7..2c215cca9edc 100644 --- a/UIDs +++ b/UIDs @@ -680,7 +680,7 @@ _dnscrypt-wrapper:*:718:65534::0:0:dnscrypt-wrapper user:/var/empty:/usr/sbin/no # free: 732 # free: 733 # free: 734 -# free: 735 +c-lightning:*:735:735::0:0:c-lightning Daemon:/var/db/c-lightning:/usr/sbin/nologin # free: 736 # free: 737 # free: 738 diff --git a/net-p2p/Makefile b/net-p2p/Makefile index 0a3b17e1b71f..290d1cd0e965 100644 --- a/net-p2p/Makefile +++ b/net-p2p/Makefile @@ -10,6 +10,7 @@ SUBDIR += bitcoin-daemon SUBDIR += bitcoin-utils SUBDIR += bitflu + SUBDIR += c-lightning SUBDIR += couchpotato SUBDIR += cpuminer SUBDIR += createtorrent diff --git a/net-p2p/c-lightning/Makefile b/net-p2p/c-lightning/Makefile new file mode 100644 index 000000000000..b2b422276924 --- /dev/null +++ b/net-p2p/c-lightning/Makefile @@ -0,0 +1,76 @@ +# Created by: Vasil Dimov +# $FreeBSD$ + +PORTNAME= c-lightning +# To build from an arbitrary git commit comment PORTVERSION and PORTREVISION (if present) +PORTVERSION= 0.8.0 +DISTVERSIONPREFIX= v +# and uncomment the following two lines (use for example -git-HEAD or -git-f8d8348c) +#PORTVERSION= 0 +#PKGNAMESUFFIX= -git-f8d8348c +CATEGORIES= net-p2p finance + +MAINTAINER= vd@FreeBSD.org +COMMENT= Lightning Network implementation in C + +LICENSE= MIT + +BUILD_DEPENDS= ${PYTHON_PKGNAMEPREFIX}mako>=1.0.14:textproc/py-mako@${PY_FLAVOR} +LIB_DEPENDS= libgmp.so:math/gmp \ + libsodium.so:security/libsodium \ + libsqlite3.so:databases/sqlite3 +RUN_DEPENDS= bitcoin-cli:net-p2p/bitcoin-utils + +USES= autoreconf:build gettext gmake libtool python:3.5+,build +BINARY_ALIAS= python=${PYTHON_CMD} python3=${PYTHON_CMD} +ALL_TARGET= default + +OPTIONS_DEFINE= COMPATIBILITY DEVELOPER EXPERIMENTAL +OPTIONS_RADIO= TESTING +OPTIONS_RADIO_TESTING= ASAN VALGRIND + +COMPATIBILITY_CONFIGURE_ENABLE= compat +COMPATIBILITY_DESC= Compatibility mode, good to disable to see if your software breaks +DEVELOPER_CONFIGURE_ENABLE= developer +DEVELOPER_DESC= Developer mode, good for testing +EXPERIMENTAL_CONFIGURE_ENABLE= experimental-features +EXPERIMENTAL_DESC= Enable experimental features +ASAN_CONFIGURE_ENABLE= address-sanitizer +ASAN_DESC= Compile with address-sanitizer +VALGRIND_CONFIGURE_ENABLE= valgrind +VALGRIND_DESC= Run tests with Valgrind + +OPTIONS_DEFAULT=COMPATIBILITY + +HAS_CONFIGURE= yes + +USE_GITHUB= yes +.if defined(PKGNAMESUFFIX) +GIT_COMMIT= ${PKGNAMESUFFIX:C/-git-//} +.else +GIT_COMMIT= ${DISTVERSIONPREFIX}${PORTVERSION} +.endif +GH_TUPLE= ElementsProject:lightning:${GIT_COMMIT} \ + ElementsProject:libwally-core:release_0.7.4:ext1/external/libwally-core \ + ianlancetaylor:libbacktrace:5a99ff7fed66b8e:ext2/external/libbacktrace \ + zserge:jsmn:v1.0.0:ext3/external/jsmn + +USERS= c-lightning +GROUPS= c-lightning + +USE_RC_SUBR= lightningd + +SUB_FILES= lightningd-bitcoin.conf.sample pkg-message +SUB_LIST= U="${USERS}" G="${GROUPS}" LIGHTNINGD_BASE_DIR="${DESTDIR}/var/db/c-lightning" +PLIST_SUB= U="${USERS}" G="${GROUPS}" + +post-patch: + ${REINPLACE_CMD} -e 's|cd external|unset CFLAGS \&\& cd external|' \ + ${WRKSRC}/external/Makefile + +post-install: + ${INSTALL_DATA} \ + ${WRKDIR}/lightningd-bitcoin.conf.sample \ + ${STAGEDIR}${PREFIX}/etc/lightningd-bitcoin.conf.sample + +.include diff --git a/net-p2p/c-lightning/distinfo b/net-p2p/c-lightning/distinfo new file mode 100644 index 000000000000..01ffaedc1ee6 --- /dev/null +++ b/net-p2p/c-lightning/distinfo @@ -0,0 +1,9 @@ +TIMESTAMP = 1577715475 +SHA256 (ElementsProject-lightning-v0.8.0_GH0.tar.gz) = 6abe19465748cfbe59a1d3943d8f390bf0f810d1ba1eda07fcc02144ab939173 +SIZE (ElementsProject-lightning-v0.8.0_GH0.tar.gz) = 2622314 +SHA256 (ElementsProject-libwally-core-release_0.7.4_GH0.tar.gz) = d1ec3085d8b12ec5e4f604f747850ef77eb734c61c23e79d6c8a3b6c69c6c699 +SIZE (ElementsProject-libwally-core-release_0.7.4_GH0.tar.gz) = 900716 +SHA256 (ianlancetaylor-libbacktrace-5a99ff7fed66b8e_GH0.tar.gz) = 2aad59f02cb008b5e912821c205ad6a140afcae69844e7ba9f7e590239ec41e2 +SIZE (ianlancetaylor-libbacktrace-5a99ff7fed66b8e_GH0.tar.gz) = 509368 +SHA256 (zserge-jsmn-v1.0.0_GH0.tar.gz) = 5b1f46312cf205e6a0923a0656893bde9e022c76d06d980958fa8dbf79f0ea06 +SIZE (zserge-jsmn-v1.0.0_GH0.tar.gz) = 11035 diff --git a/net-p2p/c-lightning/files/lightningd-bitcoin.conf.sample.in b/net-p2p/c-lightning/files/lightningd-bitcoin.conf.sample.in new file mode 100644 index 000000000000..d64202e50ddc --- /dev/null +++ b/net-p2p/c-lightning/files/lightningd-bitcoin.conf.sample.in @@ -0,0 +1,22 @@ +# An example lightningd config using Tor hidden service. +# +# Before starting lightningd configure Tor by adding the following 3 lines +# to %%LOCALBASE%%/etc/tor/torrc: +# HiddenServiceDir /var/db/tor/lightningd-bitcoin/ +# HiddenServiceVersion 3 +# HiddenServicePort 1234 127.0.0.1:5678 +# and restart the tor daemon. Then see the hidden service name from +# /var/db/tor/lightningd-bitcoin/hostname and put it in announce-addr below. +# +# See "lightningd --help" for all possible options. +# +always-use-proxy=true +announce-addr=my-tor-hidden-service.onion:1234 +bind-addr=127.0.0.1:5678 +bitcoin-rpcconnect=127.0.0.1 +bitcoin-rpcpassword=... +bitcoin-rpcport=... +bitcoin-rpcuser=... +log-file=lightningd.log +network=bitcoin +proxy=127.0.0.1:9050 diff --git a/net-p2p/c-lightning/files/lightningd.in b/net-p2p/c-lightning/files/lightningd.in new file mode 100644 index 000000000000..c476da7e1105 --- /dev/null +++ b/net-p2p/c-lightning/files/lightningd.in @@ -0,0 +1,44 @@ +#!/bin/sh +# $FreeBSD$ + +# PROVIDE: lightningd +# REQUIRE: LOGIN cleanvar +# KEYWORD: shutdown + +# Add the following to %%LOCALBASE%%/etc/rc.conf.d/lightningd to influence +# the behavior of this script (default values are listed): +# +# lightningd_enable="NO" # change to "YES" to enable +# lightningd_user="%%U%%" +# lightningd_group="%%G%%" +# lightningd_base_dir="%%LIGHTNINGD_BASE_DIR%%" +# lightningd_network="bitcoin" +# lightningd_conf="%%PREFIX%%/etc/lightningd-${lightningd_network}.conf" +# lightningd_extra_args="" # See lightningd --help + +. /etc/rc.subr + +name="lightningd" +rcvar=lightningd_enable + +load_rc_config ${name} + +: ${lightningd_enable:="NO"} +: ${lightningd_user:="%%U%%"} +: ${lightningd_group:="%%G%%"} +: ${lightningd_base_dir:="%%LIGHTNINGD_BASE_DIR%%"} +: ${lightningd_network:="bitcoin"} +: ${lightningd_conf:="%%PREFIX%%/etc/${name}-${lightningd_network}.conf"} + +pidfile="${lightningd_base_dir}/lightningd-${lightningd_network}.pid" +command="%%PREFIX%%/bin/lightningd" +command_args="" +command_args="${command_args} --lightning-dir=${lightningd_base_dir}" +command_args="${command_args} --network=${lightningd_network}" +command_args="${command_args} --daemon" + +if [ -e "${lightningd_conf}" ] ; then + command_args="${command_args} --conf=${lightningd_conf}" +fi + +run_rc_command "$1" diff --git a/net-p2p/c-lightning/files/patch-Makefile b/net-p2p/c-lightning/files/patch-Makefile new file mode 100644 index 000000000000..1abd8f570676 --- /dev/null +++ b/net-p2p/c-lightning/files/patch-Makefile @@ -0,0 +1,32 @@ +--- Makefile.orig 2019-12-08 14:26:28 UTC ++++ Makefile +@@ -1,7 +1,7 @@ + #! /usr/bin/make + + # Extract version from git, or if we're from a zipfile, use dirname +-VERSION=$(shell git describe --always --dirty=-modded --abbrev=7 2>/dev/null || pwd | sed -n 's,.*/clightning-\(v[0-9.rc]*\)$$,\1,p') ++VERSION=$(shell git describe --always --dirty=-modded --abbrev=7 2>/dev/null || pwd | sed -n 's|.*/c\{0,1\}lightning-v\{0,1\}\([0-9a-f.rc]*\)$$|\1|gp') + + ifeq ($(VERSION),) + $(error "ERROR: git is required for generating version information") +@@ -453,7 +453,7 @@ pkglibexecdir = $(libexecdir)/$(PKGNAME) + plugindir = $(pkglibexecdir)/plugins + datadir = $(PREFIX)/share + docdir = $(datadir)/doc/$(PKGNAME) +-mandir = $(datadir)/man ++mandir = $(PREFIX)/man + man1dir = $(mandir)/man1 + man5dir = $(mandir)/man5 + man7dir = $(mandir)/man7 +@@ -462,7 +462,11 @@ man8dir = $(mandir)/man8 + # Commands + MKDIR_P = mkdir -p + INSTALL = install ++ifeq ($(DEVELOPER),1) + INSTALL_PROGRAM = $(INSTALL) ++else ++INSTALL_PROGRAM = $(INSTALL) -s ++endif + INSTALL_DATA = $(INSTALL) -m 644 + + # Tags needed by some package systems. diff --git a/net-p2p/c-lightning/files/patch-tools_mockup.sh b/net-p2p/c-lightning/files/patch-tools_mockup.sh new file mode 100644 index 000000000000..9ed0e33dd00f --- /dev/null +++ b/net-p2p/c-lightning/files/patch-tools_mockup.sh @@ -0,0 +1,16 @@ +--- tools/mockup.sh.orig 2019-12-13 15:40:41 UTC ++++ tools/mockup.sh +@@ -6,8 +6,13 @@ if [ $# -eq 0 ]; then + set -- $(while read -r LINE; do + case "$LINE" in + *undefined\ reference\ to*) ++ # file.cc:(.text+0x10): undefined reference to `foo()' + LINE=${LINE#*undefined reference to \`} + echo "${LINE%\'*}" ++ ;; ++ *undefined\ symbol:*) ++ # ld: error: undefined symbol: foo() ++ echo "${LINE#*undefined symbol: }" + ;; + *) + continue diff --git a/net-p2p/c-lightning/files/patch-tools_update-mocks.sh b/net-p2p/c-lightning/files/patch-tools_update-mocks.sh new file mode 100644 index 000000000000..8f8cc2e8c269 --- /dev/null +++ b/net-p2p/c-lightning/files/patch-tools_update-mocks.sh @@ -0,0 +1,36 @@ +--- tools/update-mocks.sh.orig 2019-12-13 20:01:11 UTC ++++ tools/update-mocks.sh +@@ -12,20 +12,31 @@ trap 'mv $BASE.old $FILE; rm -f $BASE.*' EXIT + START=$(grep -F -n '/* AUTOGENERATED MOCKS START */' "$FILE" | cut -d: -f1) + END=$(grep -F -n '/* AUTOGENERATED MOCKS END */' "$FILE" | cut -d: -f1) + ++function make_binary() { ++ $MAKE "${FILE/%.c/}" 2> "${BASE}.err" >/dev/null ++} ++ + if [ -n "$START" ]; then + mv "$FILE" "${BASE}.old" + echo "${FILE}:" + head -n "$START" "${BASE}.old" > "$FILE" + tail -n +"$END" "${BASE}.old" >> "$FILE" + # Try to make binary. +- if ! $MAKE "${FILE/%.c/}" 2> "${BASE}.err" >/dev/null; then ++ if ! make_binary; then ++ # Some linkers (e.g. LLVM's one) don't print all errors. If this is the ++ # case, then re-run, asking them to do so. Search for something like ++ # this in the output: ++ # ld: error: too many errors emitted, stopping now (use -error-limit=0 to see all errors) ++ if grep -q 'too many errors emitted.*-error-limit=0' "${BASE}.err"; then ++ LDFLAGS=-Wl,-error-limit=0 make_binary || : ++ fi + tools/mockup.sh < "${BASE}.err" >> "${BASE}.stubs" + # If there are no link errors, maybe compile fail for other reason? + if ! grep -F -q 'Generated stub for' "${BASE}.stubs"; then + cat "${BASE}.err" + exit 1 + fi +- sed -n 's,.*Generated stub for \(.*\) .*,\t\1,p' < "${BASE}.stubs" ++ sed -n 's,.*Generated stub for \(.*\) .*, \1,p' < "${BASE}.stubs" + head -n "$START" "${BASE}.old" > "$FILE" + cat "${BASE}.stubs" >> "$FILE" + tail -n +"$END" "${BASE}.old" >> "$FILE" diff --git a/net-p2p/c-lightning/files/pkg-message.in b/net-p2p/c-lightning/files/pkg-message.in new file mode 100644 index 000000000000..e82c444d5151 --- /dev/null +++ b/net-p2p/c-lightning/files/pkg-message.in @@ -0,0 +1,14 @@ +[ +{ type: install + message: <