From f1b4fe514cea1a3c333b40b974f88053d74e151a Mon Sep 17 00:00:00 2001 From: Aaron Shaw Date: Sun, 5 Feb 2023 17:45:56 +0000 Subject: [PATCH] feat: add aarch64 version of gateway_mfr - add aarch64 version - bump to 0.13.49 Closes: #215 --- .github/workflows/publish-to-pypi-test.yml | 27 ++++++++++++++-------- .github/workflows/publish-to-pypi.yml | 25 +++++++++++++------- MANIFEST.in | 1 + hm_pyhelper/miner_param.py | 9 +++++++- setup.py | 2 +- 5 files changed, 45 insertions(+), 19 deletions(-) diff --git a/.github/workflows/publish-to-pypi-test.yml b/.github/workflows/publish-to-pypi-test.yml index 708f719..22ffb66 100644 --- a/.github/workflows/publish-to-pypi-test.yml +++ b/.github/workflows/publish-to-pypi-test.yml @@ -21,14 +21,21 @@ jobs: run: | wget "https://github.com/helium/gateway-mfr-rs/releases/download/${GATEWAY_MFR_RS_RELEASE}/gateway-mfr-${GATEWAY_MFR_RS_RELEASE}-arm-unknown-linux-gnueabihf-ecc608.tar.gz" wget "https://github.com/helium/gateway-mfr-rs/releases/download/${GATEWAY_MFR_RS_RELEASE}/gateway-mfr-${GATEWAY_MFR_RS_RELEASE}-arm-unknown-linux-gnueabihf-ecc608.checksum" - SHA256=$( shasum -a 256 "gateway-mfr-${GATEWAY_MFR_RS_RELEASE}-arm-unknown-linux-gnueabihf-ecc608.tar.gz" | awk '{print $1}') - echo "Generated checksum: ${SHA256}" + wget "https://github.com/helium/gateway-mfr-rs/releases/download/${GATEWAY_MFR_RS_RELEASE}/gateway-mfr-${GATEWAY_MFR_RS_RELEASE}-aarch64-unknown-linux-gnu-ecc608.tar.gz" + wget "https://github.com/helium/gateway-mfr-rs/releases/download/${GATEWAY_MFR_RS_RELEASE}/gateway-mfr-${GATEWAY_MFR_RS_RELEASE}-aarch64-unknown-linux-gnu-ecc608.checksum" + SHA256_ARM=$( shasum -a 256 "gateway-mfr-${GATEWAY_MFR_RS_RELEASE}-arm-unknown-linux-gnueabihf-ecc608.tar.gz" | awk '{print $1}') + SHA256_AARCH64=$( shasum -a 256 "gateway-mfr-${GATEWAY_MFR_RS_RELEASE}-aarch64-unknown-linux-gnu-ecc608.tar.gz" | awk '{print $1}') + echo "Generated checksum ARM: ${SHA256_ARM}" + echo "Generated checksum AARCH64: ${SHA256_AARCH64}" - # Verify the checksum - if grep -q "${SHA256}" "gateway-mfr-${GATEWAY_MFR_RS_RELEASE}-arm-unknown-linux-gnueabihf-ecc608.checksum"; then + # Verify the checksums + if grep -q "${SHA256_ARM}" "gateway-mfr-${GATEWAY_MFR_RS_RELEASE}-arm-unknown-linux-gnueabihf-ecc608.checksum" && grep -q "${SHA256_AARCH64}" "gateway-mfr-${GATEWAY_MFR_RS_RELEASE}-aarch64-unknown-linux-gnu-ecc608.checksum"; then echo "Checksum verified for gateway_mfr. Unpacking tarball..." - # Unpack the tarball + # Unpack the tarballs tar -xvf "gateway-mfr-${GATEWAY_MFR_RS_RELEASE}-arm-unknown-linux-gnueabihf-ecc608.tar.gz" + mv gateway_mfr gateway_mfr_arm + tar -xvf "gateway-mfr-${GATEWAY_MFR_RS_RELEASE}-aarch64-unknown-linux-gnu-ecc608.tar.gz" + mv gateway_mfr gateway_mfr_aarch64 exit 0 else echo "Checksum does not match. Please check download manually and rerun!" @@ -37,12 +44,14 @@ jobs: - name: Change permissions on gateway_mfr run: | - chmod +x gateway_mfr - + chmod +x gateway_mfr_arm + chmod +x gateway_mfr_aarch64 + - name: Move gateway_mfr in place run: | - mv gateway_mfr hm_pyhelper/ - + mv gateway_mfr_arm hm_pyhelper/gateway_mfr + mv gateway_mfr_aarch64 hm_pyhelper/gateway_mfr_aarch64 + - name: Install pypa/build run: | python -m pip install build --user diff --git a/.github/workflows/publish-to-pypi.yml b/.github/workflows/publish-to-pypi.yml index 345b257..48d2c12 100644 --- a/.github/workflows/publish-to-pypi.yml +++ b/.github/workflows/publish-to-pypi.yml @@ -24,14 +24,21 @@ jobs: run: | wget "https://github.com/helium/gateway-mfr-rs/releases/download/${GATEWAY_MFR_RS_RELEASE}/gateway-mfr-${GATEWAY_MFR_RS_RELEASE}-arm-unknown-linux-gnueabihf-ecc608.tar.gz" wget "https://github.com/helium/gateway-mfr-rs/releases/download/${GATEWAY_MFR_RS_RELEASE}/gateway-mfr-${GATEWAY_MFR_RS_RELEASE}-arm-unknown-linux-gnueabihf-ecc608.checksum" - SHA256=$( shasum -a 256 "gateway-mfr-${GATEWAY_MFR_RS_RELEASE}-arm-unknown-linux-gnueabihf-ecc608.tar.gz" | awk '{print $1}') - echo "Generated checksum: ${SHA256}" - - # Verify the checksum - if grep -q "${SHA256}" "gateway-mfr-${GATEWAY_MFR_RS_RELEASE}-arm-unknown-linux-gnueabihf-ecc608.checksum"; then + wget "https://github.com/helium/gateway-mfr-rs/releases/download/${GATEWAY_MFR_RS_RELEASE}/gateway-mfr-${GATEWAY_MFR_RS_RELEASE}-aarch64-unknown-linux-gnu-ecc608.tar.gz" + wget "https://github.com/helium/gateway-mfr-rs/releases/download/${GATEWAY_MFR_RS_RELEASE}/gateway-mfr-${GATEWAY_MFR_RS_RELEASE}-aarch64-unknown-linux-gnu-ecc608.checksum" + SHA256_ARM=$( shasum -a 256 "gateway-mfr-${GATEWAY_MFR_RS_RELEASE}-arm-unknown-linux-gnueabihf-ecc608.tar.gz" | awk '{print $1}') + SHA256_AARCH64=$( shasum -a 256 "gateway-mfr-${GATEWAY_MFR_RS_RELEASE}-aarch64-unknown-linux-gnu-ecc608.tar.gz" | awk '{print $1}') + echo "Generated checksum ARM: ${SHA256_ARM}" + echo "Generated checksum AARCH64: ${SHA256_AARCH64}" + + # Verify the checksums + if grep -q "${SHA256_ARM}" "gateway-mfr-${GATEWAY_MFR_RS_RELEASE}-arm-unknown-linux-gnueabihf-ecc608.checksum" && grep -q "${SHA256_AARCH64}" "gateway-mfr-${GATEWAY_MFR_RS_RELEASE}-aarch64-unknown-linux-gnu-ecc608.checksum"; then echo "Checksum verified for gateway_mfr. Unpacking tarball..." - # Unpack the tarball + # Unpack the tarballs tar -xvf "gateway-mfr-${GATEWAY_MFR_RS_RELEASE}-arm-unknown-linux-gnueabihf-ecc608.tar.gz" + mv gateway_mfr gateway_mfr_arm + tar -xvf "gateway-mfr-${GATEWAY_MFR_RS_RELEASE}-aarch64-unknown-linux-gnu-ecc608.tar.gz" + mv gateway_mfr gateway_mfr_aarch64 exit 0 else echo "Checksum does not match. Please check download manually and rerun!" @@ -40,11 +47,13 @@ jobs: - name: Change permissions on gateway_mfr run: | - chmod +x gateway_mfr + chmod +x gateway_mfr_arm + chmod +x gateway_mfr_aarch64 - name: Move gateway_mfr in place run: | - mv gateway_mfr hm_pyhelper/ + mv gateway_mfr_arm hm_pyhelper/gateway_mfr + mv gateway_mfr_aarch64 hm_pyhelper/gateway_mfr_aarch64 - name: Install pypa/build run: | diff --git a/MANIFEST.in b/MANIFEST.in index e2fe4f4..b231fdb 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -1 +1,2 @@ include hm_pyhelper/gateway_mfr +include hm_pyhelper/gateway_mfr_aarch64 diff --git a/hm_pyhelper/miner_param.py b/hm_pyhelper/miner_param.py index df2ed77..8ab4106 100644 --- a/hm_pyhelper/miner_param.py +++ b/hm_pyhelper/miner_param.py @@ -1,6 +1,7 @@ import os import subprocess import json +import platform from packaging.version import Version from retry import retry @@ -68,7 +69,13 @@ def run_gateway_mfr(sub_command: str, slot: int = 0) -> dict: def get_gateway_mfr_path() -> str: direct_path = os.path.dirname(os.path.abspath(__file__)) - return os.path.join(direct_path, 'gateway_mfr') + machine = platform.machine() + + if 'aarch64' in machine: + gateway_mfr_path = os.path.join(direct_path, 'gateway_mfr_aarch64') + else: + gateway_mfr_path = os.path.join(direct_path, 'gateway_mfr') + return gateway_mfr_path def get_gateway_mfr_version() -> Version: diff --git a/setup.py b/setup.py index 0dc9ca2..bc0bab0 100644 --- a/setup.py +++ b/setup.py @@ -3,7 +3,7 @@ setup( name='hm_pyhelper', - version='0.13.48', + version='0.13.49', author="Nebra Ltd", author_email="support@nebra.com", description="Helium Python Helper",