Exemplo n.º 1
0
            cmd.append(self.checkoutdir)

        if self.config.sticky_date:
            raise FatalError('date based checkout not yet supported\n')

        buildscript.execute(cmd, 'bzr', cwd=self.config.checkoutroot)

    def _update(self, buildscript, overwrite=False):
        if self.config.sticky_date:
            raise FatalError('date based checkout not yet supported\n')
        cmd = ['bzr', 'pull']
        if overwrite:
            cmd.append('--overwrite')
        cmd.append(self.module)
        buildscript.execute(cmd, 'bzr', cwd=self.srcdir)

    def checkout(self, buildscript):
        if os.path.exists(self.srcdir):
            self._update(buildscript)
        else:
            self._checkout(buildscript)

    def force_checkout(self, buildscript):
        if os.path.exists(self.srcdir):
            self._update(buildscript, overwrite=True)
        else:
            self._checkout(buildscript)


register_repo_type('bzr', BzrRepository)
Exemplo n.º 2
0
    def checkout(self, buildscript):
        if not inpath('bzr', os.environ['PATH'].split(os.pathsep)):
            raise CommandError(_('%s not found') % 'bzr')
        Branch.checkout(self, buildscript)

    def tree_id(self):
        if not os.path.exists(self.srcdir):
            return None
        try:
            # --tree is new in bzr 1.17
            cmd = ['bzr', 'revision-info', '--tree']
            tree_id = get_output(cmd, cwd=self.srcdir).strip()
        except CommandError:
            return None
        return tree_id

    def to_sxml(self):
        attrs = {}
        if self.revspec:
            attrs = self.revspec()[0]
        return [
            sxml.branch(repo=self.repository.name,
                        module=self.module,
                        revid=self.tree_id(),
                        **attrs)
        ]


register_repo_type('bzr', BzrRepository)
Exemplo n.º 3
0
        # XXX: doesn't support alternative checkout modes
        if not inpath('mtn', os.environ['PATH'].split(os.pathsep)):
            raise CommandError(_('%s not found') % 'mtn')

        if not os.path.exists(self.repository.database):
            self._init(buildscript)

        self._pull(buildscript)

        if os.path.exists(self.srcdir):
            try:
                self._check_for_conflict()
            except CommandError:
                buildscript.execute(['mtn', 'heads'], 'mtn', cwd=self.srcdir)
                raise

            self._update(buildscript)
        else:
            self._checkout(buildscript)

    def tree_id(self):
        try:
            output = get_output(['mtn', 'automate', 'get_base_revision_id'],
                                cwd=self.srcdir)
        except CommandError:
            return None
        return output[0]


register_repo_type('mtn', MonotoneRepository)
Exemplo n.º 4
0
            buildscript.execute(cmd,
                                cwd=copydir,
                                extra_env=get_git_extra_env())
        else:
            buildscript.execute(cmd,
                                cwd=self.config.checkoutroot,
                                extra_env=get_git_extra_env())

    def _update(self, buildscript, copydir=None):
        if self.config.sticky_date:
            raise FatalError(_('date based checkout not yet supported\n'))

        cwd = self.get_checkoutdir()
        git_extra_args = {'cwd': cwd, 'extra_env': get_git_extra_env()}

        stashed = False
        # stash uncommitted changes on the current branch
        if get_output(['git', 'diff'], **git_extra_args):
            # stash uncommitted changes on the current branch
            stashed = True
            buildscript.execute(['git', 'stash', 'save', 'jhbuild-stash'],
                                **git_extra_args)

        self._checkout(buildscript, copydir=copydir)

        if stashed:
            buildscript.execute(['git', 'stash', 'pop'], **git_extra_args)


register_repo_type('git', GitRepository)
Exemplo n.º 5
0
    def _fix_permissions(self):
        # This is a hack to make the autogen.sh and/or configure
        # scripts executable.  This is needed because Darcs does not
        # version the executable bit.
        for filename in ['autogen.sh', 'configure']:
            path = os.path.join(self.srcdir, filename)
            try:
                stat = os.stat(path)
            except OSError, e:
                continue
            os.chmod(path, stat.st_mode | 0111)

    def checkout(self, buildscript):
        if not inpath('darcs', os.environ['PATH'].split(os.pathsep)):
            raise CommandError(_('%s not found') % 'darcs')
        Branch.checkout(self, buildscript)
        self._fix_permissions()

    def tree_id(self):
        # XXX: check with some darcs expert if there is not a command to get
        # this
        if not os.path.exists(self.srcdir):
            return None
        return hashlib.md5(
            file(os.path.join(self.srcdir, '_darcs',
                              'inventory')).read()).hexdigest()


