Backed out revision bca1ad6cc378 (bug 1190522) for breaking OSX B2G Desktop builds.

This commit is contained in:
Ryan VanderMeulen 2015-08-06 15:43:45 -04:00
parent 78a311e66b
commit 64e8cd0fdb
4 changed files with 1509 additions and 117 deletions

1488
build/package/mac_osx/pkg-dmg Executable file

File diff suppressed because it is too large Load Diff

View File

@ -1,37 +0,0 @@
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
from __future__ import print_function
from mozbuild.base import MozbuildObject
from mozpack import dmg
import os
import sys
def make_dmg(source_directory, output_dmg):
build = MozbuildObject.from_environment()
extra_files = [
(os.path.join(build.distdir, 'branding', 'dsstore'), '.DS_Store'),
(os.path.join(build.distdir, 'branding', 'background.png'),
'.background/background.png'),
(os.path.join(build.distdir, 'branding', 'disk.icns'),
'.VolumeIcon.icns'),
]
volume_name = build.substs['MOZ_APP_DISPLAYNAME']
dmg.create_dmg(source_directory, output_dmg, volume_name, extra_files)
def main(args):
if len(args) != 2:
print('Usage: make_dmg.py <source directory> <output dmg>',
file=sys.stderr)
return 1
make_dmg(args[0], args[1])
return 0
if __name__ == '__main__':
sys.exit(main(sys.argv[1:]))

View File

@ -1,78 +0,0 @@
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
import errno
import mozfile
import os
import shutil
import subprocess
def mkdir(dir):
if not os.path.isdir(dir):
try:
os.makedirs(dir)
except OSError as e:
if e.errno != errno.EEXIST:
raise
def chmod(dir):
'Set permissions of DMG contents correctly'
subprocess.check_call(['chmod', '-R', 'a+rX,a-st,u+w,go-w', dir])
def rsync(source, dest):
'rsync the contents of directory source into directory dest'
# Ensure a trailing slash so rsync copies the *contents* of source.
if not source.endswith('/'):
source += '/'
subprocess.check_call(['rsync', '-a', '--copy-unsafe-links',
source, dest])
def set_folder_icon(dir):
'Set HFS attributes of dir to use a custom icon'
subprocess.check_call(['SetFile', '-a', 'C', dir])
def create_dmg_from_staged(stagedir, output_dmg, tmpdir, volume_name):
'Given a prepared directory stagedir, produce a DMG at output_dmg.'
hybrid = os.path.join(tmpdir, 'hybrid.dmg')
subprocess.check_call(['hdiutil', 'makehybrid', '-hfs',
'-hfs-volume-name', volume_name,
'-hfs-openfolder', stagedir,
'-ov', stagedir,
'-o', hybrid])
subprocess.check_call(['hdiutil', 'convert', '-format', 'UDBZ',
'-imagekey', 'bzip2-level=9',
'-ov', hybrid, '-o', output_dmg])
def create_dmg(source_directory, output_dmg, volume_name, extra_files):
'''
Create a DMG disk image at the path output_dmg from source_directory.
Use volume_name as the disk image volume name, and
use extra_files as a list of tuples of (filename, relative path) to copy
into the disk image.
'''
with mozfile.TemporaryDirectory() as tmpdir:
stagedir = os.path.join(tmpdir, 'stage')
os.mkdir(stagedir)
# Copy the app bundle over using rsync
rsync(source_directory, stagedir)
# Copy extra files
for source, target in extra_files:
full_target = os.path.join(stagedir, target)
mkdir(os.path.dirname(full_target))
shutil.copyfile(source, full_target)
# Make a symlink to /Applications. The symlink name is a space
# so we don't have to localize it. The Applications folder icon
# will be shown in Finder, which should be clear enough for users.
os.symlink('/Applications', os.path.join(stagedir, ' '))
# Set the folder attributes to use a custom icon
set_folder_icon(stagedir)
chmod(stagedir)
create_dmg_from_staged(stagedir, output_dmg, tmpdir, volume_name)

View File

@ -503,10 +503,29 @@ endif
ifeq ($(MOZ_PKG_FORMAT),DMG)
PKG_SUFFIX = .dmg
PKG_DMG_FLAGS =
ifneq (,$(MOZ_PKG_MAC_DSSTORE))
PKG_DMG_FLAGS += --copy '$(MOZ_PKG_MAC_DSSTORE):/.DS_Store'
endif
ifneq (,$(MOZ_PKG_MAC_BACKGROUND))
PKG_DMG_FLAGS += --mkdir /.background --copy '$(MOZ_PKG_MAC_BACKGROUND):/.background'
endif
ifneq (,$(MOZ_PKG_MAC_ICON))
PKG_DMG_FLAGS += --icon '$(MOZ_PKG_MAC_ICON)'
endif
ifneq (,$(MOZ_PKG_MAC_RSRC))
PKG_DMG_FLAGS += --resource '$(MOZ_PKG_MAC_RSRC)'
endif
ifneq (,$(MOZ_PKG_MAC_EXTRA))
PKG_DMG_FLAGS += $(MOZ_PKG_MAC_EXTRA)
endif
_ABS_MOZSRCDIR = $(shell cd $(MOZILLA_DIR) && pwd)
ifndef PKG_DMG_SOURCE
PKG_DMG_SOURCE = $(STAGEPATH)$(MOZ_PKG_DIR)
INNER_MAKE_PACKAGE = $(call py_action,make_dmg,'$(PKG_DMG_SOURCE)' '$(PACKAGE)')
endif
INNER_MAKE_PACKAGE = $(_ABS_MOZSRCDIR)/build/package/mac_osx/pkg-dmg \
--source '$(PKG_DMG_SOURCE)' --target '$(PACKAGE)' \
--volname '$(MOZ_APP_DISPLAYNAME)' $(PKG_DMG_FLAGS)
INNER_UNMAKE_PACKAGE = \
set -ex; \
rm -rf $(_ABS_DIST)/unpack.tmp; \