diff options
Diffstat (limited to 'attoconf')
-rw-r--r-- | attoconf/_version.py | 2 | ||||
-rw-r--r-- | attoconf/lib/arches.py | 4 | ||||
-rw-r--r-- | attoconf/lib/config_hash.py | 48 | ||||
-rw-r--r-- | attoconf/lib/install.py | 40 |
4 files changed, 71 insertions, 23 deletions
diff --git a/attoconf/_version.py b/attoconf/_version.py index 41d536a..2f23d77 100644 --- a/attoconf/_version.py +++ b/attoconf/_version.py @@ -11,7 +11,7 @@ minor = 3 # Incremented if there is a bugfix release. # Might not be contiguous. -patch = 3 +patch = 4 # Reserved for distributors and forks. # Contains arbitrary text, but no parentheses or newlines. diff --git a/attoconf/lib/arches.py b/attoconf/lib/arches.py index 595b396..007f879 100644 --- a/attoconf/lib/arches.py +++ b/attoconf/lib/arches.py @@ -27,14 +27,14 @@ def host(build, HOST): if HOST is None: BUILD, origin = build.vars['BUILD'] if origin != 'default': - origin = 'derived from BUILD' + origin = 'derived' build.vars['HOST'] = (BUILD, origin) def target(build, TARGET): if TARGET is None: HOST, origin = build.vars['HOST'] if origin != 'default': - origin = 'derived from HOST' + origin = 'derived' build.vars['TARGET'] = (HOST, origin) class Arches2(ClassyProject): diff --git a/attoconf/lib/config_hash.py b/attoconf/lib/config_hash.py new file mode 100644 index 0000000..5641558 --- /dev/null +++ b/attoconf/lib/config_hash.py @@ -0,0 +1,48 @@ +# Copyright 2013 Ben Longbons <b.r.longbons@gmail.com> +# +# This file is part of attoconf. +# +# attoconf 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 3 of the License, or +# (at your option) any later version. +# +# attoconf 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 attoconf. If not, see <http://www.gnu.org/licenses/>. + +from __future__ import print_function, division, absolute_import + +from hashlib import md5 +import os + +from ..classy import ClassyProject + + +def calc_hash(build): + hash = md5() + for var, (val, origin), in sorted(build.vars.iteritems()): + # origin is not included in the hash + hash.update('%s = %s\n' % (var, val)) + return hash.hexdigest() + + +def add_config_hash(build): + print('Generating a hash of config options ...') + build.vars['CONFIG_HASH'] = (calc_hash(build), 'special') + + +class ConfigHash(ClassyProject): + ''' Post hook add the build hash. + + This should be run before any other post hooks. + ''' + __slots__ = () + + def post(self): + self.checks.append(add_config_hash) + super(ConfigHash, self).post() diff --git a/attoconf/lib/install.py b/attoconf/lib/install.py index a807666..498b13b 100644 --- a/attoconf/lib/install.py +++ b/attoconf/lib/install.py @@ -39,63 +39,63 @@ def exec_prefix(build, EPREFIX): if EPREFIX is None: PREFIX, origin = build.vars['PREFIX'] if origin != 'default': - origin = 'derived from PREFIX' + origin = 'derived' build.vars['EPREFIX'] = (PREFIX, origin) def bindir(build, DIR): if DIR is None: EPREFIX, origin = build.vars['EPREFIX'] if origin != 'default': - origin = 'derived from EPREFIX' + origin = 'derived' build.vars['BINDIR'] = (os.path.join(EPREFIX, 'bin'), origin) def sbindir(build, DIR): if DIR is None: EPREFIX, origin = build.vars['EPREFIX'] if origin != 'default': - origin = 'derived from EPREFIX' + origin = 'derived' build.vars['SBINDIR'] = (os.path.join(EPREFIX, 'sbin'), origin) def libexecdir(build, DIR): if DIR is None: EPREFIX, origin = build.vars['EPREFIX'] if origin != 'default': - origin = 'derived from EPREFIX' + origin = 'derived' build.vars['LIBEXECDIR'] = (os.path.join(EPREFIX, 'libexec'), origin) def sysconfdir(build, DIR): if DIR is None: PREFIX, origin = build.vars['PREFIX'] if origin != 'default': - origin = 'derived from PREFIX' + origin = 'derived' build.vars['SYSCONFDIR'] = (os.path.join(PREFIX, 'etc'), origin) def sharedstatedir(build, DIR): if DIR is None: PREFIX, origin = build.vars['PREFIX'] if origin != 'default': - origin = 'derived from PREFIX' + origin = 'derived' build.vars['SHAREDSTATEDIR'] = (os.path.join(PREFIX, 'com'), origin) def localstatedir(build, DIR): if DIR is None: PREFIX, origin = build.vars['PREFIX'] if origin != 'default': - origin = 'derived from PREFIX' + origin = 'derived' build.vars['LOCALSTATEDIR'] = (os.path.join(PREFIX, 'var'), origin) def libdir(build, DIR): if DIR is None: EPREFIX, origin = build.vars['EPREFIX'] if origin != 'default': - origin = 'derived from EPREFIX' + origin = 'derived' build.vars['LIBDIR'] = (os.path.join(EPREFIX, 'lib'), origin) def includedir(build, DIR): if DIR is None: PREFIX, origin = build.vars['PREFIX'] if origin != 'default': - origin = 'derived from PREFIX' + origin = 'derived' build.vars['INCLUDEDIR'] = (os.path.join(PREFIX, 'include'), origin) def oldincludedir(build, DIR): @@ -105,14 +105,14 @@ def datarootdir(build, DIR): if DIR is None: PREFIX, origin = build.vars['PREFIX'] if origin != 'default': - origin = 'derived from PREFIX' + origin = 'derived' build.vars['DATAROOTDIR'] = (os.path.join(PREFIX, 'share'), origin) def datadir(build, DIR): if DIR is None: DATAROOTDIR, origin = build.vars['DATAROOTDIR'] if origin != 'default': - origin = 'derived from DATAROOTDIR' + origin = 'derived' build.vars['DATADIR'] = (DATAROOTDIR, origin) def packagedatadir(build, DIR): @@ -120,28 +120,28 @@ def packagedatadir(build, DIR): DATADIR, origin = build.vars['DATADIR'] PACKAGE, prigin = build.vars['PACKAGE'] if origin != 'default' or prigin != 'default': - origin = 'derived from DATADIR and PACKAGE' + origin = 'derived' build.vars['DATADIR'] = (os.path.join(DATADIR, PACKAGE), origin) def infodir(build, DIR): if DIR is None: DATAROOTDIR, origin = build.vars['DATAROOTDIR'] if origin != 'default': - origin = 'derived from DATAROOTDIR' + origin = 'derived' build.vars['INFODIR'] = (os.path.join(DATAROOTDIR, 'info'), origin) def localedir(build, DIR): if DIR is None: DATAROOTDIR, origin = build.vars['DATAROOTDIR'] if origin != 'default': - origin = 'derived from DATAROOTDIR' + origin = 'derived' build.vars['LOCALEDIR'] = (os.path.join(DATAROOTDIR, 'locale'), origin) def mandir(build, DIR): if DIR is None: DATAROOTDIR, origin = build.vars['DATAROOTDIR'] if origin != 'default': - origin = 'derived from DATAROOTDIR' + origin = 'derived' build.vars['MANDIR'] = (os.path.join(DATAROOTDIR, 'man'), origin) def docdir(build, DIR): @@ -149,35 +149,35 @@ def docdir(build, DIR): DATAROOTDIR, origin = build.vars['DATAROOTDIR'] PACKAGE, origin2 = build.vars['PACKAGE'] if origin != 'default' or origin2 != 'default': - origin = 'derived from DATAROOTDIR and PACKAGE' + origin = 'derived' build.vars['DOCDIR'] = (os.path.join(DATAROOTDIR, 'doc', PACKAGE), origin) def htmldir(build, DIR): if DIR is None: DOCDIR, origin = build.vars['DOCDIR'] if origin != 'default': - origin = 'derived from DOCDIR' + origin = 'derived' build.vars['HTMLDIR'] = (DOCDIR, origin) def dvidir(build, DIR): if DIR is None: DOCDIR, origin = build.vars['DOCDIR'] if origin != 'default': - origin = 'derived from DOCDIR' + origin = 'derived' build.vars['DVIDIR'] = (DOCDIR, origin) def pdfdir(build, DIR): if DIR is None: DOCDIR, origin = build.vars['DOCDIR'] if origin != 'default': - origin = 'derived from DOCDIR' + origin = 'derived' build.vars['PDFDIR'] = (DOCDIR, origin) def psdir(build, DIR): if DIR is None: DOCDIR, origin = build.vars['DOCDIR'] if origin != 'default': - origin = 'derived from DOCDIR' + origin = 'derived' build.vars['PSDIR'] = (DOCDIR, origin) |