Skip to content

Commit 38f7628

Browse files
authored
Merge branch 'Bitmessage:v0.6' into test_refactor_sqlthread
2 parents a13a37d + 991e470 commit 38f7628

27 files changed

+263
-137
lines changed

.buildbot/android/Dockerfile

Lines changed: 102 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -1,78 +1,117 @@
1+
12
# A container for buildbot
23
FROM ubuntu:bionic AS android
34
# FROM ubuntu:20.04 AS buildbot-bionic
45

5-
RUN apt -y update -qq
6-
RUN apt -y install wget
7-
8-
RUN wget -nc "https://dl.google.com/android/repository/sdk-tools-linux-4333796.zip"
9-
RUN wget -nc "https://dl.google.com/android/repository/android-ndk-r23b-linux.zip"
10-
RUN wget -nc "http://archive.apache.org/dist/ant/binaries/apache-ant-1.10.12-bin.tar.gz"
11-
12-
# SYSTEM DEPENDENCIES
13-
14-
RUN apt -y install --no-install-recommends python3-pip \
15-
pip3 python3 virtualenv python3-setuptools \
16-
python3-wheel git unzip sudo patch bzip2 lzma
17-
RUN apt -y autoremove
18-
19-
# BUILD DEPENDENCIES
6+
ENV ANDROID_HOME="/opt/android"
207

21-
RUN dpkg --add-architecture i386
22-
RUN apt -y update -qq
23-
RUN apt -y install -qq --no-install-recommends build-essential \
24-
ccache git python3 python3-dev libncurses5:i386 libstdc++6:i386 \
25-
libgtk2.0-0:i386 libpangox-1.0-0:i386 libpangoxft-1.0-0:i386 \
26-
libidn11:i386 zip zlib1g-dev zlib1g:i386
27-
RUN apt -y autoremove
28-
RUN apt -y clean
8+
RUN apt -y update -qq \
9+
&& apt -y install -qq --no-install-recommends curl unzip ca-certificates \
10+
&& apt -y autoremove
2911

30-
# RECIPES DEPENDENCIES
3112

32-
RUN dpkg --add-architecture i386
33-
RUN apt -y update -qq
34-
RUN apt -y install -qq --no-install-recommends libffi-dev autoconf \
35-
automake cmake gettext libltdl-dev libtool pkg-config
36-
RUN apt -y autoremove
37-
RUN apt -y clean
38-
39-
# INSTALL ANDROID PACKAGES
40-
41-
RUN pip3 install buildozer==1.2.0
42-
RUN pip3 install --upgrade cython==0.29.15
43-
44-
# INSTALL NDK
13+
ENV ANDROID_NDK_HOME="${ANDROID_HOME}/android-ndk"
14+
ENV ANDROID_NDK_VERSION="22b"
15+
ENV ANDROID_NDK_HOME_V="${ANDROID_NDK_HOME}-r${ANDROID_NDK_VERSION}"
4516

4617
# get the latest version from https://developer.android.com/ndk/downloads/index.html
47-
RUN mkdir --parents "/opt/android/android-ndk-r23b"
48-
RUN unzip -q "android-ndk-r23b-linux.zip" -d "/opt/android"
49-
RUN ln -sfn "/opt/android/android-ndk-r23b" "/opt/android/android-ndk"
50-
RUN rm -rf "android-ndk-r23b-linux.zip"
51-
52-
# INSTALL APACHE-ANT
18+
ENV ANDROID_NDK_ARCHIVE="android-ndk-r${ANDROID_NDK_VERSION}-linux-x86_64.zip"
19+
ENV ANDROID_NDK_DL_URL="https://dl.google.com/android/repository/${ANDROID_NDK_ARCHIVE}"
5320

54-
RUN tar -xf "apache-ant-1.10.12-bin.tar.gz" -C "/opt/android"
55-
RUN ln -sfn "/opt/android/apache-ant-1.10.12" "/opt/android/apache-ant"
56-
RUN rm -rf "apache-ant-1.10.12-bin.tar.gz"
21+
# download and install Android NDK
22+
RUN curl "${ANDROID_NDK_DL_URL}" \
23+
--output "${ANDROID_NDK_ARCHIVE}" \
24+
&& mkdir --parents "${ANDROID_NDK_HOME_V}" \
25+
&& unzip -q "${ANDROID_NDK_ARCHIVE}" -d "${ANDROID_HOME}" \
26+
&& ln -sfn "${ANDROID_NDK_HOME_V}" "${ANDROID_NDK_HOME}" \
27+
&& rm -rf "${ANDROID_NDK_ARCHIVE}"
5728

