Skip to content

Commit

Permalink
Merge branch 'wip/sysdeps-rebase2'
Browse files Browse the repository at this point in the history
Conflicts:
	modulesets/gnome-suites-core-3.2.modules
  • Loading branch information
cgwalters committed Jul 15, 2011
2 parents 5f0242d + faa20f5 commit 46d715f
Show file tree
Hide file tree
Showing 20 changed files with 495 additions and 183 deletions.
1 change: 1 addition & 0 deletions jhbuild/commands/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ app_PYTHON = \
rdepends.py \
sanitycheck.py \
snapshot.py \
sysdeps.py \
tinderbox.py \
uninstall.py

1 change: 1 addition & 0 deletions jhbuild/commands/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,7 @@ def run(self, config, options, args, help=None):
for modname in args:
try:
module = module_set.get_module(modname, ignore_case=True)
print module.pkg_config
except KeyError, e:
default_repo = jhbuild.moduleset.get_default_repo()
if not default_repo:
Expand Down
102 changes: 102 additions & 0 deletions jhbuild/commands/sysdeps.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
# jhbuild - a build script for GNOME 1.x and 2.x
# Copyright (C) 2011 Colin Walters <[email protected]>
#
# sysdeps.py: Install system dependencies
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA

import os
import sys
import urllib
from optparse import make_option
import logging

import jhbuild.moduleset
import jhbuild.frontends
from jhbuild.errors import UsageError, FatalError
from jhbuild.commands import Command, register_command
import jhbuild.commands.base
from jhbuild.commands.base import cmd_build
from jhbuild.utils.cmds import check_version
from jhbuild.utils.systeminstall import SystemInstall
from jhbuild.versioncontrol.tarball import TarballBranch

class cmd_sysdeps(cmd_build):
doc = N_('Check and install tarball dependencies using system packages')

name = 'sysdeps'

def __init__(self):
Command.__init__(self, [
make_option('--install',
action='store_true', default = False,
help=_('Install pkg-config modules via system'))])

def run(self, config, options, args, help=None):
config.set_from_cmdline_options(options)

installer = SystemInstall.find_best()
if installer is None:
raise FatalError(_("Don't know how to install packages on this system"))

if not config.partial_build:
raise FatalError(_("Partial build is not enabled; add partial_build = True to ~/.jhbuildrc"))

module_set = jhbuild.moduleset.load(config)
modules = args or config.modules
module_list = module_set.get_module_list(modules, process_sysdeps=False)
module_state = module_set.get_system_modules(module_list)

have_new_enough = False
have_too_old = False

print _('System installed packages which are new enough:')
for pkg_config,(module, req_version, installed_version, new_enough) in module_state.iteritems():
if (installed_version is not None) and new_enough:
have_new_enough = True
print (_(" %(pkg)s (required=%(req)s, installed=%(installed)s)" % {'pkg': pkg_config,
'req': req_version,
'installed': installed_version}))
if not have_new_enough:
print _(' (none)')

print _('System installed packages which are too old:')
for pkg_config,(module, req_version, installed_version, new_enough) in module_state.iteritems():
if (installed_version is not None) and (not new_enough):
have_too_old = False
print (_(" %(pkg)s (required=%(req)s, installed=%(installed)s)" % {'pkg': pkg_config,
'req': req_version,
'installed': installed_version}))
if not have_too_old:
print _(' (none)')

print _('No matching system package installed:')
uninstalled = []
for pkg_config,(module, req_version, installed_version, new_enough) in module_state.iteritems():
if installed_version is None:
print (_(" %(pkg)s (required=%(req)s)") % {'pkg': pkg_config,
'req': req_version})
uninstalled.append(pkg_config)
if len(uninstalled) == 0:
print _(' (none)')

if options.install:
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(uninstalled), )))
installer.install(uninstalled)

register_command(cmd_sysdeps)
24 changes: 12 additions & 12 deletions jhbuild/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
_default_jhbuildrc = os.path.join(os.environ['HOME'], '.jhbuildrc')

