Exemplo n.º 1
0
    def _update(self, buildscript, copydir=None, update_mirror=True):
        cwd = self.get_checkoutdir()
        git_extra_args = {'cwd': cwd, 'extra_env': get_git_extra_env()}

        if not os.path.exists(os.path.join(cwd, '.git')):
            if os.path.exists(os.path.join(cwd, '.svn')):
                raise CommandError(
                    _('Failed to update module as it switched to git (you should check for changes then remove the directory).'
                      ))
            raise CommandError(
                _('Failed to update module (missing .git) (you should check for changes then remove the directory).'
                  ))

        if update_mirror:
            self.update_dvcs_mirror(buildscript)

        buildscript.execute(
            ['git', 'remote', 'set-url', 'origin', self.module],
            **git_extra_args)

        buildscript.execute(['git', 'remote', 'update', 'origin'],
                            **git_extra_args)

        if self.config.sticky_date:
            self.move_to_sticky_date(buildscript)

        self.switch_branch_if_necessary(buildscript)

        self.rebase_current_branch(buildscript)

        self._update_submodules(buildscript)
Exemplo n.º 2
0
    def switch_branch_if_necessary(self, buildscript):
        """
        The switch depends on the requested tag, the requested branch, and the
        state and type of the current branch.

        An imminent branch switch generates an error if there are uncommited
        changes.
        """
        wanted_branch = self.get_branch_switch_destination()
        switch_command = []
        if self.tag:
            switch_command = ['git', 'checkout', self.tag]
        elif wanted_branch:
            if self.is_local_branch(wanted_branch):
                switch_command = ['git', 'checkout', wanted_branch]
            else:
                if not self.find_remote_branch_online_if_necessary(
                        buildscript, 'origin', wanted_branch):
                    raise CommandError(
                        _('The requested branch "%s" is '
                          'not available. Neither locally, nor remotely '
                          'in the origin remote.' % wanted_branch))
                switch_command = [
                    'git', 'checkout', '--track', '-b', wanted_branch,
                    'origin/' + wanted_branch
                ]

        if switch_command:
            if self.is_dirty():
                raise CommandError(_('Refusing to switch a dirty tree.'))
            buildscript.execute(switch_command,
                                cwd=self.get_checkoutdir(),
                                extra_env=get_git_extra_env())
Exemplo n.º 3
0
def unpack_archive(buildscript,
                   localfile,
                   target_directory,
                   checkoutdir=None,
                   enforce_standard=True):
    """
    Unpack @localfile to @target_directory; if @checkoutdir is specified make
    sure the unpacked content gets into a directory by that name
    """
    if checkoutdir:
        final_target_directory = target_directory
        target_directory = tempfile.mkdtemp(dir=final_target_directory)

    ext = os.path.splitext(localfile)[-1]
    if ext == '.lzma':
        if has_command('lzcat') and has_command('tar'):
            buildscript.execute('lzcat -d "%s" | tar xf -' % localfile,
                                cwd=target_directory)
    elif ext == '.xz' and has_command('xzcat') and has_command('tar'):
        buildscript.execute('xzcat -d "%s" | tar xf -' % localfile,
                            cwd=target_directory)
    elif ext == '.bz2' and has_command('bunzip2') and has_command('tar'):
        buildscript.execute('bunzip2 -dc "%s" | tar xf -' % localfile,
                            cwd=target_directory)
    elif ext in ('.gz',
                 '.tgz') and has_command('gunzip') and has_command('tar'):
        buildscript.execute('gunzip -dc "%s" | tar xf -' % localfile,
                            cwd=target_directory)
    elif ext == '.zip' and has_command('unzip'):
        buildscript.execute('unzip "%s"' % localfile, cwd=target_directory)
    else:
        try:
            if tarfile.is_tarfile(localfile):
                unpack_tar_file(localfile, target_directory)
            elif zipfile.is_zipfile(localfile):
                unpack_zip_file(localfile, target_directory)
            else:
                raise CommandError(
                    _('Failed to unpack %s (unknown archive type)') %
                    localfile)
        except:
            raise CommandError(_('Failed to unpack %s') % localfile)

    if checkoutdir:
        # tarball has been extracted in $destdir/$tmp/, check, then move the
        # content of that directory
        if len(os.listdir(target_directory)) == 0:
            raise CommandError(
                _('Failed to unpack %s (empty file?)') % localfile)
        if len(os.listdir(target_directory)) == 1:
            # a single directory, just move it
            tmpdirname = os.path.join(target_directory,
                                      os.listdir(target_directory)[0])
            os.rename(tmpdirname,
                      os.path.join(final_target_directory, checkoutdir))
            os.rmdir(target_directory)
        else:
            # more files, just rename the temporary directory to the final name
            os.rename(target_directory,
                      os.path.join(final_target_directory, checkoutdir))
