Skip to content
Open
Show file tree
Hide file tree
Changes from all 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
33 changes: 20 additions & 13 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
#! /usr/bin/make

# Use GNU sed on Darwin (macOS) systems, regular sed elsewhere
ifeq ($(shell uname -s),Darwin)
SED=gsed
else
SED=sed
endif

# Extract version from git, or if we're from a zipfile, use dirname
VERSION=$(shell git describe --tags --always --dirty=-modded --abbrev=7 2>/dev/null || pwd | sed -n 's|.*/c\{0,1\}lightning-v\{0,1\}\([0-9a-f.rc\-]*\)$$|v\1|gp')
VERSION=$(shell git describe --tags --always --dirty=-modded --abbrev=7 2>/dev/null || pwd | $(SED) -n 's|.*/c\{0,1\}lightning-v\{0,1\}\([0-9a-f.rc\-]*\)$$|v\1|gp')

# Next release.
CLN_NEXT_VERSION := v25.12
Expand Down Expand Up @@ -318,30 +325,30 @@ else
# Git doesn't maintain timestamps, so we only regen if sources actually changed:
# We place the SHA inside some generated files so we can tell if they need updating.
# Usage: $(call SHA256STAMP_CHANGED)
SHA256STAMP_CHANGED = [ x"`sed -n 's/.*SHA256STAMP:\([a-f0-9]*\).*/\1/p' $@ 2>/dev/null`" != x"`cat $(sort $(filter-out FORCE,$^)) | $(SHA256SUM) | cut -c1-64`" ]
SHA256STAMP_CHANGED = [ x"`$(SED) -n 's/.*SHA256STAMP:\([a-f0-9]*\).*/\1/p' $@ 2>/dev/null`" != x"`cat $(sort $(filter-out FORCE,$^)) | $(SHA256SUM) | cut -c1-64`" ]
# Usage: $(call SHA256STAMP,commentprefix,commentpostfix)
SHA256STAMP = echo "$(1) SHA256STAMP:"`cat $(sort $(filter-out FORCE,$^)) | $(SHA256SUM) | cut -c1-64`"$(2)" >> $@
endif

