summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--morphlib/artifactresolver_tests.py9
-rw-r--r--morphlib/artifactsplitrule.py42
-rw-r--r--morphlib/buildsystem.py231
-rw-r--r--morphlib/buildsystem_tests.py32
-rw-r--r--morphlib/cachekeycomputer_tests.py4
-rw-r--r--morphlib/defaults.py28
-rw-r--r--morphlib/definitions_repo.py11
-rw-r--r--morphlib/definitions_version.py2
-rw-r--r--morphlib/plugins/cross-bootstrap_plugin.py2
-rw-r--r--morphlib/sourceresolver.py11
10 files changed, 18 insertions, 354 deletions
diff --git a/morphlib/artifactresolver_tests.py b/morphlib/artifactresolver_tests.py
index 30f949c8..1ad9ba2d 100644
--- a/morphlib/artifactresolver_tests.py
+++ b/morphlib/artifactresolver_tests.py
@@ -19,10 +19,13 @@ import yaml
import morphlib
-
default_split_rules = {
- 'chunk': morphlib.artifactsplitrule.DEFAULT_CHUNK_RULES,
- 'stratum': morphlib.artifactsplitrule.DEFAULT_STRATUM_RULES,
+'chunk': [
+ ('-bins', ['(usr/)?bin/.*']),
+ ('-devel', ['(usr/)?include/.*'])],
+'stratum': [
+ ('-devel', ['.*-devel', '.*-debug']),
+ ('-runtime', ['.*-bins', '.*'])]
}
diff --git a/morphlib/artifactsplitrule.py b/morphlib/artifactsplitrule.py
index ba5abe02..ef44b8e0 100644
--- a/morphlib/artifactsplitrule.py
+++ b/morphlib/artifactsplitrule.py
@@ -189,42 +189,6 @@ class SplitRules(collections.Iterable):
for artifact, rule in self._rules)
-DEFAULT_CHUNK_RULES = [
- ('-bins', [ r"(usr/)?s?bin/.*" ]),
- ('-libs', [
- r"(usr/)?lib(32|64)?/lib[^/]*\.so(\.\d+)*",
- r"(usr/)libexec/.*"]),
- ('-devel', [
- r"(usr/)?include/.*",
- r"(usr/)?lib(32|64)?/lib.*\.a",
- r"(usr/)?lib(32|64)?/lib.*\.la",
- r"(usr/)?(lib(32|64)?|share)/pkgconfig/.*\.pc"]),
- ('-doc', [
- r"(usr/)?share/doc/.*",
- r"(usr/)?share/man/.*",
- r"(usr/)?share/info/.*"]),
- ('-locale', [
- r"(usr/)?share/locale/.*",
- r"(usr/)?share/i18n/.*",
- r"(usr/)?share/zoneinfo/.*"]),
- ('-misc', [ r".*" ]),
-]
-
-
-DEFAULT_STRATUM_RULES = [
- ('-devel', [
- r'.*-devel',
- r'.*-debug',
- r'.*-doc']),
- ('-runtime', [
- r'.*-bins',
- r'.*-libs',
- r'.*-locale',
- r'.*-misc',
- r'.*']),
-]
-
-
# A 'no-op' set of split rules. An empty list would cause everything to be
# ignored, which is unlikely to ever be what a user wants, and breaks some
# internal bits of Morph.
@@ -233,7 +197,7 @@ EMPTY_RULES = [
]
-def unify_chunk_matches(morphology, default_rules=DEFAULT_CHUNK_RULES):
+def unify_chunk_matches(morphology, default_rules=None):
'''Create split rules including defaults and per-chunk rules.
With rules specified in the morphology's 'products' field and the
@@ -262,7 +226,7 @@ def unify_chunk_matches(morphology, default_rules=DEFAULT_CHUNK_RULES):
return split_rules
-def unify_stratum_matches(morphology, default_rules=DEFAULT_STRATUM_RULES):
+def unify_stratum_matches(morphology, default_rules=None):
'''Create split rules including defaults and per-stratum rules.
With rules specified in the chunk spec's 'artifacts' fields, the
@@ -304,7 +268,7 @@ def unify_stratum_matches(morphology, default_rules=DEFAULT_STRATUM_RULES):
match_split_rules))
-def unify_system_matches(morphology, default_rules=[]):
+def unify_system_matches(morphology, default_rules=None):
'''Create split rules including defaults and per-chunk rules.
With rules specified in the morphology's 'products' field and the
diff --git a/morphlib/buildsystem.py b/morphlib/buildsystem.py
index 29d35627..d0583c49 100644
--- a/morphlib/buildsystem.py
+++ b/morphlib/buildsystem.py
@@ -13,35 +13,8 @@
# with this program. If not, see <http://www.gnu.org/licenses/>.
-import os
-
import morphlib
-
-# TODO: Make idempotent when files are hardlinks
-# Strip all ELF binary files that are executable or named like a library.
-# .so files for C, .cmxs for OCaml and .node for Node.
-# The file name and permissions checks are done with the `find` command before
-# the ELF header is checked with the shell command, because it is a lot cheaper
-# to check the mode and file name first, because it is a metadata check, rather
-# than a subprocess and a file read.
-# `file` is not used, to keep the dependency requirements down.
-_STRIP_COMMAND = r'''find "$DESTDIR" -type f \
- '(' -perm -111 -o -name '*.so*' -o -name '*.cmxs' -o -name '*.node' ')' \
- -exec sh -ec \
- 'read -n4 hdr <"$1" # check for elf header
- if [ "$hdr" != "$(printf \\x7fELF)" ]; then
- exit 0
- fi
- debugfile="$DESTDIR$PREFIX/lib/debug/$(basename "$1")"
- mkdir -p "$(dirname "$debugfile")"
- objcopy --only-keep-debug "$1" "$debugfile"
- chmod 644 "$debugfile"
- strip --remove-section=.comment --remove-section=.note --strip-unneeded "$1"
- objcopy --add-gnu-debuglink "$debugfile" "$1"' - {} ';'
-'''
-
-
class BuildSystem(object):
'''Predefined command sequences for a given build system.
@@ -89,212 +62,8 @@ class BuildSystem(object):
'build-system': self.name,
})
-
class ManualBuildSystem(BuildSystem):
'''A manual build system where the morphology must specify all commands.'''
name = 'manual'
-
-
-class DummyBuildSystem(BuildSystem):
-
- '''A dummy build system, useful for debugging morphologies.'''
-
- name = 'dummy'
-
- def __init__(self):
- BuildSystem.__init__(self)
- self.configure_commands = ['echo dummy configure']
- self.build_commands = ['echo dummy build']
- self.test_commands = ['echo dummy test']
- self.install_commands = ['echo dummy install']
- self.strip_commands = ['echo dummy strip']
-
-
-class AutotoolsBuildSystem(BuildSystem):
-
- '''The automake/autoconf/libtool holy trinity.'''
-
- name = 'autotools'
-
- def __init__(self):
- BuildSystem.__init__(self)
- self.configure_commands = [
- 'export NOCONFIGURE=1; ' +
- 'if [ -e autogen ]; then ./autogen; ' +
- 'elif [ -e autogen.sh ]; then ./autogen.sh; ' +
- 'elif [ -e bootstrap ]; then ./bootstrap; ' +
- 'elif [ -e bootstrap.sh ]; then ./bootstrap.sh; ' +
- 'elif [ ! -e ./configure ]; then autoreconf -ivf; fi',
- './configure --prefix="$PREFIX"',
- ]
- self.build_commands = [
- 'make',
- ]
- self.test_commands = [
- ]
- self.install_commands = [
- 'make DESTDIR="$DESTDIR" install',
- ]
- self.strip_commands = [_STRIP_COMMAND]
-
-
-class PythonDistutilsBuildSystem(BuildSystem):
-
- '''The Python distutils build systems.'''
-
- name = 'python-distutils'
-
- def __init__(self):
- BuildSystem.__init__(self)
- self.configure_commands = [
- ]
- self.build_commands = [
- 'python setup.py build',
- ]
- self.test_commands = [
- ]
- self.install_commands = [
- 'python setup.py install --prefix "$PREFIX" --root "$DESTDIR"',
- ]
- self.strip_commands = [_STRIP_COMMAND]
-
-
-class ExtUtilsMakeMakerBuildSystem(BuildSystem):
-
- '''The ExtUtils::MakeMaker build system.
-
- To install perl distributions into the correct location in our chroot
- we need to set PREFIX to <destdir>/<prefix> in the configure-commands.
-
- The mapping between PREFIX and the final installation
- directories is complex and depends upon the configuration of perl
- see,
- https://metacpan.org/pod/distribution/perl/INSTALL#Installation-Directories
- and ExtUtil::MakeMaker's documentation for more details.
-
- '''
-
- # This is called the 'cpan' build system for historical reasons,
- # back when morph only supported one of the perl build systems.
- name = 'cpan'
-
- def __init__(self):
- BuildSystem.__init__(self)
-
- self.configure_commands = [
- 'perl Makefile.PL PREFIX=$DESTDIR$PREFIX',
- ]
- self.build_commands = [
- 'make',
- ]
- self.test_commands = [
- # FIXME: we ought to run tests by default,
- # and use chunk morphs to disable for special cases
- # 'make test',
- ]
- self.install_commands = [
- 'make install',
- ]
- self.strip_commands = [_STRIP_COMMAND]
-
-
-
-class ModuleBuildBuildSystem(BuildSystem):
-
- '''The Module::Build build system'''
-
- name = 'module-build'
-
- def __init__(self):
- super(ModuleBuildBuildSystem, self).__init__()
-
- self.configure_commands = [
- # See the comment in ExtUtilsMakeMakerBuildSystem
- # to see why --prefix is set to $DESTDIR$PREFIX here,
- # (--prefix in Module::Build has the same meaning
- # as PREFIX in ExtUtils::MakeMaker)
- 'perl Build.PL --prefix "$DESTDIR$PREFIX"'
- ]
-
- self.build_commands = [
- './Build'
- ]
-
- self.test_commands = [
- './Build test'
- ]
-
- self.install_commands = [
- './Build install'
- ]
-
-
-class CMakeBuildSystem(BuildSystem):
-
- '''The cmake build system.'''
-
- name = 'cmake'
-
- def __init__(self):
- BuildSystem.__init__(self)
- self.configure_commands = [
- 'cmake -DCMAKE_INSTALL_PREFIX=/usr'
- ]
- self.build_commands = [
- 'make',
- ]
- self.test_commands = [
- ]
- self.install_commands = [
- 'make DESTDIR="$DESTDIR" install',
- ]
- self.strip_commands = [_STRIP_COMMAND]
-
-
-class QMakeBuildSystem(BuildSystem):
-
- '''The Qt build system.'''
-
- name = 'qmake'
-
- def __init__(self):
- BuildSystem.__init__(self)
- self.configure_commands = [
- 'qmake -makefile '
- ]
- self.build_commands = [
- 'make',
- ]
- self.test_commands = [
- ]
- self.install_commands = [
- 'make INSTALL_ROOT="$DESTDIR" install',
- ]
- self.strip_commands = [_STRIP_COMMAND]
-
-
-build_systems = [
- ManualBuildSystem(),
- AutotoolsBuildSystem(),
- PythonDistutilsBuildSystem(),
- ExtUtilsMakeMakerBuildSystem(),
- ModuleBuildBuildSystem(),
- CMakeBuildSystem(),
- QMakeBuildSystem(),
- DummyBuildSystem(),
-]
-
-
-def lookup_build_system(name):
- '''Return build system that corresponds to the name.
-
- If the name does not match any build system, raise ``KeyError``.
-
- '''
-
- for bs in build_systems:
- if bs.name == name:
- return bs
- raise KeyError('Unknown build system: %s' % name)
diff --git a/morphlib/buildsystem_tests.py b/morphlib/buildsystem_tests.py
index 6b6bf30f..e834fd3f 100644
--- a/morphlib/buildsystem_tests.py
+++ b/morphlib/buildsystem_tests.py
@@ -13,9 +13,6 @@
# with this program. If not, see <http://www.gnu.org/licenses/>.
-import os
-import shutil
-import tempfile
import unittest
import morphlib
@@ -51,32 +48,3 @@ class BuildSystemTests(unittest.TestCase):
}
self.bs.from_dict('test', commands_dict)
self.assertEqual(self.bs.configure_commands, 'foo')
-
-
-class LookupBuildSystemTests(unittest.TestCase):
-
- def lookup(self, name):
- return morphlib.buildsystem.lookup_build_system(name)
-
- def test_raises_keyerror_for_unknown_name(self):
- self.assertRaises(KeyError, self.lookup, 'unknown')
-
- def test_looks_up_manual(self):
- self.assertEqual(type(self.lookup('manual')),
- morphlib.buildsystem.ManualBuildSystem)
-
- def test_looks_up_autotools(self):
- self.assertEqual(type(self.lookup('autotools')),
- morphlib.buildsystem.AutotoolsBuildSystem)
-
- def test_looks_up_cmake(self):
- self.assertEqual(type(self.lookup('cmake')),
- morphlib.buildsystem.CMakeBuildSystem)
-
- def test_looks_up_qmake(self):
- self.assertEqual(type(self.lookup('qmake')),
- morphlib.buildsystem.QMakeBuildSystem)
-
- def test_looks_up_dummy(self):
- self.assertEqual(type(self.lookup('dummy')),
- morphlib.buildsystem.DummyBuildSystem)
diff --git a/morphlib/cachekeycomputer_tests.py b/morphlib/cachekeycomputer_tests.py
index 6e736796..a2dff969 100644
--- a/morphlib/cachekeycomputer_tests.py
+++ b/morphlib/cachekeycomputer_tests.py
@@ -29,8 +29,8 @@ class DummyBuildEnvironment:
default_split_rules = {
- 'chunk': morphlib.artifactsplitrule.DEFAULT_CHUNK_RULES,
- 'stratum': morphlib.artifactsplitrule.DEFAULT_STRATUM_RULES,
+ 'chunk': morphlib.artifactsplitrule.EMPTY_RULES,
+ 'stratum': morphlib.artifactsplitrule.EMPTY_RULES,
}
diff --git a/morphlib/defaults.py b/morphlib/defaults.py
index 9e695a90..85c8b711 100644
--- a/morphlib/defaults.py
+++ b/morphlib/defaults.py
@@ -27,13 +27,6 @@ import morphlib
class Defaults(object):
'''Represents predefined default values specific to Baserock definitions.
- The DEFAULTS file was added in definitions format version 7, which lets
- users set these defaults. The text of DEFAULTS file can be passed in as
- 'text', and will be validated and parsed if definitions_version >= 7.
-
- Prior to version 7, the defaults were hardcoded in Morph. These defaults
- will be returned if definitions_version < 7.
-
'''
def __init__(self, definitions_version, text=None):
self._build_systems = {}
@@ -44,11 +37,8 @@ class Defaults(object):
with open(schema_path) as f:
self.schema = yaml.load(f)
- if definitions_version >= 7:
- if text:
- self._build_systems, self._split_rules = self._parse(text)
- else:
- self._build_systems, self._split_rules = self._builtins()
+ if text:
+ self._build_systems, self._split_rules = self._parse(text)
def _parse(self, text):
build_systems = {}
@@ -87,20 +77,6 @@ class Defaults(object):
return build_systems, split_rules
- def _builtins(self):
- build_systems = {}
- split_rules = {}
-
- for build_system in morphlib.buildsystem.build_systems:
- build_systems[build_system.name] = build_system
-
- split_rules['chunk'] = \
- morphlib.artifactsplitrule.DEFAULT_CHUNK_RULES
- split_rules['stratum'] = \
- morphlib.artifactsplitrule.DEFAULT_STRATUM_RULES
-
- return build_systems, split_rules
-
def build_systems(self):
return self._build_systems
diff --git a/morphlib/definitions_repo.py b/morphlib/definitions_repo.py
index 8b022867..9fc4e734 100644
--- a/morphlib/definitions_repo.py
+++ b/morphlib/definitions_repo.py
@@ -229,15 +229,8 @@ class DefinitionsRepo(gitdir.GitDirectory):
defaults_text = mf.read_file('DEFAULTS', allow_missing=True)
- if version < 7:
- if defaults_text is not None:
- warnings.warn(
- "Ignoring DEFAULTS file, because these definitions are "
- "version %i" % version)
- defaults_text = None
- else:
- if defaults_text is None:
- warnings.warn("No DEFAULTS file found.")
+ if defaults_text is None:
+ warnings.warn("No DEFAULTS file found.")
defaults = morphlib.defaults.Defaults(version,
text=defaults_text)
diff --git a/morphlib/definitions_version.py b/morphlib/definitions_version.py
index 2fb7785a..b531a021 100644
--- a/morphlib/definitions_version.py
+++ b/morphlib/definitions_version.py
@@ -24,7 +24,7 @@ import yaml
import morphlib
-SUPPORTED_VERSIONS = [6, 7]
+SUPPORTED_VERSIONS = [7]
class DefinitionsVersionError(cliapp.AppException):
diff --git a/morphlib/plugins/cross-bootstrap_plugin.py b/morphlib/plugins/cross-bootstrap_plugin.py
index 8b8fbb2d..c6ab8017 100644
--- a/morphlib/plugins/cross-bootstrap_plugin.py
+++ b/morphlib/plugins/cross-bootstrap_plugin.py
@@ -156,8 +156,6 @@ class BootstrapSystemBuilder(morphlib.builder.BuilderBase):
f.write('cd $DESTDIR/$chunk_name.build\n')
f.write('export PREFIX=%s\n' % source.prefix)
- bs = morphlib.buildsystem.lookup_build_system(m['build-system'])
-
# FIXME: merge some of this with Morphology
steps = [
('pre-configure', False),
diff --git a/morphlib/sourceresolver.py b/morphlib/sourceresolver.py
index f8dac8b1..5d04ece9 100644
--- a/morphlib/sourceresolver.py
+++ b/morphlib/sourceresolver.py
@@ -232,15 +232,8 @@ class SourceResolver(object):
defaults_text = self._get_file_contents_from_definitions(
definitions_checkout_dir, 'DEFAULTS')
- if definitions_version < 7:
- if defaults_text is not None:
- warnings.warn(
- "Ignoring DEFAULTS file, because these definitions are "
- "version %i" % definitions_version)
- defaults_text = None
- else:
- if defaults_text is None:
- warnings.warn("No DEFAULTS file found.")
+ if defaults_text is None:
+ warnings.warn("No DEFAULTS file found.")
defaults = morphlib.defaults.Defaults(definitions_version,
text=defaults_text)