_known_keys = [ 'moduleset', 'modules', 'skip', 'tags', 'prefix',
'checkoutroot', 'buildroot', 'top_builddir',
'partial_build', 'checkoutroot', 'buildroot', 'top_builddir',
'autogenargs', 'makeargs',
'installprog', 'repos', 'branches', 'noxvfb', 'xvfbargs',
'builddir_pattern', 'module_autogenargs', 'module_makeargs',
Expand Down Expand Up @@ -344,12 +344,7 @@ def setup_env(self):
addpath('INFOPATH', infopathdir)

# PKG_CONFIG_PATH
if os.environ.get('PKG_CONFIG_PATH') is None:
# add system pkgconfig lookup-directories by default, as pkg-config
# usage spread and is now used by libraries that are out of jhbuild
# realm; this also helps when building a single module with
# jhbuild. It is possible to avoid this by setting PKG_CONFIG_PATH
# to the empty string.
if os.environ.get('PKG_CONFIG_PATH') is None and self.partial_build:
for dirname in ('share', 'lib', 'lib64'):
full_name = '/usr/%s/pkgconfig' % dirname
if os.path.exists(full_name):
Expand All @@ -373,10 +368,14 @@ def setup_env(self):
# XDG_DATA_DIRS
xdgdatadir = os.path.join(self.prefix, 'share')
addpath('XDG_DATA_DIRS', xdgdatadir)
if self.partial_build:
addpath('XDG_DATA_DIRS', '/usr/share')

# XDG_CONFIG_DIRS
xdgconfigdir = os.path.join(self.prefix, 'etc', 'xdg')
addpath('XDG_CONFIG_DIRS', xdgconfigdir)
if self.partial_build:
addpath('XDG_DATA_DIRS', '/etc')

# XCURSOR_PATH
xcursordir = os.path.join(self.prefix, 'share', 'icons')
Expand All @@ -389,10 +388,11 @@ def setup_env(self):
os.makedirs(aclocaldir)
except:
raise FatalError(_("Can't create %s directory") % aclocaldir)
if os.path.exists('/usr/share/aclocal'):
addpath('ACLOCAL_FLAGS', '/usr/share/aclocal')
if os.path.exists('/usr/local/share/aclocal'):
addpath('ACLOCAL_FLAGS', '/usr/local/share/aclocal')
if self.partial_build:
if os.path.exists('/usr/share/aclocal'):
addpath('ACLOCAL_FLAGS', '/usr/share/aclocal')
if os.path.exists('/usr/local/share/aclocal'):
addpath('ACLOCAL_FLAGS', '/usr/local/share/aclocal')
addpath('ACLOCAL_FLAGS', aclocaldir)

# PERL5LIB
Expand All @@ -402,7 +402,7 @@ def setup_env(self):
# These two variables are so that people who use "jhbuild shell"
# can tweak their shell prompts and such to show "I'm under jhbuild".
# The first variable is the obvious one to look for; the second
# one is for historical reasons.
# one is for historical reasons.
os.environ['UNDER_JHBUILD'] = 'true'
os.environ['CERTIFIED_GNOMIE'] = 'yes'

Expand Down
5 changes: 4 additions & 1 deletion jhbuild/defaults.jhbuildrc
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ modules = [ 'meta-gnome-core', 'meta-gnome-apps-tested' ]
# have changed.
build_policy = 'updated-deps'

# If True, ignore tarball modules already installed while building
partial_build = True

# Skip modules installed more recently than the specified relative time.
# min_age can only be specified via the command-line. Setting min_age within
# the configuration file has no effect.
Expand Down Expand Up @@ -172,4 +175,4 @@ dvcs_mirror_dir = None

# A string displayed before JHBuild executes a command. String may contain the
# variables %(command)s, %(cwd)s
print_command_pattern = '%(command)s'
print_command_pattern = '%(command)s'
43 changes: 37 additions & 6 deletions jhbuild/modtypes/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,14 +86,32 @@ def add_to_list(list, childnode):

return dependencies, after, suggests

def get_node_content(node):
node.normalize()
value = ''
for child in node.childNodes:
if child.nodeType == child.TEXT_NODE:
value += child.nodeValue
return value

def find_first_child_node(node, name):
for childnode in node.childNodes:
if (childnode.nodeType == childnode.ELEMENT_NODE and
childnode.nodeName == name):
return childnode
return None

def find_first_child_node_content(node, name):
childnode = find_first_child_node(node, name)
if childnode is None:
return None
return get_node_content(childnode)

def get_branch(node, repositories, default_repo, config):
"""Scan for a <branch> element and create a corresponding Branch object."""
name = node.getAttribute('id')
for childnode in node.childNodes:
if (childnode.nodeType == childnode.ELEMENT_NODE and
childnode.nodeName == 'branch'):
break
else:
childnode = find_first_child_node(node, 'branch')
if childnode is None:
raise FatalError(_('no <branch> element found for %s') % name)

# look up the repository for this branch ...
Expand Down Expand Up @@ -126,11 +144,13 @@ class Package:
type = 'base'
PHASE_START = 'start'
PHASE_DONE = 'done'
def __init__(self, name, dependencies = [], after = [], suggests = []):
def __init__(self, name, branch=None, dependencies = [], after = [], suggests = [], pkg_config=None):
self.name = name
self.branch = branch
self.dependencies = dependencies
self.after = after
self.suggests = suggests
self.pkg_config = pkg_config
self.tags = []
self.moduleset_name = None
self.supports_install_destdir = False
Expand Down Expand Up @@ -363,6 +383,17 @@ def branch_to_sxml(self):
"""Serialize this module's checkout branch as sxml."""
return self.branch.to_sxml()

@classmethod
def parse_from_xml(cls, node, config, uri, repositories, default_repo):
"""Create a new Package instance from a DOM XML node."""
name = node.getAttribute('id')
instance = cls(name)
instance.branch = get_branch(node, repositories, default_repo, config)
instance.dependencies, instance.after, instance.suggests = get_dependencies(node)
pkg_config = find_first_child_node_content(node, 'pkg-config')
if pkg_config != '':
instance.pkg_config = pkg_config
return instance

class DownloadableModule:
PHASE_CHECKOUT = 'checkout'
Expand Down
Loading

0 comments on commit 46d715f

Please sign in to comment.