aboutsummaryrefslogtreecommitdiff
path: root/contrib
diff options
context:
space:
mode:
Diffstat (limited to 'contrib')
-rw-r--r--contrib/devtools/README.md15
-rwxr-xr-xcontrib/devtools/copyright_header.py10
-rwxr-xr-xcontrib/devtools/gen-bitcoin-conf.sh83
-rw-r--r--contrib/devtools/iwyu/bitcoin.core.imp6
-rwxr-xr-xcontrib/guix/guix-build2
-rwxr-xr-xcontrib/guix/libexec/build.sh4
-rwxr-xr-xcontrib/linearize/linearize-data.py37
-rwxr-xr-xcontrib/linearize/linearize-hashes.py25
-rw-r--r--contrib/macdeploy/README.md2
-rwxr-xr-xcontrib/macdeploy/gen-sdk2
-rwxr-xr-xcontrib/verify-commits/verify-commits.py15
11 files changed, 155 insertions, 46 deletions
diff --git a/contrib/devtools/README.md b/contrib/devtools/README.md
index 79b0134adc..54b1a85588 100644
--- a/contrib/devtools/README.md
+++ b/contrib/devtools/README.md
@@ -90,6 +90,21 @@ example:
BUILDDIR=$PWD/build contrib/devtools/gen-manpages.py
```
+gen-bitcoin-conf.sh
+===================
+
+Generates a bitcoin.conf file in `share/examples/` by parsing the output from `bitcoind --help`. This script is run during the
+release process to include a bitcoin.conf with the release binaries and can also be run by users to generate a file locally.
+When generating a file as part of the release process, make sure to commit the changes after running the script.
+
+With in-tree builds this tool can be run from any directory within the
+repository. To use this tool with out-of-tree builds set `BUILDDIR`. For
+example:
+
+```bash
+BUILDDIR=$PWD/build contrib/devtools/gen-bitcoin-conf.sh
+```
+
security-check.py and test-security-check.py
============================================
diff --git a/contrib/devtools/copyright_header.py b/contrib/devtools/copyright_header.py
index 38f3df77c9..e20eb4b0d2 100755
--- a/contrib/devtools/copyright_header.py
+++ b/contrib/devtools/copyright_header.py
@@ -320,15 +320,13 @@ def get_most_recent_git_change_year(filename):
################################################################################
def read_file_lines(filename):
- f = open(filename, 'r', encoding="utf8")
- file_lines = f.readlines()
- f.close()
+ with open(filename, 'r', encoding="utf8") as f:
+ file_lines = f.readlines()
return file_lines
def write_file_lines(filename, file_lines):
- f = open(filename, 'w', encoding="utf8")
- f.write(''.join(file_lines))
- f.close()
+ with open(filename, 'w', encoding="utf8") as f:
+ f.write(''.join(file_lines))
################################################################################
# update header years execution
diff --git a/contrib/devtools/gen-bitcoin-conf.sh b/contrib/devtools/gen-bitcoin-conf.sh
new file mode 100755
index 0000000000..2ebbd42022
--- /dev/null
+++ b/contrib/devtools/gen-bitcoin-conf.sh
@@ -0,0 +1,83 @@
+#!/usr/bin/env bash
+# Copyright (c) 2021 The Bitcoin Core developers
+# Distributed under the MIT software license, see the accompanying
+# file COPYING or http://www.opensource.org/licenses/mit-license.php.
+
+export LC_ALL=C
+TOPDIR=${TOPDIR:-$(git rev-parse --show-toplevel)}
+BUILDDIR=${BUILDDIR:-$TOPDIR}
+BINDIR=${BINDIR:-$BUILDDIR/src}
+BITCOIND=${BITCOIND:-$BINDIR/bitcoind}
+SHARE_EXAMPLES_DIR=${SHARE_EXAMPLES_DIR:-$TOPDIR/share/examples}
+EXAMPLE_CONF_FILE=${EXAMPLE_CONF_FILE:-$SHARE_EXAMPLES_DIR/bitcoin.conf}
+
+[ ! -x "$BITCOIND" ] && echo "$BITCOIND not found or not executable." && exit 1
+
+DIRTY=""
+VERSION_OUTPUT=$($BITCOIND --version)
+if [[ $VERSION_OUTPUT == *"dirty"* ]]; then
+ DIRTY="${DIRTY}${BITCOIND}\n"
+fi
+
+if [ -n "$DIRTY" ]
+then
+ echo -e "WARNING: $BITCOIND was built from a dirty tree.\n"
+ echo -e "To safely generate a bitcoin.conf file, please commit your changes to $BITCOIND, rebuild, then run this script again.\n"
+fi
+
+echo 'Generating example bitcoin.conf file in share/examples/'
+
+# create the directory, if it doesn't exist
+mkdir -p "${SHARE_EXAMPLES_DIR}"
+
+# create the header text
+cat > "${EXAMPLE_CONF_FILE}" << 'EOF'
+##
+## bitcoin.conf configuration file.
+## Generated by contrib/devtools/gen-bitcoin-conf.sh.
+##
+## Lines beginning with # are comments.
+## All possible configuration options are provided. To use, copy this file
+## to your data directory (default or specified by -datadir), uncomment
+## options you would like to change, and save the file.
+##
+
+
+### Options
+EOF
+
+# parse the output from bitcoind --help
+# adding newlines is a bit funky to ensure portability for BSD
+# see here for more details: https://stackoverflow.com/a/24575385
+${BITCOIND} --help \
+ | sed '1,/Print this help message and exit/d' \
+ | sed -E 's/^[[:space:]]{2}\-/#/' \
+ | sed -E 's/^[[:space:]]{7}/# /' \
+ | sed -E '/[=[:space:]]/!s/#.*$/&=1/' \
+ | awk '/^#[a-z]/{x=$0;next}{if (NF==0) print x"\n",x="";else print}' \
+ | sed 's,\(^[[:upper:]].*\)\:$,\
+### \1,' \
+ | sed 's/[[:space:]]*$//' >> "${EXAMPLE_CONF_FILE}"
+
+# create the footer text
+cat >> "${EXAMPLE_CONF_FILE}" << 'EOF'
+
+# [Sections]
+# Most options will apply to all networks. To confine an option to a specific
+# network, add it under the relevant section below.
+#
+# Note: If not specified under a network section, the options addnode, connect,
+# port, bind, rpcport, rpcbind, and wallet will only apply to mainnet.
+
+# Options for mainnet
+[main]
+
+# Options for testnet
+[test]
+
+# Options for signet
+[signet]
+
+# Options for regtest
+[regtest]
+EOF
diff --git a/contrib/devtools/iwyu/bitcoin.core.imp b/contrib/devtools/iwyu/bitcoin.core.imp
new file mode 100644
index 0000000000..ce7786f58c
--- /dev/null
+++ b/contrib/devtools/iwyu/bitcoin.core.imp
@@ -0,0 +1,6 @@
+# Fixups / upstreamed changes
+[
+ { include: [ "<bits/termios-c_lflag.h>", private, "<termios.h>", public ] },
+ { include: [ "<bits/termios-struct.h>", private, "<termios.h>", public ] },
+ { include: [ "<bits/termios-tcflow.h>", private, "<termios.h>", public ] },
+]
diff --git a/contrib/guix/guix-build b/contrib/guix/guix-build
index c8f2e40f0a..74b24b9612 100755
--- a/contrib/guix/guix-build
+++ b/contrib/guix/guix-build
@@ -132,7 +132,7 @@ for host in $HOSTS; do
echo "Found macOS SDK at '${OSX_SDK}', using..."
break
else
- echo "macOS SDK does not exist at '${OSX_SDK}', please place the extracted, untarred SDK there to perform darwin builds, exiting..."
+ echo "macOS SDK does not exist at '${OSX_SDK}', please place the extracted, untarred SDK there to perform darwin builds, or define SDK_PATH environment variable. Exiting..."
exit 1
fi
;;
diff --git a/contrib/guix/libexec/build.sh b/contrib/guix/libexec/build.sh
index 2757d10a7c..cdf0020d4d 100755
--- a/contrib/guix/libexec/build.sh
+++ b/contrib/guix/libexec/build.sh
@@ -368,6 +368,10 @@ mkdir -p "$DISTSRC"
;;
esac
+ # copy over the example bitcoin.conf file. if contrib/devtools/gen-bitcoin-conf.sh
+ # has not been run before buildling, this file will be a stub
+ cp "${DISTSRC}/share/examples/bitcoin.conf" "${DISTNAME}/"
+
# Finally, deterministically produce {non-,}debug binary tarballs ready
# for release
case "$HOST" in
diff --git a/contrib/linearize/linearize-data.py b/contrib/linearize/linearize-data.py
index 7510204bb1..b72c7b0d08 100755
--- a/contrib/linearize/linearize-data.py
+++ b/contrib/linearize/linearize-data.py
@@ -34,12 +34,12 @@ def get_blk_dt(blk_hdr):
# When getting the list of block hashes, undo any byte reversals.
def get_block_hashes(settings):
blkindex = []
- f = open(settings['hashlist'], "r", encoding="utf8")
- for line in f:
- line = line.rstrip()
- if settings['rev_hash_bytes'] == 'true':
- line = bytes.fromhex(line)[::-1].hex()
- blkindex.append(line)
+ with open(settings['hashlist'], "r", encoding="utf8") as f:
+ for line in f:
+ line = line.rstrip()
+ if settings['rev_hash_bytes'] == 'true':
+ line = bytes.fromhex(line)[::-1].hex()
+ blkindex.append(line)
print("Read " + str(len(blkindex)) + " hashes")
@@ -249,19 +249,18 @@ if __name__ == '__main__':
print("Usage: linearize-data.py CONFIG-FILE")
sys.exit(1)
- f = open(sys.argv[1], encoding="utf8")
- for line in f:
- # skip comment lines
- m = re.search(r'^\s*#', line)
- if m:
- continue
-
- # parse key=value lines
- m = re.search(r'^(\w+)\s*=\s*(\S.*)$', line)
- if m is None:
- continue
- settings[m.group(1)] = m.group(2)
- f.close()
+ with open(sys.argv[1], encoding="utf8") as f:
+ for line in f:
+ # skip comment lines
+ m = re.search(r'^\s*#', line)
+ if m:
+ continue
+
+ # parse key=value lines
+ m = re.search(r'^(\w+)\s*=\s*(\S.*)$', line)
+ if m is None:
+ continue
+ settings[m.group(1)] = m.group(2)
# Force hash byte format setting to be lowercase to make comparisons easier.
# Also place upfront in case any settings need to know about it.
diff --git a/contrib/linearize/linearize-hashes.py b/contrib/linearize/linearize-hashes.py
index 0a316eb818..5959300e74 100755
--- a/contrib/linearize/linearize-hashes.py
+++ b/contrib/linearize/linearize-hashes.py
@@ -98,19 +98,18 @@ if __name__ == '__main__':
print("Usage: linearize-hashes.py CONFIG-FILE")
sys.exit(1)
- f = open(sys.argv[1], encoding="utf8")
- for line in f:
- # skip comment lines
- m = re.search(r'^\s*#', line)
- if m:
- continue
-
- # parse key=value lines
- m = re.search(r'^(\w+)\s*=\s*(\S.*)$', line)
- if m is None:
- continue
- settings[m.group(1)] = m.group(2)
- f.close()
+ with open(sys.argv[1], encoding="utf8") as f:
+ for line in f:
+ # skip comment lines
+ m = re.search(r'^\s*#', line)
+ if m:
+ continue
+
+ # parse key=value lines
+ m = re.search(r'^(\w+)\s*=\s*(\S.*)$', line)
+ if m is None:
+ continue
+ settings[m.group(1)] = m.group(2)
if 'host' not in settings:
settings['host'] = '127.0.0.1'
diff --git a/contrib/macdeploy/README.md b/contrib/macdeploy/README.md
index fa7d953ce3..64e36f22b9 100644
--- a/contrib/macdeploy/README.md
+++ b/contrib/macdeploy/README.md
@@ -58,7 +58,7 @@ previous stage) as the first argument.
./contrib/macdeploy/gen-sdk '/path/to/Xcode.app'
```
-The `sha256sum` of the generated TAR.GZ archive should be `e7ca56bc8804d16624fad68be2e71647747d6629cacaaa3de5fbfa7f444e9eae`.
+The `sha256sum` of the generated TAR.GZ archive should be `df75d30ecafc429e905134333aeae56ac65fac67cb4182622398fd717df77619`.
## Deterministic macOS DMG Notes
diff --git a/contrib/macdeploy/gen-sdk b/contrib/macdeploy/gen-sdk
index d70cc8613c..6efaaccb8e 100755
--- a/contrib/macdeploy/gen-sdk
+++ b/contrib/macdeploy/gen-sdk
@@ -95,7 +95,7 @@ def run():
tarinfo.uid, tarinfo.uname = 0, ''
tarinfo.gid, tarinfo.gname = 0, ''
# don't use isdir() as there are also executable files present
- tarinfo.mode = 0o0755 if tarinfo.mode & 0o0100 else 0x0644
+ tarinfo.mode = 0o0755 if tarinfo.mode & 0o0100 else 0o0644
return tarinfo
with cd(dir_to_add):
# recursion already adds entries in sorted order
diff --git a/contrib/verify-commits/verify-commits.py b/contrib/verify-commits/verify-commits.py
index 7e46c6fd47..0a3346140f 100755
--- a/contrib/verify-commits/verify-commits.py
+++ b/contrib/verify-commits/verify-commits.py
@@ -82,11 +82,16 @@ def main():
# get directory of this program and read data files
dirname = os.path.dirname(os.path.abspath(__file__))
print("Using verify-commits data from " + dirname)
- verified_root = open(dirname + "/trusted-git-root", "r", encoding="utf8").read().splitlines()[0]
- verified_sha512_root = open(dirname + "/trusted-sha512-root-commit", "r", encoding="utf8").read().splitlines()[0]
- revsig_allowed = open(dirname + "/allow-revsig-commits", "r", encoding="utf-8").read().splitlines()
- unclean_merge_allowed = open(dirname + "/allow-unclean-merge-commits", "r", encoding="utf-8").read().splitlines()
- incorrect_sha512_allowed = open(dirname + "/allow-incorrect-sha512-commits", "r", encoding="utf-8").read().splitlines()
+ with open(dirname + "/trusted-git-root", "r", encoding="utf8") as f:
+ verified_root = f.read().splitlines()[0]
+ with open(dirname + "/trusted-sha512-root-commit", "r", encoding="utf8") as f:
+ verified_sha512_root = f.read().splitlines()[0]
+ with open(dirname + "/allow-revsig-commits", "r", encoding="utf8") as f:
+ revsig_allowed = f.read().splitlines()
+ with open(dirname + "/allow-unclean-merge-commit", "r", encoding="utf8") as f:
+ unclean_merge_allowed = f.read().splitlines()
+ with open(dirname + "/allow-incorrect-sha512-commits", "r", encoding="utf8") as f:
+ incorrect_sha512_allowed = f.read().splitlines()
# Set commit and branch and set variables
current_commit = args.commit