Пример #1
0
    def extract(self):
        if os.path.exists(self.build_dir):
            # fix read-only permissions
            if self.config.platform == Platform.WINDOWS:
                shell.call('chmod -R +w .git/', self.build_dir, fail=False)
            try:
                commit_hash = git.get_hash(self.repo_dir, self.commit)
                checkout_hash = git.get_hash(self.build_dir, 'HEAD')
                if commit_hash == checkout_hash and not self.patches:
                    return False
            except Exception:
                pass
            shutil.rmtree(self.build_dir)
        if not os.path.exists(self.build_dir):
            os.mkdir(self.build_dir)

        # checkout the current version
        git.local_checkout(self.build_dir, self.repo_dir, self.commit)

        for patch in self.patches:
            if not os.path.isabs(patch):
                patch = self.relative_path(patch)

            if self.strip == 1:
                git.apply_patch(patch, self.build_dir)
            else:
                shell.apply_patch(patch, self.build_dir, self.strip)

        return True
Пример #2
0
    async def extract(self):
        if os.path.exists(self.config_src_dir):
            try:
                commit_hash = git.get_hash(self.repo_dir, self.commit, logfile=get_logfile(self))
                checkout_hash = git.get_hash(self.config_src_dir, 'HEAD', logfile=get_logfile(self))
                if commit_hash == checkout_hash and not self.patches:
                    return False
            except Exception:
                pass
            shutil.rmtree(self.config_src_dir)
        if not os.path.exists(self.config_src_dir):
            os.makedirs(self.config_src_dir)

        # checkout the current version
        await git.local_checkout(self.config_src_dir, self.repo_dir, self.commit, logfile=get_logfile(self))

        for patch in self.patches:
            if not os.path.isabs(patch):
                patch = self.relative_path(patch)

            if self.strip == 1:
                git.apply_patch(patch, self.config_src_dir, logfile=get_logfile(self))
            else:
                shell.apply_patch(patch, self.config_src_dir, self.strip, logfile=get_logfile(self))

        return True
Пример #3
0
    def extract(self):
        if os.path.exists(self.build_dir):
            try:
                commit_hash = git.get_hash(self.repo_dir, self.commit)
                checkout_hash = git.get_hash(self.build_dir, 'HEAD')
                if commit_hash == checkout_hash and not self.patches:
                    return False
            except Exception:
                pass
            shutil.rmtree(self.build_dir)
        if not os.path.exists(self.build_dir):
            os.mkdir(self.build_dir)

        # checkout the current version
        git.local_checkout(self.build_dir, self.repo_dir, self.commit)

        for patch in self.patches:
            if not os.path.isabs(patch):
                patch = self.relative_path(patch)

            if self.strip == 1:
                git.apply_patch(patch, self.build_dir)
            else:
                shell.apply_patch(patch, self.build_dir, self.strip)

        return True
Пример #4
0
    def extract(self):
        if os.path.exists(self.build_dir):
            try:
                commit_hash = git.get_hash(self.repo_dir, self.commit)
                checkout_hash = git.get_hash(self.build_dir, 'HEAD')
                if commit_hash == checkout_hash and not self.patches:
                    return False
            except Exception:
                pass
            shutil.rmtree(self.build_dir)
        if not os.path.exists(self.build_dir):
            os.mkdir(self.build_dir)

        # checkout the current version
        git.local_checkout(self.build_dir, self.repo_dir, self.commit)

        for patch in self.patches:
            if not os.path.isabs(patch):
                patch = self.relative_path(patch)

            if self.strip == 1:
                git.apply_patch(patch, self.build_dir)
            else:
                shell.apply_patch(patch, self.build_dir, self.strip)

        return True
Пример #5
0
    def extract(self):
        # For Git with LFS there's a bug where we can not fetch from
        # a local folder. We overcome that by using the --reference arg
        # https://github.com/git-lfs/git-lfs/issues/1207#issuecomment-217455331
        if os.path.exists(self.build_dir):
            # fix read-only permissions
            if self.config.platform == Platform.WINDOWS:
                shell.call('chmod -R +w .git/', self.build_dir, fail=False)
            try:
                commit_hash = git.get_hash(self.repo_dir, self.commit)
                checkout_hash = git.get_hash(self.build_dir, 'HEAD')
                if commit_hash == checkout_hash:
                    return False
            except Exception:
                pass
            shutil.rmtree(self.build_dir)
        if not os.path.exists(self.build_dir):
            os.mkdir(self.build_dir)
        if self.supports_non_src_build:
            return

        # get the remote this commit belongs too
        branch = shell.check_call(
            'git branch -r --contains %s' % (self.commit), self.repo_dir)
        remote = branch.strip().split('/')[0]
        # this one appears on git 2.7
        remote_url = shell.check_call('git remote get-url %s' % (remote),
                                      self.repo_dir).rstrip()
        shell.call(
            'git clone --no-checkout --reference %s %s .' %
            (self.repo_dir, remote_url), self.build_dir)
        shell.call('git checkout -b build %s' % (self.commit), self.build_dir)
        shell.call('git submodule update --init --recursive', self.build_dir)