register_repo_type('darcs', DarcsRepository)
Exemplo n.º 6
0
Arquivo: hg.py Projeto: aissat/jhbuild
    def _update(self, buildscript):
        if self.config.sticky_date:
            raise FatalError(_("date based checkout not yet supported\n"))
        if os.path.exists(SRCDIR):
            hg_update_path = os.path.join(SRCDIR, "scripts", "hg-update.py")
        else:
            hg_update_path = os.path.join(PKGDATADIR, "hg-update.py")
        hg_update_path = os.path.normpath(hg_update_path)
        buildscript.execute([hg_update_path], "hg", cwd=self.srcdir)

    def checkout(self, buildscript):
        if not inpath("hg", os.environ["PATH"].split(os.pathsep)):
            raise CommandError(_("%s not found") % "hg")
        Branch.checkout(self, buildscript)

    def get_revision_id(self):
        # Return the id of the tip, see bug #313997.
        try:
            hg = Popen(["hg", "ti", "--template", "{node}"], stdout=PIPE, cwd=self.srcdir)
        except OSError, e:
            raise CommandError(str(e))
        return hg.stdout.read().strip()

    def tree_id(self):
        if not os.path.exists(self.srcdir):
            return None
        return self.get_revision_id()


register_repo_type("hg", HgRepository)
Exemplo n.º 7
0
    def _update(self, buildscript):
        if self.config.sticky_date:
            raise FatalError(_('date based checkout not yet supported\n'))
        if os.path.exists(SRCDIR):
            hg_update_path = os.path.join(SRCDIR, 'scripts', 'hg-update.py')
        else:
            hg_update_path = os.path.join(PKGDATADIR, 'hg-update.py')
        hg_update_path = os.path.normpath(hg_update_path)
        buildscript.execute([hg_update_path], 'hg', cwd=self.srcdir)

    def checkout(self, buildscript):
        if not inpath('hg', os.environ['PATH'].split(os.pathsep)):
            raise CommandError(_('%s not found') % 'hg')
        Branch.checkout(self, buildscript)

    def get_revision_id(self):
        # Return the id of the tip, see bug #313997.
        try:
            hg = Popen(['hg', 'ti', '--template', '{node}'], stdout=PIPE,
                       cwd=self.srcdir)
        except OSError, e:
            raise CommandError(str(e))
        return hg.stdout.read().strip()

    def tree_id(self):
        if not os.path.exists(self.srcdir):
            return None
        return self.get_revision_id()

register_repo_type('hg', HgRepository)
Exemplo n.º 8
0
        ]
        if self.update_new_dirs:
            cmd.append('-d')
        if self.revision:
            cmd.extend(['-r', self.revision])
        if self.config.sticky_date:
            cmd.extend(['-D', self.config.sticky_date])
        if not (self.revision or self.config.sticky_date):
            cmd.append('-A')
        cmd.append('.')
        buildscript.execute(cmd, 'cvs', cwd=outputdir)

    def checkout(self, buildscript):
        if not inpath('cvs', os.environ['PATH'].split(os.pathsep)):
            raise CommandError(_('%s not found') % 'cvs')
        Branch.checkout(self, buildscript)

    def tree_id(self):
        if not os.path.exists(self.srcdir):
            return None
        md5sum = hashlib.md5()
        _process_directory(self.srcdir, '', md5sum.update)
        return 'jhbuild-cvs-treeid:%s' % md5sum.hexdigest()

    def to_sxml(self):
        # FIXME: fix the current revision
        return [sxml.branch(repo=self.repository.name, module=self.module)]


register_repo_type('cvs', CVSRepository)
Exemplo n.º 9
0
            raise FatalError(_('date based checkout not yet supported\n'))

        cmd = ['fossil', 'pull', self.module]
        buildscript.execute(cmd, 'fossil', cwd=self.srcdir)

        cmd = ['fossil', 'update']
        buildscript.execute(cmd, 'fossil', cwd=self.srcdir)

    def checkout(self, buildscript):
        if not inpath('fossil', os.environ['PATH'].split(os.pathsep)):
            raise CommandError(_('%s not found') % 'fossil')
        Branch.checkout(self, buildscript)

    def get_revision_id(self):
        import re

        try:
            infos = Popen(['fossil', 'info'], stdout=PIPE, cwd=self.srcdir)
        except OSError as e:
            raise CommandError(str(e))
        infos = infos.stdout.read().strip()
        return re.search(r"checkout: +(\w+)", infos).group(1)

    def tree_id(self):
        if not os.path.exists(self.srcdir):
            return None
        return self.get_revision_id()


