Ejemplo n.º 1
0
    def __init__(self, myspec, addlargs):
        TargetBase.__init__(self, myspec, addlargs)

        self.git = command('git')
        self.ebuild_repo = Path(self.settings['repos_storedir'],
                                self.settings['repo_name']).with_suffix('.git')
        self.gitdir = str(self.ebuild_repo)
Ejemplo n.º 2
0
    def run(self):
        if self.settings['snapshot_treeish'] == 'stable':
            treeish = self.update_ebuild_repo()
        else:
            treeish = self.settings['snapshot_treeish']

        self.set_snapshot(treeish)

        git_cmd = [
            self.git, '-C', self.gitdir, 'archive', '--format=tar', treeish
        ]
        tar2sqfs_cmd = [
            command('tar2sqfs'),
            str(self.snapshot), '-q', '-f', '-j1', '-c', 'gzip'
        ]

        log.notice('Creating %s tree snapshot %s from %s',
                   self.settings['repo_name'], treeish, self.gitdir)
        log.notice('>>> ' + ' '.join([*git_cmd, '|']))
        log.notice('    ' + ' '.join(tar2sqfs_cmd))

        lockfile = self.snapshot.with_suffix('.lock')
        with write_lock(lockfile):
            git = subprocess.Popen(git_cmd,
                                   stdout=subprocess.PIPE,
                                   stderr=sys.stderr,
                                   close_fds=False)
            tar2sqfs = subprocess.Popen(tar2sqfs_cmd,
                                        stdin=git.stdout,
                                        stdout=sys.stdout,
                                        stderr=sys.stderr,
                                        close_fds=False)
            git.stdout.close()
            git.wait()
            tar2sqfs.wait()

        if tar2sqfs.returncode == 0:
            log.notice('Wrote snapshot to %s', self.snapshot)
        else:
            log.error('Failed to create snapshot')
        return tar2sqfs.returncode == 0