Closed Bug 1197325 Opened 4 years ago Closed 3 years ago

Figure out how to set volume icon for DMG in Linux->Mac cross compiles

Categories

(Firefox Build System :: General, defect)

defect
Not set

Tracking

(firefox54 fixed)

RESOLVED FIXED
mozilla54
Tracking Status
firefox54 --- fixed

People

(Reporter: ted, Assigned: Callek)

References

Details

Attachments

(3 files)

Right now we call `SetFile -a C <path>` to set an HFS+ attribute on the root of the DMG to tell it to use a custom icon. On Linux we don't have that command, and we also don't have an HFS+ filesystem lying around to run it on, so we'll have to figure something else out.
I think we can do this by formatting a hfs+ disk image locally and then using the "hfs" tool from libdmg-hfsplus to manipulate the image:
dd if=/dev/zero of=/tmp/file.hfs bs=1M count=1
mkfs.hfsplus -v Test /tmp/file.hfs
./hfs/hfsplus /tmp/file.hfs add /build/mozilla-central/browser/branding/nightly/disk.icns .VolumeIcon.icns
./hfs/hfsplus /tmp/file.hfs attr / C
./dmg/dmg dmg /tmp/file.hfs /tmp/file.dmg

...gives me a DMG with a volume icon that works fine in OS X.
Mike: can you please look at this bug too?
Flags: needinfo?(mshal)
I poked around at this recently while I was sorting out the commands for bug 1324834. The bits from comment 1 still basically work, but this is the log I wound up with:
dd if=/dev/zero of=temp.hfs bs=1M count=205
mkfs.hfsplus -v Test temp.hfs
hfsplus temp.hfs addall buildbot2
hfsplus temp.hfs attr / C
hfsplus temp.hfs symlink '/ ' /Applications
dmg build temp.hfs compressed.dmg

Notes:
1) The desktop-build image doesn't have mkfs.hfsplus, and there's no package available with that binary for CentOS 6. I was able to get the source from http://pkgs.fedoraproject.org/repo/pkgs/hfsplus-tools/diskdev_cmds-540.1.linux3.tar.gz/0435afc389b919027b69616ad1b05709/diskdev_cmds-540.1.linux3.tar.gz , and then in a desktop-build container run `yum install clang` and `make` in the unpacked source directory to generate `newfs_hfs.tproj/newfs_hfs`, which is the same binary as mkfs.hfsplus. We could just put that in tooltool.
2) The `hfsplus addall` command does not handle symlinks correctly. I briefly looked at fixing that but decided I didn't want to go down that route. Not creating the symlink in the stage dir, but using `hfsplus symlink` does seem to work properly. We'd have to change the code here to accomodate: https://dxr.mozilla.org/mozilla-central/rev/80eac484366ad881c6a10bf81e8d9b8f7a676c75/python/mozbuild/mozpack/dmg.py#114
3) I changed `dmg dmg file.hfs file.dmg` to `dmg build file.hfs file.dmg`. The latter seems to create a DMG that more closely resembles what we get out of OS X.
Oh, I forgot
4) The `hfsplus` command doesn't seem to be able to dynamically expand the disk image when doing `addall`, which is a PITA. Note that the `dd` command makes a 205MB file to start with. We'll probably have to sum up the size of all the files in the staged directory and then use a size slightly larger than that. I wish the hfsplus tool actually worked well. :-/
I can take a look after 'make check' goes away. If there's someone else available to work on this, I'd be happy to help provide guidance in the meantime.
Flags: needinfo?(mshal)
Callek is working on this.
Assignee: nobody → bugspam.Callek
Status: NEW → ASSIGNED
Comment on attachment 8832186 [details]
Bug 1197325 - Generate mkfs.hfsplus.

https://reviewboard.mozilla.org/r/108514/#review110606

Thanks for putting this all in-tree!

::: build/unix/build-hfsplus/build-hfsplus.sh:8
(Diff revision 2)
> +set -x
> +
> +hfplus_version=540.1.linux3
> +md5sum=0435afc389b919027b69616ad1b05709
> +filename=diskdev_cmds-${hfplus_version}.tar.gz
> +make_flags='-j12'

I usually like `-j$(getconf _NPROCESSORS_ONLN)`

::: build/unix/build-hfsplus/build-hfsplus.sh:41
(Diff revision 2)
> +make $make_flags || exit 1
> +cd ..
> +
> +mkdir hfsplus-tools
> +cp hfsplus-source/newfs_hfs.tproj/newfs_hfs hfsplus-tools/newfs_hfs
> +cp hfsplus-source/fsck_hfs.tproj/fsck_hfs hfsplus-tools/fsck_hfs

We don't actually need fsck for anything.

::: taskcluster/scripts/misc/build-hfsplus-linux.sh:4
(Diff revision 2)
> +#!/bin/bash
> +set -x -e -v
> +
> +# This script is for building binutils for Linux.

s/binutils/hfsplus/
Attachment #8832186 - Flags: review?(ted) → review+
Comment on attachment 8832896 [details]
Bug 1197325 - Remove now unused genisoimage.

https://reviewboard.mozilla.org/r/109148/#review110608
Attachment #8832896 - Flags: review?(ted) → review+
Comment on attachment 8832187 [details]
Bug 1197325 -- Set volume icon for DMG in Linux->Mac cross compiles.

https://reviewboard.mozilla.org/r/108516/#review110610

This looks great, thanks! I was a little worried that having to do the symlink after creating the hfs volume would make things painful, but I like how you moved things around to make that work.

::: moz.configure:257
(Diff revision 2)
>  def extra_programs(target):
>      if target.kernel == 'Darwin':
>          return namespace(
>              DSYMUTIL=('dsymutil', 'llvm-dsymutil'),
>              GENISOIMAGE=('genisoimage',),
> +            MKFSHFS=('newfs_hfs',),

This can also be named `mkfs.hfsplus`, so you could list that here.

::: python/mozbuild/mozpack/dmg.py:43
(Diff revision 2)
>      'Set HFS attributes of dir to use a custom icon'
>      if not is_linux:
> -        #TODO: bug 1197325 - figure out how to support this on Linux
>          subprocess.check_call(['SetFile', '-a', 'C', dir])
> +    else:
> +        import buildconfig

I think you could just move the `import buildconfig` to the top-level of the script. I'm not sure why I had it where it is currently anyway.
Attachment #8832187 - Flags: review?(ted) → review+
Pushed by Callek@gmail.com:
https://hg.mozilla.org/integration/autoland/rev/55a8ad127517
Generate mkfs.hfsplus. r=ted
https://hg.mozilla.org/integration/autoland/rev/b5ac3fa0bbe7
Set volume icon for DMG in Linux->Mac cross compiles. r=ted
https://hg.mozilla.org/integration/autoland/rev/158233bce738
Remove now unused genisoimage. r=ted
Pushed by Callek@gmail.com:
https://hg.mozilla.org/integration/autoland/rev/f9f33149db8a
Generate mkfs.hfsplus. r=ted
https://hg.mozilla.org/integration/autoland/rev/ab096d7edae3
Set volume icon for DMG in Linux->Mac cross compiles. r=ted
https://hg.mozilla.org/integration/autoland/rev/e4c86796a079
Remove now unused genisoimage. r=ted
https://hg.mozilla.org/mozilla-central/rev/f9f33149db8a
https://hg.mozilla.org/mozilla-central/rev/ab096d7edae3
https://hg.mozilla.org/mozilla-central/rev/e4c86796a079
Status: ASSIGNED → RESOLVED
Closed: 3 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla54
Product: Core → Firefox Build System
You need to log in before you can comment on or make changes to this bug.