<commit_before>#!/bin/sh

cur_dir="$(pwd)"
os_dir=$(./platform/os.sh osdir)

if test -e "${os_dir}/libbitcoind.so"; then
  read -r -p 'libbitcoind.so already built. Rebuild? (Y/n): ' choice
  if test x"$choice" != x'y' -a x"$choice" != x'Y'; then
    echo 'libbitcoind.so ready.'
    exit 0
  fi
  rm -f "${os_dir}/libbitcoind.so"
fi

if test -n "$1"; then
  if test "$1" = 'remote'; then
    echo 'git clone'
    git clone git://github.com/bitcoin/bitcoin.git libbitcoind || exit 1
    btc_dir="${cur_dir}/libbitcoind"
  else
    btc_dir=$1
    if ! test -d "$btc_dir"; then
      "$0" remote
      exit 0
    fi
  fi
  shift
else
  btc_dir="${HOME}/bitcoin"
  if ! test -d "$btc_dir"; then
    "$0" remote
    exit 0
  fi
fi

echo "Found BTC directory: $btc_dir"

echo './patch-bitcoin.sh' "$btc_dir"
./patch-bitcoin.sh "$btc_dir" || exit 1

cd "$btc_dir" || exit 1

if ! test -d .git; then
  echo 'Please point this script to an upstream bitcoin git repo.'
  exit 1
fi

bdb_compat=0
if cat /usr/include/db.h | grep -i DB_VERSION_STRING | grep -q 'DB 4.8' \
  || test -e /usr/include/db4.8 \
  || test -e /usr/include/db4.8.h; then
  bdb_compat=1
fi
if test $bdb_compat -eq 0; then
  set -- "--with-incompatible-bdb" "$@"
fi

echo './autogen.sh'
./autogen.sh || exit 1
if test -n "$1"; then
  echo './configure --enable-daemonlib' "$@"
  ./configure --enable-daemonlib "$@" || exit 1
else
  echo './configure --enable-daemonlib'
  ./configure --enable-daemonlib || exit 1
fi
echo 'make'
make || exit 1

echo 'Copying libbitcoind.so to its appropriate location.'
cp src/libbitcoind.so "${os_dir}/libbitcoind.so" || exit 1

cd "$cur_dir"
rm -rf libbitcoind

echo 'Build finished successfully.'
exit 0<commit_msg>do not delete btc tree.<commit_after>#!/bin/sh

cur_dir="$(pwd)"
os_dir=$(./platform/os.sh osdir)

if test -e "${os_dir}/libbitcoind.so"; then
  read -r -p 'libbitcoind.so already built. Rebuild? (Y/n): ' choice
  if test x"$choice" != x'y' -a x"$choice" != x'Y'; then
    echo 'libbitcoind.so ready.'
    exit 0
  fi
  rm -f "${os_dir}/libbitcoind.so"
fi

if test -n "$1"; then
  if test "$1" = 'remote'; then
    echo 'git clone'
    git clone git://github.com/bitcoin/bitcoin.git libbitcoind || exit 1
    btc_dir="${cur_dir}/libbitcoind"
  else
    btc_dir=$1
    if ! test -d "$btc_dir"; then
      "$0" remote
      exit 0
    fi
  fi
  shift
else
  btc_dir="${HOME}/bitcoin"
  if ! test -d "$btc_dir"; then
    "$0" remote
    exit 0
  fi
fi

echo "Found BTC directory: $btc_dir"

echo './patch-bitcoin.sh' "$btc_dir"
./patch-bitcoin.sh "$btc_dir" || exit 1

cd "$btc_dir" || exit 1

if ! test -d .git; then
  echo 'Please point this script to an upstream bitcoin git repo.'
  exit 1
fi

bdb_compat=0
if cat /usr/include/db.h | grep -i DB_VERSION_STRING | grep -q 'DB 4.8' \
  || test -e /usr/include/db4.8 \
  || test -e /usr/include/db4.8.h; then
  bdb_compat=1
fi
if test $bdb_compat -eq 0; then
  set -- "--with-incompatible-bdb" "$@"
fi

echo './autogen.sh'
./autogen.sh || exit 1
if test -n "$1"; then
  echo './configure --enable-daemonlib' "$@"
  ./configure --enable-daemonlib "$@" || exit 1
else
  echo './configure --enable-daemonlib'
  ./configure --enable-daemonlib || exit 1
fi
echo 'make'
make || exit 1

echo 'Copying libbitcoind.so to its appropriate location.'
mv src/libbitcoind.so "${os_dir}/libbitcoind.so" || exit 1

echo 'Build finished successfully.'
exit 0
{'fraction_non_alphanumeric': 0.16558823529411765, 'fraction_numerical': 0.01647058823529412, 'mean_word_length': 2.913693901035673, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2183532', 'n_tokens_mistral': 1386, 'n_tokens_neox': 1339, 'n_words': 400}