Ejemplo n.º 1
0
 def DoCmd(package):
   try:
     pkg_commands[args.command](package, args)
   except error.DisabledError as e:
     if args.ignore_disabled:
       util.Log('naclports: %s' % e)
     else:
       raise e
Ejemplo n.º 2
0
def CmdPkgCheck(package, options):
  """Verify dependency information for given package(s)"""
  # The fact that we got this far means the pkg_info is basically valid.
  # This final check verifies the dependencies are valid.
  # Cache the list of all packages names since this function could be called
  # a lot in the case of "naclports check --all".
  packages = source_package.SourcePackageIterator()
  if not CmdPkgCheck.all_package_names:
    CmdPkgCheck.all_package_names = [os.path.basename(p.root) for p in packages]
  util.Log("Checking deps for %s .." % package.NAME)
  package.CheckDeps(CmdPkgCheck.all_package_names)
Ejemplo n.º 3
0
 def Download(self, package_name, config):
   if not os.path.exists(PREBUILT_ROOT):
     util.Makedirs(PREBUILT_ROOT)
   info = self.packages[(package_name, config)]
   filename = os.path.join(PREBUILT_ROOT, os.path.basename(info['BIN_URL']))
   if os.path.exists(filename):
     try:
       util.VerifyHash(filename, info['BIN_SHA1'])
       return filename
     except util.HashVerificationError:
       pass
   util.Log('Downloading prebuilt binary ...')
   util.DownloadFile(filename, info['BIN_URL'])
   util.VerifyHash(filename, info['BIN_SHA1'])
   return filename
Ejemplo n.º 4
0
def CreatePkgFile(name, version, arch, payload_dir, outfile, depends):
    """Create an archive file in FreeBSD's pkg file format"""
    util.Log('Creating pkg package: %s' % outfile)
    manifest = collections.OrderedDict()
    manifest['name'] = name
    manifest['version'] = version
    manifest['arch'] = 'nacl:0:%s' % arch

    # The following fields are required by 'pkg' but we don't have
    # meaningful values for them yet
    manifest['origin'] = name,
    manifest['comment'] = 'comment not available'
    manifest['desc'] = 'desc not available'
    manifest['maintainer'] = '*****@*****.**'
    manifest['www'] = 'https://code.google.com/p/naclports/'
    manifest['prefix'] = INSTALL_PREFIX

    if depends:
        depends_dict = collections.OrderedDict()
        CreateDependencies(depends_dict, depends)
        manifest['deps'] = depends_dict

    temp_dir = os.path.splitext(outfile)[0] + '.tmp'
    if os.path.exists(temp_dir):
        shutil.rmtree(temp_dir)
    os.mkdir(temp_dir)

    content_dir = os.path.join(temp_dir, INSTALL_PREFIX)
    shutil.copytree(payload_dir, content_dir, symlinks=True)
    WriteUCL(os.path.join(temp_dir, '+COMPACT_MANIFEST'), manifest)
    file_dict = collections.OrderedDict()
    ParseDir(temp_dir, file_dict, '/')
    manifest['files'] = file_dict
    WriteUCL(os.path.join(temp_dir, '+MANIFEST'), manifest)

    with tarfile.open(outfile, 'w:bz2') as tar:
        for filename in os.listdir(temp_dir):
            if filename.startswith('+'):
                fullname = os.path.join(temp_dir, filename)
                tar.add(fullname, arcname=filename)

        for filename in os.listdir(temp_dir):
            if not filename.startswith('+'):
                fullname = os.path.join(temp_dir, filename)
                AddFilesInDir(fullname, tar, temp_dir)
    shutil.rmtree(temp_dir)
Ejemplo n.º 5
0
 def rmtree(path):
     util.Log('removing %s' % path)
     util.RemoveTree(path)