-
Notifications
You must be signed in to change notification settings - Fork 33
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
#451: mac gatekeeper #453
Draft
hohwille
wants to merge
7
commits into
devonfw:main
Choose a base branch
from
hohwille:feature/451-mac-gatekeeper
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
#451: mac gatekeeper #453
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
9629ab4
#451: fixes and improvements for installation
hohwille a3c7fe9
code-style cleanup
hohwille 124a804
#451: improve version resolution and error handling
hohwille 52daa78
#451: fixed EditionSetCommandletTest
hohwille b8ff8f1
Merge branch 'main' into feature/451-mac-gatekeeper
hohwille 054fb05
Merge branch 'main' into feature/451-mac-gatekeeper
jan-vcapgemini a6cbea6
#451: fixed merge issues
jan-vcapgemini File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,6 +9,7 @@ | |
import java.util.Set; | ||
|
||
import com.devonfw.tools.ide.common.Tag; | ||
import com.devonfw.tools.ide.context.AbstractIdeContext; | ||
import com.devonfw.tools.ide.context.IdeContext; | ||
import com.devonfw.tools.ide.io.FileAccess; | ||
import com.devonfw.tools.ide.io.FileCopyMode; | ||
|
@@ -73,16 +74,17 @@ protected boolean doInstall(boolean silent) { | |
VersionIdentifier installedVersion = getInstalledVersion(); | ||
Step step = this.context.newStep(silent, "Install " + this.tool, configuredVersion); | ||
try { | ||
// install configured version of our tool in the software repository if not already installed | ||
ToolInstallation installation = installInRepo(configuredVersion); | ||
// check if we already have this version installed (linked) locally in IDE_HOME/software | ||
VersionIdentifier resolvedVersion = installation.resolvedVersion(); | ||
if (resolvedVersion.equals(installedVersion) && !installation.newInstallation()) { | ||
ToolRepository repository = this.context.getDefaultToolRepository(); | ||
String edition = getConfiguredEdition(); | ||
VersionIdentifier resolvedVersion = repository.resolveVersion(this.tool, edition, configuredVersion); | ||
if (resolvedVersion.equals(installedVersion)) { | ||
IdeLogLevel level = silent ? IdeLogLevel.DEBUG : IdeLogLevel.INFO; | ||
this.context.level(level).log("Version {} of tool {} is already installed", installedVersion, getToolWithEdition()); | ||
step.success(); | ||
return false; | ||
} | ||
// install configured version of our tool in the software repository if not already installed | ||
ToolInstallation installation = installInRepo(resolvedVersion, edition, repository); | ||
// we need to link the version or update the link. | ||
Path toolPath = getToolPath(); | ||
FileAccess fileAccess = this.context.getFileAccess(); | ||
|
@@ -158,17 +160,20 @@ public ToolInstallation installInRepo(VersionIdentifier version, String edition, | |
FileAccess fileAccess = this.context.getFileAccess(); | ||
if (Files.isDirectory(toolPath)) { | ||
if (Files.exists(toolVersionFile)) { | ||
if (this.context.isForceMode()) { | ||
fileAccess.delete(toolPath); | ||
} else { | ||
this.context.debug("Version {} of tool {} is already installed at {}", resolvedVersion, getToolWithEdition(this.tool, edition), toolPath); | ||
return createToolInstallation(toolPath, resolvedVersion, toolVersionFile); | ||
} | ||
this.context.debug("Version {} of tool {} is already installed at {}", resolvedVersion, getToolWithEdition(this.tool, edition), toolPath); | ||
return createToolInstallation(toolPath, resolvedVersion, toolVersionFile); | ||
} else { | ||
this.context.warning("Deleting corrupted installation at {}", toolPath); | ||
fileAccess.delete(toolPath); | ||
this.context.warning("Archiving corrupted installation at {}", toolPath); | ||
fileAccess.backup(toolPath); | ||
} | ||
} | ||
|
||
if (Files.exists(this.dependency.getDependencyJsonPath(getConfiguredEdition()))) { | ||
installDependencies(resolvedVersion); | ||
} else { | ||
this.context.trace("No Dependencies file found"); | ||
} | ||
|
||
Path target = toolRepository.download(this.tool, edition, resolvedVersion); | ||
fileAccess.mkdirs(toolPath.getParent()); | ||
boolean extract = isExtract(); | ||
|
@@ -291,13 +296,39 @@ private ToolInstallation createToolInstallation(Path rootDir, VersionIdentifier | |
if (Files.isDirectory(binFolder)) { | ||
binDir = binFolder; | ||
} | ||
if (linkDir != rootDir) { | ||
if (newInstallation && (linkDir != rootDir)) { | ||
assert (!linkDir.equals(rootDir)); | ||
this.context.getFileAccess().copy(toolVersionFile, linkDir, FileCopyMode.COPY_FILE_OVERRIDE); | ||
if (this.context.getSystemInfo().isMac() && !((AbstractIdeContext) this.context).isTest()) { | ||
Path macApp = findMacApp(linkDir); | ||
if (macApp != null) { | ||
ProcessContext pc = this.context.newProcess(); | ||
pc.executable("sudo").addArgs("xattr", "-d", "com.apple.quarantine", macApp); | ||
pc.run(); | ||
} | ||
} | ||
} | ||
return new ToolInstallation(rootDir, linkDir, binDir, resolvedVersion, newInstallation); | ||
} | ||
|
||
private Path findMacApp(Path path) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Couldn't this be moved to the |
||
|
||
while (path != null) { | ||
Path fileName = path.getFileName(); | ||
if (fileName == null) { | ||
return null; | ||
} | ||
String filename = fileName.toString(); | ||
if (filename.endsWith(".app")) { | ||
return path; | ||
} else if (filename.equals(IdeContext.FOLDER_CONTENTS)) { | ||
return path.getParent(); | ||
} | ||
path = path.getParent(); | ||
} | ||
return null; | ||
} | ||
|
||
private ToolInstallation createToolInstallation(Path rootDir, VersionIdentifier resolvedVersion, Path toolVersionFile) { | ||
|
||
return createToolInstallation(rootDir, resolvedVersion, toolVersionFile, false); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
cli/src/test/resources/ide-projects/basic/_ide/urls/docker/docker/latest/mac_arm64.urls
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
https://desktop.docker.com/mac/main/arm64/Docker.dmg |
1 change: 1 addition & 0 deletions
1
cli/src/test/resources/ide-projects/basic/_ide/urls/docker/docker/latest/mac_x64.urls
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
https://desktop.docker.com/mac/main/amd64/Docker.dmg |
1 change: 1 addition & 0 deletions
1
cli/src/test/resources/ide-projects/basic/_ide/urls/docker/docker/latest/windows_x64.urls
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
https://desktop.docker.com/win/main/amd64/Docker%20Desktop%20Installer.exe |
1 change: 1 addition & 0 deletions
1
cli/src/test/resources/ide-projects/basic/_ide/urls/docker/rancher/1.14.2/linux_x64.urls
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
https://github.com/rancher-sandbox/rancher-desktop/releases/download/v1.14.2/rancher-desktop-linux-v1.14.2.zip |
1 change: 1 addition & 0 deletions
1
...c/test/resources/ide-projects/basic/_ide/urls/docker/rancher/1.14.2/linux_x64.urls.sha256
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
2d304d3fe0dbf5efe987c2d583feeb607ce9ef507753fcf0a6b1a6b9b2128d1e |
1 change: 1 addition & 0 deletions
1
cli/src/test/resources/ide-projects/basic/_ide/urls/docker/rancher/1.14.2/mac_arm64.urls
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
https://github.com/rancher-sandbox/rancher-desktop/releases/download/v1.14.2/Rancher.Desktop-1.14.2-mac.aarch64.zip |
1 change: 1 addition & 0 deletions
1
...c/test/resources/ide-projects/basic/_ide/urls/docker/rancher/1.14.2/mac_arm64.urls.sha256
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
0ce7cf58fecbf4ea99541f51401f95ba70053b390b51ae98b16265d1a450a517 |
1 change: 1 addition & 0 deletions
1
cli/src/test/resources/ide-projects/basic/_ide/urls/docker/rancher/1.14.2/mac_x64.urls
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
https://github.com/rancher-sandbox/rancher-desktop/releases/download/v1.14.2/Rancher.Desktop-1.14.2.x86_64.dmg |
1 change: 1 addition & 0 deletions
1
...src/test/resources/ide-projects/basic/_ide/urls/docker/rancher/1.14.2/mac_x64.urls.sha256
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
e764e335d1475f8bceb3fb6d1d1892b09d3c2bee3f34355ddab8a7e157c87452 |
1 change: 1 addition & 0 deletions
1
cli/src/test/resources/ide-projects/basic/_ide/urls/docker/rancher/1.14.2/windows_x64.urls
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
https://github.com/rancher-sandbox/rancher-desktop/releases/download/v1.14.2/Rancher.Desktop.Setup.1.14.2.msi |
1 change: 1 addition & 0 deletions
1
...test/resources/ide-projects/basic/_ide/urls/docker/rancher/1.14.2/windows_x64.urls.sha256
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
01f52b7a1ebcddeda01b6979ce3505b895fdcde2c5b57f18e4f8c4a593618f3f |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe move to
MacOsHelper
class?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Major problem is that this approach does not yet work. Maybe we need to do this for all files recursively. Still looking for a better solution to the problem. After all MacOS Settings will do some magic and there should be some command to automate this "magic".
But I fully aggree that this should go to
MacOsHelper
following SoC.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is no documentation from Apple about such features. Maybe this meta-attribute needs to be set on the executable(s) rather than on the
*.all
folder. We would need more analysis on this to come up with a real solution.I will change this PR back to draft to make this clear.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We would actually need somebody to analyze this on a real mac with Gatekeeper and try various such
xattr
commands for different folders and files until we know what does the magic trick.Additionally someone must implement #415
Only after both things are addressed, we can actually implement/finish this #451 story.