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


(Firefox Build System :: General, defect)

Not set


(firefox54 fixed)

Tracking Status
firefox54 --- fixed


(Reporter: ted, Assigned: Callek)




(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 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

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 , 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:
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
Comment on attachment 8832186 [details]
Bug 1197325 - Generate mkfs.hfsplus.

Thanks for putting this all in-tree!

::: build/unix/build-hfsplus/
(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/
(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/
(Diff revision 2)
> +#!/bin/bash
> +set -x -e -v
> +
> +# This script is for building binutils for Linux.

Attachment #8832186 - Flags: review?(ted) → review+
Comment on attachment 8832896 [details]
Bug 1197325 - Remove now unused genisoimage.
Attachment #8832896 - Flags: review?(ted) → review+
Comment on attachment 8832187 [details]
Bug 1197325 -- Set volume icon for DMG in Linux->Mac cross compiles.

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/
(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
Generate mkfs.hfsplus. r=ted
Set volume icon for DMG in Linux->Mac cross compiles. r=ted
Remove now unused genisoimage. r=ted
Pushed by
Generate mkfs.hfsplus. r=ted
Set volume icon for DMG in Linux->Mac cross compiles. r=ted
Remove now unused genisoimage. r=ted
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.