Skip to content

Commit

Permalink
feat(installer): Get installer to handle multi-platform binaries [DEV…
Browse files Browse the repository at this point in the history
…-1667] (#376)

* Add support for determining the correct Github Release asset based on OS type and architecture
* Set recommended Docker image version

Signed-off-by: Andrew Nikitin <andrew.nikitin@evernym.com>
Co-authored-by: Andrew Nikitin <andrew.nikitin@evernym.com>
  • Loading branch information
ankurdotb and Andrew Nikitin committed Aug 22, 2022
1 parent 4971c01 commit 716c816
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 8 deletions.
6 changes: 3 additions & 3 deletions docker/persistent-chains/docker-compose.env
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@
CHEQD_NETWORK="mainnet"

# Define cheqd-noded software release version
# Current MAINNET recommended version: 0.6.5
# Current TESTNET recommended version: 0.6.5
DOCKER_IMAGE_VERSION="0.6.5"
# Current MAINNET recommended version: 0.6.7
# Current TESTNET recommended version: 0.6.7
DOCKER_IMAGE_VERSION="0.6.7"


###############################################################
Expand Down
18 changes: 13 additions & 5 deletions installer/installer.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,13 @@ def __init__(self, release_map):

def get_release_url(self):
try:
release_urls = [ a['browser_download_url'] for a in self.assets if (a['browser_download_url'].find("cheqd-node") > 0 and a['browser_download_url'].find(".deb")) == -1]
if len(release_urls) > 0:
return release_urls[0]
os_arch = platform.machine()
os_name = platform.system()
for _url_item in self.assets:
_url = _url_item["browser_download_url"]
if os.path.basename(_url) == f"cheqd-noded-{self.version}-{os_name}-{os_arch}.tar.gz" or \
os.path.basename(_url) == "cheqd-noded":
return _url
else:
failure_exit(f"No asset found to download for release: {self.version}")
except:
Expand Down Expand Up @@ -244,8 +248,8 @@ def get_binary(self):
fname = os.path.basename(binary_url)
try:
self.exec(f"wget -c {binary_url}")
if fname.find(".tar.lz4") != -1:
self.exec(f"tar -I -xf {fname}")
if fname.find(".tar.gz") != -1:
self.exec(f"tar -xzf {fname} -C . --strip-components=1")
self.remove_safe(fname)
self.exec(f"chmod +x {DEFAULT_BINARY_NAME}")
except:
Expand Down Expand Up @@ -409,6 +413,7 @@ def install(self):
self.log("Downloading snapshot and extracting archive. This can take a *really* long time...")
self.download_snapshot()
self.untar_from_snapshot()
self.print_success()

def post_install(self):
# Init the node with provided moniker
Expand Down Expand Up @@ -583,6 +588,9 @@ def untar_from_snapshot(self):
self.exec(f"chown -R {DEFAULT_CHEQD_USER}:{DEFAULT_CHEQD_USER} {self.cheqd_data_dir}")
except:
failure_exit(f"Failed to extract snapshot")

def print_success(self):
self.log("The cheqd-noded has been successfully installed")


class Interviewer:
Expand Down

0 comments on commit 716c816

Please sign in to comment.