Skip to content

Commit

Permalink
Merge pull request #217 from NebraLtd/shawaj/multiarch
Browse files Browse the repository at this point in the history
feat: add aarch64 version of gateway_mfr
  • Loading branch information
shawaj authored Feb 5, 2023
2 parents 6b8b324 + f1b4fe5 commit 5afb764
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 19 deletions.
27 changes: 18 additions & 9 deletions .github/workflows/publish-to-pypi-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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!"
Expand All @@ -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
Expand Down
25 changes: 17 additions & 8 deletions .github/workflows/publish-to-pypi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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!"
Expand All @@ -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: |
Expand Down
1 change: 1 addition & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
include hm_pyhelper/gateway_mfr
include hm_pyhelper/gateway_mfr_aarch64
9 changes: 8 additions & 1 deletion hm_pyhelper/miner_param.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import os
import subprocess
import json
import platform
from packaging.version import Version

from retry import retry
Expand Down Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

setup(
name='hm_pyhelper',
version='0.13.48',
version='0.13.49',
author="Nebra Ltd",
author_email="[email protected]",
description="Helium Python Helper",
Expand Down

0 comments on commit 5afb764

Please sign in to comment.