-
-
Notifications
You must be signed in to change notification settings - Fork 10.9k
Sample AppleScript implementation of quarantining #4665
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
Conversation
This fixes cask/cli/fetch double fetch tests
+ refactor into dictionary
FileUtils's copy_entry doesn't preserve extended attributes.
FileUtils's mv does the trick, at the expense of breaking lots of brew tests. Also, backing up a Cask install doesn't preserve the attributes, courtesy of FileUtils's cp_r. There are more places where the attributes are not preserved; fixes are coming later.
Non-dmg containers do not propagate the container's extended attributes when unpacking. If one checks the quarantine status when moving artifacts, these will not have the 'com.apple.quarantine' status, rendering all the efforts futile. With this commit, quarantine status is added upon download and checked after the primary container is unpacked. If the quarantine attribute is not detected in the staged path's contents, it is recovered from the downloaded file and manually applied to the unpacked contents.
As requested by @vitorgalvao, this new global flag permits to not quarantine the Cask for the current operation. Do notice that this won't have any effect in cached, quarantined downloads i.e. I don't clear the attribute if it has already been set, but I set if its previous download didn't quarantine it.
(I finally found why the audits were failing.)
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.
Can this use a custom exit code?
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.
That’s an annoying limitation of AppleScript. We can choose an error number to be displayed on stderr but we have no influence on the exit code.
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.
(My usual workaround for that is to output JSON and have that unwrapped by a shell script wrapper. I don’t feel that would be worth the effort here though.)
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.
I've updated the Swift script to just output the error message; then, we could use command.run(...).stderr.empty? instead of success? to check for errors.
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.
Yeh, outputting just the dataLocationUrl's absoluteString would be preferable, I think.
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.
Updated the script so it only outputs the error message.
With this commit, errors are signaled via: - exit code != 0 - error message in stderr This is recovered by Ruby and packed in a CaskError if it happens.
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.
Isn't it possible in AppleScript to get the NSError if this throws?
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.
I thought it wasn’t possible but now that you’ve mentioned it, I found out there’s a convoluted, poorly documented way to do it!
Updated.
This commit ports the Swift script to AppleScript according to [1]. The Swift version is preserved so both can be inspected side by side. [1]: #4656 (review)
|
Thanks for this @claui but think we're 👍 on the Swift version now. |
brew stylewith your changes locally?brew testswith your changes locally?See discussion.
Does not yet contain latest availability checks.Edit: Rebased.