def _download_and_unpack(self, buildscript): localfile = self._local_tarball if not os.path.exists(self.config.tarballdir): try: os.makedirs(self.config.tarballdir) except OSError: raise FatalError( _('tarball dir (%s) can not be created') % self.config.tarballdir) if not os.access(self.config.tarballdir, os.R_OK | os.W_OK | os.X_OK): raise FatalError( _('tarball dir (%s) must be writable') % self.config.tarballdir) try: self._check_tarball() except BuildStateError: # don't have the tarball, try downloading it and check again if has_command('wget'): res = buildscript.execute( ['wget', '--continue', self.module, '-O', localfile], extra_env={ 'LD_LIBRARY_PATH': os.environ.get('UNMANGLED_LD_LIBRARY_PATH'), 'PATH': os.environ.get('UNMANGLED_PATH') }) elif has_command('curl'): res = buildscript.execute( [ 'curl', '--continue-at', '-', '-L', self.module, '-o', localfile ], extra_env={ 'LD_LIBRARY_PATH': os.environ.get('UNMANGLED_LD_LIBRARY_PATH'), 'PATH': os.environ.get('UNMANGLED_PATH') }) else: raise FatalError(_("unable to find wget or curl")) self._check_tarball() # now to unpack it try: unpack_archive(buildscript, localfile, self.checkoutroot, self.checkoutdir) except CommandError: raise FatalError(_('failed to unpack %s') % localfile) if not os.path.exists(self.srcdir): raise BuildStateError( _('could not unpack tarball (expected %s dir)') % os.path.basename(self.srcdir)) if self.patches: self._do_patches(buildscript)
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))
def __init__(self, config, module_list=None, module_set=None): if self.__class__ is BuildScript: raise NotImplementedError('BuildScript is an abstract base class') self.modulelist = module_list self.moduleset = module_set self.module_num = 0 self.config = config # the existence of self.config.prefix is checked in config.py if not os.access(self.config.prefix, os.R_OK|os.W_OK|os.X_OK): raise FatalError(_('install prefix (%s) must be writable') % self.config.prefix) if not os.path.exists(self.config.checkoutroot): try: os.makedirs(self.config.checkoutroot) except OSError: raise FatalError( _('checkout root (%s) can not be created') % self.config.checkoutroot) if not os.access(self.config.checkoutroot, os.R_OK|os.W_OK|os.X_OK): raise FatalError(_('checkout root (%s) must be writable') % self.config.checkoutroot) if self.config.copy_dir and not os.path.exists(self.config.copy_dir): try: os.makedirs(self.config.copy_dir) except OSError: raise FatalError( _('checkout copy dir (%s) can not be created') % self.config.copy_dir) if not os.access(self.config.copy_dir, os.R_OK|os.W_OK|os.X_OK): raise FatalError(_('checkout copy dir (%s) must be writable') % self.config.copy_dir) self.subprocess_nice_args = [] if config.nice_build: chrt_args = ['chrt', '--idle', '0'] devnull = open(os.devnull, 'w') if (cmds.has_command('chrt') and subprocess.call(chrt_args + ['true'], stdout=devnull, stderr=devnull) == 0): self.subprocess_nice_args.extend(chrt_args) elif cmds.has_command('nice'): self.subprocess_nice_args.append('nice') ionice_args = ['ionice', '-c', '3', '-t'] if cmds.has_command('ionice'): subproc = subprocess.Popen(ionice_args + ['true'], stdout=devnull, stderr=subprocess.PIPE) stderr_val = subproc.communicate()[1] if subproc.returncode == 0 and len(stderr_val) == 0: self.subprocess_nice_args.extend(ionice_args)
def _download_and_unpack(self, buildscript): localfile = self._local_tarball if not os.path.exists(self.config.tarballdir): try: os.makedirs(self.config.tarballdir) except OSError: raise FatalError( _('tarball dir (%s) can not be created') % self.config.tarballdir) if not os.access(self.config.tarballdir, os.R_OK|os.W_OK|os.X_OK): raise FatalError(_('tarball dir (%s) must be writable') % self.config.tarballdir) try: self._check_tarball() except BuildStateError: # don't have the tarball, try downloading it and check again if has_command('wget'): res = buildscript.execute( ['wget', '--continue', self.module, '-O', localfile], extra_env={ 'LD_LIBRARY_PATH': os.environ.get('UNMANGLED_LD_LIBRARY_PATH'), 'PATH': os.environ.get('UNMANGLED_PATH')}) elif has_command('curl'): res = buildscript.execute( ['curl', '--continue-at', '-', '-L', self.module, '-o', localfile], extra_env={ 'LD_LIBRARY_PATH': os.environ.get('UNMANGLED_LD_LIBRARY_PATH'), 'PATH': os.environ.get('UNMANGLED_PATH')}) else: raise FatalError(_("unable to find wget or curl")) self._check_tarball() # now to unpack it. unpack_dir = self.checkoutroot; if not os.path.exists(unpack_dir): os.makedirs(unpack_dir) # now to unpack it try: unpack_archive(buildscript, localfile, unpack_dir, self.checkoutdir) except CommandError: raise FatalError(_('failed to unpack %s') % localfile) if self.expect_standard_tarball and not os.path.exists(self.srcdir): raise BuildStateError(_('could not unpack tarball (expected %s dir)' ) % os.path.basename(self.srcdir)) if self.patches: self._do_patches(buildscript)
def _download_tarball(self, buildscript, localfile): if not os.access(self.config.tarballdir, os.R_OK | os.W_OK | os.X_OK): raise FatalError( _('tarball dir (%s) must be writable') % self.config.tarballdir) """Downloads the tarball off the internet, using wget or curl.""" extra_env = { 'LD_LIBRARY_PATH': os.environ.get('UNMANGLED_LD_LIBRARY_PATH'), 'PATH': os.environ.get('UNMANGLED_PATH') } lines = [['wget', '--continue', self.module, '-O', localfile], [ 'curl', '--continue-at', '-', '-L', self.module, '-o', localfile ]] lines = [line for line in lines if has_command(line[0])] if not lines: raise FatalError(_("unable to find wget or curl")) try: return buildscript.execute(lines[0], extra_env=extra_env) except CommandError: # Cleanup potential leftover file if os.path.exists(localfile): os.remove(localfile) raise
def unpack_archive(buildscript, localfile, target_directory, checkoutdir=None): """ 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' and 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('gzip') and has_command('tar'): buildscript.execute('gzip -dc "%s" | tar xf -' % localfile, cwd=target_directory) elif ext == '.zip' and has_command('unzip'): # liuhuan: create a directory with the zip file's basename before unziping it to support zipped files without top level directory dirname=os.path.join(target_directory,os.path.basename(localfile)[:-4]) buildscript.execute('mkdir -p %s'%(dirname)) buildscript.execute('unzip -u "%s" -d "%s"' % (localfile, dirname), 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]) fileutils.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 fileutils.rename(target_directory, os.path.join(final_target_directory, checkoutdir))
def __init__(self, config, module_list=None, module_set=None): if self.__class__ is BuildScript: raise NotImplementedError('BuildScript is an abstract base class') self.modulelist = module_list self.moduleset = module_set self.module_num = 0 self.config = config # the existence of self.config.prefix is checked in config.py if not os.access(self.config.prefix, os.R_OK|os.W_OK|os.X_OK): raise FatalError(_('install prefix (%s) must be writable') % self.config.prefix) if not os.path.exists(self.config.checkoutroot): try: os.makedirs(self.config.checkoutroot) except OSError: raise FatalError( _('checkout root (%s) can not be created') % self.config.checkoutroot) if not os.access(self.config.checkoutroot, os.R_OK|os.W_OK|os.X_OK): raise FatalError(_('checkout root (%s) must be writable') % self.config.checkoutroot) if self.config.copy_dir and not os.path.exists(self.config.copy_dir): try: os.makedirs(self.config.copy_dir) except OSError: raise FatalError( _('checkout copy dir (%s) can not be created') % self.config.copy_dir) if not os.access(self.config.copy_dir, os.R_OK|os.W_OK|os.X_OK): raise FatalError(_('checkout copy dir (%s) must be writable') % self.config.copy_dir) self.subprocess_nice_args = [] if config.nice_build: if cmds.has_command('chrt'): self.subprocess_nice_args.extend(['chrt', '--idle', '0']) elif cmds.has_command('nice'): self.subprocess_nice_args.append('nice') if cmds.has_command('ionice'): self.subprocess_nice_args.extend(['ionice', '-c', '3', '-t'])
def matches(self, files_list): """@files_list should be a list of absolute file paths. Return True if this trigger script should be run.""" if self._executable is not None: if not cmds.has_command(self._executable): return False for path in files_list: for r in self._rematches: match = r.search(path) if match: return True for literal in self._literal_matches: if path.find(literal) >= 0: return True return False
def _quilt_checkout(self, buildscript): if not has_command('quilt'): raise FatalError(_("unable to find quilt")) if os.path.exists(self.quilt.srcdir) and \ os.path.exists(os.path.join(self.srcdir, '.pc/applied-patches')): buildscript.execute('quilt pop -a', cwd=self.srcdir, extra_env={'QUILT_PATCHES': self.quilt.srcdir}) self.quilt.checkout(buildscript) if not os.path.exists(self.quilt.srcdir): raise FatalError(_('could not checkout quilt patch set')) buildscript.execute('quilt push -a', cwd=self.srcdir, extra_env={'QUILT_PATCHES': self.quilt.srcdir})
def _quilt_checkout(self, buildscript): if not has_command('quilt'): raise FatalError(_("unable to find quilt")) if os.path.exists(self.quilt.srcdir) and \ os.path.exists(os.path.join(self.srcdir, '.pc/applied-patches')): buildscript.execute('quilt pop -a', cwd=self.srcdir, extra_env={'QUILT_PATCHES' : self.quilt.srcdir}) self.quilt.checkout(buildscript) if not os.path.exists(self.quilt.srcdir): raise FatalError(_('could not checkout quilt patch set')) buildscript.execute('quilt push -a', cwd=self.srcdir, extra_env={'QUILT_PATCHES' : self.quilt.srcdir})
def _download_tarball(self, buildscript, localfile): """Downloads the tarball off the internet, using wget or curl.""" extra_env = { 'LD_LIBRARY_PATH': os.environ.get('UNMANGLED_LD_LIBRARY_PATH'), 'PATH': os.environ.get('UNMANGLED_PATH') } lines = [ ['wget', '--continue', self.module, '-O', localfile], ['curl', '--continue-at', '-', '-L', self.module, '-o', localfile] ] lines = [line for line in lines if has_command(line[0])] if not lines: raise FatalError(_("unable to find wget or curl")) try: return buildscript.execute(lines[0], extra_env = extra_env) except CommandError: # Cleanup potential leftover file if os.path.exists(localfile): os.remove(localfile) raise
def run(self, config, options, args, help=None): def fmt_details(pkg_config, req_version, installed_version): fmt_list = [] if pkg_config: fmt_list.append(pkg_config) if req_version: fmt_list.append(_('required=%s') % req_version) if installed_version and installed_version != 'unknown': fmt_list.append(_('installed=%s') % installed_version) # Translators: This is used to separate items of package metadata fmt_str = _(', ').join(fmt_list) if fmt_str: return _('(%s)') % fmt_str else: return '' config.set_from_cmdline_options(options) module_set = jhbuild.moduleset.load(config) modules = args or config.modules module_list = module_set.get_full_module_list(modules, config.skip) if options.dump_all: for module in module_list: if (isinstance(module, SystemModule) or isinstance(module.branch, TarballBranch) and module.pkg_config is not None): if module.pkg_config is not None: print('pkgconfig:{0}'.format( module.pkg_config[:-3])) # remove .pc if module.systemdependencies is not None: for dep_type, value, altdeps in module.systemdependencies: sys.stdout.write('{0}:{1}'.format(dep_type, value)) for dep_type, value, empty in altdeps: sys.stdout.write(',{0}:{1}'.format( dep_type, value)) sys.stdout.write('\n') return module_state = module_set.get_module_state(module_list) have_new_enough = False have_too_old = False if options.dump: for module, (req_version, installed_version, new_enough, systemmodule) in iteritems(module_state): if new_enough: continue if installed_version is not None and systemmodule: # it's already installed but it's too old and we # don't know how to build a new one for ourselves have_too_old = True # request installation in two cases: # 1) we don't know how to build it # 2) we don't want to build it ourselves # # partial_build is on by default so this check will only # fail if someone explicitly turned it off if systemmodule or config.partial_build: assert (module.pkg_config or module.systemdependencies) if module.pkg_config is not None: print('pkgconfig:{0}'.format( module.pkg_config[:-3])) # remove .pc if module.systemdependencies is not None: for dep_type, value, altdeps in module.systemdependencies: sys.stdout.write('{0}:{1}'.format(dep_type, value)) for dep_type, value, empty in altdeps: sys.stdout.write(',{0}:{1}'.format( dep_type, value)) sys.stdout.write('\n') if have_too_old: return 1 return print(_('System installed packages which are new enough:')) for module, (req_version, installed_version, new_enough, systemmodule) in iteritems(module_state): if (installed_version is not None) and new_enough and (config.partial_build or systemmodule): have_new_enough = True print(' %s %s' % (module.name, fmt_details(module.pkg_config, req_version, installed_version))) if not have_new_enough: print(_(' (none)')) print(_('Required packages:')) print(_(' System installed packages which are too old:')) for module, (req_version, installed_version, new_enough, systemmodule) in iteritems(module_state): if (installed_version is not None) and (not new_enough) and systemmodule: have_too_old = True print(' %s %s' % (module.name, fmt_details(module.pkg_config, req_version, installed_version))) if not have_too_old: print(_(' (none)')) print(_(' No matching system package installed:')) uninstalled = [] for module, (req_version, installed_version, new_enough, systemmodule) in iteritems(module_state): if installed_version is None and (not new_enough) and systemmodule: print(' %s %s' % (module.name, fmt_details(module.pkg_config, req_version, installed_version))) if module.pkg_config is not None: uninstalled.append((module.name, 'pkgconfig', module.pkg_config[:-3])) # remove .pc elif module.systemdependencies is not None: for dep_type, value, altdeps in module.systemdependencies: uninstalled.append((module.name, dep_type, value)) if len(uninstalled) == 0: print(_(' (none)')) have_too_old = False if config.partial_build: print( _('Optional packages: (JHBuild will build the missing packages)' )) print(_(' System installed packages which are too old:')) for module, (req_version, installed_version, new_enough, systemmodule) in iteritems(module_state): if (installed_version is not None) and (not new_enough) and ( not systemmodule): have_too_old = True print(' %s %s' % (module.name, fmt_details(module.pkg_config, req_version, installed_version))) if not have_too_old: print(_(' (none)')) print(_(' No matching system package installed:')) for module, (req_version, installed_version, new_enough, systemmodule) in iteritems(module_state): if installed_version is None and (not new_enough) and ( not systemmodule): print(' %s %s' % (module.name, fmt_details(module.pkg_config, req_version, installed_version))) if module.pkg_config is not None: uninstalled.append( (module.name, 'pkgconfig', module.pkg_config[:-3])) # remove .pc if len(uninstalled) == 0: print(_(' (none)')) if options.install: installer = SystemInstall.find_best() if installer is None: # FIXME: This should be implemented per Colin's design: # https://bugzilla.gnome.org/show_bug.cgi?id=682104#c3 if cmds.has_command('apt-get'): raise FatalError( _("%(cmd)s is required to install " "packages on this system. Please " "install %(cmd)s.") % {'cmd': 'apt-file'}) raise FatalError( _("Don't know how to install packages on this system")) if len(uninstalled) == 0: logging.info( _("No uninstalled system dependencies to install for modules: %r" ) % (modules, )) else: logging.info(_("Installing dependencies on system: %s") % \ ' '.join(pkg[0] for pkg in uninstalled)) installer.install(uninstalled, assume_yes=options.assume_yes)
def run(self, config, options, args, help=None): def fmt_details(pkg_config, req_version, installed_version): fmt_list = [] if pkg_config: fmt_list.append(pkg_config) if req_version: fmt_list.append(_('required=%s') % req_version) if installed_version and installed_version != 'unknown': fmt_list.append(_('installed=%s') % installed_version) # Translators: This is used to separate items of package metadata fmt_str = _(', ').join(fmt_list) if fmt_str: return _('(%s)') % fmt_str else: return '' config.set_from_cmdline_options(options) module_set = jhbuild.moduleset.load(config) modules = args or config.modules module_list = module_set.get_full_module_list(modules, config.skip) if options.dump_all: for module in module_list: if (isinstance(module, SystemModule) or isinstance(module.branch, TarballBranch) and module.pkg_config is not None): if module.pkg_config is not None: print 'pkgconfig:{0}'.format(module.pkg_config[:-3]) # remove .pc if module.systemdependencies is not None: for dep_type, value, altdeps in module.systemdependencies: sys.stdout.write('{0}:{1}'.format(dep_type, value)) for dep_type, value, empty in altdeps: sys.stdout.write(',{0}:{1}'.format(dep_type, value)) sys.stdout.write('\n') return if options.dump_runtime: # dump runtime packages with version systemdependencies = [] for module in module_list: package_entry = module_set.packagedb.get(module.name) if package_entry: systemdependencies += package_entry.systemdependencies for module in module_list: if isinstance(module, SystemModule) and module.runtime: systemdependencies += module.systemdependencies or [] found, notfound = self._find_system_packages(systemdependencies) # TODO: print out notfound versionedpackages = {} allpackages = self._get_all_system_packages() for pattern, packages in found.iteritems(): for package in packages: if package in allpackages: versionedpackages[package] = allpackages[package] break # output the versioned packages for package, version in sorted(versionedpackages.items()): sys.stdout.write('%s=%s\n' % (package, version)) return module_state = module_set.get_module_state(module_list) have_new_enough = False have_too_old = False if options.dump: for module, (req_version, installed_version, new_enough, systemmodule) in module_state.iteritems(): if new_enough: continue if installed_version is not None and systemmodule: # it's already installed but it's too old and we # don't know how to build a new one for ourselves have_too_old = True # request installation in two cases: # 1) we don't know how to build it # 2) we don't want to build it ourselves # # partial_build is on by default so this check will only # fail if someone explicitly turned it off if systemmodule or config.partial_build: assert (module.pkg_config or module.systemdependencies) if module.pkg_config is not None: print 'pkgconfig:{0}'.format(module.pkg_config[:-3]) # remove .pc if module.systemdependencies is not None: for dep_type, value, altdeps in module.systemdependencies: sys.stdout.write('{0}:{1}'.format(dep_type, value)) for dep_type, value, empty in altdeps: sys.stdout.write(',{0}:{1}'.format(dep_type, value)) sys.stdout.write('\n') if have_too_old: return 1 return print _('System installed packages which are new enough:') for module,(req_version, installed_version, new_enough, systemmodule) in module_state.iteritems(): if (installed_version is not None) and new_enough and (config.partial_build or systemmodule): have_new_enough = True print (' %s %s' % (module.name, fmt_details(module.pkg_config, req_version, installed_version))) if not have_new_enough: print _(' (none)') uninstalled = [] print _('Required packages:') print _(' System installed packages which are too old:') for module, (req_version, installed_version, new_enough, systemmodule) in module_state.iteritems(): if (installed_version is not None) and (not new_enough) and systemmodule: have_too_old = True print (' %s %s' % (module.name, fmt_details(module.pkg_config, req_version, installed_version))) if module.pkg_config is not None: uninstalled.append((module.name, 'pkgconfig', module.pkg_config[:-3])) # remove .pc elif module.systemdependencies is not None: for dep_type, value in module.systemdependencies: uninstalled.append((module.name, dep_type, value)) if not have_too_old: print _(' (none)') print _(' No matching system package installed:') for module, (req_version, installed_version, new_enough, systemmodule) in module_state.iteritems(): if installed_version is None and (not new_enough) and systemmodule: print (' %s %s' % (module.name, fmt_details(module.pkg_config, req_version, installed_version))) if module.pkg_config is not None: uninstalled.append((module.name, 'pkgconfig', module.pkg_config[:-3])) # remove .pc elif module.systemdependencies is not None: for dep_type, value, altdeps in module.systemdependencies: uninstalled.append((module.name, dep_type, value)) for dep_type, value, empty in altdeps: uninstalled.append((module.name, dep_type, value)) if len(uninstalled) == 0: print _(' (none)') have_too_old = False if config.partial_build: print _('Optional packages: (JHBuild will build the missing packages)') print _(' System installed packages which are too old:') for module, (req_version, installed_version, new_enough, systemmodule) in module_state.iteritems(): if (installed_version is not None) and (not new_enough) and (not systemmodule): have_too_old = True print (' %s %s' % (module.name, fmt_details(module.pkg_config, req_version, installed_version))) if module.pkg_config is not None: uninstalled.append((module.name, 'pkgconfig', module.pkg_config[:-3])) # remove .pc if not have_too_old: print _(' (none)') print _(' No matching system package installed:') for module,(req_version, installed_version, new_enough, systemmodule) in module_state.iteritems(): if installed_version is None and (not new_enough) and (not systemmodule): print (' %s %s' % (module.name, fmt_details(module.pkg_config, req_version, installed_version))) if module.pkg_config is not None: uninstalled.append((module.name, 'pkgconfig', module.pkg_config[:-3])) # remove .pc if len(uninstalled) == 0: print _(' (none)') if options.install: installer = SystemInstall.find_best() if installer is None: # FIXME: This should be implemented per Colin's design: # https://bugzilla.gnome.org/show_bug.cgi?id=682104#c3 if cmds.has_command('apt-get'): raise FatalError(_("%(cmd)s is required to install " "packages on this system. Please " "install %(cmd)s.") % {'cmd' : 'apt-file'}) raise FatalError(_("Don't know how to install packages on this system")) if len(uninstalled) == 0: logging.info(_("No uninstalled system dependencies to install for modules: %r") % (modules, )) return logging.info(_("Installing dependencies on system: %s") % \ ' '.join(pkg[0] for pkg in uninstalled)) installer.install(uninstalled)
def run(self, config, options, args, help=None): def fmt_details(pkg_config, req_version, installed_version): fmt_list = [] if pkg_config: fmt_list.append(pkg_config) if req_version: fmt_list.append(_('required=%s') % req_version) if installed_version and installed_version != 'unknown': fmt_list.append(_('installed=%s') % installed_version) # Translators: This is used to separate items of package metadata fmt_str = _(', ').join(fmt_list) if fmt_str: return _('(%s)') % fmt_str else: return '' config.set_from_cmdline_options(options) module_set = jhbuild.moduleset.load(config) modules = args or config.modules module_list = module_set.get_full_module_list(modules, config.skip) module_state = module_set.get_module_state(module_list) have_new_enough = False have_too_old = False print _('System installed packages which are new enough:') for module,(req_version, installed_version, new_enough, systemmodule) in module_state.iteritems(): if (installed_version is not None) and new_enough and (config.partial_build or systemmodule): have_new_enough = True print (' %s %s' % (module.name, fmt_details(module.pkg_config, req_version, installed_version))) if not have_new_enough: print _(' (none)') print _('Required packages:') print _(' System installed packages which are too old:') for module, (req_version, installed_version, new_enough, systemmodule) in module_state.iteritems(): if (installed_version is not None) and (not new_enough) and systemmodule: have_too_old = True print (' %s %s' % (module.name, fmt_details(module.pkg_config, req_version, installed_version))) if not have_too_old: print _(' (none)') print _(' No matching system package installed:') uninstalled_pkgconfigs = [] uninstalled_filenames = [] for module, (req_version, installed_version, new_enough, systemmodule) in module_state.iteritems(): if installed_version is None and (not new_enough) and systemmodule: print (' %s %s' % (module.name, fmt_details(module.pkg_config, req_version, installed_version))) if module.pkg_config is not None: uninstalled_pkgconfigs.append((module.name, # remove .pc module.pkg_config[:-3])) elif module.systemdependencies is not None: for dep_type, value in module.systemdependencies: if dep_type.lower() == 'path': uninstalled_filenames.append( (module.name, os.path.join(config.system_prefix, 'bin', value),)) elif dep_type.lower() == 'c_include': uninstalled_filenames.append( (module.name, os.path.join(config.system_prefix, 'include', value),)) if len(uninstalled_pkgconfigs) + len(uninstalled_filenames) == 0: print _(' (none)') have_too_old = False if config.partial_build: print _('Optional packages: (JHBuild will build the missing packages)') print _(' System installed packages which are too old:') for module, (req_version, installed_version, new_enough, systemmodule) in module_state.iteritems(): if (installed_version is not None) and (not new_enough) and (not systemmodule): have_too_old = True print (' %s %s' % (module.name, fmt_details(module.pkg_config, req_version, installed_version))) if not have_too_old: print _(' (none)') print _(' No matching system package installed:') for module,(req_version, installed_version, new_enough, systemmodule) in module_state.iteritems(): if installed_version is None and (not new_enough) and (not systemmodule): print (' %s %s' % (module.name, fmt_details(module.pkg_config, req_version, installed_version))) if module.pkg_config is not None: uninstalled_pkgconfigs.append((module.name, # remove .pc module.pkg_config[:-3])) if len(uninstalled_pkgconfigs) == 0: print _(' (none)') if options.install: installer = SystemInstall.find_best() if installer is None: # FIXME: This should be implemented per Colin's design: # https://bugzilla.gnome.org/show_bug.cgi?id=682104#c3 if cmds.has_command('apt-get'): raise FatalError(_("%(cmd)s is required to install " "packages on this system. Please " "install %(cmd)s.") % {'cmd' : 'apt-file'}) raise FatalError(_("Don't know how to install packages on this system")) if (len(uninstalled_pkgconfigs) + len(uninstalled_filenames)) == 0: logging.info(_("No uninstalled system dependencies to install for modules: %r" % (modules, ))) else: logging.info(_("Installing dependencies on system: %s" % \ ' '.join([pkg[0] for pkg in uninstalled_pkgconfigs + uninstalled_filenames]))) installer.install(uninstalled_pkgconfigs, uninstalled_filenames)