Exemplo n.º 4
0
    def rebase_current_branch(self, buildscript):
        """Pull the current branch if it is tracking a remote branch."""

        if self.is_dirty(ignore_submodules=True):
            # custom behavior, instead of allowing for stash, refuse to deal with dirty tree at all
            if not is_teamcity:
                raise CommandError(
                    _('Refusing to pull branch on a dirty tree.'))
            logging.warning(
                _('Dirty tree, but TEAMCITY_VERSION is present, so ignoring'))

        branch = self.get_current_branch()
        if not branch:
            return
        if not self.is_tracking_a_remote_branch(branch):
            # custom behavior, don't want people getting an outdated build without noticing
            raise CommandError(
                _('Local branch is not tracking remote, refuse to continue.'))

        if self.has_diverged_from_remote_branch(branch):
            # custom behavior, do not merge from origin if local branch has diverged
            if not is_teamcity:
                raise CommandError(
                    _('Refusing to merge remote branch into a diverged branch.'
                      ))
            logging.warning(
                _('Branch has diverged, but TEAMCITY_VERSION is present, so ignoring'
                  ))

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

        if is_teamcity:
            logging.warning(
                _('Hard reset to remote branch, because TEAMCITY_VERSION is present'
                  ))
            buildscript.execute(['git', 'reset', '--hard', 'origin/' + branch],
                                **git_extra_args)
            buildscript.execute(['git', 'clean', '-ffxd'], **git_extra_args)
            return

        stashed = False
        if self.is_dirty(ignore_submodules=True):
            stashed = True
            buildscript.execute(['git', 'stash', 'save', 'jhbuild-stash'],
                                **git_extra_args)

        buildscript.execute(['git', 'rebase', 'origin/' + branch],
                            **git_extra_args)

        if stashed:
            # git stash pop was introduced in 1.5.5,
            if self.check_version_git('1.5.5'):
                buildscript.execute(['git', 'stash', 'pop'], **git_extra_args)
            else:
                buildscript.execute(['git', 'stash', 'apply', 'jhbuild-stash'],
                                    **git_extra_args)
Exemplo n.º 5
0
 def _check_for_conflicts(self):
     kws = {}
     kws['cwd'] = self.srcdir
     kws['env'] = os.environ.copy()
     extra_env = get_svn_extra_env()
     kws['env'].update(extra_env)
     try:
         output = subprocess.Popen(['svn', 'info', '-R'],
                 stdout = subprocess.PIPE, **kws).communicate()[0]
     except OSError as e:
         raise CommandError(str(e))
     if '\nConflict' in output:
         raise CommandError(_('Error checking for conflicts'))
Exemplo n.º 6
0
    def _exec_commands(self, buildscript, commands, ignore_failure=False):
        #Commands can contain a number of special placeholders.
        PLACEHOLDERS = {
            "@@PREFIX@@": buildscript.config.prefix,
            "@@SRCDIR@@": self.get_srcdir(buildscript)
        }

        for cmd, cwd, output_file in commands:
            #a command can have many args
            for i in range(0, len(cmd)):
                for k, v in PLACEHOLDERS.items():
                    cmd[i] = cmd[i].replace(k, v)
            #also do replacements in the working directory
            if cwd != None:
                for k, v in PLACEHOLDERS.items():
                    cwd = cwd.replace(k, v)
            # and the output path
            if output_file != None:
                for k, v in PLACEHOLDERS.items():
                    output_file = output_file.replace(k, v)
            try:
                buildscript.execute(cmd, cwd=cwd, output_file=output_file)
            except CommandError, e:
                if not ignore_failure:
                    raise CommandError(e)
