[ostree/wip/multibuild: 2/2] wip
- From: Colin Walters <walters src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [ostree/wip/multibuild: 2/2] wip
- Date: Tue, 27 Dec 2011 23:10:14 +0000 (UTC)
commit 96baf2bd3c4d096f89b28b7ac6f22d9d56ab871c
Author: Colin Walters <walters verbum org>
Date: Tue Dec 27 11:13:16 2011 -0500
wip
Makefile-ostbuild.am | 19 +-
gnomeos/3.4/gobject-introspection.txt | 1 +
gnomeos/3.4/gtk-doc.txt | 2 +
gnomeos/3.4/libarchive.txt | 2 +
gnomeos/3.4/libxslt.txt | 2 +
gnomeos/3.4/manifest.json | 11 +
src/ostbuild/ostbuild-fetch | 8 -
src/ostbuild/pyostbuild/buildutil.py | 40 ++++
.../pyostbuild/builtin_autodiscover_meta.py | 5 +-
src/ostbuild/pyostbuild/builtin_build.py | 204 ++++++++++++++++++++
.../pyostbuild/builtin_chroot_compile_one.py | 12 +-
.../pyostbuild/builtin_commit_artifacts.py | 19 +--
src/ostbuild/pyostbuild/builtin_compile_one.py | 196 ++++++-------------
src/ostbuild/pyostbuild/builtins.py | 12 ++
src/ostbuild/pyostbuild/kvfile.py | 23 +++
src/ostbuild/pyostbuild/main.py | 1 +
src/ostbuild/pyostbuild/ostbuildrc.py | 41 ++++
17 files changed, 426 insertions(+), 172 deletions(-)
---
diff --git a/Makefile-ostbuild.am b/Makefile-ostbuild.am
index f32a834..e848322 100644
--- a/Makefile-ostbuild.am
+++ b/Makefile-ostbuild.am
@@ -19,21 +19,20 @@ ostbuild: src/ostbuild/ostbuild.in Makefile
sed -e s,@libdir\@,$(libdir), -e s,@datarootdir\@,$(datarootdir), -e s,@PYTHON\@,$(PYTHON), $< > $ tmp && mv $ tmp $@
bin_SCRIPTS += ostbuild
-bin_SCRIPTS += \
- src/ostbuild/ostbuild-nice-and-log-output \
- $(NULL)
-
pyostbuilddir=$(libdir)/ostbuild/pyostbuild
pyostbuild_PYTHON = \
- src/ostbuild/pyostbuild/__init__.py \
- src/ostbuild/pyostbuild/builtins.py \
- src/ostbuild/pyostbuild/main.py \
- src/ostbuild/pyostbuild/ostbuildlog.py \
- src/ostbuild/pyostbuild/subprocess_helpers.py \
+ src/ostbuild/pyostbuild/buildutil.py \
src/ostbuild/pyostbuild/builtin_autodiscover_meta.py \
+ src/ostbuild/pyostbuild/builtin_build.py \
src/ostbuild/pyostbuild/builtin_chroot_compile_one.py \
src/ostbuild/pyostbuild/builtin_commit_artifacts.py \
src/ostbuild/pyostbuild/builtin_compile_one.py \
+ src/ostbuild/pyostbuild/builtins.py \
+ src/ostbuild/pyostbuild/kvfile.py \
+ src/ostbuild/pyostbuild/main.py \
+ src/ostbuild/pyostbuild/ostbuildlog.py \
+ src/ostbuild/pyostbuild/ostbuildrc.py \
+ src/ostbuild/pyostbuild/subprocess_helpers.py \
$(NULL)
bin_PROGRAMS += src/ostbuild/ostbuild-user-chroot
@@ -41,3 +40,5 @@ bin_PROGRAMS += src/ostbuild/ostbuild-user-chroot
ostbuild_user_chroot_SOURCES = src/ostbuild/ostbuild-user-chroot.c
ostbuild_user_chroot_CFLAGS = $(AM_CFLAGS)
+bin_SCRIPTS += src/ostbuild/ostbuild-nice-and-log-output
+
diff --git a/gnomeos/3.4/gobject-introspection.txt b/gnomeos/3.4/gobject-introspection.txt
new file mode 100644
index 0000000..142d75f
--- /dev/null
+++ b/gnomeos/3.4/gobject-introspection.txt
@@ -0,0 +1 @@
+SRC=git:git://git.gnome.org/gobject-introspection
diff --git a/gnomeos/3.4/gtk-doc.txt b/gnomeos/3.4/gtk-doc.txt
new file mode 100644
index 0000000..0f1e7ef
--- /dev/null
+++ b/gnomeos/3.4/gtk-doc.txt
@@ -0,0 +1,2 @@
+SRC=git:git://git.gnome.org/gtk-doc
+COMPONENT=devel
diff --git a/gnomeos/3.4/libarchive.txt b/gnomeos/3.4/libarchive.txt
new file mode 100644
index 0000000..99a349c
--- /dev/null
+++ b/gnomeos/3.4/libarchive.txt
@@ -0,0 +1,2 @@
+SRC=svn:http://libarchive.googlecode.com/svn/trunk/libarchive-read-only
+CONFIGURE_OPTS=--disable-bsdtar --disable-bsdcpio
diff --git a/gnomeos/3.4/libxslt.txt b/gnomeos/3.4/libxslt.txt
new file mode 100644
index 0000000..a060dfa
--- /dev/null
+++ b/gnomeos/3.4/libxslt.txt
@@ -0,0 +1,2 @@
+SRC=git:git://git.gnome.org/libxslt
+EXTRA_OECONF = "--disable-static"
diff --git a/gnomeos/3.4/manifest.json b/gnomeos/3.4/manifest.json
new file mode 100644
index 0000000..0e38c44
--- /dev/null
+++ b/gnomeos/3.4/manifest.json
@@ -0,0 +1,11 @@
+{
+ "name": "gnomeos-3.4",
+ "architectures": ["i686"],
+ "base": "gnomeos-3.4-yocto",
+
+ "components": [
+ "libxslt",
+ "gtk-doc",
+ "gobject-introspection"
+ ]
+}
diff --git a/src/ostbuild/pyostbuild/buildutil.py b/src/ostbuild/pyostbuild/buildutil.py
new file mode 100755
index 0000000..2c0b021
--- /dev/null
+++ b/src/ostbuild/pyostbuild/buildutil.py
@@ -0,0 +1,40 @@
+# Copyright (C) 2011 Colin Walters <walters verbum org>
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2 of the License, or (at your option) any later version.
+#
+# This library 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
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the
+# Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+# Boston, MA 02111-1307, USA.
+
+import re
+
+ARTIFACT_RE = re.compile(r'^artifact-([^,]+),([^,]+),([^,]+),([^,]+),(.+)-((?:runtime)|(?:devel))\.tar\.gz$')
+
+def parse_artifact_name(artifact_basename):
+ match = ARTIFACT_RE.match(artifact_basename)
+ if match is None:
+ raise ValueError("Invalid artifact basename %s" % (artifact_basename))
+ return {'buildroot': match.group(1),
+ 'buildroot_version': match.group(2),
+ 'name': match.group(3),
+ 'branch': match.group(4),
+ 'version': match.group(5),
+ 'type': match.group(6)}
+
+def branch_name_for_build(buildroot, name, branch):
+ return 'artifacts/%s/%s/%s' % (buildroot, name, branch)
+
+def branch_name_for_artifact(a):
+ return branch_name_for_build(a['buildroot'],
+ a['name'],
+ a['branch'])
+
diff --git a/src/ostbuild/pyostbuild/builtin_autodiscover_meta.py b/src/ostbuild/pyostbuild/builtin_autodiscover_meta.py
index 6808024..3d7ec8f 100755
--- a/src/ostbuild/pyostbuild/builtin_autodiscover_meta.py
+++ b/src/ostbuild/pyostbuild/builtin_autodiscover_meta.py
@@ -72,10 +72,7 @@ class OstbuildAutodiscoverMeta(builtins.Builtin):
def _discover_version_from_git(self):
if os.path.isdir('.git'):
- try:
- version = subprocess.check_output(['git', 'describe'])
- except subprocess.CalledProcessError, e:
- version = subprocess.check_output(['git', 'rev-parse', 'HEAD'])
+ version = subprocess.check_output(['git', 'describe', '--long', '--abbrev=42', '--always'])
return version.strip()
return None
diff --git a/src/ostbuild/pyostbuild/builtin_build.py b/src/ostbuild/pyostbuild/builtin_build.py
new file mode 100755
index 0000000..c063f30
--- /dev/null
+++ b/src/ostbuild/pyostbuild/builtin_build.py
@@ -0,0 +1,204 @@
+# Copyright (C) 2011 Colin Walters <walters verbum org>
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2 of the License, or (at your option) any later version.
+#
+# This library 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
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the
+# Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+# Boston, MA 02111-1307, USA.
+
+import os,sys,subprocess,tempfile,re,shutil
+import argparse
+import json
+
+from . import builtins
+from .ostbuildlog import log, fatal
+from .subprocess_helpers import run_sync
+from . import ostbuildrc
+from . import buildutil
+from . import kvfile
+
+class OstbuildBuild(builtins.Builtin):
+ name = "build"
+ short_description = "Rebuild all artifacts from the given manifest"
+
+ def __init__(self):
+ builtins.Builtin.__init__(self)
+
+ def _ensure_vcs_checkout(self, name, keytype, uri, branch):
+ assert keytype == 'git'
+ destname = os.path.join(self.srcdir, name)
+ tmp_destname = destname + '.tmp'
+ if os.path.isdir(tmp_destname):
+ shutil.rmtree(tmp_destname)
+ if not os.path.isdir(destname):
+ run_sync(['git', 'clone', uri, tmp_destname])
+ os.rename(tmp_destname, destname)
+ subprocess.check_call(['git', 'checkout', '-q', branch], cwd=destname)
+ return destname
+
+ def _get_vcs_version_from_checkout(self, name):
+ vcsdir = os.path.join(self.srcdir, name)
+ return subprocess.check_output(['git', 'rev-parse', 'HEAD'], cwd=vcsdir)
+
+ def _parse_src_key(self, srckey):
+ idx = srckey.find(':')
+ if idx < 0:
+ raise ValueError("Invalid SRC uri=%s" % (srckey, ))
+ keytype = srckey[:idx]
+ if keytype not in ('git'):
+ raise ValueError("Unsupported SRC uri=%s" % (srckey, ))
+ uri = srckey[idx+1:]
+ idx = uri.rfind('#')
+ if idx < 0:
+ branch = "master"
+ else:
+ branch = uri[idx+1:]
+ uri = uri[0:idx]
+ return (keytype, uri, branch)
+
+ def _parse_artifact_vcs_version(self, ver):
+ idx = ver.rfind('-')
+ if idx > 0:
+ vcs_ver = ver[idx+1:]
+ else:
+ vcs_ver = ver
+ if not vcs_ver.startswith('g'):
+ raise ValueError("Invalid artifact version '%s'" % (ver, ))
+ return vcs_ver[1:]
+
+ def _build_one_component(self, name, architecture, meta):
+ (keytype, uri, branch) = self._parse_src_key(meta['SRC'])
+ component_src = self._ensure_vcs_checkout(name, keytype, uri, branch)
+ buildroot = '%s-%s-devel' % (self.manifest['name'], architecture)
+ branchname = 'artifacts/%s/%s/%s' % (buildroot, name, branch)
+ try:
+ previous_commit_version = subprocess.check_output(['ostree', '--repo=' + self.repo,
+ 'rev-parse', branchname],
+ stderr=open('/dev/null', 'w'))
+ previous_commit_version = previous_commit_version.strip()
+ log("Previous build of '%s' is %s" % (branchname, previous_commit_version))
+ except subprocess.CalledProcessError, e:
+ previous_commit_version = None
+ log("No previous build for '%s' found" % (branchname, ))
+ if previous_commit_version is not None:
+ previous_artifact_version = subprocess.check_output(['ostree', '--repo=' + self.repo,
+ 'show', '--print-metadata-key=ostbuild-artifact-version', previous_commit_version])
+ previous_artifact_version = previous_artifact_version.strip()
+ previous_buildroot_version = subprocess.check_output(['ostree', '--repo=' + self.repo,
+ 'show', '--print-metadata-key=ostbuild-buildroot-version', previous_commit_version])
+ previous_buildroot_version = previous_buildroot_version.strip()
+ current_buildroot_version = subprocess.check_output(['ostree', '--repo=' + self.repo,
+ 'rev-parse', buildroot])
+ current_buildroot_version = current_buildroot_version.strip()
+
+ previous_vcs_version = self._parse_artifact_vcs_version(previous_artifact_version)
+ current_vcs_version = self._get_vcs_version_from_checkout(name)
+ vcs_version_matches = False
+ if previous_vcs_version == current_vcs_version:
+ vcs_version_matches = True
+ log("VCS version is unchanged from '%s'" % (previous_vcs_version, ))
+ else:
+ log("VCS version is now '%s', was '%s'" % (current_vcs_version, previous_vcs_version))
+ buildroot_version_matches = False
+ if vcs_version_matches:
+ buildroot_version_matches = (current_buildroot_version == previous_buildroot_version)
+ if buildroot_version_matches:
+ log("Already have build '%s' of src commit '%s' for '%s' in buildroot '%s'" % (previous_commit_version, previous_vcs_version, branchname, buildroot))
+ return
+ else:
+ log("Buildroot is now '%s'" % (current_buildroot_version, ))
+
+ component_resultdir = os.path.join(self.workdir, 'name', 'results')
+ if os.path.isdir(component_resultdir):
+ shutil.rmtree(component_resultdir)
+ os.makedirs(component_resultdir)
+ current_machine = os.uname()[4]
+ if current_machine != architecture:
+ log("Current architecture '%s' differs from target '%s', using setarch" % (current_machine, architecture))
+ args = ['setarch', architecture]
+ else:
+ args = []
+ args.extend(['ostbuild', 'chroot-compile-one',
+ '--repo=' + self.repo,
+ '--buildroot=' + buildroot,
+ '--workdir=' + self.workdir,
+ '--resultdir=' + component_resultdir])
+ run_sync(args, cwd=component_src)
+ artifact_files = []
+ for name in os.listdir(component_resultdir):
+ if name.startswith('artifact-'):
+ artifact_files.append(os.path.join(component_resultdir, name))
+ assert len(artifact_files) >= 1 and len(artifact_files) <= 2
+ run_sync(['ostbuild', 'commit-artifacts',
+ '--repo=' + self.repo] + artifact_files)
+ artifacts = []
+ for filename in artifact_files:
+ parsed = buildutil.parse_artifact_name(name)
+ artifacts.append(parsed)
+ def _sort_artifact(a, b):
+ if a['type'] == b['type']:
+ return 0
+ elif a['type'] == 'runtime':
+ return -1
+ return 1
+ artifacts.sort(_sort_artifact)
+ return artifacts
+
+ def _compose(self, suffix, artifacts):
+ compose_contents = [self.manifest['base'] + '-' + suffix]
+ compose_contents.extend(artifacts)
+ child_args = ['ostree', '--repo=' + self.repo, 'compose',
+ '-b', self.manifest['name'] + '-' + suffix, '-s', 'Compose']
+ child_args.extend(compose_contents)
+ run_sync(child_args)
+
+ def execute(self, argv):
+ parser = argparse.ArgumentParser(description=self.short_description)
+ parser.add_argument('--manifest', required=True)
+
+ args = parser.parse_args(argv)
+
+ self.parse_config()
+
+ self.manifest = json.load(open(args.manifest))
+ dirname = os.path.dirname(args.manifest)
+ components = self.manifest['components']
+ runtime_components = []
+ devel_components = []
+ runtime_artifacts = []
+ devel_artifacts = []
+ for component_name in components:
+ for architecture in self.manifest['architectures']:
+ path = os.path.join(dirname, component_name + '.txt')
+ f = open(path)
+ component_meta = kvfile.parse(f)
+
+ artifact_branches = self._build_one_component(component_name, architecture, component_meta)
+
+ target_component = component_meta.get('COMPONENT')
+ if target_component == 'devel':
+ devel_components.append(component_name)
+ else:
+ runtime_components.append(component_name)
+ for branch in artifact_branches:
+ if branch['type'] == 'runtime':
+ runtime_artifacts.append(branch)
+ devel_artifacts.extend(artifact_branches)
+
+ f.close()
+
+ devel_branches = map(buildutil.branch_name_for_artifact, devel_artifacts)
+ self._compose(architecture + '-devel', devel_branches)
+ runtime_branches = map(buildutil.branch_name_for_artifact, runtime_artifacts)
+ self._compose(architecture + '-runtime', runtime_artifacts)
+
+builtins.register(OstbuildBuild)
diff --git a/src/ostbuild/pyostbuild/builtin_chroot_compile_one.py b/src/ostbuild/pyostbuild/builtin_chroot_compile_one.py
index 9414fad..cbb4fe2 100755
--- a/src/ostbuild/pyostbuild/builtin_chroot_compile_one.py
+++ b/src/ostbuild/pyostbuild/builtin_chroot_compile_one.py
@@ -39,11 +39,11 @@ class OstbuildChrootCompileOne(builtins.Builtin):
short_description = "Build artifacts from the current source directory in a chroot"
def execute(self, argv):
- parser = argparse.ArgumentParser(description="Build a module in a given root")
+ parser = argparse.ArgumentParser(description=self.short_description)
parser.add_argument('--workdir')
- parser.add_argument('--repo')
+ parser.add_argument('--repo', required=True)
parser.add_argument('--resultdir')
- parser.add_argument('--branch')
+ parser.add_argument('--buildroot', required=True)
parser.add_argument('--meta')
parser.add_argument('--debug-shell', type=bool)
@@ -79,10 +79,10 @@ class OstbuildChrootCompileOne(builtins.Builtin):
shutil.rmtree(child_tmpdir)
os.mkdir(child_tmpdir)
- rev = subprocess.check_output(['ostree', '--repo=' + args.repo, 'rev-parse', args.branch])
+ rev = subprocess.check_output(['ostree', '--repo=' + args.repo, 'rev-parse', args.buildroot])
rev=rev.strip()
- metadata['BUILDROOT'] = args.branch
+ metadata['BUILDROOT'] = args.buildroot
metadata['BUILDROOT_VERSION'] = rev
rootdir = os.path.join(workdir, 'root-' + rev)
@@ -136,7 +136,7 @@ class OstbuildChrootCompileOne(builtins.Builtin):
'/bin/sh']
if not args.debug_shell:
child_args += ['-c',
- 'cd "%s" && ostbuild-compile-one-impl OSTBUILD_RESULTDIR=/ostbuild/results OSTBUILD_META=_ostbuild-meta' % (chroot_sourcedir, )
+ 'cd "%s" && ostbuild compile-one OSTBUILD_RESULTDIR=/ostbuild/results OSTBUILD_META=_ostbuild-meta' % (chroot_sourcedir, )
]
run_sync(child_args, env=BUILD_ENV)
diff --git a/src/ostbuild/pyostbuild/builtin_commit_artifacts.py b/src/ostbuild/pyostbuild/builtin_commit_artifacts.py
index af78e71..19ff99b 100644
--- a/src/ostbuild/pyostbuild/builtin_commit_artifacts.py
+++ b/src/ostbuild/pyostbuild/builtin_commit_artifacts.py
@@ -26,13 +26,13 @@ import argparse
from . import builtins
from .ostbuildlog import log, fatal
from .subprocess_helpers import run_sync
+from . import buildutil
class OstbuildCommitArtifacts(builtins.Builtin):
name = "commit-artifacts"
short_description = "Commit artifacts to their corresponding repository branches"
def execute(self, argv):
- artifact_re = re.compile(r'^artifact-([^,]+),([^,]+),([^,]+),([^,]+),([^.]+)\.tar\.gz$')
parser = argparse.ArgumentParser(self.short_description)
parser.add_argument('--repo')
@@ -45,21 +45,14 @@ class OstbuildCommitArtifacts(builtins.Builtin):
for arg in args.artifacts:
basename = os.path.basename(arg)
- match = artifact_re.match(basename)
- if match is None:
- fatal("Invalid artifact name: %s" % (arg, ))
- buildroot = match.group(1)
- buildroot_version = match.group(2)
- name = match.group(3)
- branch = match.group(4)
- version = match.group(5)
+ parsed = buildutil.parse_artifact_name(basename)
- branch_name = 'artifacts/%s/%s/%s' % (buildroot, name, branch)
+ branch_name = buildutil.branch_name_for_artifact(parsed)
run_sync(['ostree', '--repo=' + args.repo,
- 'commit', '-b', branch_name, '-s', 'Build ' + version,
- '--add-metadata-string=ostree-buildroot-version=' + buildroot_version,
- '--add-metadata-string=ostree-artifact-version=' + version,
+ 'commit', '-b', branch_name, '-s', 'Build ' + parsed['version'],
+ '--add-metadata-string=ostree-buildroot-version=' + parsed['buildroot_version'],
+ '--add-metadata-string=ostree-artifact-version=' + parsed['version'],
'--skip-if-unchanged', '--tar-autocreate-parents', '--tree=tar=' + arg])
builtins.register(OstbuildCommitArtifacts)
diff --git a/src/ostbuild/pyostbuild/builtin_compile_one.py b/src/ostbuild/pyostbuild/builtin_compile_one.py
index edcae1c..3d083fd 100755
--- a/src/ostbuild/pyostbuild/builtin_compile_one.py
+++ b/src/ostbuild/pyostbuild/builtin_compile_one.py
@@ -36,43 +36,12 @@ _BLACKLIST_REGEXPS = map(re.compile,
_DEVEL_REGEXPS = map(re.compile,
[r'/usr/include/',
r'/usr/share/pkgconfig/',
+ r'/usr/share/aclocal/',
r'/(?:usr/)lib(?:|(?:32)|(?:64))/pkgconfig/.*\.pc$',
r'/(?:usr/)lib(?:|(?:32)|(?:64))/[^/]+\.so$'
+ r'/(?:usr/)lib(?:|(?:32)|(?:64))/[^/]+\.a$'
])
-class BuildSystemScanner(object):
- @classmethod
- def _find_file(cls, names):
- for name in names:
- if os.path.exists(name):
- return name
- return None
-
- @classmethod
- def get_configure_source_script(cls):
- return cls._find_file(('./configure.ac', './configure.in'))
-
- @classmethod
- def get_configure_script(cls):
- return cls._find_file(('./configure', ))
-
- @classmethod
- def get_bootstrap_script(cls):
- return cls._find_file(('./autogen.sh', ))
-
- @classmethod
- def get_silent_rules(cls):
- src = cls.get_configure_source_script()
- if not src:
- return False
- f = open(src)
- for line in f:
- if line.find('AM_SILENT_RULES') >= 0:
- f.close()
- return True
- f.close()
- return False
-
class OstbuildCompileOne(builtins.Builtin):
name = "compile-one"
short_description = "Build artifacts from the current source directory"
@@ -81,25 +50,12 @@ class OstbuildCompileOne(builtins.Builtin):
builtins.Builtin.__init__(self)
self.tempfiles = []
- def _search_file(self, filename, pattern):
- f = open(filename)
- for line in f:
- if line.startswith(pattern):
- f.close()
- return line
- f.close()
- return None
-
- def _find_buildapi_makevariable(self, name, builddir='.'):
- var = '.%s:' % (name, )
- line = None
- path = os.path.join(builddir, 'Makefile.in')
- if os.path.exists(path):
- line = self._search_file(path, var)
- path = os.path.join(builddir, 'Makefile')
- if not line and os.path.exists(path):
- line = self._search_file(path, var)
- return line is not None
+ def _has_buildapi_configure_variable(self, name):
+ var = '#buildapi-variable-%s' % (name, )
+ for line in open('configure'):
+ if line.find(var) >= 0:
+ return True
+ return False
def execute(self, args):
self.default_buildapi_jobs = ['-j', '%d' % (cpu_count() * 2, )]
@@ -160,46 +116,29 @@ class OstbuildCompileOne(builtins.Builtin):
if k not in self.metadata:
fatal('Missing required key "%s" in metadata' % (k, ))
- self.phase_bootstrap()
+ autogen_script = None
+ if not os.path.exists('configure'):
+ for name in ['autogen', 'autogen.sh']:
+ if os.path.exists(name):
+ autogen_script = name
+ if autogen_script is None:
+ fatal("No configure or autogen script detected; unknown buildsystem")
- def phase_bootstrap(self):
- have_configure = BuildSystemScanner.get_configure_script()
- have_configure_source = BuildSystemScanner.get_configure_source_script()
- if not (have_configure or have_configure_source):
- fatal("No configure or bootstrap script detected; unknown buildsystem")
- return
+ if autogen_script is not None:
+ env = dict(os.environ)
+ env['NOCONFIGURE'] = '1'
+ run_sync(['./' + autogen_script], env=env)
- need_v1 = BuildSystemScanner.get_silent_rules()
- if need_v1:
- log("Detected AM_SILENT_RULES, adding --disable-silent-rules to configure")
- self.configargs.append('--disable-silent-rules')
-
- if have_configure:
- self.phase_configure()
- else:
- bootstrap = BuildSystemScanner.get_bootstrap_script()
- if bootstrap:
- log("Detected bootstrap script: %s, using it" % (bootstrap, ))
- args = [bootstrap]
- # Add NOCONFIGURE; GNOME style scripts use this
- env = dict(os.environ)
- env['NOCONFIGURE'] = '1'
- run_sync(args, env=env)
- else:
- log("No bootstrap script found; using generic autoreconf")
- run_sync(['autoreconf', '-f', '-i'])
- self.phase_configure()
-
- def phase_configure(self):
use_builddir = True
- doesnot_support_builddir = self._find_buildapi_makevariable('buildapi-no-builddir')
+ doesnot_support_builddir = self._has_buildapi_configure_variable('no-builddir')
if doesnot_support_builddir:
- log("Found .buildapi-no-builddir; copying source tree to _build")
- shutil.rmtree('_build')
- os.mkdir('_build')
+ log("Found no-builddir Build API variable; copying source tree to _build")
+ if os.path.isdir('_build'):
+ shutil.rmtree('_build')
shutil.copytree('.', '_build', symlinks=True,
ignore=shutil.ignore_patterns('_build'))
use_builddir = False
+ builddir = '.'
if use_builddir:
builddir = '_build'
@@ -207,26 +146,20 @@ class OstbuildCompileOne(builtins.Builtin):
if not os.path.isdir(builddir):
os.mkdir(builddir)
- configstatus = 'config.status'
- if not os.path.exists(configstatus):
- if use_builddir:
- args = ['../configure']
- else:
- args = ['./configure']
- args.extend(self.configargs)
- if use_builddir:
- run_sync(args, cwd=builddir)
- else:
- run_sync(args)
+ if use_builddir:
+ args = ['../configure']
else:
- log("Found %s, skipping configure" % (configstatus, ))
- self.phase_build(builddir=builddir)
-
- build_status = False
-
- def phase_build(self, builddir=None):
- if not os.path.exists(os.path.join(builddir, 'Makefile')):
+ args = ['./configure']
+ args.extend(self.configargs)
+ if use_builddir:
+ run_sync(args, cwd=builddir)
+ else:
+ run_sync(args)
+
+ makefile_path = os.path.join(builddir, 'Makefile')
+ if not os.path.exists(makefile_path):
fatal("No Makefile found")
+
args = list(self.makeargs)
user_specified_jobs = False
for arg in args:
@@ -234,35 +167,18 @@ class OstbuildCompileOne(builtins.Builtin):
user_specified_jobs = True
if not user_specified_jobs:
- notparallel = self._find_buildapi_makevariable('NOTPARALLEL', builddir=builddir)
- if not notparallel:
+ has_notparallel = False
+ for line in open(makefile_path):
+ if line.startswith('.NOTPARALLEL'):
+ has_notparallel = True
+ log("Found .NOTPARALLEL")
+
+ if not has_notparallel:
log("Didn't find NOTPARALLEL, using parallel make by default")
args.extend(self.default_buildapi_jobs)
run_sync(args, cwd=builddir)
-
- self.phase_make_artifacts(builddir=builddir)
-
- def make_artifact(self, name, from_files, tempdir=None, resultdir=None):
- targz_name = name + '.tar.gz'
- (fd,filelist_temp)=tempfile.mkstemp(prefix='ostree-filelist-%s' % (name, ))
- os.close(fd)
- self.tempfiles.append(filelist_temp)
- f = open(filelist_temp, 'w')
- for filename in from_files:
- assert ('\n' not in filename)
- f.write(filename)
- f.write('\n')
- f.close()
- if resultdir:
- result_path = os.path.join(resultdir, targz_name)
- else:
- result_path = targz_name
- args = ['tar', '-c', '-z', '-C', tempdir, '-f', result_path, '-T', filelist_temp]
- run_sync(args)
- log("created: %s" % (os.path.abspath (result_path), ))
-
- def phase_make_artifacts(self, builddir=None):
+
name = self.metadata['NAME']
assert ',' not in name
branch = self.metadata['BRANCH']
@@ -318,9 +234,6 @@ class OstbuildCompileOne(builtins.Builtin):
self.make_artifact(artifact_prefix + '-devel', devel_files, tempdir=tempdir, resultdir=self.ostbuild_resultdir)
self.make_artifact(artifact_prefix + '-runtime', runtime_files, tempdir=tempdir, resultdir=self.ostbuild_resultdir)
- self.phase_complete()
-
- def phase_complete(self):
for tmpname in self.tempfiles:
assert os.path.isabs(tmpname)
if os.path.isdir(tmpname):
@@ -331,5 +244,24 @@ class OstbuildCompileOne(builtins.Builtin):
pass
except OSError, e:
pass
-
+
+ def make_artifact(self, name, from_files, tempdir=None, resultdir=None):
+ targz_name = name + '.tar.gz'
+ (fd,filelist_temp)=tempfile.mkstemp(prefix='ostree-filelist-%s' % (name, ))
+ os.close(fd)
+ self.tempfiles.append(filelist_temp)
+ f = open(filelist_temp, 'w')
+ for filename in from_files:
+ assert ('\n' not in filename)
+ f.write(filename)
+ f.write('\n')
+ f.close()
+ if resultdir:
+ result_path = os.path.join(resultdir, targz_name)
+ else:
+ result_path = targz_name
+ args = ['tar', '-c', '-z', '-C', tempdir, '-f', result_path, '-T', filelist_temp]
+ run_sync(args)
+ log("created: %s" % (os.path.abspath (result_path), ))
+
builtins.register(OstbuildCompileOne)
diff --git a/src/ostbuild/pyostbuild/builtins.py b/src/ostbuild/pyostbuild/builtins.py
index a398b6a..b997c07 100755
--- a/src/ostbuild/pyostbuild/builtins.py
+++ b/src/ostbuild/pyostbuild/builtins.py
@@ -21,12 +21,24 @@ import os
import sys
import argparse
+from . import ostbuildrc
+from .ostbuildlog import log, fatal
+
_all_builtins = {}
class Builtin(object):
name = None
short_description = None
+ def parse_config(self):
+ self.repo = ostbuildrc.get_key('repo')
+ self.srcdir = ostbuildrc.get_key('srcdir')
+ if not os.path.isdir(self.srcdir):
+ fatal("Specified srcdir '%s' is not a directory" % (self.srcdir, ))
+ self.workdir = ostbuildrc.get_key('workdir')
+ if not os.path.isdir(self.workdir):
+ fatal("Specified workdir '%s' is not a directory", (self.workdir, ))
+
def execute(self, args):
raise NotImplementedError()
diff --git a/src/ostbuild/pyostbuild/kvfile.py b/src/ostbuild/pyostbuild/kvfile.py
new file mode 100755
index 0000000..075d4b0
--- /dev/null
+++ b/src/ostbuild/pyostbuild/kvfile.py
@@ -0,0 +1,23 @@
+# Copyright (C) 2011 Colin Walters <walters verbum org>
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2 of the License, or (at your option) any later version.
+#
+# This library 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
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the
+# Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+# Boston, MA 02111-1307, USA.
+
+def parse(stream):
+ ret = {}
+ for line in stream:
+ (k,v) = line.split('=', 1)
+ ret[k.strip()] = v.strip()
+ return ret
diff --git a/src/ostbuild/pyostbuild/main.py b/src/ostbuild/pyostbuild/main.py
index b30a6d6..eb9a659 100755
--- a/src/ostbuild/pyostbuild/main.py
+++ b/src/ostbuild/pyostbuild/main.py
@@ -23,6 +23,7 @@ import argparse
from . import builtins
from . import builtin_autodiscover_meta
+from . import builtin_build
from . import builtin_chroot_compile_one
from . import builtin_commit_artifacts
from . import builtin_compile_one
diff --git a/src/ostbuild/pyostbuild/ostbuildrc.py b/src/ostbuild/pyostbuild/ostbuildrc.py
new file mode 100755
index 0000000..413f7f1
--- /dev/null
+++ b/src/ostbuild/pyostbuild/ostbuildrc.py
@@ -0,0 +1,41 @@
+# Copyright (C) 2011 Colin Walters <walters verbum org>
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2 of the License, or (at your option) any later version.
+#
+# This library 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
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the
+# Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+# Boston, MA 02111-1307, USA.
+
+import os,sys,ConfigParser
+
+_config = None
+
+def get():
+ global _config
+ if _config is None:
+ configpath = os.path.expanduser('~/.config/ostbuild.cfg')
+ parser = ConfigParser.RawConfigParser()
+ parser.read([configpath])
+
+ _config = {}
+ for (k, v) in parser.items('global'):
+ _config[k.strip()] = v.strip()
+ return _config
+
+def get_key(name, provided_args=None):
+ config = get()
+ if provided_args:
+ v = provided_args.get(name)
+ if v is not None:
+ return v
+ return config[name]
+
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]