diff --git a/.github/workflows/PR.yaml b/.github/workflows/PR.yaml index e3a2f617c..7277b1d0e 100644 --- a/.github/workflows/PR.yaml +++ b/.github/workflows/PR.yaml @@ -30,7 +30,7 @@ jobs: uses: actions/checkout@v4 - name: setup id: setup - uses: hyperledger/indy-shared-gha/.github/actions/workflow-setup@v1 + uses: hyperledger/indy-shared-gha/.github/actions/workflow-setup@v2 - name: testsNeeded id: testsNeeded uses: dorny/paths-filter@v3 @@ -46,12 +46,12 @@ jobs: name: Lint needs: [workflow-setup] if: ${{ needs.workflow-setup.outputs.testsNeeded == 'true' }} - uses: hyperledger/indy-shared-gha/.github/workflows/lint.yaml@v1 + uses: hyperledger/indy-shared-gha/.github/workflows/lint.yaml@v2 build-image: name: Create Builder Image needs: [workflow-setup, lint] - uses: hyperledger/indy-shared-gha/.github/workflows/buildimage.yaml@v1 + uses: hyperledger/indy-shared-gha/.github/workflows/buildimage.yaml@v2 with: CACHE_KEY_BUILD: ${{ needs.workflow-setup.outputs.CACHE_KEY_BUILD }} DOCKER_IMAGE: ghcr.io/${{ needs.workflow-setup.outputs.GITHUB_REPOSITORY_NAME }}/node-build @@ -60,7 +60,7 @@ jobs: build_packages: name: Build Packages needs: [workflow-setup, build-image] - uses: hyperledger/indy-shared-gha/.github/workflows/buildpackages.yaml@v1 + uses: hyperledger/indy-shared-gha/.github/workflows/buildpackages.yaml@v2 with: DOCKER_IMAGE: ghcr.io/${{ needs.workflow-setup.outputs.GITHUB_REPOSITORY_NAME }}/node-build:${{ needs.workflow-setup.outputs.UBUNTU_VERSION }} UBUNTU_VERSION: ${{ needs.workflow-setup.outputs.UBUNTU_VERSION }} diff --git a/.github/workflows/Push.yaml b/.github/workflows/Push.yaml index ba6d6c00d..59388f905 100644 --- a/.github/workflows/Push.yaml +++ b/.github/workflows/Push.yaml @@ -29,16 +29,16 @@ jobs: uses: actions/checkout@v4 - name: setup id: setup - uses: hyperledger/indy-shared-gha/.github/actions/workflow-setup@v1 + uses: hyperledger/indy-shared-gha/.github/actions/workflow-setup@v2 lint: name: Lint - uses: hyperledger/indy-shared-gha/.github/workflows/lint.yaml@v1 + uses: hyperledger/indy-shared-gha/.github/workflows/lint.yaml@v2 build-image: name: Create Builder Image needs: [workflow-setup, lint] - uses: hyperledger/indy-shared-gha/.github/workflows/buildimage.yaml@v1 + uses: hyperledger/indy-shared-gha/.github/workflows/buildimage.yaml@v2 with: CACHE_KEY_BUILD: ${{ needs.workflow-setup.outputs.CACHE_KEY_BUILD }} DOCKER_IMAGE: ghcr.io/${{ needs.workflow-setup.outputs.GITHUB_REPOSITORY_NAME }}/node-build @@ -47,7 +47,7 @@ jobs: build_packages: name: Build Packages needs: [workflow-setup, build-image] - uses: hyperledger/indy-shared-gha/.github/workflows/buildpackages.yaml@v1 + uses: hyperledger/indy-shared-gha/.github/workflows/buildpackages.yaml@v2 with: DOCKER_IMAGE: ghcr.io/${{ needs.workflow-setup.outputs.GITHUB_REPOSITORY_NAME }}/node-build:${{ needs.workflow-setup.outputs.UBUNTU_VERSION }} UBUNTU_VERSION: ${{ needs.workflow-setup.outputs.UBUNTU_VERSION }} @@ -67,7 +67,7 @@ jobs: name: Publish Artifacts needs: [workflow-setup, indy_node_tests] if: needs.workflow-setup.outputs.publish == 'true' - uses: hyperledger/indy-shared-gha/.github/workflows/publish_artifacts.yaml@v1 + uses: hyperledger/indy-shared-gha/.github/workflows/publish_artifacts.yaml@v2 with: COMPONENT: 'dev' UBUNTU_VERSION: ${{ needs.workflow-setup.outputs.UBUNTU_VERSION }} diff --git a/.github/workflows/build/Dockerfile.ubuntu-2204 b/.github/workflows/build/Dockerfile.ubuntu-2204 new file mode 100644 index 000000000..030a5f936 --- /dev/null +++ b/.github/workflows/build/Dockerfile.ubuntu-2204 @@ -0,0 +1,42 @@ +FROM ubuntu:22.04 + +ARG uid=1000 +ARG user=indy + +RUN apt-get update -y && apt-get install -y \ + # common stuff + git \ + wget \ + gnupg \ + apt-transport-https \ + ca-certificates \ + apt-utils \ + curl \ + jq + +# ======================================================================================================== +# Update repository signing keys +# -------------------------------------------------------------------------------------------------------- +# Hyperledger +RUN apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 9692C00E657DDE61 && \ + # Sovrin + apt-key adv --keyserver keyserver.ubuntu.com --recv-keys CE7709D068DB5E88 && \ + # Bionic-Security + apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 3B4FE6ACC0B21F32 +# ======================================================================================================== + +# ToDo: +# - Eliminate dependency on obsolete bionic repositories. + +# Plenum +# - https://github.com/hyperledger/indy-plenum/issues/1546 +# - Needed to pick up rocksdb=5.8.8 +RUN echo "deb https://hyperledger.jfrog.io/artifactory/indy jammy dev" >> /etc/apt/sources.list && \ + echo "deb http://security.ubuntu.com/ubuntu bionic-security main" >> /etc/apt/sources.list && \ + echo "deb https://repo.sovrin.org/deb bionic master" >> /etc/apt/sources.list && \ + echo "deb https://repo.sovrin.org/sdk/deb bionic master" >> /etc/apt/sources.list + +RUN apt-get update -y && apt-get install -y rubygems python3-pip && apt-get -y autoremove && rm -rf /var/lib/apt/lists/* + +# install fpm +RUN gem install --no-document rake dotenv:2.8.1 fpm:1.15.0 diff --git a/.github/workflows/publishRelease.yaml b/.github/workflows/publishRelease.yaml index f8d12c8e7..b36288afd 100644 --- a/.github/workflows/publishRelease.yaml +++ b/.github/workflows/publishRelease.yaml @@ -33,12 +33,12 @@ jobs: uses: actions/checkout@v4 - name: get-release-info id: get-release-info - uses: hyperledger/indy-shared-gha/.github/actions/get-release-info@v1 + uses: hyperledger/indy-shared-gha/.github/actions/get-release-info@v2 with: versionString: "${{ github.event.head_commit.message }}" - name: workflow-setup id: workflow-setup - uses: hyperledger/indy-shared-gha/.github/actions/workflow-setup@v1 + uses: hyperledger/indy-shared-gha/.github/actions/workflow-setup@v2 createRelease: name: Create Release @@ -110,7 +110,7 @@ jobs: name: Publish Artifacts needs: [release-infos, createRelease] if: needs.release-infos.outputs.isVersionBump == 'true' && needs.release-infos.outputs.publish == 'true' - uses: hyperledger/indy-shared-gha/.github/workflows/publish_artifacts.yaml@v1 + uses: hyperledger/indy-shared-gha/.github/workflows/publish_artifacts.yaml@v2 with: COMPONENT: ${{ needs.release-infos.outputs.component }} UBUNTU_VERSION: ${{ needs.release-infos.outputs.UBUNTU_VERSION }} @@ -123,7 +123,7 @@ jobs: convertPyVersion: name: "Convert to python version flavour" needs: [release-infos, publish_artifacts] - uses: hyperledger/indy-shared-gha/.github/workflows/pyVersionConversion.yaml@v1 + uses: hyperledger/indy-shared-gha/.github/workflows/pyVersionConversion.yaml@v2 with: VERSIONTAG: ${{ needs.release-infos.outputs.VERSIONTAG }} diff --git a/.github/workflows/releasepr.yaml b/.github/workflows/releasepr.yaml index 80fc1ece5..b88139e12 100644 --- a/.github/workflows/releasepr.yaml +++ b/.github/workflows/releasepr.yaml @@ -26,24 +26,24 @@ jobs: uses: actions/checkout@v4 - name: get-release-info id: get-release-info - uses: hyperledger/indy-shared-gha/.github/actions/get-release-info@v1 + uses: hyperledger/indy-shared-gha/.github/actions/get-release-info@v2 with: versionString: "${{ github.event.pull_request.body }}" - name: workflow-setup id: workflow-setup - uses: hyperledger/indy-shared-gha/.github/actions/workflow-setup@v1 + uses: hyperledger/indy-shared-gha/.github/actions/workflow-setup@v2 lint: name: Lint needs: [release-infos] if: needs.release-infos.outputs.isVersionBump == 'true' - uses: hyperledger/indy-shared-gha/.github/workflows/lint.yaml@v1 + uses: hyperledger/indy-shared-gha/.github/workflows/lint.yaml@v2 build-docker-image: name: Create Builder Image needs: [release-infos, lint] if: needs.release-infos.outputs.isVersionBump == 'true' - uses: hyperledger/indy-shared-gha/.github/workflows/buildimage.yaml@v1 + uses: hyperledger/indy-shared-gha/.github/workflows/buildimage.yaml@v2 with: CACHE_KEY_BUILD: ${{ needs.release-infos.outputs.CACHE_KEY_BUILD }} DOCKER_IMAGE: ghcr.io/${{ needs.release-infos.outputs.GITHUB_REPOSITORY_NAME }}/node-build @@ -53,7 +53,7 @@ jobs: name: Build Packages needs: [release-infos, build-docker-image] if: needs.release-infos.outputs.isVersionBump == 'true' - uses: hyperledger/indy-shared-gha/.github/workflows/buildpackages.yaml@v1 + uses: hyperledger/indy-shared-gha/.github/workflows/buildpackages.yaml@v2 with: DOCKER_IMAGE: ghcr.io/${{ needs.release-infos.outputs.GITHUB_REPOSITORY_NAME }}/node-build:${{ needs.release-infos.outputs.UBUNTU_VERSION }} UBUNTU_VERSION: ${{ needs.release-infos.outputs.UBUNTU_VERSION }} diff --git a/.github/workflows/tag.yaml b/.github/workflows/tag.yaml index b30e3329e..5ddea355e 100644 --- a/.github/workflows/tag.yaml +++ b/.github/workflows/tag.yaml @@ -21,12 +21,12 @@ jobs: fetch-depth: 0 - name: extract branch id: get-branch - uses: hyperledger/indy-shared-gha/.github/actions/branch-from-tag@v1 + uses: hyperledger/indy-shared-gha/.github/actions/branch-from-tag@v2 with: tag: ${{ github.ref }} - name: get-release-info id: get-release-info - uses: hyperledger/indy-shared-gha/.github/actions/get-release-info@v1 + uses: hyperledger/indy-shared-gha/.github/actions/get-release-info@v2 with: versionString: "${{ github.ref }}" diff --git a/build-scripts/ubuntu-2204/Dockerfile b/build-scripts/ubuntu-2204/Dockerfile new file mode 100644 index 000000000..2c6ef0fe5 --- /dev/null +++ b/build-scripts/ubuntu-2204/Dockerfile @@ -0,0 +1,75 @@ +FROM ubuntu:22.04 + +ARG uid=1000 +ARG user=indy + +RUN apt-get update -y && apt-get install -y \ + # common stuff + git \ + wget \ + gnupg \ + apt-transport-https \ + ca-certificates \ + apt-utils + +# ======================================================================================================== +# Update repository signing keys +# -------------------------------------------------------------------------------------------------------- +# Hyperledger +RUN apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 9692C00E657DDE61 && \ + # Sovrin + apt-key adv --keyserver keyserver.ubuntu.com --recv-keys CE7709D068DB5E88 && \ + # Bionic-Security + apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 3B4FE6ACC0B21F32 +# ======================================================================================================== + +# Plenum +# - https://github.com/hyperledger/indy-plenum/issues/1546 +# - Needed to pick up rocksdb=5.8.8 +RUN echo "deb https://hyperledger.jfrog.io/artifactory/indy jammy dev" >> /etc/apt/sources.list && \ + echo "deb http://security.ubuntu.com/ubuntu bionic-security main" >> /etc/apt/sources.list && \ + echo "deb https://repo.sovrin.org/deb bionic master" >> /etc/apt/sources.list && \ + echo "deb https://repo.sovrin.org/sdk/deb bionic master" >> /etc/apt/sources.list + +# Sovrin +RUN apt-key adv --keyserver keyserver.ubuntu.com --recv-keys CE7709D068DB5E88 + +RUN apt-get update -y && apt-get install -y \ + # Python + python3-pip \ + python3-nacl \ + # rocksdb python wrapper + rocksdb=5.8.8 \ + libgflags-dev \ + libsnappy-dev \ + zlib1g-dev \ + libbz2-dev \ + liblz4-dev \ + libgflags-dev \ + # zstd is needed for caching in github actions pipeline + zstd \ + # fpm + ruby \ + ruby-dev \ + rubygems \ + gcc \ + make \ + # Indy Node and Plenum + libssl1.0.0 \ + ursa=0.3.2-1 \ + # Indy SDK + libindy=1.15.0~1625-bionic \ + # Need to move libursa.so to parent dir + && mv /usr/lib/ursa/* /usr/lib && rm -rf /usr/lib/ursa + +RUN pip3 install -U \ + # Required by setup.py + setuptools==50.3.2 \ + 'pyzmq==22.3.0' + +# install fpm +RUN gem install --no-document rake dotenv:2.8.1 fpm:1.14.2 + +RUN apt-get -y autoremove \ + && rm -rf /var/lib/apt/lists/* + diff --git a/build-scripts/ubuntu-2204/README.md b/build-scripts/ubuntu-2204/README.md new file mode 100644 index 000000000..d972042dc --- /dev/null +++ b/build-scripts/ubuntu-2204/README.md @@ -0,0 +1,30 @@ +### Build indy-node using docker + +``` +./build-indy-node-docker.sh +``` +Built package is placed in a docker volume `indy-node-deb-u1604`. + +### Build indy-node + +``` +./build-indy-node.sh +``` + +Built package is placed in the `output-path` folder. + +### Build 3rd-party dependencies using docker + +``` +./build-3rd-parties-docker.sh +``` + +Built packages are placed in a docker volume `indy-node-deb-u1604`. + +### Build 3rd-party dependencies + +``` +./build-3rd-parties-docker.sh +``` + +Built packages are placed in the `output-path` folder. diff --git a/build-scripts/ubuntu-2204/build-3rd-parties-docker.sh b/build-scripts/ubuntu-2204/build-3rd-parties-docker.sh new file mode 100755 index 000000000..1045d4035 --- /dev/null +++ b/build-scripts/ubuntu-2204/build-3rd-parties-docker.sh @@ -0,0 +1,24 @@ +#!/usr/bin/env bash + +set -x +set -e + +if [ -z "$2" ]; then + CMD="/root/build-3rd-parties.sh /output" +else + CMD="$2" +fi + +PKG_NAME=indy-node +IMAGE_NAME="${PKG_NAME}-build-u2204" +OUTPUT_VOLUME_NAME="${1:-"${PKG_NAME}-deb-u2204"}" + +docker build -t "${PKG_NAME}-build-u2204" -f Dockerfile . +docker volume create --name "${OUTPUT_VOLUME_NAME}" + +docker run \ + -i \ + --rm \ + -v "${OUTPUT_VOLUME_NAME}:/output" \ + "${IMAGE_NAME}" \ + $CMD diff --git a/build-scripts/ubuntu-2204/build-3rd-parties.sh b/build-scripts/ubuntu-2204/build-3rd-parties.sh new file mode 100755 index 000000000..b2cdee516 --- /dev/null +++ b/build-scripts/ubuntu-2204/build-3rd-parties.sh @@ -0,0 +1,94 @@ +#!/usr/bin/env bash + +set -e +set -x + +# Ensure OUTPUT_PATH is defined as a fully qualified path +pushd $(dirname $(realpath "$0")) +OUTPUT_PATH=${1:-.} +if [ ! -d "${OUTPUT_PATH}" ]; then + mkdir -p ${OUTPUT_PATH} +fi +OUTPUT_PATH=$(realpath ${OUTPUT_PATH}) +popd + +wheel2debconf="$(dirname "$(realpath "$0")")"/wheel2deb.yml + +function build_from_pypi { + PACKAGE_NAME="$1" + + if [ -z "$2" ]; then + PACKAGE_VERSION="" + # Get the most recent package version from PyPI to be included in the package name of the Debian artifact + curl -X GET "https://pypi.org/pypi/${PACKAGE_NAME}/json" > "${PACKAGE_NAME}.json" + PACKAGE_VERSION="==$(cat "${PACKAGE_NAME}.json" | jq --raw-output '.info.version')" + rm "${PACKAGE_NAME}.json" + else + PACKAGE_VERSION="==$2" + fi + POSTINST_TMP="postinst-${PACKAGE_NAME}" + PREREM_TMP="prerm-${PACKAGE_NAME}" + cp postinst "${POSTINST_TMP}" + cp prerm "${PREREM_TMP}" + sed -i "s/{package_name}/python3-${PACKAGE_NAME}/" "${POSTINST_TMP}" + sed -i "s/{package_name}/python3-${PACKAGE_NAME}/" "${PREREM_TMP}" + + fpm --input-type "python" \ + --output-type "deb" \ + --architecture "amd64" \ + --verbose \ + --python-package-name-prefix "python3"\ + --python-bin "/usr/bin/python3" \ + --exclude "*.pyc" \ + --exclude "*.pyo" \ + --maintainer "Hyperledger " \ + --after-install "${POSTINST_TMP}" \ + --before-remove "${PREREM_TMP}" \ + --package "${OUTPUT_PATH}" \ + "${PACKAGE_NAME}${PACKAGE_VERSION}" + + rm "${POSTINST_TMP}" + rm "${PREREM_TMP}" +} + +function build_from_pypi_wheel { + PACKAGE_NAME=$1 + + if [ -z $2 ]; then + PACKAGE_VERSION="" + # Get the most recent package version from PyPI to be included in the package name of the Debian artifact + curl -X GET "https://pypi.org/pypi/${PACKAGE_NAME}/json" > "${PACKAGE_NAME}.json" + PACKAGE_VERSION="==$(cat "${PACKAGE_NAME}.json" | jq --raw-output '.info.version')" + rm "${PACKAGE_NAME}.json" + else + PACKAGE_VERSION="==$2" + fi + + rm -rvf /tmp/wheel + mkdir /tmp/wheel + pushd /tmp/wheel + pip3 wheel ${PACKAGE_NAME}${PACKAGE_VERSION} + # Can't build cytoolz using wheel for rlp, but can't build rlp with fpm + rm -f /tmp/wheel/cytoolz* + wheel2deb --config ${wheel2debconf} + popd + mv /tmp/wheel/output/*.deb ${OUTPUT_PATH} + rm -rvf /tmp/wheel +} + +# Install any python requirements needed for the builds. +pip3 install wheel2deb +apt-get update -y && apt-get install -y debhelper + +# build 3rd parties: +# build_from_pypi +# TODO duplicates list from Jenkinsfile.cd + +SCRIPT_PATH="${BASH_SOURCE[0]}" +pushd `dirname ${SCRIPT_PATH}` >/dev/null + +build_from_pypi_wheel importlib-metadata 3.10.1 +build_from_pypi timeout-decorator +build_from_pypi distro 1.7.0 + +popd >/dev/null \ No newline at end of file diff --git a/build-scripts/ubuntu-2204/build-indy-node-docker.sh b/build-scripts/ubuntu-2204/build-indy-node-docker.sh new file mode 100755 index 000000000..c478e68ce --- /dev/null +++ b/build-scripts/ubuntu-2204/build-indy-node-docker.sh @@ -0,0 +1,31 @@ +#!/bin/bash -xe + +PKG_SOURCE_PATH="$1" +VERSION="$2" +PKG_NAME=indy-node +IMAGE_NAME="${PKG_NAME}-build-u2204" +OUTPUT_VOLUME_NAME="${3:-"${PKG_NAME}-deb-u2204"}" +PACKAGE_VERSION="${4:-$VERSION}" + +if [[ (-z "${PKG_SOURCE_PATH}") || (-z "${VERSION}") ]]; then + echo "Usage: $0 [ [package-version]]" + exit 1; +fi + +if [ -z "$5" ]; then + CMD="/root/build-${PKG_NAME}.sh /input ${VERSION} /output ${PACKAGE_VERSION}" +else + CMD="$5" +fi + +docker build -t "${IMAGE_NAME}" -f Dockerfile . +docker volume create --name "${OUTPUT_VOLUME_NAME}" + +docker run \ + -i \ + --rm \ + -v "${PKG_SOURCE_PATH}:/input" \ + -v "${OUTPUT_VOLUME_NAME}:/output" \ + -e PKG_NAME="${PKG_NAME}" \ + "${IMAGE_NAME}" \ + $CMD diff --git a/build-scripts/ubuntu-2204/build-indy_node.sh b/build-scripts/ubuntu-2204/build-indy_node.sh new file mode 100755 index 000000000..4bc6a0b84 --- /dev/null +++ b/build-scripts/ubuntu-2204/build-indy_node.sh @@ -0,0 +1,47 @@ +#!/bin/bash -xe + +INPUT_PATH="$1" +VERSION="$2" +OUTPUT_PATH="${3:-.}" +PACKAGE_VERSION=${4:-$VERSION} + +PACKAGE_NAME=indy-node + +# copy the sources to a temporary folder +TMP_DIR="$(mktemp -d)" +cp -r "${INPUT_PATH}/." "${TMP_DIR}" + +# prepare the sources +cd "${TMP_DIR}/build-scripts/ubuntu-2204" +./prepare-package.sh "${TMP_DIR}" indy_node "${VERSION}" debian-packages + +echo "Fetching the indy-plenum version from setup.py and converting it to deb format ..." +plenumDebVersion=$(grep -oP "indy-plenum==\d+.\d+.\d+((-|.)?(rc|dev)\d+)?" ${TMP_DIR}/setup.py | grep -oP "\d+.\d+.\d+((-|.)?(rc|dev)\d+)?" | sed 's/\./\~/3') +echo "plenumDebVersion: ${plenumDebVersion}" + +sed -i "s/{package_name}/${PACKAGE_NAME}/" "prerm" + +fpm --input-type "python" \ + --output-type "deb" \ + --architecture "amd64" \ + --verbose \ + --python-package-name-prefix "python3" \ + --python-bin "/usr/bin/python3" \ + --exclude "*.pyc" \ + --exclude "*.pyo" \ + --depends at \ + --depends iptables \ + --depends libsodium23 \ + --depends "indy-plenum(=${plenumDebVersion})" \ + --python-disable-dependency "indy-plenum" \ + --no-python-fix-dependencies \ + --maintainer "Hyperledger " \ + --before-install "preinst_node" \ + --after-install "postinst_node" \ + --before-remove "prerm" \ + --name "${PACKAGE_NAME}" \ + --version ${PACKAGE_VERSION} \ + --package "${OUTPUT_PATH}" \ + "${TMP_DIR}" + +rm -rf "${TMP_DIR}" diff --git a/build-scripts/ubuntu-2204/postinst b/build-scripts/ubuntu-2204/postinst new file mode 100644 index 000000000..bd8a31d2a --- /dev/null +++ b/build-scripts/ubuntu-2204/postinst @@ -0,0 +1,8 @@ +#!/bin/bash + +# Automatically added from template: +if which py3compile >/dev/null 2>&1; then + py3compile -O -p {package_name} /usr/local/lib/python3.10/dist-packages/ +fi + +# End automatically added section diff --git a/build-scripts/ubuntu-2204/postinst_node b/build-scripts/ubuntu-2204/postinst_node new file mode 100644 index 000000000..7274fbef8 --- /dev/null +++ b/build-scripts/ubuntu-2204/postinst_node @@ -0,0 +1,198 @@ +#!/bin/bash + +# it should be fixed +ENABLE_STDOUT_LOGGING="enableStdOutLogging" +GENERAL_CONFIG_DIR="/etc/indy" +GENERAL_DATA_DIR="/var/lib/indy" +GENERAL_LOG_DIR="/var/log/indy" + +INSTALL_DIR='/usr/local/lib/python3.10/dist-packages' + +NOFILES_SOFT_LIMIT=65536 +NOFILES_HARD_LIMIT=131072 + +CLIENT_CONNECTIONS_LIMIT=500 + + +# create general indy config folder if does not exist +mkdir -p $GENERAL_CONFIG_DIR +# create general indy data folder if does not exist +mkdir -p $GENERAL_DATA_DIR +# create general indy log folder if does not exist +mkdir -p $GENERAL_LOG_DIR + +# create indy node config if does not exist +if [ ! -f $GENERAL_CONFIG_DIR/indy_config.py ]; then + cp $INSTALL_DIR/indy_node/general_config/indy_config.py $GENERAL_CONFIG_DIR +else + if [ -z "$(grep $ENABLE_STDOUT_LOGGING $GENERAL_CONFIG_DIR/indy_config.py)" ]; then + printf "\n%s\n%s\n" "# Disable stdout logging" "$ENABLE_STDOUT_LOGGING = False" >> $GENERAL_CONFIG_DIR/indy_config.py + fi +fi + +chmod -R ug+rwx $GENERAL_CONFIG_DIR +chmod -R ug+rwx $GENERAL_DATA_DIR +chmod -R ug+rwx $GENERAL_LOG_DIR + + +# init_indy_node script +cat < /usr/local/bin/init_indy_node +#!/bin/bash + +if [ \$# -lt 5 ]; then + echo "" + echo "Usage: \$0 name ip port client_ip client_port [seed]"; + echo " name - node name"; + echo " ip - node IP"; + echo " port - node port"; + echo " client_ip - node client IP"; + echo " client_port - node client port"; + echo " seed - node seed"; + echo "" + exit 1; +fi + +echo "NODE_NAME=\$1" > $GENERAL_CONFIG_DIR/indy.env +echo "NODE_IP=\$2" >> $GENERAL_CONFIG_DIR/indy.env +echo "NODE_PORT=\$3" >> $GENERAL_CONFIG_DIR/indy.env +echo "NODE_CLIENT_IP=\$4" >> $GENERAL_CONFIG_DIR/indy.env +echo "NODE_CLIENT_PORT=\$5" >> $GENERAL_CONFIG_DIR/indy.env +echo "CLIENT_CONNECTIONS_LIMIT=$CLIENT_CONNECTIONS_LIMIT" >> $GENERAL_CONFIG_DIR/indy.env + +if [ -z \$6 ]; then + init_indy_keys --name \$1 +else + init_indy_keys --name \$1 --seed \$6 +fi +EOF + +chmod +x /usr/local/bin/init_indy_node + +# add systemd script +cat < /etc/systemd/system/indy-node.service +[Unit] +Description=Indy Node +Requires=indy-node-control.service + +[Service] +EnvironmentFile=$GENERAL_CONFIG_DIR/indy.env +ExecStart=/usr/bin/env python3 -O /usr/local/bin/start_indy_node \${NODE_NAME} \${NODE_IP} \${NODE_PORT} \${NODE_CLIENT_IP} \${NODE_CLIENT_PORT} +User=indy +Group=indy +Restart=on-failure +RestartSec=10 +StartLimitBurst=10 +StartLimitInterval=200 +TimeoutSec=300 +LimitNOFILE=$NOFILES_SOFT_LIMIT:$NOFILES_HARD_LIMIT + +[Install] +WantedBy=multi-user.target +EOF + + +cat < /etc/systemd/system/indy-node-control.service +[Unit] +Description=Service for upgrade of existing Indy Node and other operations +#Requires=indy.service +#After=indy.service +After=network.target + +[Service] +Type=simple +EnvironmentFile=$GENERAL_CONFIG_DIR/node_control.conf +ExecStart=/usr/bin/env python3 -O /usr/local/bin/start_node_control_tool \$TEST_MODE --hold-ext \${HOLD_EXT} +Restart=on-failure +RestartSec=10 +StartLimitBurst=10 +StartLimitInterval=200 +TimeoutSec=300 + +[Install] +WantedBy=multi-user.target +EOF + +# add supervisord script +cat < /etc/supervisor/indy-node.conf +[supervisord] +nodaemon=true +logfile=/var/log/indy/supervisord.log +logfile_maxbytes=10MB +loglevel=critical + +[supervisorctl] +serverurl=http://127.0.0.1:9001 + +[inet_http_server] +port = 127.0.0.1:9001 + +[rpcinterface:supervisor] +supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface + +[program:indy-node] +command=sh -ac '. $GENERAL_CONFIG_DIR/indy.env;/usr/bin/env python3 -O /usr/local/bin/start_indy_node \${NODE_NAME} \${NODE_IP} \${NODE_PORT} \${NODE_CLIENT_IP} \${NODE_CLIENT_PORT}' +user=indy +stdout_logfile=/dev/stdout +stdout_logfile_maxbytes=0 +stderr_logfile=/dev/stderr +stderr_logfile_maxbytes=0 +autorestart=true +startsecs=15 +startretries=6 +stopasgroup=true +killasgroup=true + +[program:indy-node-control] +command=sh -ac '. $GENERAL_CONFIG_DIR/node_control.conf;/usr/bin/env python3 -O /usr/local/bin/start_node_control_tool \${TEST_MODE} --hold-ext "\${HOLD_EXT}"' +stdout_logfile=/dev/stdout +stdout_logfile_maxbytes=0 +stderr_logfile=/dev/stderr +stderr_logfile_maxbytes=0 +autorestart=true +startsecs=15 +startretries=6 +stopasgroup=true +killasgroup=true +EOF + +HOLD_EXT_ADDED=$(grep HOLD_EXT /etc/indy/node_control.conf) +if [ ! -f $GENERAL_CONFIG_DIR/node_control.conf ] || [ -z "${HOLD_EXT_ADDED}" ]; then + cat < $GENERAL_CONFIG_DIR/node_control.conf +# Uncomment this to run agent in test mode: +#TEST_MODE=--test + +TEST_MODE= +HOLD_EXT= +EOF +fi +sed -ie '/HOLD_EXT/{ s/\\//g}' $GENERAL_CONFIG_DIR/node_control.conf + +mv /usr/local/bin/upgrade_indy_node_ubuntu1604.sh /usr/local/bin/upgrade_indy_node +mv /usr/local/bin/upgrade_indy_node_ubuntu1604_test.sh /usr/local/bin/upgrade_indy_node_test +mv /usr/local/bin/restart_indy_node_ubuntu1604.sh /usr/local/bin/restart_indy_node +mv /usr/local/bin/restart_sovrin_node_ubuntu1604.sh /usr/local/bin/restart_sovrin_node +mv /usr/local/bin/complete_rebranding_upgrade_ubuntu1604.sh /usr/local/bin/complete_rebranding_upgrade + +chmod +x /usr/local/bin/upgrade_indy_node +chmod +x /usr/local/bin/upgrade_indy_node_test +chmod +x /usr/local/bin/restart_indy_node +chmod +x /usr/local/bin/restart_sovrin_node +chmod +x /usr/local/bin/complete_rebranding_upgrade + +rm -f /usr/local/bin/delete_indy_node.bat /usr/local/bin/upgrade_indy_node_test.bat \ + /usr/local/bin/restart_indy_node.bat /usr/local/bin/install_nssm.bat /usr/local/bin/upgrade_indy_node.bat \ + /usr/local/bin/install_indy_node.bat /usr/local/bin/restart_upgrade_agent.bat + +chown -R indy:indy $GENERAL_CONFIG_DIR +chown -R indy:indy $GENERAL_DATA_DIR +chown -R indy:indy $GENERAL_LOG_DIR +chmod -R ug+rw $GENERAL_CONFIG_DIR +chmod -R ug+rw $GENERAL_DATA_DIR +chmod -R ug+rw $GENERAL_LOG_DIR + +# Automatically added from template: +if which py3compile >/dev/null 2>&1; then + py3compile -O -p indy-node $INSTALL_DIR +fi + +# End automatically added section diff --git a/build-scripts/ubuntu-2204/preinst_node b/build-scripts/ubuntu-2204/preinst_node new file mode 100644 index 000000000..4e1addfb6 --- /dev/null +++ b/build-scripts/ubuntu-2204/preinst_node @@ -0,0 +1,5 @@ +#!/bin/bash + +if ! id -u indy > /dev/null 2>&1; then + useradd -r -m -s /bin/bash -U indy +fi diff --git a/build-scripts/ubuntu-2204/prepare-package.sh b/build-scripts/ubuntu-2204/prepare-package.sh new file mode 100755 index 000000000..ab5aabb1b --- /dev/null +++ b/build-scripts/ubuntu-2204/prepare-package.sh @@ -0,0 +1,57 @@ +#!/bin/bash -xe + +if [ "$1" = "--help" ] ; then + echo "Usage: $0 " + echo " - Set to 'debian-packages' when preparing deb packages, and 'python-packages' when preparing PyPi packages." + exit 0 +fi + +repo="$1" +module_name="$2" +version_dotted="$3" +distro_packages="$4" + +BUMP_SH_SCRIPT="bump_version.sh" +GENERATE_MANIFEST_SCRIPT="generate_manifest.sh" + +pushd $repo + +echo -e "\nSetting version to $version_dotted" +bash -ex $BUMP_SH_SCRIPT $version_dotted +cat $module_name/__version__.json + +echo -e "\nGenerating manifest" +bash -ex $GENERATE_MANIFEST_SCRIPT +cat $module_name/__manifest__.json + +if [ "$distro_packages" = "debian-packages" ]; then + echo -e "\n\nPrepares indy-node debian package version" + sed -i -r "s~indy-node==([0-9\.]+[0-9])(\.)?([a-z]+)~indy-node==\1\~\3~" setup.py + + # Update the package names to match the names that are available on the os. + echo -e "\nAdapt the dependencies for the Canonical archive" + sed -i "s~timeout-decorator~python3-timeout-decorator~" setup.py + sed -i "s~distro~python3-distro~" setup.py + sed -i "s~importlib-metadata=~python3-importlib-metadata=~" setup.py + + echo "Preparing config files" + GENERAL_CONFIG_DIR="\/etc\/indy" + REPO_GENERAL_CONFIG_DIR="indy_node/general_config" + # Define user config directory + sed -i "s/^\(GENERAL_CONFIG_DIR\s*=\s*\).*\$/\1\"$GENERAL_CONFIG_DIR\"/" indy_common/config.py + # Create user config + cp $REPO_GENERAL_CONFIG_DIR/general_config.py $REPO_GENERAL_CONFIG_DIR/indy_config.py + cat $REPO_GENERAL_CONFIG_DIR/ubuntu_platform_config.py >> $REPO_GENERAL_CONFIG_DIR/indy_config.py + rm -f $REPO_GENERAL_CONFIG_DIR/general_config.py + rm -f $REPO_GENERAL_CONFIG_DIR/ubuntu_platform_config.py + rm -f $REPO_GENERAL_CONFIG_DIR/windows_platform_config.py +elif [ "$distro_packages" = "python-packages" ]; then + echo -e "\nNo adaption of dependencies for python packages" +else + echo -e "\nNo distribution specified. Please, specify distribution as 'debian-packages' or 'python-packages'." + exit 1 +fi + +popd + +echo -e "\nFinished preparing $repo for publishing\n" \ No newline at end of file diff --git a/build-scripts/ubuntu-2204/prerm b/build-scripts/ubuntu-2204/prerm new file mode 100644 index 000000000..40af9b22a --- /dev/null +++ b/build-scripts/ubuntu-2204/prerm @@ -0,0 +1,7 @@ +#!/bin/bash + +# Automatically added from template: + +dpkg -L {package_name} | perl -ne 's,/([^/]*)\.py$,/__pycache__/\1.*, or next; unlink $_ or die $! foreach glob($_)' + +# End automatically added section \ No newline at end of file diff --git a/build-scripts/ubuntu-2204/wheel2deb.yml b/build-scripts/ubuntu-2204/wheel2deb.yml new file mode 100644 index 000000000..667347381 --- /dev/null +++ b/build-scripts/ubuntu-2204/wheel2deb.yml @@ -0,0 +1,6 @@ +# change setting for all wheels +.: + maintainer_name: "Hyperledger" + maintainer_email: "hyperledger-indy@lists.hyperledger.org" + extended_desc: "Hyperledger package for indy-plenum" + version_template: "{upstream_version}" diff --git a/pytest.ini b/pytest.ini index 4e4756c9a..8e2b4c5a5 100644 --- a/pytest.ini +++ b/pytest.ini @@ -1,5 +1,4 @@ [pytest] -asyncio_mode = auto testpaths = indy_common indy_node \ No newline at end of file diff --git a/setup.py b/setup.py index 165ea3ace..522f7a4ef 100644 --- a/setup.py +++ b/setup.py @@ -55,9 +55,7 @@ (BASE_DIR, ['data/nssm_original.exe']) )], - # Update ./build-scripts/ubuntu-xxxx/build-3rd-parties.sh when this list gets updated. - # - Excluding changes to indy-plenum. - install_requires=['indy-plenum==1.13.1', + install_requires=['indy-plenum==1.14.0-rc0', # importlib-metadata needs to be pinned to 3.10.1 because from v4.0.0 the package # name ends in python3-importlib-metadata_0.0.0_amd64.deb # see also build-scripts/ubuntu-2004/build-3rd-parties.sh