register_repo_type('fossil', FossilRepository)
Exemplo n.º 10
0
from jhbuild.utils.sxml import sxml

class SystemRepository(Repository):

    branch_xml_attrs = ['version']

    def branch(self, name, version = None):
        instance = SystemBranch(self, version)
        return instance

    def to_sxml(self):
        return [sxml.repository(type='system', name=self.name)]

class SystemBranch(Branch):

    def __init__(self, repository, version):
        Branch.__init__(self, repository, module = None, checkoutdir = None)
        self.version = version

    def branchname(self):
        return self.version
    branchname = property(branchname)

    def to_sxml(self):
        return ([sxml.branch(module=self.module,
                             repo=self.repository,
                             version=self.version)])


register_repo_type('system', SystemRepository)
Exemplo n.º 11
0
        if self.update_new_dirs:
            cmd.append('-d')
        if self.revision:
            cmd.extend(['-r', self.revision])
        if self.config.sticky_date:
            cmd.extend(['-D', self.config.sticky_date])
        if not (self.revision or self.config.sticky_date):
            cmd.append('-A')
        cmd.append('.')
        buildscript.execute(cmd, 'cvs', cwd=outputdir)

    def checkout(self, buildscript):
        if not inpath('cvs', os.environ['PATH'].split(os.pathsep)):
            raise CommandError(_('%s not found') % 'cvs')
        Branch.checkout(self, buildscript)

    def tree_id(self):
        if not os.path.exists(self.srcdir):
            return None
        md5sum = hashlib.md5()
        _process_directory(self.srcdir, '', md5sum.update)
        return 'jhbuild-cvs-treeid:%s' % md5sum.hexdigest()

    def to_sxml(self):
        # FIXME: fix the current revision
        return [sxml.branch(repo=self.repository.name,
                            module=self.module)]


register_repo_type('cvs', CVSRepository)
Exemplo n.º 12
0
        if date:
            raise BuildStageError('date based checkout not yet supported\n')

        archive, version = split_name(self.module)
        # how do you move a working copy to another branch?
        wc_archive, wc_version = get_version(self.srcdir)
        if (wc_archive, wc_version) != (archive, version):
            cmd = ['baz', 'switch', self.module]
        else:
            cmd = ['baz', 'update']

        buildscript.execute(cmd, 'arch', cwd=self.srcdir)

    def checkout(self, buildscript):
        if os.path.exists(self.srcdir):
            self._update(buildscript)
        else:
            self._checkout(buildscript)

    def force_checkout(self, buildscript):
        self._checkout(buildscript)

    def tree_id(self):
        data = get_output(['baz', 'tree-id', '-d', self.srcdir])
        return data.strip()



register_repo_type('arch', ArchRepository)
Exemplo n.º 13
0
        if self.config.sticky_date:
            raise FatalError('date based checkout not yet supported\n')

        buildscript.execute(cmd, 'darcs', cwd=self.config.checkoutroot)

    def _update(self, buildscript):
        if self.config.sticky_date:
            raise FatalError('date based checkout not yet supported\n')
        buildscript.execute(['darcs', 'pull', '-a'], 'darcs', cwd=self.srcdir)

    def _fix_permissions(self):
        # This is a hack to make the autogen.sh and/or configure
        # scripts executable.  This is needed because Darcs does not
        # version the executable bit.
        for filename in ['autogen.sh', 'configure']:
            path = os.path.join(self.srcdir, filename)
            try:
                stat = os.stat(path)
            except OSError, e:
                continue
            os.chmod(path, stat.st_mode | 0111)

    def checkout(self, buildscript):
        if os.path.exists(self.srcdir):
            self._update(buildscript)
        else:
            self._checkout(buildscript)
        self._fix_permissions()

