Add early binary download support; Rename download vars

This commit is contained in:
Taylor Helsper 2022-09-12 00:01:20 -05:00
parent 8d1fb8f753
commit 66e4a0a02f
4 changed files with 39 additions and 14 deletions

View File

@ -10,7 +10,7 @@
],
"latest_version": "v1.3.1",
"linux_user": "lndg",
"targz_download_url": "https://github.com/cryptosharks131/lndg/archive/refs/tags/{VERSION}.tar.gz",
"download_source_url": "https://github.com/cryptosharks131/lndg/archive/refs/tags/{VERSION}.tar.gz",
"install_env_vars": {"var1":"val2", "var2": "val2"},
"http_port": "8889",
"https_port": "8890",

View File

@ -16,8 +16,9 @@
],
"latest_version": "v1.30.0",
"linux_user": "root",
"targz_download_url": "https://github.com/FILL_IN_GITHUB_USER/FILL_IN_GITHUB_PROJECT/archive/refs/tags/{VERSION}.tar.gz",
"skip_targz_download": true,
"download_skip": true,
"download_type": "source",
"download_source_url": "https://github.com/FILL_IN_GITHUB_USER/FILL_IN_GITHUB_PROJECT/archive/refs/tags/{VERSION}.tar.gz",
"install_env_vars": {},
"supports_app_page": true,
"supports_testnet": true,
@ -54,5 +55,5 @@
"homepage_section": "remote_services",
"homepage_order": 4,
"app_type": "custom",
"sdk_version": 1
"sdk_version": 2
}

View File

@ -16,7 +16,8 @@
],
"linux_user": "wetty",
"latest_version": "v2.4.2",
"targz_download_url": "https://github.com/butlerx/wetty/archive/refs/tags/{VERSION}.tar.gz",
"download_type": "source",
"download_source_url": "https://github.com/butlerx/wetty/archive/refs/tags/{VERSION}.tar.gz",
"install_env_vars": {},
"supports_app_page": true,
"supports_testnet": true,
@ -53,5 +54,5 @@
"homepage_section": "apps",
"homepage_order": 92,
"app_type": "custom",
"sdk_version": 1
"sdk_version": 2
}

View File

@ -160,8 +160,11 @@ def initialize_application_defaults(app):
if not "screenshots" in app: app["screenshots"] = get_app_screenshots( app["short_name"] )
if not "app_tile_name" in app: app["app_tile_name"] = app["name"]
if not "linux_user" in app: app["linux_user"] = "bitcoin"
if not "skip_targz_download" in app: app["skip_targz_download"] = False
if not "targz_download_url" in app: app["targz_download_url"] = "not_specified"
if not "supported_archs" in app: app["supported_archs"] = None
if not "download_skip" in app: app["download_skip"] = False
if not "download_type" in app: app["download_type"] = "source" # source or binary
if not "download_source_url" in app: app["download_source_url"] = "not_specified"
if not "download_binary_url" in app: app["download_binary_url"] = {} # Expected to be dictionary of "arch" : "url"
app["install_folder"] = "/opt/mynode/{}".format(app["short_name"])
app["storage_folder"] = "/mnt/hdd/mynode/{}".format(app["short_name"])
if not "install_env_vars" in app: app["install_env_vars"] = []
@ -206,7 +209,9 @@ def initialize_application_defaults(app):
if not "app_page_content" in app: app["app_page_content"] = []
# Update fields that may use variables that need replacing, like {VERSION}, {SHORT_NAME}, etc...
app["targz_download_url"] = replace_app_info_variables(app, app["targz_download_url"])
app["download_source_url"] = replace_app_info_variables(app, app["download_source_url"])
for arch in app["download_binary_url"]:
app["download_binary_url"][arch] = replace_app_info_variables(app, app["download_binary_url"][arch])
app["app_tile_button_onclick"] = replace_app_info_variables(app, app["app_tile_button_onclick"])
for btn in app["app_page_additional_buttons"]:
if "onclick" in btn:
@ -613,11 +618,29 @@ def install_application_tarball(app_data):
run_linux_cmd("chmod -R 777 /tmp/mynode_dynamic_app_extract")
# Download and extract
if not app_data["skip_targz_download"]:
if "targz_download_url" not in app_data:
log_message(" APP MISSING TARGZ DOWNLOAD URL")
raise ValueError("APP MISSING TARGZ DOWNLOAD URL")
run_linux_cmd("wget -O /tmp/mynode_dynamic_app_download/app.tar.gz {}".format(app_data["targz_download_url"]))
if not app_data["download_skip"]:
download_url = "not_specified"
if app_data["download_type"] == "source" and "download_source_url" == None:
log_message(" APP MISSING SOURCE DOWNLOAD URL")
raise ValueError("APP MISSING SOURCE DOWNLOAD URL")
if app_data["download_type"] == "binary" and "download_binary_url" == None:
log_message(" APP MISSING BINARY DOWNLOAD URL")
raise ValueError("APP MISSING BINARY DOWNLOAD URL")
if app_data["download_type"] == "source":
download_url = app_data["download_source_url"]
elif app_data["download_type"] == "binary":
found = False
for arch in app_data["download_binary_url"]:
if arch == get_device_arch():
download_url = app_data["download_binary_url"][arch]
if not found:
log_message(" CANNOT FIND BINARY URL FOR APP: {} CURRENT ARCH: {}".format(app_data["short_name"], get_device_arch()))
else:
log_message(" UNKNOWN download_type {}".format(app_data["download_type"]))
raise ValueError(" UNKNOWN download_type {}".format(app_data["download_type"]))
run_linux_cmd("wget -O /tmp/mynode_dynamic_app_download/app.tar.gz {}".format(download_url))
time.sleep(1)
run_linux_cmd("sync")
run_linux_cmd("sudo -u {} tar -xvf /tmp/mynode_dynamic_app_download/app.tar.gz -C /tmp/mynode_dynamic_app_extract/".format(app_data["linux_user"]))