Exemplo n.º 7
0
    def execute(self, command, hint=None, cwd=None, extra_env=None):
        if not command:
            raise CommandError(_('No command given'))

        kws = {
            'close_fds': True
            }
        print_args = {'cwd': ''}
        if cwd:
            print_args['cwd'] = cwd
        else:
            try:
                print_args['cwd'] = os.getcwd()
            except OSError:
                pass

        if isinstance(command, (str, unicode)):
            kws['shell'] = True
            print_args['command'] = command
        else:
            print_args['command'] = ' '.join(command)

        if not self.config.quiet_mode:
            if self.config.print_command_pattern:
                try:
                    print self.config.print_command_pattern % print_args
                except TypeError, e:
                    raise FatalError('\'print_command_pattern\' %s' % e)
                except KeyError, e:
                    raise FatalError(_('%(configuration_variable)s invalid key'
                                       ' %(key)s' % \
                                       {'configuration_variable' :
                                            '\'print_command_pattern\'',
                                        'key' : e}))
Exemplo n.º 8
0
    def get_revision_id(self):
        import re

        try:
            infos = Popen(['fossil', 'info'], stdout=PIPE, cwd=self.srcdir)
        except OSError, e:
            raise CommandError(str(e))
Exemplo n.º 9
0
 def _get_commit_from_date(self):
     cmd = ['git', 'log', '--max-count=1', '--first-parent',
             '--until=%s' % self.config.sticky_date, 'master']
     cmd_desc = ' '.join(cmd)
     proc = subprocess.Popen(cmd, stdout=subprocess.PIPE,
                             cwd=self.get_checkoutdir(),
                             env=get_git_extra_env())
     stdout = proc.communicate()[0]
     if not stdout.strip():
         raise CommandError(_('Command %s returned no output') % cmd_desc)
     for line in stdout.splitlines():
         if line.startswith('commit '):
             commit = line.split(None, 1)[1].strip()
             return commit
     raise CommandError(_('Command %s did not include commit line: %r')
                        % (cmd_desc, stdout))
Exemplo n.º 10
0
 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))
Exemplo n.º 11
0
 def do_configure(self, buildscript):
     buildscript.set_action(_('Configuring'), self)
     srcdir = self.get_srcdir(buildscript)
     builddir = self.get_builddir(buildscript)
     if os.path.exists(builddir):
         try:
             # Clear CMake files so we get a clean configure.
             os.unlink(os.path.join(builddir, 'CMakeCache.txt'))
             shutil.rmtree(os.path.join(builddir, 'CMakeFiles'))
         except:
             pass
     else:
         os.makedirs(builddir)
     prefix = os.path.expanduser(buildscript.config.prefix)
     if not inpath('cmake', os.environ['PATH'].split(os.pathsep)):
         raise CommandError(_('%s not found') % 'cmake')
     baseargs = '-DCMAKE_INSTALL_PREFIX=%s -DCMAKE_INSTALL_LIBDIR=lib' % prefix
     cmakeargs = self.get_cmakeargs()
     if self.use_ninja:
         baseargs += ' -G Ninja'
     # CMake on Windows generates VS projects or NMake makefiles by default.
     # When using MSYS "MSYS Makefiles" is the best guess. "Unix Makefiles"
     # and "MinGW Makefiles" could also work (each is a bit different).
     if os.name == 'nt' and os.getenv("MSYSCON") and '-G' not in cmakeargs:
         baseargs += ' -G "MSYS Makefiles"'
     cmd = 'cmake %s %s %s' % (baseargs, cmakeargs, srcdir)
     buildscript.execute(cmd, cwd=builddir, extra_env=self.extra_env)
Exemplo n.º 12
0
    def ensure_ninja_binary(self):
        for f in ['ninja', 'ninja-build']:
            if inpath(f, os.environ['PATH'].split(os.pathsep)):
                self.ninja_binary = f
                return

        raise CommandError(_('%s not found') % 'ninja')
