Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Download suitable runtime from GitHub automatically #22

Merged
merged 3 commits into from
Jul 7, 2023

Conversation

TheAssassin
Copy link
Member

We no longer ship any runtimes with the AppImage, but just download the latest continuous release.

TODO: download latest released runtime, and allow users to specify the release they want to download a runtime for. (We need to parse the GitHub API to find the latest release; the latter variant just skips that step and replaces one component in the URL.)

Fixes #11.

We no longer ship any runtimes with the AppImage, but just download the latest continuous release.

TODO: download latest *released* runtime, and allow users to specify the release they want to download a runtime for. (We need to parse the GitHub API to find the latest release; the latter variant just skips that step and replaces one component in the URL.)
@TheAssassin TheAssassin requested a review from probonopd July 6, 2023 13:59
Copy link
Member

@probonopd probonopd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where does libcurl look for certificates? (This might be a showstopper, since every Linux distribution thinks it needs to invent new paths for them.)

src/appimagetool_fetch_runtime.c Show resolved Hide resolved
curl_global_init(CURL_GLOBAL_ALL);

char* url = NULL;
int url_size = asprintf(&url, "https://github.com/AppImage/type2-runtime/releases/download/continuous/runtime-%s", arch);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need to use free on the memory allocated by asprintf?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

True. I'll use a stack buffer. The URL is pretty short, after all.

return false;
}

curl_easy_setopt(handle, CURLOPT_URL, url);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't we check the return values of curl_easy_setopt calls?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could (and maybe should), but I don't expect any issues with this code. Even their docs suggest to use these options like this. We could improve on this later. Also, we have a perspective on replacing all of this with a more user friendly C++ interface to libcurl.

src/appimagetool_fetch_runtime.c Outdated Show resolved Hide resolved
src/appimagetool_fetch_runtime.c Show resolved Hide resolved
src/appimagetool_fetch_runtime.c Outdated Show resolved Hide resolved
@probonopd
Copy link
Member

Before merging, let's at least try this on Debian, Alpine, openSUSE, Alma Linux to get an understanding on whether the certificates stuff works.

@TheAssassin
Copy link
Member Author

It obviously works on Alpine, I already told you Ubuntu works (thus Debian will work, too). Please feel free to run the remaining tests while I fix the code.

@TheAssassin
Copy link
Member Author

Also, as suggested on IRC, we can always optimize on this later on. We should open an issue for a custom certificate chain lookup if need be. We can get inspiration from some related issues.

@TheAssassin TheAssassin merged commit 7a10b89 into main Jul 7, 2023
@TheAssassin TheAssassin deleted the download-runtime branch July 7, 2023 12:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Automatically download suitable runtime
2 participants