Mercurial > gub
view bin/gib @ 6512:ccc20ae889ca default tip guix
mingw::guile-2.0.7 builds.
author | Jan Nieuwenhuizen <janneke@gnu.org> |
---|---|
date | Thu, 24 Mar 2016 08:03:39 +0100 |
parents | 72b46c22bf99 |
children |
line wrap: on
line source
#! /usr/bin/env python """ Copyright (c) 2005--2008 Jan Nieuwenhuizen <janneke@gnu.org> Han-Wen Nienhuys <hanwen@xs4all.nl> 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, 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., 675 Mass Ave, Cambridge, MA 02139, USA. """ def argv0_relocation (): import os, sys bindir = os.path.dirname (sys.argv[0]) prefix = os.path.dirname (bindir) if not prefix: prefix = bindir + '/..' sys.path.insert (0, prefix) argv0_relocation () import inspect import optparse import os import sys import pickle # from gub import misc from gub import gup from gub import installer import gub.settings from gub import locker from gub import gub_log from gub import runner from gub import versiondb def parse_command_line (): p = optparse.OptionParser () p.usage='''gib [OPTION]... PACKAGE... ''' p.description='''Gub\'s Installer Builder - collect in platform dependent package format''' examples = ''' Examples: gib lilypond # TODO: add --branch goo... gib -p mingw lilypond ''' misc.optparse_epilog (p, examples) p.add_option ('-B', '--branch', dest='branches', default=['*=*'], action='append', help='set branch for package') p.add_option ('-l', '--skip-if-locked', default=False, dest="skip_if_locked", action="store_true", help="Return successfully if another build is already running") p.add_option ('--version-db', action='store', default='versiondb/lilypond.versions', dest='version_db') p.add_option ("--no-strip", action="store_false", default=True, dest="do_strip", help="don't perform strip stage") p.add_option ("--setting", '-s', action="append", default=[], dest="settings", help="extra overrides for settings") p.add_option ('-p', '--platform', action='store', dest='platform', type='choice', default=None, help='select target platform', choices=list (gub.settings.platforms.keys ())) p.add_option ('-v', '--verbose', action='count', dest='verbosity', default=0) (options, args) = p.parse_args () return (options, args) def check_installer (installer, options, args): settings = installer.settings install_manager = gup.PackageDictManager () install_manager.read_package_headers (settings.packages, settings.branch_dict) install_manager.read_package_headers (settings.cross_packages, settings.branch_dict) ## can't interrogate installer yet, because version is not known yet. checksum_file = installer.installer_checksum_file if not os.path.exists (checksum_file): return False checksum = open (checksum_file).read () return checksum == get_installer_checksum ( [install_manager.package_dict (p) for p in install_manager.installed_packages ()]) def build_installer (installer_obj): logger = gub_log.default_logger # theoretically, we could run DeferredRunner but we would have to # CommandRunner-ify PackageManager too. - that does not seem worth # the effort. command_runner = runner.CommandRunner (logger) available = dict (inspect.getmembers (installer_obj, lambda x: hasattr (x, '__call__'))) installer_obj.connect_command_runner (command_runner) try: for s in installer_obj.stages (): if s in available: logger.write_log (' *** Stage: %s (installer, %s)\n' % (s, installer_obj.settings.platform), 'stage') available[s] () installer_file = installer_obj.installer_file ().replace (os.getcwd () + '/', '') logger.write_log ('installer left in: %(installer_file)s\n' % locals (), 'info') except: t, v, b = sys.exc_info () if t == installer.ChecksumShortCircuit: logger.write_log ('*** checksum matches: no rebuild necessary\n', 'stage') checksum_file = v.file logger.write_log ('checksum file: %(checksum_file)s\n' % locals (), 'info') return raise installer_obj.connect_command_runner (None) def main (): (options, args) = parse_command_line () # TODO: should run gub -p PLATFORM TARGET from here. settings = gub.settings.Settings (options.platform) for s in options.settings: (k, v) = tuple (s.split ('=')) if k in settings.__dict__: gub_log.warn ('overwriting %s = %s with %s\n' % (k, settings.__dict__[k], v)) settings.__dict__[k] = v db = versiondb.VersionDataBase (options.version_db) branch_dict = dict ([tuple (branch_setting.split ('=')) for branch_setting in options.branches]) log = gub_log.set_default_log (settings.expand ('%(logdir)s/installer.log'), options.verbosity) installer_obj = installer.get_installer (settings, args, db, branch_dict) try: build_installer (installer_obj) except locker.LockedError: gub_log.error ('another build in progress. Skipping.') if options.skip_if_locked: sys.exit (0) raise gub_log.stage ('done\n') gub_log.default_logger.show_logfile () if __name__ == '__main__': main ()