Exemplo n.º 13
0
    def execute(self,
                command,
                hint=None,
                cwd=None,
                extra_env=None,
                output_file=None):
        if not command:
            raise CommandError(_('No command given'))

        kws = {'close_fds': True}
        if isinstance(command, (str, unicode)):
            kws['shell'] = True
            pretty_command = command
        else:
            pretty_command = ' '.join(command)

        if not self.config.quiet_mode:
            print pretty_command

        kws['stdin'] = subprocess.PIPE

        if output_file != None:
            kws['stdout'] = open(output_file, 'w')
        else:
            if hint in ('cvs', 'svn', 'hg-update.py'):
                kws['stdout'] = subprocess.PIPE
                kws['stderr'] = subprocess.STDOUT
            else:
                kws['stdout'] = None
                kws['stderr'] = None

            if self.config.quiet_mode:
                kws['stdout'] = subprocess.PIPE
                kws['stderr'] = subprocess.STDOUT

        if cwd is not None:
            kws['cwd'] = cwd

        if extra_env is not None:
            kws['env'] = os.environ.copy()
            kws['env'].update(extra_env)

        try:
            p = subprocess.Popen(command, **kws)
        except OSError, e:
            raise CommandError(str(e))
Exemplo n.º 14
0
    def _do_patches(self, buildscript):
        # now patch the working tree
        for (patch, patchstrip) in self.patches:
            patchfile = ''
            if urlparse.urlparse(patch)[0]:
                # patch name has scheme, get patch from network
                try:
                    patchfile = httpcache.load(
                        patch, nonetwork=buildscript.config.nonetwork)
                except urllib2.HTTPError as e:
                    raise BuildStateError(
                        _('could not download patch (error: %s)') % e.code)
                except urllib2.URLError as e:
                    raise BuildStateError(_('could not download patch'))
            elif self.repository.moduleset_uri:
                # get it relative to the moduleset uri, either in the same
                # directory or a patches/ subdirectory
                for patch_prefix in ('.', 'patches', '../patches'):
                    uri = urlparse.urljoin(self.repository.moduleset_uri,
                                           os.path.join(patch_prefix, patch))
                    try:
                        patchfile = httpcache.load(
                            uri, nonetwork=buildscript.config.nonetwork)
                    except Exception as e:
                        continue
                    if not os.path.isfile(patchfile):
                        continue
                    break
                else:
                    patchfile = ''

            if not patchfile:
                # nothing else, use jhbuild provided patches
                possible_locations = []
                if self.config.modulesets_dir:
                    possible_locations.append(
                        os.path.join(self.config.modulesets_dir, 'patches'))
                    possible_locations.append(
                        os.path.join(self.config.modulesets_dir, '../patches'))
                if PKGDATADIR:
                    possible_locations.append(
                        os.path.join(PKGDATADIR, 'patches'))
                if SRCDIR:
                    possible_locations.append(os.path.join(SRCDIR, 'patches'))
                for dirname in possible_locations:
                    patchfile = os.path.join(dirname, patch)
                    if os.path.exists(patchfile):
                        break
                else:
                    raise CommandError(_('Failed to find patch: %s') % patch)

            buildscript.set_action(_('Applying patch'),
                                   self,
                                   action_target=patch)
            # patchfile can be a relative file
            buildscript.execute('patch -p%d < "%s"' %
                                (patchstrip, os.path.abspath(patchfile)),
                                cwd=self.raw_srcdir)
Exemplo n.º 15
0
    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)
Exemplo n.º 16
0
    def _get_patch_files(self, buildscript):
        patch_files = []

        # now patch the working tree
        for (patch, patchstrip) in self.patches:
            patchfile = ''
            if urlutils.urlparse(patch)[0]:
                # patch name has scheme, get patch from network
                try:
                    patchfile = httpcache.load(
                        patch, nonetwork=buildscript.config.nonetwork)
                except urlutils.HTTPError as e:
                    raise BuildStateError(
                        _('could not download patch (error: %s)') % e.code)
                except urlutils.URLError:
                    raise BuildStateError(_('could not download patch'))
            elif self.repository.moduleset_uri:
                # get it relative to the moduleset uri, either in the same
                # directory or a patches/ subdirectory
                for patch_prefix in ('.', 'patches', '../patches'):
                    uri = urlutils.urljoin(self.repository.moduleset_uri,
                                           os.path.join(patch_prefix, patch))
                    try:
                        patchfile = httpcache.load(
                            uri, nonetwork=buildscript.config.nonetwork)
                    except Exception:
                        continue
                    if not os.path.isfile(patchfile):
                        continue
                    break
                else:
                    patchfile = ''

            if not patchfile:
                # nothing else, use jhbuild provided patches
                possible_locations = []
                if self.config.modulesets_dir:
                    possible_locations.append(
                        os.path.join(self.config.modulesets_dir, 'patches'))
                    possible_locations.append(
                        os.path.join(self.config.modulesets_dir, '../patches'))
                if PKGDATADIR:
                    possible_locations.append(
                        os.path.join(PKGDATADIR, 'patches'))
                if SRCDIR:
                    possible_locations.append(os.path.join(SRCDIR, 'patches'))
                for dirname in possible_locations:
                    patchfile = os.path.join(dirname, patch)
                    if os.path.exists(patchfile):
                        break
                else:
                    raise CommandError(_('Failed to find patch: %s') % patch)

            patch_files.append((patchfile, patch, patchstrip))

        return patch_files