58-
# INSTALL SDK
29+
ENV ANDROID_SDK_HOME="${ANDROID_HOME}/android-sdk"
5930

6031
# get the latest version from https://developer.android.com/studio/index.html
61-
RUN mkdir --parents "/opt/android/android-sdk"
62-
RUN unzip -q "sdk-tools-linux-4333796.zip" -d "/opt/android/android-sdk"
63-
RUN rm -rf "sdk-tools-linux-4333796.zip"
64-
# update Android SDK, install Android API, Build Tools...
65-
RUN mkdir --parents "/opt/android/android-sdk/.android/"
32+
ENV ANDROID_SDK_TOOLS_VERSION="8092744"
33+
ENV ANDROID_SDK_BUILD_TOOLS_VERSION="30.0.3"
34+
ENV ANDROID_SDK_TOOLS_ARCHIVE="commandlinetools-linux-${ANDROID_SDK_TOOLS_VERSION}_latest.zip"
35+
ENV ANDROID_SDK_TOOLS_DL_URL="https://dl.google.com/android/repository/${ANDROID_SDK_TOOLS_ARCHIVE}"
36+
ENV ANDROID_SDK_MANAGER="${ANDROID_SDK_HOME}/tools/bin/sdkmanager --sdk_root=${ANDROID_SDK_HOME}"
37+
38+
# download and install Android SDK
39+
RUN curl "${ANDROID_SDK_TOOLS_DL_URL}" \
40+
--output "${ANDROID_SDK_TOOLS_ARCHIVE}" \
41+
&& mkdir --parents "${ANDROID_SDK_HOME}" \
42+
&& unzip -q "${ANDROID_SDK_TOOLS_ARCHIVE}" -d "${ANDROID_SDK_HOME}" \
43+
&& mv "${ANDROID_SDK_HOME}/cmdline-tools" "${ANDROID_SDK_HOME}/tools" \
44+
&& rm -rf "${ANDROID_SDK_TOOLS_ARCHIVE}"
45+
46+
# update Android SDK, install Android API, Build Tools...
47+
RUN mkdir --parents "${ANDROID_SDK_HOME}/.android/" \
48+
&& echo '### User Sources for Android SDK Manager' \
49+
> "${ANDROID_SDK_HOME}/.android/repositories.cfg"
50+
6651
# accept Android licenses (JDK necessary!)
67-
RUN apt -y update -qq
68-
RUN apt -y install -qq --no-install-recommends openjdk-11-jdk
69-
RUN apt -y autoremove
70-
RUN yes | "/opt/android/android-sdk/tools/bin/sdkmanager" "build-tools;29.0.2" > /dev/null
52+
RUN apt -y update -qq \
53+
&& apt -y install -qq --no-install-recommends \
54+
openjdk-11-jdk-headless \
55+
&& apt -y autoremove
56+
RUN yes | ${ANDROID_SDK_MANAGER} --licenses > /dev/null
57+
7158
# download platforms, API, build tools
72-
RUN "/opt/android/android-sdk/tools/bin/sdkmanager" "platforms;android-24" > /dev/null
73-
RUN "/opt/android/android-sdk/tools/bin/sdkmanager" "platforms;android-28" > /dev/null
74-
RUN "/opt/android/android-sdk/tools/bin/sdkmanager" "build-tools;29.0.2" > /dev/null
75-
RUN "/opt/android/android-sdk/tools/bin/sdkmanager" "extras;android;m2repository" > /dev/null
76-
RUN find /opt/android/android-sdk -type f -perm /0111 -print0|xargs -0 chmod a+x
77-
RUN chown -R buildbot.buildbot /opt/android/android-sdk
78-
RUN chmod +x "/opt/android/android-sdk/tools/bin/avdmanager"
59+
RUN ${ANDROID_SDK_MANAGER} "platforms;android-30" > /dev/null && \
60+
${ANDROID_SDK_MANAGER} "build-tools;${ANDROID_SDK_BUILD_TOOLS_VERSION}" > /dev/null && \
61+
${ANDROID_SDK_MANAGER} "extras;android;m2repository" > /dev/null && \
62+
chmod +x "${ANDROID_SDK_HOME}/tools/bin/avdmanager"
63+
64+
# download ANT
65+
ENV APACHE_ANT_VERSION="1.9.4"
66+
ENV APACHE_ANT_ARCHIVE="apache-ant-${APACHE_ANT_VERSION}-bin.tar.gz"
67+
ENV APACHE_ANT_DL_URL="https://archive.apache.org/dist/ant/binaries/${APACHE_ANT_ARCHIVE}"
68+
ENV APACHE_ANT_HOME="${ANDROID_HOME}/apache-ant"
69+
ENV APACHE_ANT_HOME_V="${APACHE_ANT_HOME}-${APACHE_ANT_VERSION}"
70+
71+
RUN curl "${APACHE_ANT_DL_URL}" \
72+
--output "${APACHE_ANT_ARCHIVE}" \
73+
&& tar -xf "${APACHE_ANT_ARCHIVE}" -C "${ANDROID_HOME}" \
74+
&& ln -sfn "${APACHE_ANT_HOME_V}" "${APACHE_ANT_HOME}" \
75+
&& rm -rf "${APACHE_ANT_ARCHIVE}"
76+
77+
# install system/build dependencies
78+
RUN apt -y update -qq \
79+
&& apt -y install -qq --no-install-recommends \
80+
python3 \
81+
python3-dev \
82+
python3-pip \
83+
python3-setuptools \
84+
python3-venv \
85+
wget \
86+
lbzip2 \
87+
bzip2 \
88+
lzma \
89+
patch \
90+
sudo \
91+
software-properties-common \
92+
git \
93+
zip \
94+
unzip \
95+
build-essential \
96+
ccache \
97+
autoconf \
98+
libtool \
99+
pkg-config \
100+
zlib1g-dev \
101+
libncurses5-dev \
102+
libncursesw5-dev \
103+
libtinfo5 \
104+
cmake \
105+
libffi-dev \
106+
libssl-dev \
107+
automake \
108+
gettext \
109+
libltdl-dev \
110+
libidn11 \
111+
&& apt -y autoremove \
112+
&& apt -y clean
113+
114+
# INSTALL ANDROID PACKAGES
115+
116+
RUN pip3 install buildozer==1.2.0
117+
RUN pip3 install --upgrade cython==0.29.15

