Changeset View
Changeset View
Standalone View
Standalone View
contrib/release/debian-packages.sh
#!/usr/bin/env bash | #!/usr/bin/env bash | ||||
export LC_ALL=C | export LC_ALL=C | ||||
set -euo pipefail | set -euo pipefail | ||||
DEFAULT_PPA="bitcoin-abc" | DEFAULT_PPA="bitcoin-abc" | ||||
DPUT_CONFIG_FILE=~/".dput.cf" | DPUT_CONFIG_FILE=~/".dput.cf" | ||||
help_message() { | help_message() { | ||||
echo "Build and sign Debian packages and push to a PPA." | echo "Build and sign Debian packages and push to a PPA." | ||||
echo "Usage: $0 <options> package_version signer" | echo "Usage: $0 <options> signer" | ||||
echo | echo | ||||
echo "Example usage: $0 0.21.2 \"Jason B. Cox <jasonbcox@bitcoinabc.org>\"" | echo "Example usage: $0 \"Jason B. Cox <jasonbcox@bitcoinabc.org>\"" | ||||
echo | |||||
echo "package_version must be of the form: MAJOR.MINOR.REVISION[.OPTIONALPATCH]" | |||||
echo "OPTIONALPATCH may be necessary when source files have changed but the version revision has not, as the PPA will" | |||||
echo "reject source archives of the same name." | |||||
echo | echo | ||||
echo "signer must be of the form: 'YOUR NAME <your-email@domain.com>'" | echo "signer must be of the form: 'YOUR NAME <your-email@domain.com>'" | ||||
echo | echo | ||||
echo "Note: This script will prompt you to sign with your PGP key." | echo "Note: This script will prompt you to sign with your PGP key." | ||||
echo | echo | ||||
echo "-d, --dry-run Build and sign the packages, but do not push them to the PPA." | echo "-d, --dry-run Build and sign the packages, but do not push them to the PPA." | ||||
echo "-h, --help Display this help message." | echo "-h, --help Display this help message." | ||||
echo "-p, --ppa PPA hostname. Defaults to: '${DEFAULT_PPA}'. If no config file exists at ${DPUT_CONFIG_FILE}" | echo "-p, --ppa <ppa-name> PPA hostname. Defaults to: '${DEFAULT_PPA}'. If no config file exists at ${DPUT_CONFIG_FILE}" | ||||
echo " then one will be created using '${DEFAULT_PPA}'. Setting this option to a hostname other than" | echo " then one will be created using '${DEFAULT_PPA}'. Setting this option to a hostname other than" | ||||
echo " the default will require that you add the necessary settings to the config file." | echo " the default will require that you add the necessary settings to the config file." | ||||
echo "-v, --version <version> Set the package version. Defaults to the version returned by 'bitcoind --version'." | |||||
echo " If set, version must be of the form: MAJOR.MINOR.REVISION[.OPTIONALPATCH]" | |||||
echo " OPTIONALPATCH may be necessary when source files have changed but the version revision has not," | |||||
echo " as the PPA will reject source archives of the same name." | |||||
} | } | ||||
DRY_RUN="false" | DRY_RUN="false" | ||||
NUM_EXPECTED_ARGUMENTS=2 | NUM_EXPECTED_ARGUMENTS=1 | ||||
PACKAGE_VERSION="" | |||||
PPA="${DEFAULT_PPA}" | PPA="${DEFAULT_PPA}" | ||||
# Parse command line arguments | # Parse command line arguments | ||||
while [[ $# -ne 0 ]]; do | while [[ $# -ne 0 ]]; do | ||||
case $1 in | case $1 in | ||||
-d|--dry-run) | -d|--dry-run) | ||||
DRY_RUN="true" | DRY_RUN="true" | ||||
shift # shift past argument | shift # shift past argument | ||||
;; | ;; | ||||
-h|--help) | -h|--help) | ||||
help_message | help_message | ||||
exit 0 | exit 0 | ||||
;; | ;; | ||||
-p|--ppa) | -p|--ppa) | ||||
PPA="$2" | PPA="$2" | ||||
shift # shift past argument | shift # shift past argument | ||||
shift # shift past value | shift # shift past value | ||||
;; | ;; | ||||
-v|--version) | |||||
PACKAGE_VERSION="$2" | |||||
echo "${PACKAGE_VERSION}" | grep -E "[0-9]+\.[0-9]+\.[0-9]+(\.[0-9]+)?" || { | |||||
echo "Error: package_version is not formatted correctly" | |||||
echo | |||||
help_message | |||||
exit 20 | |||||
} | |||||
shift # shift past argument | |||||
shift # shift past value | |||||
;; | |||||
*) | *) | ||||
if [ "$#" -le "${NUM_EXPECTED_ARGUMENTS}" ]; then | if [ "$#" -le "${NUM_EXPECTED_ARGUMENTS}" ]; then | ||||
break | break | ||||
fi | fi | ||||
echo "Unknown argument: $1" | echo "Unknown argument: $1" | ||||
help_message | help_message | ||||
exit 1 | exit 1 | ||||
;; | ;; | ||||
Show All 12 Lines | |||||
if [ "$#" -ne "${NUM_EXPECTED_ARGUMENTS}" ]; then | if [ "$#" -ne "${NUM_EXPECTED_ARGUMENTS}" ]; then | ||||
echo "Error: Expects ${NUM_EXPECTED_ARGUMENTS} arguments" | echo "Error: Expects ${NUM_EXPECTED_ARGUMENTS} arguments" | ||||
echo | echo | ||||
help_message | help_message | ||||
exit 20 | exit 20 | ||||
fi | fi | ||||
PACKAGE_VERSION="$1" | SIGNER="$1" | ||||
echo "Package version:" | |||||
echo "${PACKAGE_VERSION}" | grep -E "[0-9]+\.[0-9]+\.[0-9]+(\.[0-9]+)?" || { | |||||
echo "Error: package_version is not formatted correctly" | |||||
echo | |||||
help_message | |||||
exit 20 | |||||
} | |||||
SIGNER="$2" | |||||
echo "Signer:" | echo "Signer:" | ||||
echo "${SIGNER}" | grep ".* <.*@.*>" || { | echo "${SIGNER}" | grep ".* <.*@.*>" || { | ||||
echo "Error: signer is not formatted correctly" | echo "Error: signer is not formatted correctly" | ||||
echo | echo | ||||
help_message | help_message | ||||
exit 21 | exit 21 | ||||
} | } | ||||
Show All 17 Lines | |||||
} | } | ||||
# Build package source archive | # Build package source archive | ||||
TOPLEVEL="$(git rev-parse --show-toplevel)" | TOPLEVEL="$(git rev-parse --show-toplevel)" | ||||
"${TOPLEVEL}"/contrib/devtools/build_cmake.sh | "${TOPLEVEL}"/contrib/devtools/build_cmake.sh | ||||
pushd "${TOPLEVEL}"/build | pushd "${TOPLEVEL}"/build | ||||
ninja package_source | ninja package_source | ||||
# Get package version if one wasn't explicitly set | |||||
if [ -z "${PACKAGE_VERSION}" ]; then | |||||
PACKAGE_VERSION=$(./src/bitcoind --version | grep -Eo "[0-9]+\.[0-9]+\.[0-9]+") | |||||
fi | |||||
echo "Package version: ${PACKAGE_VERSION}" | |||||
# Unpack the package source | # Unpack the package source | ||||
SOURCE_VERSION=$(echo "${PACKAGE_VERSION}" | grep -oE "[0-9]+\.[0-9]+\.[0-9]+") | SOURCE_VERSION=$(echo "${PACKAGE_VERSION}" | grep -oE "[0-9]+\.[0-9]+\.[0-9]+") | ||||
SOURCE_BASE_NAME="bitcoin-abc-${SOURCE_VERSION}" | SOURCE_BASE_NAME="bitcoin-abc-${SOURCE_VERSION}" | ||||
SOURCE_ARCHIVE="${SOURCE_BASE_NAME}.tar.gz" | SOURCE_ARCHIVE="${SOURCE_BASE_NAME}.tar.gz" | ||||
tar -zxf "${SOURCE_ARCHIVE}" | tar -zxf "${SOURCE_ARCHIVE}" | ||||
# Rename the package source archive. debuild is picky about the naming. | # Rename the package source archive. debuild is picky about the naming. | ||||
CONTROL_SOURCE_NAME=$(grep "Source: " "${TOPLEVEL}"/contrib/debian/control | cut -c 9-) | CONTROL_SOURCE_NAME=$(grep "Source: " "${TOPLEVEL}"/contrib/debian/control | cut -c 9-) | ||||
▲ Show 20 Lines • Show All 42 Lines • Show Last 20 Lines |