aboutsummaryrefslogtreecommitdiff
path: root/contrib/devtools
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/devtools')
-rwxr-xr-xcontrib/devtools/clang-format-diff.py2
-rwxr-xr-xcontrib/devtools/copyright_header.py32
-rwxr-xr-xcontrib/devtools/github-merge.py6
-rwxr-xr-xcontrib/devtools/optimize-pngs.py4
-rwxr-xr-xcontrib/devtools/security-check.py2
-rwxr-xr-xcontrib/devtools/symbol-check.py48
-rwxr-xr-xcontrib/devtools/update-translations.py2
7 files changed, 53 insertions, 43 deletions
diff --git a/contrib/devtools/clang-format-diff.py b/contrib/devtools/clang-format-diff.py
index 77e845a9b4..f322b3a880 100755
--- a/contrib/devtools/clang-format-diff.py
+++ b/contrib/devtools/clang-format-diff.py
@@ -109,7 +109,7 @@ def main():
match = re.search('^\+\+\+\ (.*?/){%s}(\S*)' % args.p, line)
if match:
filename = match.group(2)
- if filename == None:
+ if filename is None:
continue
if args.regex is not None:
diff --git a/contrib/devtools/copyright_header.py b/contrib/devtools/copyright_header.py
index c5fcddea04..6d7a592f01 100755
--- a/contrib/devtools/copyright_header.py
+++ b/contrib/devtools/copyright_header.py
@@ -15,35 +15,32 @@ import os
################################################################################
EXCLUDE = [
- # libsecp256k1:
- 'src/secp256k1/include/secp256k1.h',
- 'src/secp256k1/include/secp256k1_ecdh.h',
- 'src/secp256k1/include/secp256k1_recovery.h',
- 'src/secp256k1/include/secp256k1_schnorr.h',
- 'src/secp256k1/src/java/org_bitcoin_NativeSecp256k1.c',
- 'src/secp256k1/src/java/org_bitcoin_NativeSecp256k1.h',
- 'src/secp256k1/src/java/org_bitcoin_Secp256k1Context.c',
- 'src/secp256k1/src/java/org_bitcoin_Secp256k1Context.h',
- # univalue:
- 'src/univalue/test/object.cpp',
- 'src/univalue/lib/univalue_escapes.h',
# auto generated:
'src/qt/bitcoinstrings.cpp',
'src/chainparamsseeds.h',
# other external copyrights:
'src/tinyformat.h',
- 'src/leveldb/util/env_win.cc',
- 'src/crypto/ctaes/bench.c',
'test/functional/test_framework/bignum.py',
# python init:
'*__init__.py',
]
EXCLUDE_COMPILED = re.compile('|'.join([fnmatch.translate(m) for m in EXCLUDE]))
+EXCLUDE_DIRS = [
+ # git subtrees
+ "src/crypto/ctaes/",
+ "src/leveldb/",
+ "src/secp256k1/",
+ "src/univalue/",
+]
+
INCLUDE = ['*.h', '*.cpp', '*.cc', '*.c', '*.py']
INCLUDE_COMPILED = re.compile('|'.join([fnmatch.translate(m) for m in INCLUDE]))
def applies_to_file(filename):
+ for excluded_dir in EXCLUDE_DIRS:
+ if filename.startswith(excluded_dir):
+ return False
return ((EXCLUDE_COMPILED.match(filename) is None) and
(INCLUDE_COMPILED.match(filename) is not None))
@@ -81,7 +78,7 @@ ANY_COPYRIGHT_STYLE_OR_YEAR_STYLE = ("%s %s" % (ANY_COPYRIGHT_STYLE,
ANY_COPYRIGHT_COMPILED = re.compile(ANY_COPYRIGHT_STYLE_OR_YEAR_STYLE)
def compile_copyright_regex(copyright_style, year_style, name):
- return re.compile('%s %s %s' % (copyright_style, year_style, name))
+ return re.compile('%s %s,? %s' % (copyright_style, year_style, name))
EXPECTED_HOLDER_NAMES = [
"Satoshi Nakamoto\n",
@@ -107,6 +104,9 @@ EXPECTED_HOLDER_NAMES = [
"Jan-Klaas Kollhof\n",
"Sam Rushing\n",
"ArtForz -- public domain half-a-node\n",
+ "Intel Corporation",
+ "The Zcash developers",
+ "Jeremy Rubin",
]
DOMINANT_STYLE_COMPILED = {}
@@ -491,7 +491,7 @@ def get_git_change_year_range(filename):
def file_already_has_core_copyright(file_lines):
index, _ = get_updatable_copyright_line(file_lines)
- return index != None
+ return index is not None
################################################################################
# insert header execution
diff --git a/contrib/devtools/github-merge.py b/contrib/devtools/github-merge.py
index 4e90f85f50..4f827401fb 100755
--- a/contrib/devtools/github-merge.py
+++ b/contrib/devtools/github-merge.py
@@ -14,7 +14,6 @@
# In case of a clean merge that is accepted by the user, the local branch with
# name $BRANCH is overwritten with the merged result, and optionally pushed.
-from __future__ import division,print_function,unicode_literals
import os
from sys import stdin,stdout,stderr
import argparse
@@ -23,10 +22,7 @@ import subprocess
import sys
import json
import codecs
-try:
- from urllib.request import Request,urlopen
-except:
- from urllib2 import Request,urlopen
+from urllib.request import Request, urlopen
# External tools (can be overridden using environment)
GIT = os.getenv('GIT','git')
diff --git a/contrib/devtools/optimize-pngs.py b/contrib/devtools/optimize-pngs.py
index 8b1f41f7e1..e9481dbbcf 100755
--- a/contrib/devtools/optimize-pngs.py
+++ b/contrib/devtools/optimize-pngs.py
@@ -27,7 +27,7 @@ def content_hash(filename):
pngcrush = 'pngcrush'
git = 'git'
folders = ["src/qt/res/movies", "src/qt/res/icons", "share/pixmaps"]
-basePath = subprocess.check_output([git, 'rev-parse', '--show-toplevel'], universal_newlines=True).rstrip('\n')
+basePath = subprocess.check_output([git, 'rev-parse', '--show-toplevel'], universal_newlines=True, encoding='utf8').rstrip('\n')
totalSaveBytes = 0
noHashChange = True
@@ -50,7 +50,7 @@ for folder in folders:
sys.exit(0)
#verify
- if "Not a PNG file" in subprocess.check_output([pngcrush, "-n", "-v", file_path], stderr=subprocess.STDOUT, universal_newlines=True):
+ if "Not a PNG file" in subprocess.check_output([pngcrush, "-n", "-v", file_path], stderr=subprocess.STDOUT, universal_newlines=True, encoding='utf8'):
print("PNG file "+file+" is corrupted after crushing, check out pngcursh version")
sys.exit(1)
diff --git a/contrib/devtools/security-check.py b/contrib/devtools/security-check.py
index 57af1c1066..44b7f6c7cc 100755
--- a/contrib/devtools/security-check.py
+++ b/contrib/devtools/security-check.py
@@ -86,7 +86,7 @@ def check_ELF_RELRO(executable):
# This does not affect security: the permission flags of the GNU_RELRO program header are ignored, the PT_LOAD header determines the effective permissions.
# However, the dynamic linker need to write to this area so these are RW.
# Glibc itself takes care of mprotecting this area R after relocations are finished.
- # See also http://permalink.gmane.org/gmane.comp.gnu.binutils/71347
+ # See also https://marc.info/?l=binutils&m=1498883354122353
if typ == 'GNU_RELRO':
have_gnu_relro = True
diff --git a/contrib/devtools/symbol-check.py b/contrib/devtools/symbol-check.py
index 6808e77da7..c6158c9422 100755
--- a/contrib/devtools/symbol-check.py
+++ b/contrib/devtools/symbol-check.py
@@ -36,17 +36,18 @@ import os
# (glibc) GLIBC_2_11
#
MAX_VERSIONS = {
-'GCC': (4,4,0),
-'CXXABI': (1,3,3),
-'GLIBCXX': (3,4,13),
-'GLIBC': (2,11)
+'GCC': (4,4,0),
+'CXXABI': (1,3,3),
+'GLIBCXX': (3,4,13),
+'GLIBC': (2,11),
+'LIBATOMIC': (1,0)
}
# See here for a description of _IO_stdin_used:
# https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=634261#109
# Ignore symbols that are exported as part of every executable
IGNORE_EXPORTS = {
-'_edata', '_end', '_init', '__bss_start', '_fini', '_IO_stdin_used', 'stdin', 'stdout', 'stderr'
+'_edata', '_end', '__end__', '_init', '__bss_start', '__bss_start__', '_bss_end__', '__bss_end__', '_fini', '_IO_stdin_used', 'stdin', 'stdout', 'stderr'
}
READELF_CMD = os.getenv('READELF', '/usr/bin/readelf')
CPPFILT_CMD = os.getenv('CPPFILT', '/usr/bin/c++filt')
@@ -59,8 +60,12 @@ ALLOWED_LIBRARIES = {
'libanl.so.1', # DNS resolve
'libm.so.6', # math library
'librt.so.1', # real-time (clock)
+'libatomic.so.1',
'ld-linux-x86-64.so.2', # 64-bit dynamic linker
'ld-linux.so.2', # 32-bit dynamic linker
+'ld-linux-aarch64.so.1', # 64-bit ARM dynamic linker
+'ld-linux-armhf.so.3', # 32-bit ARM dynamic linker
+'ld-linux-riscv64-lp64d.so.1', # 64-bit RISC-V dynamic linker
# bitcoin-qt only
'libX11-xcb.so.1', # part of X11
'libX11.so.6', # part of X11
@@ -69,7 +74,13 @@ ALLOWED_LIBRARIES = {
'libfreetype.so.6', # font parsing
'libdl.so.2' # programming interface to dynamic linker
}
-
+ARCH_MIN_GLIBC_VER = {
+'80386': (2,1),
+'X86-64': (2,2,5),
+'ARM': (2,4),
+'AArch64':(2,17),
+'RISC-V': (2,27)
+}
class CPPFilt(object):
'''
Demangle C++ symbol names.
@@ -94,23 +105,25 @@ def read_symbols(executable, imports=True):
Parse an ELF executable and return a list of (symbol,version) tuples
for dynamic, imported symbols.
'''
- p = subprocess.Popen([READELF_CMD, '--dyn-syms', '-W', executable], stdout=subprocess.PIPE, stderr=subprocess.PIPE, stdin=subprocess.PIPE, universal_newlines=True)
+ p = subprocess.Popen([READELF_CMD, '--dyn-syms', '-W', '-h', executable], stdout=subprocess.PIPE, stderr=subprocess.PIPE, stdin=subprocess.PIPE, universal_newlines=True)
(stdout, stderr) = p.communicate()
if p.returncode:
raise IOError('Could not read symbols for %s: %s' % (executable, stderr.strip()))
syms = []
for line in stdout.splitlines():
line = line.split()
+ if 'Machine:' in line:
+ arch = line[-1]
if len(line)>7 and re.match('[0-9]+:$', line[0]):
(sym, _, version) = line[7].partition('@')
is_import = line[6] == 'UND'
if version.startswith('@'):
version = version[1:]
if is_import == imports:
- syms.append((sym, version))
+ syms.append((sym, version, arch))
return syms
-def check_version(max_versions, version):
+def check_version(max_versions, version, arch):
if '_' in version:
(lib, _, ver) = version.rpartition('_')
else:
@@ -119,7 +132,7 @@ def check_version(max_versions, version):
ver = tuple([int(x) for x in ver.split('.')])
if not lib in max_versions:
return False
- return ver <= max_versions[lib]
+ return ver <= max_versions[lib] or lib == 'GLIBC' and ver <= ARCH_MIN_GLIBC_VER[arch]
def read_libraries(filename):
p = subprocess.Popen([READELF_CMD, '-d', '-W', filename], stdout=subprocess.PIPE, stderr=subprocess.PIPE, stdin=subprocess.PIPE, universal_newlines=True)
@@ -142,16 +155,17 @@ if __name__ == '__main__':
retval = 0
for filename in sys.argv[1:]:
# Check imported symbols
- for sym,version in read_symbols(filename, True):
- if version and not check_version(MAX_VERSIONS, version):
+ for sym,version,arch in read_symbols(filename, True):
+ if version and not check_version(MAX_VERSIONS, version, arch):
print('%s: symbol %s from unsupported version %s' % (filename, cppfilt(sym), version))
retval = 1
# Check exported symbols
- for sym,version in read_symbols(filename, False):
- if sym in IGNORE_EXPORTS:
- continue
- print('%s: export of symbol %s not allowed' % (filename, cppfilt(sym)))
- retval = 1
+ if arch != 'RISC-V':
+ for sym,version,arch in read_symbols(filename, False):
+ if sym in IGNORE_EXPORTS:
+ continue
+ print('%s: export of symbol %s not allowed' % (filename, cppfilt(sym)))
+ retval = 1
# Check dependency libraries
for library_name in read_libraries(filename):
if library_name not in ALLOWED_LIBRARIES:
diff --git a/contrib/devtools/update-translations.py b/contrib/devtools/update-translations.py
index f0098cfcdf..1b9d3a4c27 100755
--- a/contrib/devtools/update-translations.py
+++ b/contrib/devtools/update-translations.py
@@ -125,7 +125,7 @@ def escape_cdata(text):
return text
def contains_bitcoin_addr(text, errors):
- if text != None and ADDRESS_REGEXP.search(text) != None:
+ if text is not None and ADDRESS_REGEXP.search(text) is not None:
errors.append('Translation "%s" contains a bitcoin address. This will be removed.' % (text))
return True
return False