register_repo_type('darcs', DarcsRepository)
Exemplo n.º 14
0
    def may_checkout(self, buildscript):
        if os.path.exists(self._local_tarball):
            return True
        elif buildscript.config.nonetwork:
            return False
        return True

    def tree_id(self):
        md5sum = hashlib.md5()
        if self.patches:
            for patch in self.patches:
                md5sum.update(patch[0])
        if self.quilt:
            md5sum.update(get_output('quilt files',
                        cwd=self.srcdir,
                        extra_env={'QUILT_PATCHES' : self.quilt.srcdir}))
        return '%s-%s' % (self.version, md5sum.hexdigest())

    def to_sxml(self):
        return ([sxml.branch(module=self.module,
                             repo=self.repository.name,
                             version=self.version,
                             size=str(self.source_size),
                             hash=self.source_hash)]
                + [[sxml.patch(file=patch, strip=str(strip))]
                   for patch, strip in self.patches])


register_repo_type('tarball', TarballRepository)
Exemplo n.º 15
0
        if self.config.sticky_date:
            raise FatalError(_('date based checkout not yet supported\n'))

        cmd = ['fossil', 'pull', self.module]
        buildscript.execute(cmd, 'fossil', cwd=self.srcdir)

        cmd = ['fossil', 'update']
        buildscript.execute(cmd, 'fossil', cwd=self.srcdir)

    def checkout(self, buildscript):
        if not inpath('fossil', os.environ['PATH'].split(os.pathsep)):
            raise CommandError(_('%s not found') % 'fossil')
        Branch.checkout(self, buildscript)

    def get_revision_id(self):
        import re

        try:
            infos = Popen(['fossil', 'info'], stdout=PIPE, cwd=self.srcdir)
        except OSError as e:
            raise CommandError(str(e))
        infos = infos.stdout.read().strip()
        return re.search(r"checkout: +(\w+)", infos).group(1)

    def tree_id(self):
        if not os.path.exists(self.srcdir):
            return None
        return self.get_revision_id()

register_repo_type('fossil', FossilRepository)
Exemplo n.º 16
0
        elif buildscript.config.nonetwork:
            return False
        return True

    def tree_id(self):
        md5sum = hashlib.md5()
        if self.patches:
            for patch in self.patches:
                md5sum.update(patch[0].encode("utf-8"))
        if self.quilt:
            md5sum.update(
                get_output('quilt files',
                           cwd=self.srcdir,
                           extra_env={
                               'QUILT_PATCHES': self.quilt.srcdir
                           }).encode("utf-8"))
        return '%s-%s' % (self.version, md5sum.hexdigest())

    def to_sxml(self):
        return ([
            sxml.branch(module=self.module,
                        repo=self.repository.name,
                        version=self.version,
                        size=str(self.source_size),
                        hash=self.source_hash)
        ] + [[sxml.patch(file=patch, strip=str(strip))]
             for patch, strip in self.patches])


register_repo_type('tarball', TarballRepository)
Exemplo n.º 17
0
                info = get_info(self.srcdir)
        except CommandError:
            return None
        try:
            url = info['url']
            root = info['repository root']
            uuid = info['repository uuid']
            rev = info['last changed rev']
        except KeyError:
            return None

        # get the path within the repository
        assert url.startswith(root)
        path = url[len(root):]
        while path.startswith('/'):
            path = path[1:]

        return '%s,%s,%s' % (uuid.lower(), rev, path)

    def to_sxml(self):
        return (call_with_info(lambda rev:
                                   [sxml.branch(repo=self.repository.name,
                                                module=self.module,
                                                revision=rev)],
                               self.srcdir, 'last changed rev')
                or [sxml.branch(repo=self.repository.name,
                                module=self.module)])


register_repo_type('svn', SubversionRepository)
Exemplo n.º 18
0
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA

from jhbuild.versioncontrol import Branch, Repository, register_repo_type
from jhbuild.utils.sxml import sxml

class SystemRepository(Repository):

    branch_xml_attrs = ['version']

    def branch(self, name, version, module = None,
               checkoutdir = None):
        instance = SystemBranch(self, module, version, checkoutdir)
        return instance

    def to_sxml(self):
        return [sxml.repository(type='system', name=self.name)]

class SystemBranch(Branch):

    def __init__(self, repository, module, version, checkoutdir):
        Branch.__init__(self, repository, module, checkoutdir)
        self.version = version

    def to_sxml(self):
        return ([sxml.branch(module=self.module,
                             repo=self.repository,
                             version=self.version)])


