コード例 #1
0
ファイル: setup.py プロジェクト: wangfan008/cerbero
def parse_dir(dirpath, extension=None):
    if os.path.exists('.git'):
        files = shell.check_output(['git', 'ls-files', dirpath]).split('\n')
        files.remove('')
    else:
        files = shell.check_output(['find', dirpath, '-type', 'f']).split('\n')
        files.remove('')
    if extension is None:
        return files
    return [f for f in files if f.endswith(extension)]
コード例 #2
0
ファイル: linux.py プロジェクト: wangfan008/cerbero
 def check_arch():
     native_arch = shell.check_output(['dpkg', '--print-architecture'])
     if native_arch == arch:
         return
     foreign_archs = shell.check_output(['dpkg', '--print-foreign-architectures'])
     if arch in foreign_archs.split():
         return
     raise ConfigurationError(('Architecture %s is missing from your setup. ' + \
                               'You can add it with: "dpkg --add-architecture %s",' + \
                               ' then run "apt-get update."') \
                               % (arch, arch))
コード例 #3
0
ファイル: linux.py プロジェクト: wangfan008/cerbero
    def __init__(self, config, offline, assume_yes):
        UnixBootstrapper.__init__(self, config, offline, assume_yes)

        has_multilib = True
        try:
          shell.check_output (["pacman", "-Sp", "gcc-multilib"])
        except CommandError:
          has_multilib = False

        if self.config.arch == Architecture.X86_64 and has_multilib:
            self.packages.append('gcc-multilib')
        else:
            self.packages.append('gcc')
コード例 #4
0
ファイル: env.py プロジェクト: pzw520125/cerbero
def _get_vswhere_vs_install(vswhere, vs_versions):
    import json
    vswhere_exe = str(vswhere)
    # Get a list of installation paths for all installed Visual Studio
    # instances, from VS 2013 to the latest one, sorted from newest to
    # oldest, and including preview releases.
    # Will not include BuildTools installations.
    out = check_output([
        vswhere_exe, '-legacy', '-prerelease', '-format', 'json', '-utf8',
        '-sort'
    ])
    installs = json.loads(out)
    program_files = get_program_files_dir()
    for install in installs:
        version = install['installationVersion']
        vs_version = 'vs' + version.split('.', maxsplit=1)[0]
        if vs_version not in vs_versions:
            continue
        prefix = install['installationPath']
        suffix = VCVARSALLS[vs_version][1]
        path = program_files / prefix / suffix
        # Find the location of the Visual Studio installation
        if path.is_file():
            return path.as_posix(), vs_version
    raise FatalError(
        'vswhere.exe could not find Visual Studio installation(s). '
        'Looked for version(s): ' + ', '.join(vs_versions))
コード例 #5
0
 def list_file_deps(self, prefix, path):
     files = shell.check_output(['otool', '-L', path]).splitlines()[1:]
     # Shared libraries might be relocated, we look for files with the
     # prefix or starting with @rpath
     files = [
         x.strip().split(' ')[0] for x in files
         if prefix in x or "@rpath" in x
     ]
     return [x.replace("@rpath/", prefix) for x in files]
コード例 #6
0
ファイル: filesprovider.py プロジェクト: viviedu/cerbero
def get_implib_dllname(config, path):
    if config.msvc_toolchain_env and path.endswith('.lib'):
        lib_exe = shutil.which('lib', path=config.msvc_toolchain_env['PATH'][0])
        if not lib_exe:
            raise FatalError('lib.exe not found, check cerbero configuration')
        try:
            ret = shell.check_output([lib_exe, '-list', path])
        except FatalError:
            return 0
        # The last non-empty line should contain the dllname
        return ret.split('\n')[-2]
    dlltool = os.environ.get('DLLTOOL', None)
    if not dlltool:
        raise FatalError('dlltool not found, check cerbero configuration')
    try:
        return shell.check_output([dlltool, '-I', path])
    except FatalError:
        return 0
コード例 #7
0
ファイル: osxrelocator.py プロジェクト: jiatingxiu/cerbero
 def list_shared_libraries(object_file):
     res = shell.check_output([OTOOL_CMD, '-L', object_file]).splitlines()
     # We don't use the first line
     libs = res[1:]
     # Remove the first character tabulation
     libs = [x[1:] for x in libs]
     # Remove the version info
     libs = [x.split(' ', 1)[0] for x in libs]
     return libs
