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

Install Elastic #456

Merged
merged 23 commits into from
Nov 18, 2024
Merged

Install Elastic #456

merged 23 commits into from
Nov 18, 2024

Conversation

Gold872
Copy link
Contributor

@Gold872 Gold872 commented Oct 16, 2024

Resolves #423

scripts/elastic.gradle Outdated Show resolved Hide resolved
Co-authored-by: Gold856 <[email protected]>
files/Elastic.sh Outdated Show resolved Hide resolved
@sciencewhiz
Copy link
Contributor

sciencewhiz commented Nov 12, 2024

Elastic fails to run on macArm on macOS 15.1, possibly because it isn't notarized or another signing problem.

@sciencewhiz
Copy link
Contributor

I might have been chasing something else. After the installer is run, elastic isn't unzipped. When I manually unzip it, it runs. While I was troubleshooting, I downloaded Elastic direct from GitHub and after unzipping both the WPILib and the regular versions, they didn't run for me.

@sciencewhiz
Copy link
Contributor

To fix the extraction, it needs code in the tools updater similar to AdvantageScope

private static void installAdvantageScope(String toolsPath) {
if (SystemUtils.IS_OS_MAC) {
String arch = System.getProperty("os.arch");
boolean isArm = arch.equals("arm64") || arch.equals("aarch64");
String archiveFileName = "advantagescope-wpilib-mac-" +
(isArm ? "arm64" : "x64") +
".tar.gz";
String advantageScopeFolder = Paths.get(new File(toolsPath).getParent(), "advantagescope").toString();
Path archivePath = Paths.get(advantageScopeFolder, archiveFileName);
try {
Runtime.getRuntime().exec(new String[] {
"tar", "-xzf", archivePath.toString(), "-C", advantageScopeFolder
}).waitFor();
} catch (IOException | InterruptedException e) {
System.out.println(e.toString());
e.printStackTrace();
}
}
}

if (tool.name.equals("AdvantageScope")) {
installAdvantageScope(toolsPath);

@Gold872
Copy link
Contributor Author

Gold872 commented Nov 14, 2024

I'm looking into implementing this extraction, and I noticed that the AdvantageScope file extension for macos is a .tar.gz but Elastic is a .zip

I'm not entirely familiar with development on MacOS, is the tar.gz format required for portable apps on mac? I don't have a way of testing this on my machine.

If necessary I can change the zip format and finish up the next release within the next few days

@sciencewhiz
Copy link
Contributor

I thought that it might be a problem, but the zip extracts and runs on my Mac, so I don't think it's necessary to change to .tar.gz, although that would be a more standard for Mac and Linux.

@Gold872
Copy link
Contributor Author

Gold872 commented Nov 14, 2024

When extracting it on macos, did you have to extract it twice? I noticed that there was a zip file in the zip file

@Gold872
Copy link
Contributor Author

Gold872 commented Nov 14, 2024

I just did some playing around with the CI, turns out it was putting the zip file within another zip file when uploading. There isn't an easy way to get around it besides manually extracting it before manually uploading it to the release. I'll copy the code that AdvantageScope has for extracting and use it for this. The changes won't work until the next release which should be somewhat soon.

@sciencewhiz
Copy link
Contributor

When extracting it on macos, did you have to extract it twice?

I didn't look specifically. The gui extracted automatically, but may have handled the double zipping seamlessly.

.tar.gz is standard for Mac and Linux.

@Gold856
Copy link
Contributor

Gold856 commented Nov 14, 2024

The double zip is actually needed to ensure the bundle contents stay unchanged. If you try to upload the raw .app bundle as a GitHub Actions artifact, it will actually change permissions (and possibly some other things), which will causes the integrity checks to fail (since the contents aren't exactly the same). AdvantageScope is packaged the same way for Mac, with a double archive, one of which gets stripped during the installer build process, and then the final extraction happening on the user's computer. Elastic could stay as a zip, as long as macOS has unzip or another tool to extract zip files.

@Gold872
Copy link
Contributor Author

Gold872 commented Nov 14, 2024

I see, that explains why the double zip is needed. I'll probably keep Elastic in the tar.gz format since it seems to have more options with extractions.

The second extraction will keep failing until the next release since it's trying to find a tar.gz file that doesn't exist yet

This does raise the question though of how to sign this with the WPILib signature, since at some point during the build process it would have to be double extracted, and then zipped again. Not sure how this should be done without having it lose the signature.

@sciencewhiz
Copy link
Contributor

The changes won't work until the next release which should be somewhat soon.

How soon? WPILib is planning another beta release this weekend, and it would be very nice to get Elastic in.

@sciencewhiz
Copy link
Contributor

This does raise the question though of how to sign this with the WPILib signature, since at some point during the build process it would have to be double extracted, and then zipped again. Not sure how this should be done without having it lose the signature.

Normal extraction and compression shouldn't mess with the signature. It's just the way that Gradle does it that does.

@Gold872
Copy link
Contributor Author

Gold872 commented Nov 15, 2024

How soon? WPILib is planning another beta release this weekend, and it would be very nice to get Elastic in.

I'm just waiting for one more PR to be finished and then it'll be ready to release, so it should be ready within the next day or so.

After the release I'll just have to update the tag in versions.gradle and it should be good to go

@Gold872
Copy link
Contributor Author

Gold872 commented Nov 16, 2024

@sciencewhiz the new update + build should fix the macos extraction, let me know if there are any issues with it besides notarization

@sciencewhiz
Copy link
Contributor

It's still double compressed, a tar.gz is inside the zip, so it doesn't get successfully extracted in the ToolsUpdater

@Gold872
Copy link
Contributor Author

Gold872 commented Nov 16, 2024

It's still double compressed, a tar.gz is inside the zip, so it doesn't get successfully extracted in the ToolsUpdater

iirc isn't it supposed to be double compressed and it gets extracted twice during the installation?

@Gold872
Copy link
Contributor Author

Gold872 commented Nov 16, 2024

Looking at how advantagescope is structured with its wpilib mac release, I think I see what I was doing wrong, this should hopefully fix it

@sciencewhiz
Copy link
Contributor

It's no longer double compressed, but the tar.gz didn't get extracted

@Gold872
Copy link
Contributor Author

Gold872 commented Nov 16, 2024

That's odd, it should have the same logic as advantagescope where it gets extracted during installation

@sciencewhiz
Copy link
Contributor

It does extract on a fresh install. I think that's a problem unrelated to this PR that I've seen before

@sciencewhiz
Copy link
Contributor

sciencewhiz commented Nov 16, 2024

Windows failure is fixed by #470

@PeterJohnson PeterJohnson merged commit 02729d7 into wpilibsuite:main Nov 18, 2024
6 of 7 checks passed
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.

Bundle Elastic with installer
6 participants