.buildbot/kivy/Dockerfile

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,25 @@
22
FROM ubuntu:bionic AS kivy
33
# FROM ubuntu:20.04 AS buildbot-bionic
44

5+
ENV DEBIAN_FRONTEND=noninteractive
6+
57
RUN apt-get update
68

79
RUN apt-get -y install sudo
810

911
RUN apt-get install -yq python-setuptools \
1012
python-setuptools libssl-dev libpq-dev python-prctl python-dev \
11-
python-dev python-virtualenv python-pip virtualenv \
12-
libssl-dev \
13-
python-dev \
13+
python-virtualenv python-pip virtualenv \
14+
libjpeg-dev zlib1g-dev python3-dev \
1415
python3-virtualenv \
1516
python3-pip \
16-
wget
17+
wget \
18+
build-essential libcap-dev libmtdev-dev xvfb xclip git python3-opencv
19+
20+
RUN ln -sf /usr/bin/python3 /usr/bin/python
21+
22+
RUN pip3 install Cython Pillow pyzbar telenium
1723

18-
RUN wget -O /usr/local/bin/travis2bash.sh https://git.bitmessage.org/Bitmessage/buildbot-scripts/raw/branch/master/travis2bash.sh
24+
RUN pip3 install --upgrade setuptools pip
1925

20-
RUN chmod a+rx "/usr/local/bin/travis2bash.sh"
26+
RUN pip3 install -e git+https://github.com/kivymd/KivyMD#egg=kivymd

.buildbot/kivy/build.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/bin/sh
2+
3+
python setup.py install --user

.buildbot/kivy/test.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
#!/bin/bash
22

3-
travis2bash.sh .travis-kivy.yml
3+
xvfb-run python tests-kivy.py

.buildbot/tox/Dockerfile

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
FROM ubuntu:bionic AS tox
2+
3+
RUN apt-get update
4+
5+
# Common apt packages
6+
RUN apt-get install -yq --no-install-suggests --no-install-recommends \
7+
software-properties-common build-essential libcap-dev libssl-dev \
8+
python-all-dev python-setuptools wget xvfb language-pack-en \
9+
libffi-dev python3-dev python3-pip python3.8 python3.8-dev python3.8-venv \
10+
python-msgpack python-pip python-qt4 python-six qtbase5-dev qt5-default \
11+
tor
12+
13+
RUN python3.8 -m pip install setuptools wheel
14+
RUN python3.8 -m pip install --upgrade pip tox virtualenv
15+
16+
ENV LANG en_US.UTF-8
17+
ENV LANGUAGE en_US:en
18+
ENV LC_ALL en_US.UTF-8

.buildbot/tox/test.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/bin/sh
2+
3+
tox -e lint-basic # || exit 1
4+
tox

Dockerfile

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# A container for PyBitmessage daemon
22