コード例 #8
0
ファイル: recipe.py プロジェクト: pzw520125/cerbero
 def _get_la_deps_from_pc(self, laname, pcname, env):
     ret = shell.check_output(
         ['pkg-config', '--libs-only-l', '--static', pcname],
         env=env,
         logfile=self.logfile)
     # Don't add the library itself to the list of dependencies
     return [
         'lib' + lib[2:] for lib in self._get_unique_ordered(ret.split())
         if lib[2:] != laname[3:]
     ]
コード例 #9
0
 def _perl_version(self):
     try:
         version = shell.check_output("perl -e 'print \"$]\";'")
     except FatalError:
         m.warning(_("Perl not found, you may need to run bootstrap."))
         version = '0.000000'
     # FIXME: when perl's mayor is >= 10
     mayor = str(version[0])
     minor = str(int(version[2:5]))
     revision = str(int(version[5:8]))
     return '.'.join([mayor, minor, revision])
コード例 #10
0
def revision(repo):
    '''
    Get the current revision of a repository with svnversion

    @param repo: the path to the repository
    @type  repo: str
    '''
    rev = shell.check_output(['svnversion'], cmd_dir=repo).splitlines()[0]
    if rev[-1] == 'M':
        rev = rev[:-1]
    return rev
コード例 #11
0
ファイル: git.py プロジェクト: jiatingxiu/cerbero
def list_tags(git_dir):
    '''
    List all tags

    @param git_dir: path of the git repository
    @type git_dir: str
    @param fail: raise an error if the command failed
    @type fail: false
    @return: list of tag names (str)
    @rtype: list
    '''
    return shell.check_output([GIT, 'tag', '-l'], cmd_dir=git_dir).strip().splitlines()
コード例 #12
0
ファイル: debugpackages.py プロジェクト: wangfan008/cerbero
    def find_orphan_files(self, allfiles, prefix, excludes=[]):
        cmd = ['find', '.', '-type', 'f']
        for x in excludes:
            cmd += ['(', '!', '-name', x, ')']
        distfiles = shell.check_output(cmd, cmd_dir=prefix).splitlines()
        # remove './' from the list of files
        distfiles = [f[2:] for f in distfiles]
        orphan = sorted(list((set(distfiles) - set(allfiles))))

        if len(orphan) > 0:
            m.message("Found orphan files:")
            m.message('\n'.join(orphan))
コード例 #13
0
 def gendef(self, dllpath, outputdir, libname):
     defname = libname + '.def'
     def_contents = shell.check_output('gendef - %s' % dllpath, outputdir,
                                       logfile=self.logfile)
     # If the output doesn't contain a 'LIBRARY' directive, gendef errored
     # out. However, gendef always returns 0 so we need to inspect the
     # output and guess.
     if 'LIBRARY' not in def_contents:
         raise FatalError('gendef failed on {!r}\n{}'.format(dllpath, def_contents))
     with open(os.path.join(outputdir, defname), 'w') as f:
         f.write(def_contents)
     return defname
コード例 #14
0
    def _call(cmd, delimiter=None, env=None):
        env = os.environ.copy() if env is None else env.copy()
        output = shell.check_output(cmd, env=env)
        output = output.strip()

        if delimiter:
            res = output.split('%s' % delimiter)
            if res[0] == ' ':
                res.remove(' ')
            if res[0] == '':
                res.remove('')
            return [x.strip() for x in res]
        return output
コード例 #15
0
 def list_file_deps(self, prefix, path):
     env = os.environ.copy()
     env['LC_ALL'] = 'C'
     files = shell.check_output(['objdump', '-xw', path],
                                env=env).splitlines()
     prog = re.compile(r"(?i)^.*DLL[^:]*: (\S+\.dll)$")
     files = [
         prog.sub(r"\1", x) for x in files if prog.match(x) is not None
     ]
     files = [
         os.path.join(prefix, 'bin', x) for x in files
         if x.lower().endswith('dll')
     ]
     return [os.path.realpath(x) for x in files if os.path.exists(x)]
