예제 #1
0
def handle_extras(extras_file, exceptions_path, additions_path, force,
                  exceptions, except_list, additions_list):
    """Handle downloading and sorting the except/add file."""
    extras = parse_extras(extras_file)
    # Check for additional packages
    if extras['additions']:
        print "Adding additional packages."
        for addition in extras['additions']:
            item_name = getURLitemBasename(addition)
            if "http" in addition:
                print "Considering %s" % addition
                if item_name.endswith('.mobileconfig'):
                    # profiles must be downloaded into the 'exceptions' directory
                    if handle_dl(item_name, addition, exceptions_path, force):
                        except_list.append(item_name)
                else:
                    if handle_dl(item_name, addition, additions_path, force):
                        additions_list.append(
                            os.path.join(additions_path, item_name))
            else:
                "Adding %s locally" % addition
                additions_list.append(addition)
    if extras['exceptions']:
        for exception in extras['exceptions']:
            exceptions.append(exception)
예제 #2
0
def handle_extras(extras_file, exceptions_path, additions_path,
                  force, exceptions, except_list, additions_list):
  """Handle downloading and sorting the except/add file."""
  extras = parse_extras(extras_file)
  # Check for additional packages
  if extras['additions']:
    print "Adding additional packages."
    for addition in extras['additions']:
      item_name = getURLitemBasename(addition)
      if "http" in addition:
        print "Considering %s" % addition
        if item_name.endswith('.mobileconfig'):
          # profiles must be downloaded into the 'exceptions' directory
          if handle_dl(item_name, addition, exceptions_path,
                       force):
            except_list.append(item_name)
        else:
          if handle_dl(item_name, addition, additions_path,
                       force):
            additions_list.append(os.path.join(additions_path,
                                  item_name))
      else:
        "Adding %s locally" % addition
        additions_list.append(addition)
  if extras['exceptions']:
    for exception in extras['exceptions']:
      exceptions.append(exception)
예제 #3
0
def process_managed_installs(install_list, exceptions, except_list, item_list,
                             exceptions_path, download_path, force):
  """Download managed_installs."""
  print "Checking for managed installs..."
  print "Exceptions list: %s" % exceptions
  for item in install_list:
    print "Looking at: %s" % item['name']
    if item['name'] in exceptions:
      print "Adding to exceptions list."
      exception = True
    elif 'installer_type' not in item:
      # Assume it's a package
      if (
        'postinstall_script',
        'preinstall_script',
        'installcheck_script'
      ) in item:
        # We shouldn't try to do anything with Munki scripts
        exception = True
      exception = False
    elif item['installer_type'] == 'nopkg':
      # Obviously we don't attempt to handle these
      print "Nopkg found, skipping."
      continue
    elif item['installer_type'] == 'profile':
      # Profiles go into the 'exceptions' dir automatically
      print "Profile found, adding to exceptions."
      exception = True
    elif item['installer_type'] == 'copy_from_dmg':
      exception = False
      if (
        len(item['items_to_copy']) != 1 or
        item['items_to_copy'][0]['destination_path'] != '/Applications'
      ):
        # Only copy_from_dmgs that have single items going
        # into /Applications are supported
        print "Complex copy_from_dmg found, adding to exceptions."
        exception = True
    else:
      # It's probably something Adobe related
      exception = True
    itemurl = get_item_url(item)
    item_basename = getURLitemBasename(itemurl)
    if exception:
      # Try to download the exception into the exceptions directory
      # Add it to the exceptions list
      if handle_dl(item_basename, itemurl, exceptions_path,
                   force):
        except_list.append(urllib2.unquote(item_basename))
    else:
      # Add it to the item list
      if handle_dl(item_basename, itemurl, download_path,
                   force):
        item_list.append(urllib2.unquote(item_basename))
예제 #4
0
def download_url_to_cache(url, cache, force=False):
  """Take a URL and downloads it to a local cache."""
  cache_path = os.path.join(cache, urllib2.unquote(getURLitemBasename(url)))
  custom_headers = ['']
  if BASIC_AUTH:
    # custom_headers = ['Authorization: Basic %s' % BASIC_AUTH]
    custom_headers = BASIC_AUTH
  if force:
    return getResourceIfChangedAtomically(
      url, cache_path,
      custom_headers=custom_headers,
      resume=True,
      expected_hash='no')
  return getResourceIfChangedAtomically(
    url, cache_path, custom_headers=custom_headers)
예제 #5
0
def process_managed_installs(install_list, exceptions, except_list, item_list,
                             exceptions_path, download_path, force):
    """Download managed_installs."""
    print "Checking for managed installs..."
    print "Exceptions list: %s" % exceptions
    for item in install_list:
        print "Looking at: %s" % item['name']
        if item['name'] in exceptions:
            print "Adding to exceptions list."
            exception = True
        elif 'installer_type' not in item:
            # Assume it's a package
            if ('postinstall_script', 'preinstall_script',
                    'installcheck_script') in item:
                # We shouldn't try to do anything with Munki scripts
                exception = True
            exception = False
        elif item['installer_type'] == 'nopkg':
            # Obviously we don't attempt to handle these
            print "Nopkg found, skipping."
            continue
        elif item['installer_type'] == 'profile':
            # Profiles go into the 'exceptions' dir automatically
            print "Profile found, adding to exceptions."
            exception = True
        elif item['installer_type'] == 'copy_from_dmg':
            exception = False
            if (len(item['items_to_copy']) != 1
                    or item['items_to_copy'][0]['destination_path'] !=
                    '/Applications'):
                # Only copy_from_dmgs that have single items going
                # into /Applications are supported
                print "Complex copy_from_dmg found, adding to exceptions."
                exception = True
        else:
            # It's probably something Adobe related
            exception = True
        itemurl = get_item_url(item)
        item_basename = getURLitemBasename(itemurl)
        if exception:
            # Try to download the exception into the exceptions directory
            # Add it to the exceptions list
            if handle_dl(item_basename, itemurl, exceptions_path, force):
                except_list.append(urllib2.unquote(item_basename))
        else:
            # Add it to the item list
            if handle_dl(item_basename, itemurl, download_path, force):
                item_list.append(urllib2.unquote(item_basename))
예제 #6
0
def download_url_to_cache(url, cache, force=False):
    """Take a URL and downloads it to a local cache."""
    cache_path = os.path.join(cache, urllib2.unquote(getURLitemBasename(url)))
    custom_headers = ['']
    if BASIC_AUTH:
        # custom_headers = ['Authorization: Basic %s' % BASIC_AUTH]
        custom_headers = BASIC_AUTH
    if force:
        return getResourceIfChangedAtomically(url,
                                              cache_path,
                                              custom_headers=custom_headers,
                                              resume=True,
                                              expected_hash='no')
    return getResourceIfChangedAtomically(url,
                                          cache_path,
                                          custom_headers=custom_headers)