# generate-wire.py --page [header|impl] hdrfilename wirename < csv > file
%_wiregen.h: %_wire.csv $(WIRE_GEN_DEPS)
@if $(call SHA256STAMP_CHANGED); then \
$(call VERBOSE,"wiregen $@",tools/generate-wire.py --page header $($@_args) $@ `basename $< .csv | sed 's/_exp_/_/'` < $< > $@ && $(call SHA256STAMP,//,)); \
$(call VERBOSE,"wiregen $@",tools/generate-wire.py --page header $($@_args) $@ `basename $< .csv | $(SED) 's/_exp_/_/'` < $< > $@ && $(call SHA256STAMP,//,)); \
fi

%_wiregen.c: %_wire.csv $(WIRE_GEN_DEPS)
@if $(call SHA256STAMP_CHANGED); then \
$(call VERBOSE,"wiregen $@",tools/generate-wire.py --page impl $($@_args) ${@:.c=.h} `basename $< .csv | sed 's/_exp_/_/'` < $< > $@ && $(call SHA256STAMP,//,)); \
$(call VERBOSE,"wiregen $@",tools/generate-wire.py --page impl $($@_args) ${@:.c=.h} `basename $< .csv | $(SED) 's/_exp_/_/'` < $< > $@ && $(call SHA256STAMP,//,)); \
fi

%_printgen.h: %_wire.csv $(WIRE_GEN_DEPS)
@if $(call SHA256STAMP_CHANGED); then \
$(call VERBOSE,"printgen $@",tools/generate-wire.py -s -P --page header $($@_args) $@ `basename $< .csv | sed 's/_exp_/_/'` < $< > $@ && $(call SHA256STAMP,//,)); \
$(call VERBOSE,"printgen $@",tools/generate-wire.py -s -P --page header $($@_args) $@ `basename $< .csv | $(SED) 's/_exp_/_/'` < $< > $@ && $(call SHA256STAMP,//,)); \
fi

%_printgen.c: %_wire.csv $(WIRE_GEN_DEPS)
@if $(call SHA256STAMP_CHANGED); then \
$(call VERBOSE,"printgen $@",tools/generate-wire.py -s -P --page impl $($@_args) ${@:.c=.h} `basename $< .csv | sed 's/_exp_/_/'` < $< > $@ && $(call SHA256STAMP,//,)); \
$(call VERBOSE,"printgen $@",tools/generate-wire.py -s -P --page impl $($@_args) ${@:.c=.h} `basename $< .csv | $(SED) 's/_exp_/_/'` < $< > $@ && $(call SHA256STAMP,//,)); \
fi

RUST_PROFILE ?= debug
Expand Down Expand Up @@ -411,7 +418,7 @@ ALL_TEST_GEN += $(GRPC_GEN)
$(GRPC_GEN) &: cln-grpc/proto/node.proto cln-grpc/proto/primitives.proto
$(PYTHON) -m grpc_tools.protoc -I cln-grpc/proto cln-grpc/proto/node.proto --python_out=$(GRPC_PATH)/ --grpc_python_out=$(GRPC_PATH)/ --experimental_allow_proto3_optional
$(PYTHON) -m grpc_tools.protoc -I cln-grpc/proto cln-grpc/proto/primitives.proto --python_out=$(GRPC_PATH)/ --experimental_allow_proto3_optional
find $(GRPC_DIR)/ -type f -name "*.py" -print0 | xargs -0 sed -i'.bak' -e 's/^import \(.*\)_pb2 as .*__pb2/from pyln.grpc import \1_pb2 as \1__pb2/g'
find $(GRPC_DIR)/ -type f -name "*.py" -print0 | xargs -0 $(SED) -i'.bak' -e 's/^import \(.*\)_pb2 as .*__pb2/from pyln.grpc import \1_pb2 as \1__pb2/g'
find $(GRPC_DIR)/ -type f -name "*.py.bak" -print0 | xargs -0 rm -f

# We make pretty much everything depend on these.
Expand Down Expand Up @@ -444,7 +451,7 @@ mkdocs.yml: $(MANPAGES:=.md)
@$(call VERBOSE, "genidx $@", \
find doc -maxdepth 1 -name '*\.[0-9]\.md' | \
cut -b 5- | LC_ALL=C sort | \
sed 's/\(.*\)\.\(.*\).*\.md/- "\1": "\1.\2.md"/' | \
$(SED) 's/\(.*\)\.\(.*\).*\.md/- "\1": "\1.\2.md"/' | \
$(PYTHON) devtools/blockreplace.py mkdocs.yml manpages --language=yml --indent " " \
)

Expand Down Expand Up @@ -559,7 +566,7 @@ check-python-flake8:
@# E731 do not assign a lambda expression, use a def
@# W503: line break before binary operator
@# E741: ambiguous variable name
@uv run flake8 --ignore=E501,E731,E741,W503,F541,E275 --exclude $(shell echo ${PYTHON_GENERATED} | sed 's/ \+/,/g') ${PYSRC}
@uv run flake8 --ignore=E501,E731,E741,W503,F541,E275 --exclude $(shell echo ${PYTHON_GENERATED} | $(SED) 's/ \+/,/g') ${PYSRC}

check-pytest-pyln-proto:
PATH=$(PYLN_PATH) PYTHONPATH=$(MY_CHECK_PYTHONPATH) uv run $(PYTEST) contrib/pyln-proto/tests/
Expand Down Expand Up @@ -717,7 +724,7 @@ $(ALL_TEST_PROGRAMS:=.o): $(ALL_GEN_SOURCES)

update-ccan:
mv ccan ccan.old
DIR=$$(pwd)/ccan; cd ../ccan && ./tools/create-ccan-tree -a $$DIR `cd $$DIR.old/ccan && find * -name _info | sed s,/_info,, | $(SORT)` $(CCAN_NEW)
DIR=$$(pwd)/ccan; cd ../ccan && ./tools/create-ccan-tree -a $$DIR `cd $$DIR.old/ccan && find * -name _info | $(SED) s,/_info,, | $(SORT)` $(CCAN_NEW)
mkdir -p ccan/tools/configurator
cp ../ccan/tools/configurator/configurator.c ../ccan/doc/configurator.1 ccan/tools/configurator/
$(MAKE) ccan/config.h
Expand Down Expand Up @@ -772,8 +779,8 @@ update-pyln-versions: $(PYLNS:%=update-pyln-version-%)
update-pyln-version-%:
@if [ -z "$(NEW_VERSION)" ]; then echo "Set NEW_VERSION!" >&2; exit 1; fi
@echo "Updating contrib/pyln-$* to $(NEW_VERSION)"
@sed -i.bak 's/^version = .*/version = "$(NEW_VERSION)"/' contrib/pyln-$*/pyproject.toml && rm contrib/pyln-$*/pyproject.toml.bak
@sed -i.bak 's/^__version__ = .*/__version__ = "$(NEW_VERSION)"/' contrib/pyln-$*/pyln/$*/__init__.py && rm contrib/pyln-$*/pyln/$*/__init__.py.bak
@$(SED) -i.bak 's/^version = .*/version = "$(NEW_VERSION)"/' contrib/pyln-$*/pyproject.toml && rm contrib/pyln-$*/pyproject.toml.bak
@$(SED) -i.bak 's/^__version__ = .*/__version__ = "$(NEW_VERSION)"/' contrib/pyln-$*/pyln/$*/__init__.py && rm contrib/pyln-$*/pyln/$*/__init__.py.bak

pyln-release: $(PYLNS:%=pyln-release-%)

Expand Down Expand Up @@ -805,7 +812,7 @@ update-lock:
update-reckless-version:
@if [ -z "$(NEW_VERSION)" ]; then echo "Set NEW_VERSION!" >&2; exit 1; fi
@echo "Updating tools/reckless to $(NEW_VERSION)"
@sed -i.bak "s/__VERSION__ = '.*'/__VERSION__ = '$(NEW_VERSION)'/" tools/reckless && rm tools/reckless.bak
@$(SED) -i.bak "s/__VERSION__ = '.*'/__VERSION__ = '$(NEW_VERSION)'/" tools/reckless && rm tools/reckless.bak

update-dot-version:
@if [ -z "$(NEW_VERSION)" ]; then echo "Set NEW_VERSION!" >&2; exit 1; fi
Expand Down
17 changes: 12 additions & 5 deletions contrib/plugins/cowsay.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
#! /bin/sh

# Use GNU sed on Darwin (macOS) systems, regular sed elsewhere
if [ "$(uname -s)" = "Darwin" ]; then
SED="gsed"
else
SED="sed"
fi

maybe_cowsay()
{
cowsay || cat <<EOF
Expand All @@ -17,24 +24,24 @@ EOF
# Eg. {"jsonrpc":"2.0","id":2,"method":"getmanifest","params":{}}\n\n
read -r JSON
read -r _
id=$(echo "$JSON" | sed 's/.*"id" *: *\([^,]*\),.*/\1/')
id=$(echo "$JSON" | $SED 's/.*"id" *: *\([^,]*\),.*/\1/')

echo '{"jsonrpc":"2.0","id":'"$id"',"result":{"dynamic":true,"options":[],"rpcmethods":[{"name":"cowsay","usage":"<string>","description":"Have a cow, man!"}]}}'

# Eg. {"jsonrpc":"2.0","id":5,"method":"init","params":{"options":{},"configuration":{"lightning-dir":"/home/rusty/.lightning","rpc-file":"lightning-rpc","startup":false}}}\n\n
read -r JSON
read -r _
id=$(echo "$JSON" | sed 's/.*"id" *: *\([^,]*\),.*/\1/')
id=$(echo "$JSON" | $SED 's/.*"id" *: *\([^,]*\),.*/\1/')

echo '{"jsonrpc":"2.0","id":'"$id"',"result":{}}'

# eg. { "jsonrpc" : "2.0", "method" : "cowsay", "id" : 6, "params" :[ "hello"] }
while read -r JSON; do
read -r _
id=$(echo "$JSON" | sed 's/.*"id" *: *\([^,]*\),.*/\1/')
params=$(echo "$JSON" | sed 's/.*"params" *: *//' | tr -d '[{}]"')
id=$(echo "$JSON" | $SED 's/.*"id" *: *\([^,]*\),.*/\1/')
params=$(echo "$JSON" | $SED 's/.*"params" *: *//' | tr -d '[{}]"')
echo '{"jsonrpc":"2.0","id":'"$id"',"result":{"format-hint":"simple","cowsay":"'
# FIXME: lightning-cli does not unescape \\, so we replace with an L.
printf "%s" "$params" | maybe_cowsay | sed 's/\\/L/g' | sed ':a;N;$!ba;s/\n/\\n/g' | tr '\012' '"'
printf "%s" "$params" | maybe_cowsay | $SED 's/\\/L/g' | $SED ':a;N;$!ba;s/\n/\\n/g' | tr '\012' '"'
echo '}}'
done
2 changes: 1 addition & 1 deletion doc/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ doc/index.rst: $(MARKDOWNPAGES_WITH_EXT) $(NON_PREFIXED_MARKDOWNPAGES_WITH_EXT)
for m in $(MARKDOWNPAGES_WITH_EXT) $(NON_PREFIXED_MARKDOWNPAGES_WITH_EXT); do \
base=$$(basename "$$m"); \
echo "$$base" | \
sed -E 's/^(.*)\.([0-9]+)\.md$$/\1 <\1.\2.md>/; t; s/^(.*)\.md$$/\1 <\1.md>/'; \
$(SED) -E 's/^(.*)\.([0-9]+)\.md$$/\1 <\1.\2.md>/; t; s/^(.*)\.md$$/\1 <\1.md>/'; \
done | \
LC_ALL=C sort | \
$(PYTHON) devtools/blockreplace.py doc/index.rst manpages --language=rst --indent " " \
Expand Down
4 changes: 2 additions & 2 deletions plugins/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -277,9 +277,9 @@ plugins/sql-schema_gen.h: $(SQL_SCHEMA_PARTS)
SEP=""; \
echo "\"{"; \
for l in $(SQL_LISTRPCS); do \
echo "$$SEP\"$$l\":{\"properties\":$$(cat plugins/sql-schema_$${l}_gen.h)}" | sed s/\"/\\\"/g; \
echo "$$SEP\"$$l\":{\"properties\":$$(cat plugins/sql-schema_$${l}_gen.h)}" | $(SED) s/\"/\\\"/g; \
SEP=","; \
done | sed "s/\\\"/\\\\\"/g"; \
done | $(SED) "s/\\\"/\\\\\"/g"; \
echo "}\"") | tr -d " \n" > $@ \
)

Expand Down
13 changes: 10 additions & 3 deletions tools/build-release.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
#! /bin/sh
set -e

# Use GNU sed on Darwin (macOS) systems, regular sed elsewhere
if [ "$(uname -s)" = "Darwin" ]; then
SED="gsed"
else
SED="sed"
fi

# When run inside docker (from below), we do build and drop result in /release
if [ "$1" = "--inside-docker" ]; then
echo "Inside docker: starting build"
Expand Down Expand Up @@ -103,7 +110,7 @@ if [ "$(git diff --name-only)" != "" ] && ! $FORCE_UNCLEAN; then
fi

# Skip 'v' here in $VERSION
MTIME=${FORCE_MTIME:-$(sed -n "s/^## \\[.*${VERSION#v}\\] - \\([-0-9]*\\).*/\\1/p" < CHANGELOG.md)}
MTIME=${FORCE_MTIME:-$($SED -n "s/^## \\[.*${VERSION#v}\\] - \\([-0-9]*\\).*/\\1/p" < CHANGELOG.md)}
echo "mTime: $MTIME"

if [ -z "$MTIME" ]; then
Expand All @@ -130,7 +137,7 @@ else
fi

RELEASEDIR="$(pwd)/release"
BARE_VERSION="$(echo "${VERSION}" | sed 's/^v//g')"
BARE_VERSION="$(echo "${VERSION}" | $SED 's/^v//g')"
TARBALL="${RELEASEDIR}/lightningd_${BARE_VERSION}.orig.tar.bz2"
DATE=$(date +%Y%m%d%H%M%S)
echo "Targets: $TARGETS"
Expand Down Expand Up @@ -166,7 +173,7 @@ if [ "$WITHOUT_ZIP" = "false" ]; then
# Non-executables become -rw-r--r--
find "$RELEASEDIR/clightning-$VERSION" -type f ! -perm -100 -print0 | xargs -0r chmod 644
# zip -r doesn't have a deterministic order, and git ls-files does.
LANG=C git ls-files --recurse-submodules | sed "s@^@clightning-$VERSION/@" | (cd release && zip -@ -X "clightning-$VERSION.zip")
LANG=C git ls-files --recurse-submodules | $SED "s@^@clightning-$VERSION/@" | (cd release && zip -@ -X "clightning-$VERSION.zip")
rm -r "$RELEASEDIR/clightning-$VERSION"
echo "Zip File Created"
fi
Expand Down
11 changes: 9 additions & 2 deletions tools/check-manpage.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
#!/usr/bin/env bash
# Needs bash for process substitition, ie <(

# Use GNU sed on Darwin (macOS) systems, regular sed elsewhere
if [ "$(uname -s)" = "Darwin" ]; then
SED="gsed"
else
SED="sed"
fi

if [ $# != 2 ]; then
echo "Usage $0 <command> <markdown.md>" >&2
exit 1
Expand All @@ -10,7 +17,7 @@ get_cmd_opts()
{
# Trim out -- after first one: ensure width sufficient to give desc
# on same line, and ignore single-letter prefix e.g. -X|--ex
COLUMNS=1000 $1 --help | sed -n 's/^\(-.|\)\?\(--[^ ]*\)\( \| \).*/\2/p' | while IFS=$'\n' read -r opt; do
COLUMNS=1000 $1 --help | $SED -n 's/^\(-.|\)\?\(--[^ ]*\)\( \| \).*/\2/p' | while IFS=$'\n' read -r opt; do
case "$opt" in
# We don't document dev options.
--dev-*)
Expand Down Expand Up @@ -46,7 +53,7 @@ if [ -z "$CMD_OPTNAMES" ]; then
fi

# Now, gather (long) opt names from man page, make sure they match.
MAN_OPTNAMES=$(grep -vi 'deprecated in' "$2" | sed -E -n 's,^\* \*\*(--)?([^*/]*)\*\*(/\*\*-.\*\*)?(=?).*,\2\4,p'| sort)
MAN_OPTNAMES=$(grep -vi 'deprecated in' "$2" | $SED -E -n 's,^\* \*\*(--)?([^*/]*)\*\*(/\*\*-.\*\*)?(=?).*,\2\4,p'| sort)

if [ "$CMD_OPTNAMES" != "$MAN_OPTNAMES" ]; then
echo "diff of command names vs manpage names":
Expand Down
11 changes: 9 additions & 2 deletions tools/md2man.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
#! /bin/sh

# Use GNU sed on Darwin (macOS) systems, regular sed elsewhere
if [ "$(uname -s)" = "Darwin" ]; then
SED="gsed"
else
SED="sed"
fi

if [ $# != 2 ]; then
echo "Usage: $0 <lowdown> <markdownpage>" >&2
exit 1
Expand Down Expand Up @@ -29,14 +36,14 @@ TITLELINE="$(head -n1 "$SOURCE")"
# Replace lightning-cli with $ lightning-cli but do not replace it if it is preceded with (
# because it is used in the examples to run it in the shell, eg. $(lightning-cli listpeerchannels)
# shellcheck disable=SC2016 # These are not variables, shellcheck!
SOURCE=$(tail -n +3 "$SOURCE" | sed -E '
SOURCE=$(tail -n +3 "$SOURCE" | $SED -E '
:a;N;$!ba;
s#(\(lightning-cli)#\x1#ig;
s#lightning-cli#$ lightning-cli#g;
s#\x1#(lightning-cli#g;
' |
# Lowdown requires a blank line before every preformatted text block
sed '
$SED '
/^$/{:0;N;/\n$/b0};s/^[[:blank:]]*```/\n\0/;
/\n[[:blank:]]*```/{:1;n;/^[[:blank:]]*```/!b1}
')
Expand Down
9 changes: 8 additions & 1 deletion tools/mockup.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
#!/usr/bin/env bash

# Use GNU sed on Darwin (macOS) systems, regular sed elsewhere
if [ "$(uname -s)" = "Darwin" ]; then
SED="gsed"
else
SED="sed"
fi

if [ $# = 0 ]; then
echo 'Usage: mockup.sh <filename> [SYMBOLS...]' >&2
exit 1
Expand Down Expand Up @@ -73,5 +80,5 @@ for SYMBOL; do

echo "/* Generated stub for $SYMBOL */"

tail -n "+${LINE}" < "$FILE" | head -n "$NUM" | sed 's/^extern *//' | sed 's/PRINTF_FMT([^)]*)//' | sed 's/NON_NULL_ARGS([^)]*)//' | sed 's/NO_NULL_ARGS//g' | sed 's/NORETURN//g' | sed 's/RETURNS_NONNULL//g' | sed 's/LAST_ARG_NULL//g' | sed 's/WARN_UNUSED_RESULT//g' | sed 's/,/ UNNEEDED,/g' | sed 's/\([a-z0-9A-Z*_]* [a-z0-9A-Z*_]*\));/\1 UNNEEDED);/' | sed "s/;\$/$STUB/" | sed 's/[[:space:]]*$//'
tail -n "+${LINE}" < "$FILE" | head -n "$NUM" | $SED 's/^extern *//' | $SED 's/PRINTF_FMT([^)]*)//' | $SED 's/NON_NULL_ARGS([^)]*)//' | $SED 's/NO_NULL_ARGS//g' | $SED 's/NORETURN//g' | $SED 's/RETURNS_NONNULL//g' | $SED 's/LAST_ARG_NULL//g' | $SED 's/WARN_UNUSED_RESULT//g' | $SED 's/,/ UNNEEDED,/g' | $SED 's/\([a-z0-9A-Z*_]* [a-z0-9A-Z*_]*\));/\1 UNNEEDED);/' | $SED "s/;\$/$STUB/" | $SED 's/[[:space:]]*$//'
done
11 changes: 9 additions & 2 deletions tools/repro-build.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
#! /bin/sh

# Use GNU sed on Darwin (macOS) systems, regular sed elsewhere
if [ "$(uname -s)" = "Darwin" ]; then
SED="gsed"
else
SED="sed"
fi

set -e

LANG=C
Expand Down Expand Up @@ -55,12 +62,12 @@ fi

ARCH=$(dpkg --print-architecture)
PLATFORM="$OS"-"$VER"
VERSION=${FORCE_VERSION:-$(git describe --tags --always --dirty=-modded --abbrev=7 2>/dev/null || pwd | sed -n 's,.*/clightning-\(v[0-9.rc\-]*\)$,\1,p')}
VERSION=${FORCE_VERSION:-$(git describe --tags --always --dirty=-modded --abbrev=7 2>/dev/null || pwd | $SED -n 's,.*/clightning-\(v[0-9.rc\-]*\)$,\1,p')}
MAKEPAR=${MAKEPAR:-1}

# eg. ## [0.6.3] - 2019-01-09: "The Smallblock Conspiracy"
# Skip 'v' here in $VERSION
MTIME=${FORCE_MTIME:-$(sed -n "s/^## \\[${VERSION#v}\\] - \\([-0-9]*\\).*/\\1/p" < CHANGELOG.md)}
MTIME=${FORCE_MTIME:-$($SED -n "s/^## \\[${VERSION#v}\\] - \\([-0-9]*\\).*/\\1/p" < CHANGELOG.md)}
if [ -z "$MTIME" ]; then
echo "No date found for $VERSION in CHANGELOG.md" >&2
exit 1
Expand Down
Loading