Exemplo n.º 17
0
 def is_dirty(self, ignore_submodules=True):
     submodule_options = []
     if ignore_submodules:
         if not self.check_version_git('1.5.6'):
             raise CommandError(_('Need at least git-1.5.6 from June/08 '
                     'to operate'))
         submodule_options = ['--ignore-submodules']
     return not self.execute_git_predicate(
             ['git', 'diff', '--exit-code', '--quiet'] + submodule_options
             + ['HEAD'])
Exemplo n.º 18
0
 def do_build(self, buildscript):
     buildscript.set_action(_('Building'), self)
     srcdir = self.get_srcdir(buildscript)
     builddir = self.get_builddir(buildscript)
     ant = os.environ.get('ANT', 'ant')
     if not inpath(ant, os.environ['PATH'].split(os.pathsep)):
         raise CommandError(_('Missing ant build tool'))
     cmd = [ant]
     #if srcdir != builddir:
     #    cmd.extend(['--build-base', builddir])
     buildscript.execute(cmd, cwd=srcdir)
Exemplo n.º 19
0
 def get_current_branch(self):
     """Returns either a branchname or None if head is detached"""
     if not self.is_inside_work_tree():
         raise CommandError(_('Unexpected: Checkoutdir is not a git '
                 'repository:' + self.get_checkoutdir()))
     try:
         return os.path.basename(
                 get_output(['git', 'symbolic-ref', '-q', 'HEAD'],
                         cwd=self.get_checkoutdir(),
                         extra_env=get_git_extra_env()).strip())
     except CommandError:
         return None
Exemplo n.º 20
0
    def _check_for_conflict(self):
        """Checks 'mtn automate heads' for more than 1 head which would mean we have
          conflicts"""

        output = get_output(['mtn', 'automate', 'heads'],
                            cwd=self.srcdir)

        heads = len(output.splitlines())

        if heads > 1:
            raise CommandError(_('branch %(branch)s has %(num)d heads') %
                               {'branch':self.branch, 'num':heads})
Exemplo n.º 21
0
def get_output(cmd, cwd=None, extra_env=None, get_stderr=True):
    '''Return the output (stdout and stderr) from the command.

    If the extra_env dictionary is not empty, then it is used to
    update the environment in the child process.

    If the get_stderr parameter is set to False, then stderr output is ignored.
    
    Raises CommandError if the command exited abnormally or had a non-zero
    error code.
    '''
    if cmd is None:
        raise CommandError(_('Call to undefined command'))

    kws = {}
    if isinstance(cmd, string_types):
        kws['shell'] = True
    if cwd is not None:
        kws['cwd'] = cwd
    if extra_env is not None:
        kws['env'] = os.environ.copy()
        kws['env'].update(extra_env)

    if get_stderr:
        stderr_output = subprocess.STDOUT
    else:
        stderr_output = subprocess.PIPE
    try:
        p = subprocess.Popen(cmd,
                             close_fds=True,
                             stdin=subprocess.PIPE,
                             stdout=subprocess.PIPE,
                             stderr=stderr_output,
                             **kws)
    except OSError as e:
        raise CommandError(str(e))
    stdout, stderr = p.communicate()
    if p.returncode != 0:
        raise CommandError(_('Error running %s') % cmd, p.returncode)
    return udecode(stdout)
Exemplo n.º 22
0
 def do_configure(self, buildscript):
     buildscript.set_action(_('Configuring'), self)
     srcdir = self.get_srcdir(buildscript)
     builddir = self.get_builddir(buildscript)
     if not os.path.exists(builddir):
         os.makedirs(builddir)
     prefix = os.path.expanduser(buildscript.config.prefix)
     if not inpath('meson', os.environ['PATH'].split(os.pathsep)):
         raise CommandError(_('%s not found') % 'meson')
     baseargs = '--prefix %s' % prefix
     mesonargs = self.get_mesonargs()
     cmd = 'meson %s %s %s' % (baseargs, mesonargs, srcdir)
     buildscript.execute(cmd, cwd=builddir, extra_env=self.extra_env)