コード例 #16
0
ファイル: git.py プロジェクト: jiatingxiu/cerbero
def check_line_endings(platform):
    '''
    Checks if on windows we don't use the automatic line endings conversion
    as it breaks everything

    @param platform: the host platform
    @type platform: L{cerbero.config.Platform}
    @return: true if git config is core.autorlf=false
    @rtype: bool
    '''
    if platform != Platform.WINDOWS:
        return True
    val = shell.check_output([GIT, 'config', '--get', 'core.autocrlf'], fail=False)
    if ('false' in val.lower()):
        return True
    return False
コード例 #17
0
ファイル: git.py プロジェクト: jiatingxiu/cerbero
def get_hash(git_dir, commit, logfile=None):
    '''
    Get a commit hash from a valid commit.
    Can be used to check if a commit exists

    @param git_dir: path of the git repository
    @type git_dir: str
    @param commit: the commit to log
    @type commit: str
    '''
    if not os.path.isdir(os.path.join(git_dir, '.git')):
        # If a recipe's source type is switched from tarball to git, then we
        # can get called from built_version() when the directory isn't git.
        # Return a fixed string + unix time to trigger a full fetch.
        return 'not-git-' + str(time.time())
    return shell.check_output([GIT, 'rev-parse', commit], cmd_dir=git_dir,
                              fail=False, quiet=True, logfile=logfile).rstrip()
コード例 #18
0
ファイル: git.py プロジェクト: jiatingxiu/cerbero
async def submodules_update(git_dir, src_dir=None, fail=True, offline=False, logfile=None):
    '''
    Update submodules asynchronously from local directory

    @param git_dir: path of the git repository
    @type git_dir: str
    @param src_dir: path or base URI of the source directory
    @type src_dir: src
    @param fail: raise an error if the command failed
    @type fail: false
    @param offline: don't use the network
    @type offline: false
    '''
    if src_dir:
        config = shell.check_output([GIT, 'config', '--file=.gitmodules', '--list'],
                                    fail=False, cmd_dir=git_dir, logfile=logfile)
        config_array = [s.split('=', 1) for s in config.splitlines()]
        for c in config_array:
            if c[0].startswith('submodule.') and c[0].endswith('.path'):
                submodule = c[0][len('submodule.'):-len('.path')]
                shell.new_call([GIT, 'config', '--file=.gitmodules', 'submodule.{}.url'.format(submodule),
                                os.path.join(src_dir, c[1])], cmd_dir=git_dir, logfile=logfile)
    shell.new_call([GIT, 'submodule', 'init'], cmd_dir=git_dir, logfile=logfile)
    if src_dir or not offline:
        await shell.async_call([GIT, 'submodule', 'sync'], cmd_dir=git_dir, logfile=logfile,
                               cpu_bound=False)
        await shell.async_call([GIT, 'submodule', 'update'], cmd_dir=git_dir, fail=fail,
                               logfile=logfile, cpu_bound=False)
    else:
        await shell.async_call([GIT, 'submodule', 'update', '--no-fetch'], cmd_dir=git_dir,
                               fail=fail, logfile=logfile, cpu_bound=False)
    if src_dir:
        for c in config_array:
            if c[0].startswith('submodule.') and c[0].endswith('.url'):
                shell.new_call([GIT, 'config', '--file=.gitmodules', c[0], c[1]],
                               cmd_dir=git_dir, logfile=logfile)
        await shell.async_call([GIT, 'submodule', 'sync'], cmd_dir=git_dir, logfile=logfile,
                               cpu_bound=False)
コード例 #19
0
 def get_file_type(self, filepath):
     return shell.check_output([self.FILE_CMD, '-bh',
                                filepath])[:-1]  #remove trailing \n
コード例 #20
0
ファイル: osxrelocator.py プロジェクト: wangfan008/cerbero
 def _is_mach_o_file(self, filename):
     return os.path.splitext(filename)[1] in ['.dylib', '.so'] or \
             shell.check_output(['file', '-bh', filename]).startswith('Mach-O')
コード例 #21
0
 def list_deps(self, prefix, path):
     files = shell.check_output(['ldd', path]).splitlines()
     return [x.split(' ')[2] for x in files if prefix in x]