Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@claui
Copy link
Contributor

@claui claui commented Aug 12, 2018

  • Have you followed the guidelines in our Contributing document?
  • Have you checked to ensure there aren't other open Pull Requests for the same change? See discussion
  • Have you added an explanation of what your changes do and why you'd like us to include them?
  • Have you written new tests for your changes? Here's an example. amyspark has
  • Have you successfully run brew style with your changes locally?
  • Have you successfully run brew tests with your changes locally?

See discussion.

Does not yet contain latest availability checks. Edit: Rebased.

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.)
@ghost ghost assigned claui Aug 12, 2018
@ghost ghost added the in progress Maintainers are working on this label Aug 12, 2018
Copy link
Member

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?

Copy link
Contributor Author

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.

Copy link
Contributor Author

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.)

Copy link
Contributor

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.

Copy link
Member

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.

Copy link
Contributor Author

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.
Copy link
Contributor

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?

Copy link
Contributor Author

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)
@MikeMcQuaid
Copy link
Member

Thanks for this @claui but think we're 👍 on the Swift version now.

@ghost ghost removed the in progress Maintainers are working on this label Aug 27, 2018
@claui claui deleted the com-apple-quarantine-applescript branch August 27, 2018 09:35
@lock lock bot added the outdated PR was locked due to age label Sep 26, 2018
@lock lock bot locked as resolved and limited conversation to collaborators Sep 26, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

outdated PR was locked due to age

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants