Changeset View
Changeset View
Standalone View
Standalone View
scripts/fetch_documentation.sh
#!/usr/bin/env bash | #!/usr/bin/env bash | ||||
set -euxo pipefail | set -euxo pipefail | ||||
# Github repository parameters | # Github repository parameters | ||||
GITHUB_OWNER='Bitcoin-ABC' | GITHUB_OWNER='Bitcoin-ABC' | ||||
GITHUB_REPO='bitcoin-abc' | GITHUB_REPO='bitcoin-abc' | ||||
# Max number of release versions to display | # Max number of release versions to display | ||||
MAX_RELEASES=15 | MAX_RELEASES=15 | ||||
# Min version for rpc docs generation | # Min version for rpc docs generation | ||||
MIN_VERSION_RPC_DOCS='0.22.1' | MIN_VERSION_RPC_DOCS='0.23.0' | ||||
# Min version for man pages generation | # Min version for man pages generation | ||||
MIN_VERSION_MAN_PAGES='0.22.1' | MIN_VERSION_MAN_PAGES='0.23.0' | ||||
# jq must be installed | # jq must be installed | ||||
if ! command -v jq > /dev/null; then | if ! command -v jq > /dev/null; then | ||||
echo "Error: 'jq' is not installed." | echo "Error: 'jq' is not installed." | ||||
exit 10 | exit 10 | ||||
fi | fi | ||||
▲ Show 20 Lines • Show All 76 Lines • ▼ Show 20 Lines | do | ||||
mkdir -p "${INSTALL_DIR}" | mkdir -p "${INSTALL_DIR}" | ||||
pushd "${BUILD_DIR}" | pushd "${BUILD_DIR}" | ||||
if [ "${BUILD_RPC_DOCS}" = "yes" ] && [ ! -d "${VERSION_DIR}/rpc" ] | if [ "${BUILD_RPC_DOCS}" = "yes" ] && [ ! -d "${VERSION_DIR}/rpc" ] | ||||
then | then | ||||
# Build and install the release version | # Build and install the release version | ||||
cmake -GNinja "${SRC_DIR}" -DCLIENT_VERSION_IS_RELEASE=ON -DCMAKE_INSTALL_PREFIX="${INSTALL_DIR}" | cmake -GNinja "${SRC_DIR}" -DCLIENT_VERSION_IS_RELEASE=ON -DCMAKE_INSTALL_PREFIX="${INSTALL_DIR}" | ||||
# Prior to version 0.22.2, the rpc-doc target required to manually spin a | |||||
# regtest bitcoind server. | |||||
if version_greater_equal "${VERSION}" "0.22.2" | |||||
then | |||||
ninja doc-rpc | ninja doc-rpc | ||||
else | |||||
# FIXME Remove the else branch after versions < 0.22.2 are obsolete | |||||
( | |||||
ninja install/strip | |||||
BITCOIND_PID_FILE="${VERSION_DIR}/bitcoind_${VERSION}.pid" | |||||
"${INSTALL_DIR}"/bin/bitcoind -regtest -daemon -pid="${BITCOIND_PID_FILE}" | |||||
shutdown_bitcoind() { | |||||
"${INSTALL_DIR}"/bin/bitcoin-cli -regtest stop > /dev/null 2>&1 | |||||
# Waiting for bitcoind shut down | |||||
PID_WAIT_COUNT=0 | |||||
while [ -e "${BITCOIND_PID_FILE}" ] | |||||
do | |||||
: $((PID_WAIT_COUNT+=1)) | |||||
if [ "${PID_WAIT_COUNT}" -gt 20 ] | |||||
then | |||||
echo "Timed out waiting for bitcoind to stop" | |||||
exit 3 | |||||
fi | |||||
sleep 0.5 | |||||
done | |||||
} | |||||
trap "shutdown_bitcoind" EXIT | |||||
# Waiting for bitcoind to spin up | |||||
RPC_HELP_WAIT_COUNT=0 | |||||
while ! "${INSTALL_DIR}"/bin/bitcoin-cli -regtest help > /dev/null 2>&1 | |||||
do | |||||
: $((RPC_HELP_WAIT_COUNT+=1)) | |||||
if [ "${RPC_HELP_WAIT_COUNT}" -gt 10 ] | |||||
then | |||||
echo "Timed out waiting for bitcoind to start" | |||||
exit 2 | |||||
fi | |||||
sleep 0.5 | |||||
done | |||||
ninja doc-rpc | |||||
) | |||||
fi | |||||
# Cache the result | # Cache the result | ||||
cp -R "${BUILD_DIR}/doc/rpc/en/${VERSION}/rpc" "${VERSION_DIR}/" | cp -R "${BUILD_DIR}/doc/rpc/en/${VERSION}/rpc" "${VERSION_DIR}/" | ||||
fi | fi | ||||
if [ "${BUILD_MAN_PAGES}" = "yes" ] && [ ! -d "${VERSION_DIR}/man" ] | if [ "${BUILD_MAN_PAGES}" = "yes" ] && [ ! -d "${VERSION_DIR}/man" ] | ||||
then | then | ||||
# xvfb is only needed to build headlessly. | # xvfb is only needed to build headlessly. | ||||
if ! command -v xvfb-run | if ! command -v xvfb-run | ||||
then | then | ||||
echo "xvfb is required to build the docs headlessly, please install it." | echo "xvfb is required to build the docs headlessly, please install it." | ||||
exit 3 | exit 3 | ||||
fi | fi | ||||
if [[ "${VERSION}" == "0.22.3" ]]; then | |||||
# Cherry pick a fix to ensure the version number is set correctly | |||||
git cherry-pick 6f59a8facadb99ffa0f64421d7248043de507c64 | |||||
fi | |||||
# Build and install the man pages | # Build and install the man pages | ||||
cmake -GNinja "${SRC_DIR}" -DCLIENT_VERSION_IS_RELEASE=ON -DCMAKE_INSTALL_PREFIX="${INSTALL_DIR}" | cmake -GNinja "${SRC_DIR}" -DCLIENT_VERSION_IS_RELEASE=ON -DCMAKE_INSTALL_PREFIX="${INSTALL_DIR}" | ||||
# Version 0.22.4 calls xvfb-run and can cause a race, so force using a | xvfb-run -a -e /dev/stderr ninja install-manpages-html | ||||
# single job. | |||||
# FIXME Remove the -j1 once 0.22.4 gets obsoleted. | |||||
xvfb-run -a -e /dev/stderr ninja -j1 install-manpages-html | |||||
mkdir -p "${VERSION_DIR}/man" | mkdir -p "${VERSION_DIR}/man" | ||||
# Cache the result | # Cache the result | ||||
cp "${INSTALL_DIR}"/share/man/html/* "${VERSION_DIR}/man/" | cp "${INSTALL_DIR}"/share/man/html/* "${VERSION_DIR}/man/" | ||||
fi | fi | ||||
popd | popd | ||||
Show All 24 Lines |