Ejemplo n.º 1
0
 def makedmg(self, d, volname, internet_enable=True, format='UDBZ'):
     ''' Copy a directory d into a dmg named volname '''
     print('\nSigning...')
     sys.stdout.flush()
     destdir = os.path.join(SW, 'dist')
     try:
         shutil.rmtree(destdir)
     except EnvironmentError as err:
         if err.errno != errno.ENOENT:
             raise
     os.mkdir(destdir)
     dmg = os.path.join(destdir, volname + '.dmg')
     if os.path.exists(dmg):
         os.unlink(dmg)
     tdir = tempfile.mkdtemp()
     appdir = os.path.join(tdir, os.path.basename(d))
     shutil.copytree(d, appdir, symlinks=True)
     if self.sign_installers:
         with timeit() as times:
             sign_app(appdir)
         print('Signing completed in %d minutes %d seconds' % tuple(times))
     os.symlink('/Applications', os.path.join(tdir, 'Applications'))
     size_in_mb = int(
         subprocess.check_output(['du', '-s', '-k', tdir
                                  ]).decode('utf-8').split()[0]) / 1024.
     cmd = [
         '/usr/bin/hdiutil', 'create', '-srcfolder', tdir, '-volname',
         volname, '-format', format
     ]
     if 190 < size_in_mb < 250:
         # We need -size 255m because of a bug in hdiutil. When the size of
         # srcfolder is close to 200MB hdiutil fails with
         # diskimages-helper: resize request is above maximum size allowed.
         cmd += ['-size', '255m']
     print('\nCreating dmg...')
     with timeit() as times:
         subprocess.check_call(cmd + [dmg])
         if internet_enable:
             subprocess.check_call(
                 ['/usr/bin/hdiutil', 'internet-enable', '-yes', dmg])
     print('dmg created in %d minutes and %d seconds' % tuple(times))
     shutil.rmtree(tdir)
     size = os.stat(dmg).st_size / (1024 * 1024.)
     print('\nInstaller size: %.2fMB\n' % size)
     return dmg
Ejemplo n.º 2
0
 def makedmg(self, d, volname, internet_enable=True, format='UDBZ'):
     ''' Copy a directory d into a dmg named volname '''
     print('\nSigning...')
     sys.stdout.flush()
     destdir = os.path.join(SW, 'dist')
     try:
         shutil.rmtree(destdir)
     except EnvironmentError as err:
         if err.errno != errno.ENOENT:
             raise
     os.mkdir(destdir)
     dmg = os.path.join(destdir, volname + '.dmg')
     if os.path.exists(dmg):
         os.unlink(dmg)
     tdir = tempfile.mkdtemp()
     appdir = os.path.join(tdir, os.path.basename(d))
     shutil.copytree(d, appdir, symlinks=True)
     if self.sign_installers:
         with timeit() as times:
             sign_app(appdir)
         print('Signing completed in %d minutes %d seconds' % tuple(times))
     os.symlink('/Applications', os.path.join(tdir, 'Applications'))
     size_in_mb = int(subprocess.check_output(['du', '-s', '-k', tdir]).decode('utf-8').split()[0]) / 1024.
     cmd = ['/usr/bin/hdiutil', 'create', '-srcfolder', tdir, '-volname', volname, '-format', format]
     if 190 < size_in_mb < 250:
         # We need -size 255m because of a bug in hdiutil. When the size of
         # srcfolder is close to 200MB hdiutil fails with
         # diskimages-helper: resize request is above maximum size allowed.
         cmd += ['-size', '255m']
     print('\nCreating dmg...')
     with timeit() as times:
         subprocess.check_call(cmd + [dmg])
         if internet_enable:
             subprocess.check_call(['/usr/bin/hdiutil', 'internet-enable', '-yes', dmg])
     print('dmg created in %d minutes and %d seconds' % tuple(times))
     shutil.rmtree(tdir)
     size = os.stat(dmg).st_size / (1024 * 1024.)
     print('\nInstaller size: %.2fMB\n' % size)
     return dmg