Ejemplo n.º 1
0
def generate_png_from_copy_from_dmg_item(install_item, repo_path):
    dmgpath = os.path.join(repo_path, 'pkgs',
                           install_item['installer_item_location'])
    mountpoints = munkicommon.mountdmg(dmgpath)
    if mountpoints:
        mountpoint = mountpoints[0]
        apps = [
            item for item in install_item.get('items_to_copy', [])
            if item.get('source_item', '').endswith('.app')
        ]
        if len(apps):
            app_path = os.path.join(mountpoint, apps[0]['source_item'])
            icon_path = iconutils.findIconForApp(app_path)
            if icon_path:
                png_path = os.path.join(repo_path, u'icons',
                                        install_item['name'] + u'.png')
                result = iconutils.convertIconToPNG(icon_path, png_path)
                if result:
                    print_utf8(u'\tWrote: %s' % png_path)
                else:
                    print_err_utf8(u'\tError converting %s to png.' %
                                   icon_path)
            else:
                print_utf8(u'\tNo application icons found.')
        else:
            print_utf8(u'\tNo application icons found.')
        munkicommon.unmountdmg(mountpoint)
Ejemplo n.º 2
0
def generate_pngs_from_installer_pkg(install_item, repo_path):
    icon_paths = []
    mountpoint = None
    pkg_path = None
    item_path = os.path.join(
        repo_path, u'pkgs', install_item['installer_item_location'])
    if munkicommon.hasValidDiskImageExt(item_path):
        dmg_path = item_path
        mountpoints = munkicommon.mountdmg(dmg_path)
        if mountpoints:
            mountpoint = mountpoints[0]
            if install_item.get('package_path'):
                pkg_path = os.path.join(
                    mountpoint, install_item['package_path'])
            else:
                # find first item that appears to be a pkg at the root
                for fileitem in munkicommon.listdir(mountpoints[0]):
                    if munkicommon.hasValidPackageExt(fileitem):
                        pkg_path = os.path.join(mountpoint, fileitem)
                        break
    elif munkicommon.hasValidPackageExt(item_path):
        pkg_path = item_path
    if pkg_path:
        if os.path.isdir(pkg_path):
            icon_paths = iconutils.extractAppIconsFromBundlePkg(pkg_path)
        else:
            icon_paths = iconutils.extractAppIconsFromFlatPkg(pkg_path)

    if mountpoint:
        munkicommon.unmountdmg(mountpoint)

    if len(icon_paths) == 1:
        png_path = os.path.join(
            repo_path, u'icons', install_item['name'] + u'.png')
        result = iconutils.convertIconToPNG(icon_paths[0], png_path)
        if result:
            print_utf8(u'\tWrote: %s' % png_path)
    elif len(icon_paths) > 1:
        index = 1
        for icon_path in icon_paths:
            png_path = os.path.join(
                repo_path, u'icons',
                install_item['name'] + '_' + str(index) + u'.png')
            result = iconutils.convertIconToPNG(icon_path, png_path)
            if result:
                print_utf8(u'\tWrote: %s' % png_path)
            index += 1
    else:
        print_utf8(u'\tNo application icons found.')
Ejemplo n.º 3
0
def generate_pngs_from_installer_pkg(install_item, repo_path):
    icon_paths = []
    mountpoint = None
    pkg_path = None
    item_path = os.path.join(repo_path, u'pkgs',
                             install_item['installer_item_location'])
    if munkicommon.hasValidDiskImageExt(item_path):
        dmg_path = item_path
        mountpoints = munkicommon.mountdmg(dmg_path)
        if mountpoints:
            mountpoint = mountpoints[0]
            if install_item.get('package_path'):
                pkg_path = os.path.join(mountpoint,
                                        install_item['package_path'])
            else:
                # find first item that appears to be a pkg at the root
                for fileitem in munkicommon.listdir(mountpoints[0]):
                    if munkicommon.hasValidPackageExt(fileitem):
                        pkg_path = os.path.join(mountpoint, fileitem)
                        break
    elif munkicommon.hasValidPackageExt(item_path):
        pkg_path = item_path
    if pkg_path:
        if os.path.isdir(pkg_path):
            icon_paths = iconutils.extractAppIconsFromBundlePkg(pkg_path)
        else:
            icon_paths = iconutils.extractAppIconsFromFlatPkg(pkg_path)

    if mountpoint:
        munkicommon.unmountdmg(mountpoint)

    if len(icon_paths) == 1:
        png_path = os.path.join(repo_path, u'icons',
                                install_item['name'] + u'.png')
        result = iconutils.convertIconToPNG(icon_paths[0], png_path)
        if result:
            print_utf8(u'\tWrote: %s' % png_path)
    elif len(icon_paths) > 1:
        index = 1
        for icon_path in icon_paths:
            png_path = os.path.join(
                repo_path, u'icons',
                install_item['name'] + '_' + str(index) + u'.png')
            result = iconutils.convertIconToPNG(icon_path, png_path)
            if result:
                print_utf8(u'\tWrote: %s' % png_path)
            index += 1
    else:
        print_utf8(u'\tNo application icons found.')
Ejemplo n.º 4
0
def generate_png_from_copy_from_dmg_item(install_item, repo_path):
    dmgpath = os.path.join(
        repo_path, 'pkgs', install_item['installer_item_location'])
    mountpoints = munkicommon.mountdmg(dmgpath)
    if mountpoints:
        mountpoint = mountpoints[0]
        apps = [item for item in install_item.get('items_to_copy', [])
                if item.get('source_item', '').endswith('.app')]
        if len(apps):
            app_path = os.path.join(mountpoint, apps[0]['source_item'])
            icon_path = iconutils.findIconForApp(app_path)
            if icon_path:
                png_path = os.path.join(
                    repo_path, u'icons', install_item['name'] + u'.png')
                result = iconutils.convertIconToPNG(icon_path, png_path)
                if result:
                    print_utf8(u'\tWrote: %s' % png_path)
                else:
                    print_err_utf8(u'\tError converting %s to png.' % icon_path)
            else:
                print_utf8(u'\tNo application icons found.')
        else:
            print_utf8(u'\tNo application icons found.')
        munkicommon.unmountdmg(mountpoint)
Ejemplo n.º 5
0
            # Update with input variables
            if cli_values:
                cataloginfo.update(cli_values)
                
            # Update with calculated values
            if calc_values:
                cataloginfo.update(calc_values)
            
            # Render new task
            rendered_template = template.render(**cataloginfo)
    except:
        print "Unable to read application data from disk image!"
        sys.exit(1)
    finally:
        #eject the dmg
        munkicommon.unmountdmg(mountpoints[0])

# -----------------------------------------------------------------------------
# OS X Flat Installer Package (.pkg)
# -----------------------------------------------------------------------------
elif file_mime == 'application/octet-stream' and file_extension == '.pkg' and args.package:
    if args.template:
        template = env.get_template(args.template)
    else:
        template = env.get_template('appleflatpackageinstaller.bes')
    
    pkginfo = munkicommon.getPackageMetaData(file_path)
    
    pkginfo.update(get_sha_size(file_path))
    pkginfo.update(get_env_source_mime_data())
    pkginfo['base_file_name'] = base_file_name