Exemplo n.º 23
0
 def get_current_branch(self):
     """Returns either a branchname or None if head is detached"""
     if not self.is_inside_work_tree():
         raise CommandError(
             _('Unexpected: Checkoutdir is not a git '
               'repository:' + self.get_checkoutdir()))
     try:
         full_branch = get_output(['git', 'symbolic-ref', '-q', 'HEAD'],
                                  cwd=self.get_checkoutdir(),
                                  extra_env=get_git_extra_env()).strip()
         # strip refs/heads/ to get the branch name only
         return full_branch.replace('refs/heads/', '')
     except CommandError:
         return None
Exemplo n.º 24
0
    def execute(self, command, hint=None, cwd=None, extra_env=None):
        assert self.modulefp, 'not currently building a module'

        kws = {
            'close_fds': True
            }
        self.modulefp.write('<pre>')
        if isinstance(command, (str, unicode)):
            self.modulefp.write('<span class="command">%s</span>\n'
                                % escape(command))
            kws['shell'] = True
        else:
            self.modulefp.write('<span class="command">%s</span>\n'
                                % escape(' '.join(command)))
        kws['stdin'] = subprocess.PIPE
        kws['stdout'] = subprocess.PIPE
        kws['stderr'] = subprocess.PIPE
        if hint == 'cvs':
            def format_line(line, error_output, fp=self.modulefp):
                if line[-1] == '\n': line = line[:-1]
                if line.startswith('C '):
                    fp.write('<span class="conflict">%s</span>\n'
                                        % escape(line))
                else:
                    fp.write('%s\n' % escape(line))
            kws['stderr'] = subprocess.STDOUT
        else:
            def format_line(line, error_output, fp=self.modulefp):
                if line[-1] == '\n': line = line[:-1]
                if error_output:
                    fp.write('<span class="error">%s</span>\n'
                                        % escape(line))
                else:
                    fp.write('%s\n' % escape(line))

        if cwd is not None:
            kws['cwd'] = cwd

        if extra_env is not None:
            kws['env'] = os.environ.copy()
            kws['env'].update(extra_env)

        try:
            p = subprocess.Popen(command, **kws)
        except OSError, e:
            self.modulefp.write('<span class="error">Error: %s</span>\n'
                                % escape(str(e)))
            raise CommandError(str(e))
Exemplo n.º 25
0
 def do_configure(self, buildscript):
     buildscript.set_action(_('Configuring'), self)
     srcdir = self.get_srcdir(buildscript)
     builddir = self.get_builddir(buildscript)
     # meson does not allow configuring if the builddir already exists,
     # so we'll need to get rid of it and start over to configure again.
     if os.path.exists(builddir):
         shutil.rmtree(builddir)
     os.makedirs(builddir)
     prefix = os.path.expanduser(buildscript.config.prefix)
     if not inpath('meson', os.environ['PATH'].split(os.pathsep)):
         raise CommandError(_('%s not found') % 'meson')
     baseargs = '--prefix %s --libdir %s' % (prefix, self.get_libdir())
     mesonargs = self.get_mesonargs()
     cmd = 'meson %s %s %s' % (baseargs, mesonargs, srcdir)
     buildscript.execute(cmd, cwd=builddir, extra_env=self.extra_env)
Exemplo n.º 26
0
    def do_configure(self, buildscript):
        buildscript.set_action(_('Configuring'), self)
        builddir = self.get_builddir(buildscript)
        destdir = self.prepare_installroot(buildscript)

        if not inpath('qmake', os.environ['PATH'].split(os.pathsep)):
            raise CommandError(_('%s not found') % 'qmake')

        # qmake leaves Makefiles that cannot be updated
        if hasattr(self.branch, 'delete_unknown_files'):
            self.branch.delete_unknown_files(buildscript)

        qmakeargs = self.eval_args(self.qmakeargs)
        qmakeargs = qmakeargs.replace('${destdir}', destdir)
        cmd = 'qmake %s' % qmakeargs
        buildscript.execute(cmd, cwd = builddir, extra_env = self.extra_env)