Пример #6
0
    def extract(self):
        # For Git with LFS there's a bug where we can not fetch from
        # a local folder. We overcome that by using the --reference arg
        # https://github.com/git-lfs/git-lfs/issues/1207#issuecomment-217455331
        if os.path.exists(self.build_dir):
            # fix read-only permissions
            if self.config.platform == Platform.WINDOWS:
                shell.call('chmod -R +w .git/', self.build_dir, fail=False)
            try:
                commit_hash = git.get_hash(self.repo_dir, self.commit)
                checkout_hash = git.get_hash(self.build_dir, 'HEAD')
                if commit_hash == checkout_hash:
                    return False
            except Exception:
                pass
            shutil.rmtree(self.build_dir)
        if not os.path.exists(self.build_dir):
            os.mkdir(self.build_dir)
        if self.supports_non_src_build:
            return

        # get the remote this commit belongs too
        branch = shell.check_call('git branch -r --contains %s' % (self.commit), self.repo_dir)
        remote = branch.strip().split('/')[0]
        # this one appears on git 2.7
        remote_url = shell.check_call('git remote get-url %s' % (remote), self.repo_dir).rstrip()
        shell.call('git clone --no-checkout --reference %s %s .' % (self.repo_dir, remote_url), self.build_dir)
        shell.call('git checkout -b build %s' % (self.commit), self.build_dir)
        shell.call('git submodule update --init --recursive', self.build_dir)
Пример #7
0
    def extract(self):
        if os.path.exists(self.build_dir):
            # fix read-only permissions
            if self.config.platform == Platform.WINDOWS:
                shell.call('chmod -R +w .git/', self.build_dir, fail=False)
            try:
                commit_hash = git.get_hash(self.repo_dir, self.commit)
                checkout_hash = git.get_hash(self.build_dir, 'HEAD')
                if commit_hash == checkout_hash:
                    return False
            except Exception:
                pass
            shutil.rmtree(self.build_dir)
        if not os.path.exists(self.build_dir):
            os.mkdir(self.build_dir)
        if self.supports_non_src_build:
            return

        # checkout the current version
        git.local_checkout(self.build_dir, self.repo_dir, self.commit)
        return True
Пример #8
0
    def extract(self):
        if os.path.exists(self.build_dir):
            # fix read-only permissions
            if self.config.platform == Platform.WINDOWS:
                shell.call('chmod -R +w .git/', self.build_dir, fail=False)
            try:
                commit_hash = git.get_hash(self.repo_dir, self.commit)
                checkout_hash = git.get_hash(self.build_dir, 'HEAD')
                if commit_hash == checkout_hash:
                    return False
            except Exception:
                pass
            shutil.rmtree(self.build_dir)
        if not os.path.exists(self.build_dir):
            os.mkdir(self.build_dir)
        if self.supports_non_src_build:
            return

        # checkout the current version
        git.local_checkout(self.build_dir, self.repo_dir, self.commit)
        return True
Пример #9
0
    def run(self, config, args):
        if not config.uninstalled:
            raise FatalError(
                _("fetch-cache is only available with "
                  "cerbero-uninstalled"))

        git_dir = os.path.dirname(sys.argv[0])
        sha = git.get_hash(git_dir, args.commit)
        deps = self.get_deps(config, args)
        if not args.skip_fetch:
            dep = self.find_dep(deps, sha)
            if dep:
                run_until_complete(self.fetch_dep(config, dep, args.namespace))
        if args.job_id:
            self.update_log(config, args, deps, sha)
Пример #10
0
 def built_version(self):
     return '%s+git~%s' % (self.version, git.get_hash(self.repo_dir, self.commit))
Пример #11
0
 def built_version(self):
     return '%s+git~%s' % (self.version, git.get_hash(self.repo_dir, self.commit, logfile=get_logfile(self)))
Пример #12
0
 def get_git_sha(self, args):
     git_dir = os.path.abspath(os.path.dirname(sys.argv[0]))
     return git.get_hash(git_dir, args.commit)