Opened 6 years ago

Closed 6 years ago

Last modified 6 years ago

#20119 closed enhancement (fixed)

More typical dmg for Mac distribution

Reported by: mgoerner Owned by:
Priority: major Milestone: sage-7.1
Component: porting Keywords:
Cc: mgoerner, kcrisman, iandrus, vbraun Merged in:
Authors: Matthias Goerner Reviewers: Volker Braun
Report Upstream: N/A Work issues:
Branch: 7b66c50 (Commits, GitHub, GitLab) Commit:
Dependencies: Stopgaps:

Status badges

Description

Most Mac applications come in a dmg with an arrow pointing to a symlink of Applications. I have taken one of the dmg's and added the necessary files to make this work:

http://unhyperbolic.org/macSage/screenshot.png

http://unhyperbolic.org/macSage/

Could we change the sage Mac distribution to be like that?

All that is necessary is copying two files (.DT_store and .background/background.png) to the directory from which the dmg is created by hditutil in local/bin/sage-bdist.

I got the background image above from the Apache project, we should probably design one for sage, for some inspiration, here is the FireFox? one: http://i.stack.imgur.com/joTDs.png

Change History (26)

comment:1 follow-up: Changed 6 years ago by mgoerner

I left out some fine print when I said "all the is necessary". It is not quiet as easy, but solvable!

The problem is that the volume name in the dmg we are creating is changing since it contains the sage version number. And the .DT_store doesn't save a relative path to the background image but a pair (volume name, absolute path within volume), so we need to update the .DT_store for every release.

Luckily, there are pure python tools to update the .DT_store file such as ds_store and mac_alias so that we can create a .DT_store file by hand once in finder and then do the update programmatically for subsequent releases or flavors.

dmg-builder for example does that here

We can write a little python script invoked by local/bin/sage-bdist to use the above libraries to:

  • ds_store.DSStore.open the file
  • get the value at the key [ '.' ][ 'icvp' ][ 'backgroundImageAlias' ]
  • deserialize to a mac_alias.Alias object
  • change the volume name in that object's volume info
  • write it all back

mac_alias seems to use Mac OS X specific API, so we might need to use the system's python for that.

One question I have if I were to implement it: this would mean that the dmg build process becomes dependent on the above packages ds_store and mac_alias, where should these be installed?

comment:2 Changed 6 years ago by mgoerner

And another suggestion about the Mac App: I think we should add a symlink into the Sage-VERSION.app folder sage -> Contents/Resources?/sage/sage so that people who have the app installed but for some reason need to use it from the command line do not need to descend down Contents/Resources?.

comment:3 in reply to: ↑ 1 Changed 6 years ago by kcrisman

  • Cc vbraun added

One question I have if I were to implement it: this would mean that the dmg build process becomes dependent on the above packages ds_store and mac_alias, where should these be installed?

Hmm, that might not be something easy to deal with, since usually we like "batteries included" including for anyone to build. But maybe the release manager would be able to incorporate something like this in build scripts that aren't intended for everyone's consumption?

comment:4 follow-up: Changed 6 years ago by vbraun

If you just need to change a path in the template .DT_store then I'd just use sed. Alternatively make a virtualenv Python package install with the necessary packages somewhere e.g. in src/mac-app/tools/.

Note that the mac app is built with the Makefile in #19673 and not with anything in the Sage repo until somebody manages to review that trivial ticket. In particular sage-bdist is not used.

comment:5 in reply to: ↑ 4 Changed 6 years ago by mgoerner

Replying to vbraun:

If you just need to change a path in the template .DT_store then I'd just use sed.