3-
FROM ubuntu:xenial
3+
FROM ubuntu:bionic
44

55
RUN apt-get update
66

@@ -9,35 +9,29 @@ RUN apt-get install -yq --no-install-suggests --no-install-recommends \
99
build-essential libcap-dev libssl-dev \
1010
python-all-dev python-msgpack python-pip python-setuptools
1111

12-
RUN pip2 install --upgrade pip
13-
1412
EXPOSE 8444 8442
1513

1614
ENV HOME /home/bitmessage
1715
ENV BITMESSAGE_HOME ${HOME}
1816

1917
WORKDIR ${HOME}
2018
ADD . ${HOME}
19+
COPY packages/docker/launcher.sh /usr/bin/
2120

22-
# Install tests dependencies
23-
RUN pip2 install -r requirements.txt
2421
# Install
25-
RUN python2 setup.py install
22+
RUN pip2 install jsonrpclib .
23+
24+
# Cleanup
25+
RUN rm -rf /var/lib/apt/lists/*
26+
RUN rm -rf ${HOME}
2627

2728
# Create a user
28-
RUN useradd bitmessage && chown -R bitmessage ${HOME}
29+
RUN useradd -r bitmessage && chown -R bitmessage ${HOME}
2930

3031
USER bitmessage
3132

32-
# Clean HOME
33-
RUN rm -rf ${HOME}/*
34-
3533
# Generate default config
3634
RUN pybitmessage -t
3735

38-
# Setup environment
39-
RUN APIPASS=$(tr -dc a-zA-Z0-9 < /dev/urandom | head -c32 && echo) \
40-
&& echo "\napiusername: api\napipassword: $APIPASS" \
41-
&& echo "apienabled = true\napiinterface = 0.0.0.0\napiusername = api\napipassword = $APIPASS" >> keys.dat
42-
43-
CMD ["pybitmessage", "-d"]
36+
ENTRYPOINT ["launcher.sh"]
37+
CMD ["-d"]

MANIFEST.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@ include COPYING
22
include README.md
33
include requirements.txt
44
recursive-include desktop *
5+
recursive-include packages/apparmor *

packages/docker/launcher.sh

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#!/bin/sh
2+
3+
# Setup the environment for docker container
4+
APIUSER=${USER:-api}
5+
APIPASS=${PASSWORD:-$(tr -dc a-zA-Z0-9 < /dev/urandom | head -c32 && echo)}
6+
7+
echo "\napiusername: $APIUSER\napipassword: $APIPASS"
8+
9+
sed -i -e "s|\(apiinterface = \).*|\10\.0\.0\.0|g" \
10+
-e "s|\(apivariant = \).*|\1json|g" \
11+
-e "s|\(apiusername = \).*|\1$APIUSER|g" \
12+
-e "s|\(apipassword = \).*|\1$APIPASS|g" \
13+
-e "s|apinotifypath = .*||g" ${BITMESSAGE_HOME}/keys.dat
14+
15+
# Run
16+
exec pybitmessage "$@"

setup.cfg

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ max-line-length = 119
88

99
[flake8]
1010
max-line-length = 119
11+
exclude = bitmessagecli.py,bitmessagecurses,bitmessageqt,plugins,tests,umsgpack
1112
ignore = E722,F841,W503
1213
# E722: pylint is preferred for bare-except
1314
# F841: pylint is preferred for unused-variable

src/api.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,9 @@
6262
import hashlib
6363
import httplib
6464
import json
65-
import random # nosec
65+
import random
6666
import socket
67-
import subprocess
67+
import subprocess # nosec B404
6868
import time
6969
import xmlrpclib
7070
from binascii import hexlify, unhexlify
@@ -240,7 +240,7 @@ def serve_forever(self, poll_interval=None):
240240
if attempt > 0:
241241
logger.warning(
242242
'Failed to start API listener on port %s', port)
243-
port = random.randint(32767, 65535)
243+
port = random.randint(32767, 65535) # nosec B311
244244
se = StoppableRPCServer(
245245
(config.get(
246246
'bitmessagesettings', 'apiinterface'),
@@ -266,7 +266,7 @@ def serve_forever(self, poll_interval=None):
266266
if apiNotifyPath:
267267
logger.info('Trying to call %s', apiNotifyPath)
268268
try:
269-
subprocess.call([apiNotifyPath, "startingUp"])
269+
subprocess.call([apiNotifyPath, "startingUp"]) # nosec B603
270270
except OSError:
271271
logger.warning(
272272
'Failed to call %s, removing apinotifypath setting',

src/bitmessagekivy/baseclass/__init__.py

Whitespace-only changes.

0 commit comments

Comments
 (0)