register_repo_type('system', SystemRepository)
Exemplo n.º 19
0
            raise FatalError(_("date based checkout not yet supported\n"))

        cmd = ["fossil", "pull", self.module]
        buildscript.execute(cmd, "fossil", cwd=self.srcdir)

        cmd = ["fossil", "update"]
        buildscript.execute(cmd, "fossil", cwd=self.srcdir)

    def checkout(self, buildscript):
        if not inpath("fossil", os.environ["PATH"].split(os.pathsep)):
            raise CommandError(_("%s not found") % "fossil")
        Branch.checkout(self, buildscript)

    def get_revision_id(self):
        import re

        try:
            infos = Popen(["fossil", "info"], stdout=PIPE, cwd=self.srcdir)
        except OSError, e:
            raise CommandError(str(e))
        infos = infos.stdout.read().strip()
        return re.search(r"checkout: +(\w+)", infos).group(1)

    def tree_id(self):
        if not os.path.exists(self.srcdir):
            return None
        return self.get_revision_id()


register_repo_type("fossil", FossilRepository)
Exemplo n.º 20
0
            raise FatalError(_('date based checkout not yet supported\n'))
        if os.path.exists(SRCDIR):
            hg_update_path = os.path.join(SRCDIR, 'scripts', 'hg-update.py')
        else:
            hg_update_path = os.path.join(PKGDATADIR, 'hg-update.py')
        hg_update_path = os.path.normpath(hg_update_path)
        buildscript.execute([hg_update_path], 'hg', cwd=self.srcdir)

    def checkout(self, buildscript):
        if not inpath('hg', os.environ['PATH'].split(os.pathsep)):
            raise CommandError(_('%s not found') % 'hg')
        Branch.checkout(self, buildscript)

    def get_revision_id(self):
        # Return the id of the tip, see bug #313997.
        try:
            hg = Popen(['hg', 'ti', '--template', '{node}'],
                       stdout=PIPE,
                       cwd=self.srcdir)
        except OSError, e:
            raise CommandError(str(e))
        return hg.stdout.read().strip()

    def tree_id(self):
        if not os.path.exists(self.srcdir):
            return None
        return self.get_revision_id()


register_repo_type('hg', HgRepository)
Exemplo n.º 21
0
        cmd.append(self.module)

        if copydir:
            buildscript.execute(cmd, cwd=copydir, extra_env=get_git_extra_env())
        else:
            buildscript.execute(cmd, cwd=self.config.checkoutroot,
                    extra_env=get_git_extra_env())

    def _update(self, buildscript, copydir=None):
        if self.config.sticky_date:
            raise FatalError(_('date based checkout not yet supported\n'))

        cwd = self.get_checkoutdir()
        git_extra_args = {'cwd': cwd, 'extra_env': get_git_extra_env()}

        stashed = False
        # stash uncommitted changes on the current branch
        if get_output(['git', 'diff'], **git_extra_args):
            # stash uncommitted changes on the current branch
            stashed = True
            buildscript.execute(['git', 'stash', 'save', 'jhbuild-stash'],
                    **git_extra_args)

        self._checkout(buildscript, copydir=copydir)

        if stashed:
            buildscript.execute(['git', 'stash', 'pop'], **git_extra_args)

register_repo_type('git', GitRepository)
Exemplo n.º 22
0
        # XXX: doesn't support alternative checkout modes
        if not inpath('mtn', os.environ['PATH'].split(os.pathsep)):
            raise CommandError(_('%s not found') % 'mtn')

        if not os.path.exists(self.repository.database):
            self._init(buildscript)

        self._pull(buildscript)

        if os.path.exists(self.srcdir):
            try:
                self._check_for_conflict()
            except CommandError:
                buildscript.execute(['mtn', 'heads'], 'mtn', cwd=self.srcdir)
                raise

            self._update(buildscript)
        else:
            self._checkout(buildscript)

    def tree_id(self):
        try:
            output = get_output(['mtn', 'automate', 'get_base_revision_id'],
                                cwd=self.srcdir)
        except CommandError:
            return None
        return output[0]


register_repo_type('mtn', MonotoneRepository)
Exemplo n.º 23
0
    def __init__(self, config, name):
        Repository.__init__(self, config, name)

    branch_xml_attrs = ['version']

    def branch(self, name, version = None):
        instance = PipBranch(self, version)
        return instance

    def to_sxml(self):
        return [sxml.repository(type='pip', name=self.name)]

class PipBranch(Branch):

    def __init__(self, repository, version):
        Branch.__init__(self, repository, module = None, checkoutdir = None)
        self.version = version

    def branchname(self):
        return self.version
    branchname = property(branchname)

    def tree_id(self):
        return self.version

    def to_sxml(self):
        return ([sxml.branch(repo=self.repository.name, version=self.version)])

register_repo_type('pip', PipRepository)