Unfortunately, it is a binary format and not that easy :( But I got it to work.

Alternatively make a virtualenv Python package install with the necessary packages somewhere e.g. in src/mac-app/tools/.

Just to make sure, you mean in, e.g., the Makefile, creating a virtualenv, installing the needed packages in there and then run it or you mean creating a virtualenv and checking it into the sage repository?

Note that the mac app is built with the Makefile in #19673 and not with anything in the Sage repo until somebody manages to review that trivial ticket. In particular sage-bdist is not used.

Thanks for letting me know.

comment:6 Changed 6 years ago by kcrisman

But sage-bdist is still possible for local builds? (E.g. providing builds for older Mac platforms...)

comment:7 Changed 6 years ago by vbraun

No, sage-bdist won't work. You need https://github.com/sagemath/binary-pkg to make relocatable binaries. The latter should also work on reasonably old OSX versions but we don't have any to test. Considering that anything but the most recent OSX version has unpatched root exploits its not a priority for me.

comment:8 follow-up: Changed 6 years ago by iandrus

Could we perhaps always name the volume the same thing, and change the name of the dmg file?

comment:9 in reply to: ↑ 8 Changed 6 years ago by mgoerner

Replying to iandrus:

Could we perhaps always name the volume the same thing, and change the name of the dmg file?

Yes, but then we also need to stick to the same name for the .app directory in the dmg file (which is what SnapPy? does) because the icon positions stored in the .DT_store are keyed by file name. Right now, it is named Sage-VERSION.app, so it is changing. And I would like to keep the .app name as is including the version number, especially since once it is installed, a user cannot change the name, so cannot keep an old version while installing a new version.

comment:10 Changed 6 years ago by mgoerner

  • Branch set to u/mgoerner/createDSStore

comment:11 Changed 6 years ago by mgoerner

  • Authors set to Matthias Goerner
  • Commit set to db17474cf8af39dbd6baa0454f181afc1f0bfe74

New commits:

db17474Adding python script that creates a .DS_Store for the app.dmg distribution for Mac so that the icons are placed on top of a supplied background image when opening the dmg in finder.

comment:12 Changed 6 years ago by git

  • Commit changed from db17474cf8af39dbd6baa0454f181afc1f0bfe74 to c03804bc812d046161d136d717a6e6c3597d1745

Branch pushed to git repo; I updated commit sha1. New commits:

c48edacAdding background image that will be used for app.dmg distribution.
c066dafMakefile for building the mac app
2a18cf5Improve the Mac app Makefile
105edb2Prevent copying Sage.app inside the versioned app
db0c354Exclude .git/ from Mac app
4e6400cMerge branch 'u/iandrus/makefile_for_osx_app' (http://trac.sagemath.org/ticket/19673) into u/mgoerner/createDSStore (http://trac.sagemath.org/ticket/20119)
c03804bAdding code to Makefile building .app.dmg distribution to:

comment:13 Changed 6 years ago by mgoerner

Here is a screenshot: http://unhyperbolic.org/macSage/screenshot2.png

It is done, though we might want to wait until ticket 19673 is reviewed and rebase the changes off that branch.

comment:14 Changed 6 years ago by mgoerner

  • Branch changed from u/mgoerner/createDSStore to u/mgoerner/createDSStoreClean

comment:15 Changed 6 years ago by mgoerner

  • Commit changed from c03804bc812d046161d136d717a6e6c3597d1745 to 7b66c50be6c44f97d9779b40aaca15cd2ee035e4

comment:16 Changed 6 years ago by mgoerner

  • Status changed from new to needs_review

comment:17 Changed 6 years ago by vbraun

  • Reviewers set to Volker Braun
  • Status changed from needs_review to positive_review

Lgtm

comment:18 Changed 6 years ago by vbraun

  • Milestone changed from sage-wishlist to sage-7.1

comment:19 Changed 6 years ago by vbraun

  • Branch changed from u/mgoerner/createDSStoreClean to 7b66c50be6c44f97d9779b40aaca15cd2ee035e4
  • Resolution set to fixed
  • Status changed from positive_review to closed

comment:20 Changed 6 years ago by kcrisman

  • Commit 7b66c50be6c44f97d9779b40aaca15cd2ee035e4 deleted

I realize now that this requires a slight change to some documentation - see #20189

comment:21 follow-up: Changed 6 years ago by kcrisman

Matthias: This broke dmg construction on some older Mac OS versions. See here.

Any ideas for a quick workaround? I really just need to make the "old" app bundle and then drop in the binary and then hdiutil it to a dmg, as in the old script. It would also be good to see if there was a fix that worked for older OS X but my immediate need is to make a binary for upload before they take this older computer away from me (because I don't think a lot of people will be making binaries for 10.7 much longer but some will still have it).

Thanks!

comment:22 in reply to: ↑ 21 ; follow-up: Changed 6 years ago by mgoerner

I think you can just remove $(TARGET)/.DS_store from the non_app_files: target in src/mac-app/Makefile and then build it on 10.7 -without the nice arrangement of the icons and background image :(

I am not sure how you can tell binary_pkg to pick up that change. I would commit that change to a local repository and point binary_pkg's sage_yaml to that local repository.

Replying to kcrisman:

Matthias: This broke dmg construction on some older Mac OS versions. See here.

Any ideas for a quick workaround? I really just need to make the "old" app bundle and then drop in the binary and then hdiutil it to a dmg, as in the old script. It would also be good to see if there was a fix that worked for older OS X but my immediate need is to make a binary for upload before they take this older computer away from me (because I don't think a lot of people will be making binaries for 10.7 much longer but some will still have it).

Thanks!

comment:23 in reply to: ↑ 22 ; follow-up: Changed 6 years ago by kcrisman

I think you can just remove $(TARGET)/.DS_store from the non_app_files: target in src/mac-app/Makefile and then build it on 10.7 -without the nice arrangement of the icons and background image :(

Well, hopefully someone would still be able to use it.

I am not sure how you can tell binary_pkg to pick up that change. I would commit that change to a local repository and point binary_pkg's sage_yaml to that local repository.

Hmm, I didn't think of that. Hopefully I can get the syntax right. Thanks!

It would really be nice if one wasn't forced to use binary-pkg, though I understand why that change was made. No one would have been hurt by keeping sage-bdist around.

comment:24 in reply to: ↑ 23 Changed 6 years ago by kcrisman

I am not sure how you can tell binary_pkg to pick up that change. I would commit that change to a local repository and point binary_pkg's sage_yaml to that local repository.

Hmm, I didn't think of that. Hopefully I can get the syntax right. Thanks!

Unfortunately I can't get the syntax right - I'll followup on sage-release again.

comment:25 follow-up: Changed 6 years ago by vbraun

This ticket is closed, can you open a new one? I have a suggestion but I'm not going to make it on a closed ticket.

comment:26 in reply to: ↑ 25 Changed 6 years ago by kcrisman

This ticket is closed, can you open a new one? I have a suggestion but I'm not going to make it on a closed ticket.

Ok, though thanks for your comment here unclear if it solved my problem yet.

Note: See TracTickets for help on using tickets.