Mail archive
alpine-devel

Re: [alpine-devel] [PATCH] testing/bitcoin: upgrade to 0.9.1

From: Natanael Copa <ncopa_at_alpinelinux.org>
Date: Thu, 8 May 2014 15:55:05 +0200

On Thu, 8 May 2014 10:04:49 +0000
Stuart Cardall <developer_at_it-offshore.co.uk> wrote:

> Sources changed to github & 2 previous patches no longer required.
>
> It now also builds the Qt front end with QR Code support.
>
> Includes a patch to fix a locale bug proposed upstream.
>
> Includes the init & post-install scripts from namecoin.
>
> Built successfuly on Musl & uclibc 32 bit (& so does namecoin)

Thanks!

I applied some of it. I also fixed util-linux's hexdump which was
broken and made the tests fail.

I'm waiting with the init.d script and post-install. The install
scripts must not be interactive (we cannot ask for anything from user)

-nc

> ---
> testing/bitcoin/11-ssize_t.patch | 10 ++++
> testing/bitcoin/20-set-default-env.patch | 38 ++++++++++++++
> testing/bitcoin/APKBUILD | 87 ++++++++++++++++++++++----------
> testing/bitcoin/bitcoin.conf | 10 ++++
> testing/bitcoin/bitcoin.confd | 13 +++++
> testing/bitcoin/bitcoin.initd | 33 ++++++++++++
> testing/bitcoin/bitcoin.post-install | 53 +++++++++++++++++++
> testing/bitcoin/boost-thread.patch | 11 ----
> testing/bitcoin/make.patch | 13 -----
> testing/bitcoin/ssize_t.patch | 12 -----
> 10 files changed, 216 insertions(+), 64 deletions(-)
> create mode 100644 testing/bitcoin/11-ssize_t.patch
> create mode 100644 testing/bitcoin/20-set-default-env.patch
> create mode 100644 testing/bitcoin/bitcoin.conf
> create mode 100644 testing/bitcoin/bitcoin.confd
> create mode 100644 testing/bitcoin/bitcoin.initd
> create mode 100644 testing/bitcoin/bitcoin.post-install
> delete mode 100644 testing/bitcoin/boost-thread.patch
> delete mode 100644 testing/bitcoin/make.patch
> delete mode 100644 testing/bitcoin/ssize_t.patch
>
> diff --git a/testing/bitcoin/11-ssize_t.patch b/testing/bitcoin/11-ssize_t.patch
> new file mode 100644
> index 0000000..4f99995
> --- /dev/null
> +++ b/testing/bitcoin/11-ssize_t.patch
> _at_@ -0,0 +1,10 @@
> +--- src/leveldb/db/db_iter.cc
> ++++ src.new/leveldb/db/db_iter.cc
> +_at_@ -2,6 +2,7 @@
> + // Use of this source code is governed by a BSD-style license that can be
> + // found in the LICENSE file. See the AUTHORS file for names of contributors.
> +
> ++#include <sys/types.h>
> + #include "db/db_iter.h"
> +
> + #include "db/filename.h"
> diff --git a/testing/bitcoin/20-set-default-env.patch b/testing/bitcoin/20-set-default-env.patch
> new file mode 100644
> index 0000000..290eecb
> --- /dev/null
> +++ b/testing/bitcoin/20-set-default-env.patch
> _at_@ -0,0 +1,38 @@
> +--- src/bitcoin-cli.cpp
> ++++ src.new/bitcoin-cli.cpp
> +_at_@ -53,6 +53,16 @@
> +
> + int main(int argc, char* argv[])
> + {
> ++ #ifndef WIN32
> ++ try
> ++ {
> ++ boost::filesystem::path::codecvt(); // Raises runtime error if current locale is invalid
> ++ } catch(std::runtime_error &e)
> ++ {
> ++ setenv("LC_ALL", "C", 1); // Force C locale
> ++ }
> ++ #endif
> ++
> + try
> + {
> + if(!AppInitRPC(argc, argv))
> +--- src/bitcoind.cpp
> ++++ src.new/bitcoind.cpp
> +_at_@ -166,6 +166,16 @@
> +
> + int main(int argc, char* argv[])
> + {
> ++ #ifndef WIN32
> ++ try
> ++ {
> ++ boost::filesystem::path::codecvt(); // Raises runtime error if current locale is invalid
> ++ } catch(std::runtime_error &e)
> ++ {
> ++ setenv("LC_ALL", "C", 1); // Force C locale
> ++ }
> ++ #endif
> ++
> + bool fRet = false;
> +
> + // Connect bitcoind signal handlers
> diff --git a/testing/bitcoin/APKBUILD b/testing/bitcoin/APKBUILD
> index cd95737..8c84cb1 100644
> --- a/testing/bitcoin/APKBUILD
> +++ b/testing/bitcoin/APKBUILD
> _at_@ -1,25 +1,29 @@
> -# Maintainer: Natanael Copa <ncopa_at_alpinelinux.org>
> +# Contributor: Natanael Copa <ncopa_at_alpinelinux.org>
> +# Maintainer: Stuart Cardall <developer_at_it-offshore.co.uk>
> pkgname=bitcoin
> -pkgver=0.8.6
> -pkgrel=1
> +pkgver=0.9.1
> +pkgrel=0
> pkgdesc="decentralized P2P electronic cash system"
> url="http://www.bitcoin.org/"
> -arch=""
> +arch="all"
> license="MIT"
> depends=""
> -depends_dev=""
> -makedepends="$depends_dev boost-dev openssl-dev db-dev miniupnpc-dev"
> -install=""
> -subpackages=""
> -source="http://sourceforge.net/projects/bitcoin/files/Bitcoin/bitcoin-0.8.6/bitcoin-$pkgver-linux.tar.gz
> - make.patch
> - boost-thread.patch
> - ssize_t.patch"
> +depends_dev="autoconf automake"
> +makedepends="$depends_dev boost-dev openssl-dev db-dev miniupnpc-dev qt-dev protobuf-dev libqrencode-dev"
> +install="$pkgname.post-install"
> +subpackages="$pkgname-qt"
> +source="https://github.com/bitcoin/bitcoin/archive/v$pkgver.tar.gz
> + 11-ssize_t.patch
> + 20-set-default-env.patch
> + $pkgname.initd
> + $pkgname.confd
> + $pkgname.conf
> + "
>
> -_builddir="$srcdir"/bitcoin-$pkgver-linux/src
> +_builddir="$srcdir"/bitcoin-$pkgver
> prepare() {
> local i
> - cd "$_builddir"
> + cd "$_builddir"/src
> for i in $source; do
> case $i in
> *.patch) msg $i; patch -p1 -i "$srcdir"/$i || return 1;;
> _at_@ -29,24 +33,51 @@ prepare() {
>
> build() {
> cd "$_builddir"
> - cd src
> - make -f makefile.unix
> + ./autogen.sh
> + # libboost tests fail on MUSL with 'undefined reference' if bitcoin-qt is also built
> + # bitcoind builds & passes all tests on both uclibc & musl
> + ./configure \
> + --disable-tests \
> + --with-incompatible-bdb \
> + || return 1
> + make || return 1
> +}
> +
> +qt() {
> + pkgdesc="Bitcoin with a Qt frontend & QR Code support"
> + #depends="bitcoin=$pkgver-r$pkgrel"
> + cd "$srcdir"/bitcoin-$pkgver/src/qt
> + install -Dm755 bitcoin-qt "$pkgdir"/usr/bin/bitcoin-qt || return 1
> + mkdir -p "$subpkgdir"/usr/bin
> + mv "$pkgdir"/usr/bin/bitcoin-qt \
> + "$subpkgdir"/usr/bin/
> }
>
> package() {
> cd "$_builddir"
> + install -m755 -D "$srcdir"/$pkgname.initd "$pkgdir"/etc/init.d/$pkgname || return 1
> + # daemon config
> + install -m600 -D "$srcdir"/$pkgname.confd "$pkgdir"/etc/conf.d/$pkgname || return 1
> + # app config
> + install -m600 -D "$srcdir"/$pkgname.conf "$pkgdir"/etc/$pkgname.conf || return 1
> install -Dm755 src/bitcoind "$pkgdir"/usr/bin/bitcoind || return 1
> }
>
> -md5sums="4c24497a3c88adf1ef9855efaf31cf87 bitcoin-0.8.6-linux.tar.gz
> -baffb25d5cb9f2e859c462c8b5e2fbef make.patch
> -c1233bd720e62f1b90608232f269b4f9 boost-thread.patch
> -716a88e668729e89d3eb929da86f7f04 ssize_t.patch"
> -sha256sums="73495de53d1a30676884961e39ff46c3851ff770eeaa767331d065ff0ce8dd0c bitcoin-0.8.6-linux.tar.gz
> -a37ea4e7eed4678397e66164d0a053049d7ae6baf69b46cc127eabbac81efe95 make.patch
> -99c2ab6fb597d2b80b98c7f016de5523f9716c5e11c2455e20326538e3c101ab boost-thread.patch
> -f0a094c7b374338ad153ee06b7dd2369dad6b97b1f1bb0252da12c9aaace5321 ssize_t.patch"
> -sha512sums="efdf4509eb668504fe60d019c5787a511eedda4b6d57ced824b02a1a3b7ce943eb86137c5ffd15015f5e457c6253da970fcd53fae47ae2d4156f812e42985bf4 bitcoin-0.8.6-linux.tar.gz
> -1c0275e7439e7d26d0f2ae91d04af7ea5b9e3740555a8ddba414f767d18101268eb80a41d0b85f21a2968b92fdc37d395c3bd7dd68d0856d228963c06e17b42f make.patch
> -3ad8e5e8ded91b49fff707f779d5987a8ab33ad6eb9a3233f1f35e146c665aa71c0dc1983e58d9fb7f662e8d238f59dc1b8606a665644a5bcc48681f6ee8ca9d boost-thread.patch
> -98aa5ad81bdb4ae961b791bc978c39117cdf2d83c2181f92bebbb0db107d9b6e86eda265fb3f93ff8a5ca8a7754d7148818b98095d57201dff9363d60b97e7dd ssize_t.patch"
> +md5sums="7a9c14c09b04e3e37d703fbfe5c3b1e2 v0.9.1.tar.gz
> +e51b99d89210b41f8e9db1c773c3eed8 11-ssize_t.patch
> +997318f9a1487ac074053c0bafcc3297 20-set-default-env.patch
> +edcc1526d5c7330fbbe08f506aab7adc bitcoin.initd
> +5806cde9a5509f1a65dc10bf6271b59f bitcoin.confd
> +4b2bb76ce8d056ad6e7178cd1f84794d bitcoin.conf"
> +sha256sums="bf5021a426b5e38a741a5294a0ceb22daa74cda11c6dc0478c4aa48c55fdccb3 v0.9.1.tar.gz
> +b6be699bd669ededfced84c15bc1cfcd13b5d094327ce590cabfe53742db1217 11-ssize_t.patch
> +18cdfab561fcd419d561ea4df48f5b12de1fb7474f2950487ac354d737be33e0 20-set-default-env.patch
> +47a953530ecba668387db37b70d6b557011ea1ea7e5c23014fcdc8791ade7b5a bitcoin.initd
> +1d1d890c5b5b2d817e7531922deb212764c75af5e7fcccaebc04f8288ce39303 bitcoin.confd
> +0ec190624a1185b4168d25e315831d722add0df2900830a1b71cf6010b241275 bitcoin.conf"
> +sha512sums="75be422fc263f209783fc66d9fd99027d67c7460c599a23badafcf5546ce7cb21206fce04c516a1c101aeff13542b332249b3b70a70c483aa82a5048dbdc9d92 v0.9.1.tar.gz
> +031727cbc917b3eaeb8d9098fc7c9695d96cf4dd648ddacf634334ec8645b37453a9e7ac3e9c815c0793ecdd002175509852b23b1dfd170fbf900373474d0944 11-ssize_t.patch
> +1fd5e2c2475198b3e564e650e6a6a971b58df686bfccfc518786827db57be4e093766e984d199bdf019c5e18d75a096e8bfaa572d26b2c367e39785f7c81e216 20-set-default-env.patch
> +2502d0f10d06789c6f1ece00747d24dce87062eb537d035f08503f069d758e434ee197150fa150828cde3743c9c76e2c7cf97ab3dd18acf9239af2785ff56e94 bitcoin.initd
> +942857b0a71c5be2a87f193eebba2e85a1b8665cd13641246ac223e96648b51901c666c9a5dd354e12069a7bb18855406c1b48e67dbe348faff575b643d00828 bitcoin.confd
> +db2de1f5a675d424cabd371ef0eb8ce75a23fdc5d81cd11cfe219c0367811c6dae253d64726adb315750c7611bec6daab52a541c6a760bfa5cc7894554fa3ce7 bitcoin.conf"
> diff --git a/testing/bitcoin/bitcoin.conf b/testing/bitcoin/bitcoin.conf
> new file mode 100644
> index 0000000..bcc5241
> --- /dev/null
> +++ b/testing/bitcoin/bitcoin.conf
> _at_@ -0,0 +1,10 @@
> +# Bitcoin configuration file for Alpine Linux
> +#
> +#proxy=127.0.0.1:9050 #use TOR Socks Proxy
> +rpcallowip=127.0.0.1
> +rpcuser=changeme
> +rpcpassword=changeme
> +rpcport=changeme
> +daemon=1
> +#gen=1 #generate bitcoins
> +
> diff --git a/testing/bitcoin/bitcoin.confd b/testing/bitcoin/bitcoin.confd
> new file mode 100644
> index 0000000..00238aa
> --- /dev/null
> +++ b/testing/bitcoin/bitcoin.confd
> _at_@ -0,0 +1,13 @@
> +# Bitcoin daemon conf.d file for Alpine Linux
> +#
> +##################################################
> +## If run as a NON root user / group change ##
> +## 'pidfile' below to a user writable location ##
> +##################################################
> +name=bitcoind
> +daemon=/usr/bin/$name
> +config=/etc/bitcoin.conf
> +user=root
> +group=root
> +pidfile=/var/run/$name.pid
> +
> diff --git a/testing/bitcoin/bitcoin.initd b/testing/bitcoin/bitcoin.initd
> new file mode 100644
> index 0000000..23987b3
> --- /dev/null
> +++ b/testing/bitcoin/bitcoin.initd
> _at_@ -0,0 +1,33 @@
> +#!/sbin/runscript
> +
> +# Bitcoin init.d file for Alpine Linux.
> +
> +config_file=/etc/conf.d/bitcoin
> +
> +depend() {
> + need net
> + after firewall
> +}
> +
> +check_config() {
> + [ -f "$config_file" ] || eend "$config_file is missing"
> + [ -f "/usr/bin/bitcoind" ] || eend "Bitcoin Daemon is not installed"
> +}
> +
> +start() {
> + ebegin "Starting ${name}"
> + check_config || return 1
> + start-stop-daemon --start --quiet \
> + --pidfile /var/run/${name}.pid \
> + --user ${user}:${group} \
> + --exec ${daemon} -- -conf=${config} -pid=${pidfile}
> + eend $?
> +}
> +
> +stop() {
> + ebegin "Stopping ${name}"
> + start-stop-daemon --stop --quiet \
> + --pidfile ${pidfile} \
> + --exec ${daemon}
> + eend $?
> +}
> \ No newline at end of file
> diff --git a/testing/bitcoin/bitcoin.post-install b/testing/bitcoin/bitcoin.post-install
> new file mode 100644
> index 0000000..9b4d140
> --- /dev/null
> +++ b/testing/bitcoin/bitcoin.post-install
> _at_@ -0,0 +1,53 @@
> +#!/bin/sh
> +
> +NORMAL="\033[1;0m"
> +STRONG="\033[1;1m"
> +GREEN="\033[1;32m"
> +
> +config=$(grep config /etc/conf.d/bitcoin |sed 's/config=//')
> +
> +randgen() {
> + output=$(< /dev/urandom tr -dc '0-9a-zA-Z!_at_#$%^&*_+-' | head -c${1:-$1}) 2>/dev/null
> + echo $output
> +}
> +
> +# Generate random port
> +randport() {
> + n=$RANDOM
> + while [ $n -gt 65536 ] && [ $n -lt 1024 ]; do
> + n=$RANDOM
> + done
> + echo $n
> +}
> +
> +# Find unused TCP port
> +findRandomTcpPort(){
> + port=$(randport)
> + while :
> + do
> + (echo >/dev/tcp/localhost/$port) &>/dev/null && port=$(randport) || break
> + done
> + echo $port
> +}
> +
> +GenPasswd(){
> + sed -i "/rpcuser=/ c \rpcuser=USER-"$(randgen 32)"" $config
> + sed -i "/rpcpassword=/ c \rpcpassword=PW-"$(randgen 64)"" $config
> + sed -i "/rpcport=/ c \rpcport="$(findRandomTcpPort)"" $config
> + print_green "Generated random user / password / port in:" " $config\n"
> +}
> +
> +
> +print_green() {
> + local prompt="${STRONG}$1${GREEN}$2${NORMAL}"
> + printf "${prompt}%s"
> +}
> +
> +if grep -F "changeme" $config 1>/dev/null; then
> + GenPasswd
> +else
> + print_green "Generate a new random username / password / port in: $config ?" " [ y | n <default> ] "; read ans
> + if [ "$ans" = "y" ] || [ "$ans" = "Y" ]; then
> + GenPasswd
> + fi
> +fi
> diff --git a/testing/bitcoin/boost-thread.patch b/testing/bitcoin/boost-thread.patch
> deleted file mode 100644
> index e71a980..0000000
> --- a/testing/bitcoin/boost-thread.patch
> +++ /dev/null
> _at_@ -1,11 +0,0 @@
> ---- ./src/makefile.unix.old 2013-12-14 13:14:50.445065372 +0000
> -+++ ./src/makefile.unix 2013-12-14 13:13:35.834253950 +0000
> -_at_@ -37,7 +37,7 @@
> - -l boost_system$(BOOST_LIB_SUFFIX) \
> - -l boost_filesystem$(BOOST_LIB_SUFFIX) \
> - -l boost_program_options$(BOOST_LIB_SUFFIX) \
> -- -l boost_thread$(BOOST_LIB_SUFFIX) \
> -+ -l boost_thread-mt$(BOOST_LIB_SUFFIX) \
> - -l db_cxx$(BDB_LIB_SUFFIX) \
> - -l ssl \
> - -l crypto
> diff --git a/testing/bitcoin/make.patch b/testing/bitcoin/make.patch
> deleted file mode 100644
> index d27fbd6..0000000
> --- a/testing/bitcoin/make.patch
> +++ /dev/null
> _at_@ -1,13 +0,0 @@
> -diff --git a/src/makefile.unix b/src/makefile.unix
> -index 8110235..91ae3a9 100644
> ---- a/src/makefile.unix
> -+++ b/src/makefile.unix
> -_at_@ -157,7 +157,7 @@ LIBS += $(CURDIR)/leveldb/libleveldb.a $(CURDIR)/leveldb/libmemenv.a
> - DEFS += $(addprefix -I,$(CURDIR)/leveldb/include)
> - DEFS += $(addprefix -I,$(CURDIR)/leveldb/helpers)
> - leveldb/libleveldb.a:
> -- _at_echo "Building LevelDB ..." && cd leveldb && $(MAKE) CC=$(CC) CXX=$(CXX) OPT="$(xCXXFLAGS)" libleveldb.a libmemenv.a && cd ..
> -+ _at_echo "Building LevelDB ..." && cd leveldb && $(MAKE) CC="$(CC)" CXX="$(CXX)" OPT="$(xCXXFLAGS)" libleveldb.a libmemenv.a && cd ..
> -
> - # auto-generated dependencies:
> - -include obj/*.P
> diff --git a/testing/bitcoin/ssize_t.patch b/testing/bitcoin/ssize_t.patch
> deleted file mode 100644
> index 2c21854..0000000
> --- a/testing/bitcoin/ssize_t.patch
> +++ /dev/null
> _at_@ -1,12 +0,0 @@
> -diff --git a/src/leveldb/db/db_iter.cc b/src/leveldb/db/db_iter.cc
> -index 071a54e..68a18f2 100644
> ---- a/src/leveldb/db/db_iter.cc
> -+++ b/src/leveldb/db/db_iter.cc
> -_at_@ -2,6 +2,7 @@
> - // Use of this source code is governed by a BSD-style license that can be
> - // found in the LICENSE file. See the AUTHORS file for names of contributors.
> -
> -+#include <sys/types.h>
> - #include "db/db_iter.h"
> -
> - #include "db/filename.h"



---
Unsubscribe:  alpine-devel+unsubscribe_at_lists.alpinelinux.org
Help:         alpine-devel+help_at_lists.alpinelinux.org
---
Received on Thu May 08 2014 - 15:55:05 GMT