Exemplo n.º 27
0
 def do_configure(self, buildscript):
     buildscript.set_action(_('Configuring'), self)
     srcdir = self.get_srcdir(buildscript)
     builddir = self.get_builddir(buildscript)
     if not os.path.exists(builddir):
         os.mkdir(builddir)
     prefix = os.path.expanduser(buildscript.config.prefix)
     if not inpath('cmake', os.environ['PATH'].split(os.pathsep)):
         raise CommandError(_('%s not found') % 'cmake')
     baseargs = '-DCMAKE_INSTALL_PREFIX=%s -DLIB_INSTALL_DIR=%s -Dlibdir=%s' % (
                     prefix, buildscript.config.libdir, buildscript.config.libdir)
     cmd = 'cmake %s %s %s' % (baseargs, self.get_cmakeargs(), srcdir)
     if os.path.exists(os.path.join(builddir, 'CMakeCache.txt')):
         # remove that file, as it holds the result of a previous cmake
         # configure run, and would be reused unconditionnaly
         # (cf https://bugzilla.gnome.org/show_bug.cgi?id=621194)
         os.unlink(os.path.join(builddir, 'CMakeCache.txt'))
     buildscript.execute(cmd, cwd = builddir, extra_env = self.extra_env)
Exemplo n.º 28
0
    def checkout(self, buildscript):
        # 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)
Exemplo n.º 29
0
    def execute(self, command, hint=None, cwd=None, extra_env=None):
        if not command:
            raise CommandError(_('No command given'))

        kws = {'close_fds': True}
        print_args = {'cwd': ''}
        if cwd:
            print_args['cwd'] = cwd
        else:
            try:
                print_args['cwd'] = os.getcwd()
            except OSError:
                pass

        if isinstance(command, (str, unicode)):
            kws['shell'] = True
            print_args['command'] = command
        else:
            print_args['command'] = ' '.join(command)

        # get rid of hint if pretty printing is disabled.
        if not self.config.pretty_print:
            hint = None
        elif os.name == 'nt':
            # pretty print also doesn't work on Windows;
            # see https://bugzilla.gnome.org/show_bug.cgi?id=670349
            hint = None

        if not self.config.quiet_mode:
            if self.config.print_command_pattern:
                try:
                    print self.config.print_command_pattern % print_args
                except TypeError, e:
                    raise FatalError('\'print_command_pattern\' %s' % e)
                except KeyError, e:
                    raise FatalError(_('%(configuration_variable)s invalid key'
                                       ' %(key)s' % \
                                       {'configuration_variable' :
                                            '\'print_command_pattern\'',
                                        'key' : e}))
Exemplo n.º 30
0
 def do_configure(self, buildscript):
     buildscript.set_action(_('Configuring'), self)
     srcdir = self.get_srcdir(buildscript)
     builddir = self.get_builddir(buildscript)
     if not os.path.exists(builddir):
         os.makedirs(builddir)
     prefix = os.path.expanduser(buildscript.config.prefix)
     if not inpath('cmake', os.environ['PATH'].split(os.pathsep)):
         raise CommandError(_('%s not found') % 'cmake')
     baseargs = '-DCMAKE_INSTALL_PREFIX=%s -DCMAKE_INSTALL_LIBDIR=lib' % prefix
     cmakeargs = self.get_cmakeargs()
     # CMake on Windows generates VS projects or NMake makefiles by default.
     # When using MSYS "MSYS Makefiles" is the best guess. "Unix Makefiles"
     # and "MinGW Makefiles" could also work (each is a bit different).
     if os.name == 'nt' and os.getenv("MSYSCON") and '-G' not in cmakeargs:
         baseargs += ' -G "MSYS Makefiles"'
     cmd = 'cmake %s %s %s' % (baseargs, cmakeargs, srcdir)
     if os.path.exists(os.path.join(builddir, 'CMakeCache.txt')):
         # remove that file, as it holds the result of a previous cmake
         # configure run, and would be reused unconditionnaly
         # (cf https://bugzilla.gnome.org/show_bug.cgi?id=621194)
         os.unlink(os.path.join(builddir, 'CMakeCache.txt'))
     buildscript.execute(cmd, cwd=builddir, extra_env=self.extra_env)