# Boston, MA 02111-1307, USA.

import os
import subprocess

from cerbero.config import Platform
from cerbero.commands import Command, register_command
from cerbero.utils import N_


class Shell(Command):
    doc = N_('Starts a shell with the build environment')
    name = 'shell'

    def __init__(self):
        Command.__init__(self, [])

    def run(self, config, args):
        if config.platform == Platform.WINDOWS:
            # $MINGW_PREFIX/home/username
            msyscon = os.environ.get('MSYSCON',
                os.path.join(os.path.expanduser('~'), '..', '..', 'msys.bat'))
            if 'mysys.bat' in msyscon:
                msyscon = '%s -noxvrt' % msys
            subprocess.check_call(msyscon)
        else:
            shell = os.environ.get('SHELL', '/bin/bash')
            os.execlp(shell, shell)

register_command(Shell)
示例#2
0
文件: build.py 项目: fluendo/cerbero
                no_deps=False, store=None, dry_run=False, use_binaries=False,
                upload_binaries=False, build_missing=False):
        if not store:
            store = PackagesStore(config)
        cookbook = store.cookbook

        oven = Oven(cookbook, force=self.force, missing_files=missing_files,
                    dry_run=dry_run, store=store)

        if isinstance(recipes, str):
            recipes = [recipes]

        if no_deps:
            ordered_recipes = recipes
        else:
            ordered_recipes = cookbook.list_recipes_deps(recipes)
        oven.start_cooking(ordered_recipes, use_binaries, upload_binaries,
                build_missing)


class BuildOne(Build):
    doc = N_('Build or rebuild a single recipe without its dependencies')
    name = 'buildone'

    def __init__(self):
        Build.__init__(self, True, True)


register_command(BuildOne)
register_command(Build)
示例#3
0
            ],
        )

    def run(self, config, args):
        store = PackagesStore(config)
        p_name = args.package[0]
        if args.list_files:
            m.message("\n".join(store.get_package_files_list(p_name)))
        else:
            p = store.get_package(p_name)
            licenses = [p.license]
            if not isinstance(p, MetaPackage):
                recipes_licenses = p.recipes_licenses()
                recipes_licenses.update(p.devel_recipes_licenses())
                for recipe_name, categories_licenses in recipes_licenses.iteritems():
                    for category_licenses in categories_licenses.itervalues():
                        licenses.extend(category_licenses)
            licenses = sorted(list(set(licenses)))
            d = {
                "name": p.name,
                "version": p.version,
                "url": p.url,
                "licenses": " and ".join([l.acronym for l in licenses]),
                "desc": p.shortdesc,
                "deps": ", ".join([p.name for p in store.get_package_deps(p_name, True)]),
            }
            m.message(INFO_TPL % d)


register_command(PackageInfo)
示例#4
0
        store = PackagesStore(config)
        p = store.get_package(p_name)
        ordered_recipes = map(lambda x: cookbook.get_recipe(x),
                    p.recipes_dependencies())

        for recipe in ordered_recipes:
            if cookbook.recipe_needs_build(recipe.name):
                raise CommandError(_("Recipe %s is not built yet" % recipe.name))

        for recipe in ordered_recipes:
            # call step function
            stepfunc = None
            try:
                stepfunc = getattr(recipe, 'check')
            except:
                m.message('%s has no check step, skipped' % recipe.name)

            if stepfunc:
                try:
                    m.message('Running checks for recipe %s' % recipe.name)
                    stepfunc()
                except Exception, ex:
                    failed.append(recipe.name)
                    m.warning(_("%s checks failed: %s") % (recipe.name, ex))
        if failed:
            raise CommandError(_("Error running %s checks on:\n    " +
                        "\n    ".join(failed)) % p_name)

register_command(CheckPackage)
示例#5
0
文件: list.py 项目: GStreamer/cerbero
    def run(self, config, args):
        store = PackagesStore(config)
        packages = store.get_packages_list()
        if len(packages) == 0:
            m.message(_("No packages found"))
        for p in packages:
            m.message("%s - %s" % (p.name, p.version))

class ShowConfig(Command):
    doc = N_('Show configuration settings')
    name = 'show-config'

    def __init__(self):
        Command.__init__(self, [])

    def run(self, config, args):
        for n in config._properties:
            if n == "variants":
                print "%25s :" % (n)
                variants = getattr(config, n).__dict__
                for v in variants:
                    print "%30s : %s" % (v, variants[v])
            else:
                print "%25s : %s" % (n, getattr(config, n))


register_command(List)
register_command(ListPackages)
register_command(ShowConfig)
示例#6
0
class GenLibraryFiles(Command):
    doc = N_('Generate MSVC compatible library files (.lib)')
    name = 'genlibfiles'

    def __init__(self):
        Command.__init__(self,
            [ArgparseArgument('-o', '--output_dir', default=None,
                help=_('output directory where .lib files will be saved')),
            ])

    def run(self, config, args):
        if config.target_platform != Platform.WINDOWS:
            raise UsageError(_('%s command can only be used targetting '
                             'Windows platforms') % self.name)

        if args.output_dir is not None and not os.path.exists(args.output_dir):
            os.makedirs(args.output_dir)

        cookbook = CookBook(config)
        recipes = cookbook.get_recipes_list()
        for recipe in recipes:
            try:
                recipe.gen_library_file(args.output_dir)
            except Exception as e:
                m.message(_("Error generaring library files for %s:\n %s") %
                          (recipe.name, e))


register_command(GenLibraryFiles)
示例#7
0
文件: runit.py 项目: AlertMe/cerbero
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
# Library General Public License for more details.
#
# You should have received a copy of the GNU Library 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.


from cerbero.commands import Command, register_command
from cerbero.utils import _, N_, ArgparseArgument, shell


class Run(Command):
    doc = N_('Runs a command in the cerbero shell')
    name = 'run'

    def __init__(self):
        Command.__init__(self,
            [ArgparseArgument('cmd', nargs='*',
                             help=_('command to run')),
            ])

    def run(self, config, args):
        command = ' '.join(args.cmd)
        shell.call(command)


register_command(Run)
示例#8
0
        bundle_recipes = remove_list_duplicates(bundle_recipes)

        for p in packages:
            setup_args.append('--package=' + p)

        for r in bundle_recipes:
            setup_args.append('--recipe=' + r.name)
            if r.stype != SourceType.CUSTOM:
                bundle_dirs.append(r.repo_dir)

        if not args.no_bootstrap:
            build_tools = BuildTools(config, args.offline)
            bs_recipes = build_tools.BUILD_TOOLS + \
                         build_tools.PLAT_BUILD_TOOLS.get(config.platform, [])
            b_recipes = []
            for r in bs_recipes:
                b_recipes += cookbook.list_recipe_deps(r)
            b_recipes = remove_list_duplicates(b_recipes)

            for r in b_recipes:
                if r.stype != SourceType.CUSTOM:
                    bundle_dirs.append(r.repo_dir)

        setup_args.append('--source-dirs=' + ','.join(bundle_dirs))

        command = str(config._relative_path('setup.py'))
        run_setup(command, setup_args)


register_command(BundleSource)
示例#9
0
        else:
            pkg = Packager(config, p, self.store)
        m.action(_("Creating package for %s") % p.name)
        output_dir = os.path.abspath(args.output_dir)
        if args.tarball:
            paths = pkg.pack(output_dir,
                             args.no_devel,
                             args.force,
                             args.keep_temp,
                             split=not args.no_split)
        else:
            paths = pkg.pack(output_dir, args.no_devel, args.force,
                             args.keep_temp)
        if None in paths:
            paths.remove(None)
        paths = p.post_package(paths, output_dir) or paths
        m.action(
            _("Package successfully created in %s") %
            ' '.join([os.path.abspath(x) for x in paths]))

    def _build_deps(self, config, package, has_devel, offline, dry_run):
        build_command = build.Build()
        build_command.runargs(config,
                              package.recipes_dependencies(has_devel),
                              cookbook=self.store.cookbook,
                              dry_run=dry_run,
                              offline=offline)


register_command(Package)
示例#10
0
        if platform_files:
            unparsed_files = platform_files.split(',')
            self.validate_platform_files(unparsed_files)

            parsed_files = {}
            for desc in unparsed_files:
                platform_index = desc.index(':')
                platform = desc[:platform_index]
                files = desc[platform_index + 1:]
                if not platform in parsed_files:
                    parsed_files[platform] = [files]
                else:
                    parsed_files[platform].append(files)

            if extra_files:
                parsed_files = self.merge_dict(parsed_files, extra_files)
        else:
            parsed_files = extra_files

        template_arg = []
        for platform, files in parsed_files.iteritems():
            template_arg.append(
                self.supported_platforms[platform] + ': [' + \
                    ', '.join(['\'' + recipe_files + '\'' \
                        for recipe_files in files]) + \
                    ']')
        return ', '.join(template_arg)


register_command(AddPackage)
示例#11
0
文件: fetch.py 项目: zaheerm/cerbero
                             default=False,
                             help=_('do not fetch dependencies')),
        ]
        Fetch.__init__(self, args)

    def run(self, config, args):
        cookbook = CookBook(config)
        return self.fetch(cookbook, args.recipes, args.no_deps,
                          args.reset_rdeps, args.full_reset)


class FetchPackage(Fetch):
    doc = N_('Fetch the recipes sources from a package')
    name = 'fetch-package'

    def __init__(self):
        args = [
            ArgparseArgument('package', nargs=1, help=_('package to fetch')),
        ]
        Fetch.__init__(self, args)

    def run(self, config, args):
        store = PackagesStore(config)
        package = store.get_package(args.package[0])
        return self.fetch(store.cookbook, package.recipes_dependencies(), True,
                          args.reset_rdeps, args.full_reset)


register_command(FetchRecipes)
register_command(FetchPackage)
示例#12
0
        recipe = cookbook.get_recipe(recipe_name)

        if recursive:
            ordered_recipes = cookbook.list_recipe_deps(recipe_name)
        else:
            ordered_recipes = [recipe]

        for recipe in ordered_recipes:
            if cookbook.recipe_needs_build(recipe.name):
                raise FatalError(_("Recipe %s is not built yet" % recipe.name))

        for recipe in ordered_recipes:
            # call step function
            stepfunc = None
            try:
                stepfunc = getattr(recipe, 'check')
            except:
                m.message('%s has no check step, skipped' % recipe.name)

            if stepfunc:
                try:
                    stepfunc()
                except FatalError, e:
                    raise e
                except Exception, ex:
                    raise FatalError(_("Error running %s checks: %s") %
                        (recipe.name, ex))

register_command(Check)
示例#13
0
                             action='store_true',
                             default=False,
                             help=_('list all dependencies, including the '
                                    'build ones')),
        ])

    def run(self, config, args):
        cookbook = CookBook(config)
        recipe_name = args.recipe[0]
        all_deps = args.all

        if all_deps:
            recipes = cookbook.list_recipe_deps(recipe_name)
        else:
            recipes = [
                cookbook.get_recipe(x)
                for x in cookbook.get_recipe(recipe_name).list_deps()
            ]

        if len(recipes) == 0:
            m.message(_('%s has 0 dependencies') % recipe_name)
            return
        for recipe in recipes:
            # Don't print the recipe we asked for
            if recipe.name == recipe_name:
                continue
            m.message(recipe.name)


register_command(Deps)
示例#14
0
    def __init__(self):
        Command.__init__(self, [])

    def run(self, config, args):
        cookbook = CookBook(config)
        recipes = cookbook.get_recipes_list()
        if len(recipes) == 0:
            m.message(_("No recipes found"))
        for recipe in recipes:
            m.message("%s - %s" % (recipe.name, recipe.version))


class ListPackages(Command):
    doc = N_('List all the available packages')
    name = 'list-packages'

    def __init__(self):
        Command.__init__(self, [])

    def run(self, config, args):
        store = PackagesStore(config)
        packages = store.get_packages_list()
        if len(packages) == 0:
            m.message(_("No packages found"))
        for p in packages:
            m.message("%s - %s" % (p.name, p.version))


register_command(List)
register_command(ListPackages)
示例#15
0
文件: wipe.py 项目: deepak6/cerbero
        options = ['yes', 'no']
        msg = _("WARNING!!!\n"
                "This command will delete cerbero's build cache, "
                "the sources directory and the builds directory "
                "to reset the build system to its initial state.\n"
                "The following paths will be removed:\n%s\n"
                "Do you want to continue?" % '\n'.join(to_remove))
        # Ask once
        if shell.prompt(msg, options) == options[0]:
            msg = _("Are you sure?")
            # Ask twice
            if shell.prompt(msg, options) == options[0]:
                # Start with the Apocalypse
                self.wipe(to_remove)

    def wipe(self, paths):
        for path in paths:
            m.action(_("Removing path: %s") % path)
            if not os.path.exists(path):
                continue
            if os.path.isfile(path):
                if not os.access(path, os.W_OK):
                    os.chmod(path, stat.S_IWUSR)
                os.remove(path)
            else:
                shutil.rmtree(path, onerror=_onerror)


register_command(Wipe)
示例#16
0
                     '%s/lib/gstreamer-1.0' % prefix_env)
        self._putvar('GST_PLUGIN_SYSTEM_PATH_1_0',
                     '%s/lib/gstreamer-1.0' % prefix_env)
        self._putvar(
            'PYTHONPATH', '%s/%s/site-packages${PYTHONPATH:+:$PYTHONPATH}' %
            (prefix_env, py_prefix))
        self._putvar('CFLAGS', '-I%s/include ${CFLAGS}' % prefix_env, " ")
        self._putvar('CXXFLAGS', '-I%s/include ${CXXFLAGS}' % prefix_env, " ")
        self._putvar('CPPFLAGS', '-I%s/include ${CPPFLAGS}' % prefix_env, " ")
        self._putvar('LDFLAGS', '-L%s ${LDFLAGS}' % libdir, " ")
        self._putvar('GIO_EXTRA_MODULES', '%s/gio/modules' % libdir)
        self._putvar('GI_TYPELIB_PATH', '%s/girepository-1.0' % libdir)

        envstr = 'export %s="%s"\n' % (prefix_env_name, prefix)
        for e, v in env.items():
            envstr += 'export %s="%s"\n' % (e, v)
        try:
            filepath = os.path.join(output_dir, name)

            if not os.path.exists(os.path.dirname(filepath)):
                os.mkdir(os.path.dirname(filepath))

            with open(filepath, 'w+') as f:
                f.write(SCRIPT_TPL % (envstr, cmd))
            shell.new_call(['chmod', '+x', filepath])
        except IOError as ex:
            raise FatalError(_("Error creating script: %s" % ex))


register_command(GenSdkShell)
示例#17
0
        allfiles = [p.all_files_list() for p in store.get_packages_list() if\
                    isinstance(p, Package)]
        allfiles = list(itertools.chain(*allfiles))

        self.find_duplicates(allfiles)
        self.find_orphan_files(allfiles, config.prefix, args.exclude)

    def find_duplicates(self, allfiles):
        count = collections.Counter(allfiles)
        duplicates = [x for x in count if count[x] > 1]
        if len(duplicates) > 0:
            m.message("Found duplicates files in packages:")
            m.message("%r" % duplicates)

    def find_orphan_files(self, allfiles, prefix, excludes=[]):
        cmd = 'find . -type f %s'
        exc = map(lambda x: "\\( ! -name '%s' \\)" % x, excludes)
        cmd = cmd % ' '.join(exc)

        distfiles = shell.check_call(cmd, prefix).split('\n')
        # remove './' from the list of files
        distfiles = [f[2:] for f in distfiles]
        orphan = sorted(list((set(distfiles) - set(allfiles))))

        if len(orphan) > 0:
            m.message("Found orphan files:")
            m.message('\n'.join(orphan))


register_command(DebugPackages)
示例#18
0
class TarballBuildTools(Command):
    doc = N_('Generate abstract for package')
    name = 'tar-build-tools'

    def __init__(self, force=None, no_deps=None):
        args = [
            ArgparseArgument('--output-dir',
                             type=str,
                             default='.',
                             help=_('directory of package stored'))
        ]

        Command.__init__(self, args)

    def run(self, config, args):

        name = 'build-tools'

        abst = Abstract(config)
        filename = abst.fullname(name) + '.tar.bz2'
        path = os.path.join(args.output_dir, filename)
        import tarfile

        tar = tarfile.open(path, "w:bz2")
        for name in os.listdir(config.build_tools_prefix):
            tar.add(os.path.join(config.build_tools_prefix, name), name)
        tar.close()


register_command(TarballBuildTools)
    def __init__(self):
        Command.__init__(self,
            [ArgparseArgument('recipe', nargs=1,
                             help=_('name of the recipe')),
            ArgparseArgument('--all', action='store_true', default=False,
                             help=_('list all dependencies, including the '
                                    'build ones')),
            ])

    def run(self, config, args):
        cookbook = CookBook(config)
        recipe_name = args.recipe[0]
        all_deps = args.all

        if all_deps:
            recipes = cookbook.list_recipe_deps(recipe_name)
        else:
            recipes = [cookbook.get_recipe(x) for x in
                        cookbook.get_recipe(recipe_name).list_deps()]

        if len(recipes) == 0:
            m.message(_('%s has 0 dependencies') % recipe_name)
            return
        for recipe in recipes:
            # Don't print the recipe we asked for
            if recipe.name == recipe_name:
                continue
            m.message(recipe.name)

register_command(Deps)
示例#20
0
文件: list.py 项目: zaheerm/cerbero
    def run(self, config, args):
        store = PackagesStore(config)
        packages = store.get_packages_list()
        if len(packages) == 0:
            m.message(_("No packages found"))
        for p in packages:
            m.message("%s - %s" % (p.name, p.version))

class ShowConfig(Command):
    doc = N_('Show configuration settings')
    name = 'show-config'

    def __init__(self):
        Command.__init__(self, [])

    def run(self, config, args):
        for n in config._properties:
            if n == "variants":
                print "%25s :" % (n)
                variants = getattr(config, n).__dict__
                for v in variants:
                    print "%30s : %s" % (v, variants[v])
            else:
                print "%25s : %s" % (n, getattr(config, n))


register_command(List)
register_command(ListPackages)
register_command(ShowConfig)
示例#21
0
        self._putvar('CFLAGS',  '-I%s/include ${CFLAGS}' % prefix_env, " ")
        self._putvar('CXXFLAGS',  '-I%s/include ${CXXFLAGS}' % prefix_env, " ")
        self._putvar('CPPFLAGS',  '-I%s/include ${CPPFLAGS}' % prefix_env, " ")
        self._putvar('LDFLAGS',  '-L%s ${LDFLAGS}' % libdir, " ")
        self._putvar('GIO_EXTRA_MODULES',  '%s/gio/modules' % libdir)
        self._putvar('GI_TYPELIB_PATH',  '%s/girepository-1.0' % libdir)
        if config.variants.python3:
            self._putvar('PYTHONHOME', prefix_env)
            self._putvar('PYTHON', "python3", None)
        if config.variants.gtk3:
            self._putvar('GTK_PATH', '%s/gtk-3.0' % libdir, None)
            self._putvar('GTK_DATA_PREFIX', prefix_env, None)

        envstr = 'export %s="%s"\n' % (prefix_env_name, prefix)
        for e, v in env.items():
            envstr += 'export %s="%s"\n' % (e, v)
        try:
            filepath = os.path.join(output_dir, name)

            if not os.path.exists(os.path.dirname(filepath)):
              os.mkdir(os.path.dirname(filepath))

            with open(filepath, 'w+') as f:
                f.write(SCRIPT_TPL % (envstr, cmd))
            shell.call("chmod +x %s" % filepath)
        except IOError as ex:
            raise FatalError(_("Error creating script: %s" % ex))


register_command(GenSdkShell)
示例#22
0
            msg = _("Are you sure?")
            # Ask twice
            if shell.prompt(msg, options) == options[0]:
                # Start with the Apocalypse
                self.wipe(to_remove)

    def wipe(self, paths):
        def _onerror(func, path, exc_info):
            if not os.access(path, os.W_OK):
                os.chmod(path, stat.S_IWUSR)
                func(path)
            # Handle "Directory is not empty" errors
            elif exc_info[1][0] == 145:
                shutil.rmtree(path, onerror=_onerror)
            else:
                raise

        for path in paths:
            m.action(_("Removing path: %s") % path)
            if not os.path.exists(path):
                continue
            if os.path.isfile(path):
                if not os.access(path, os.W_OK):
                    os.chmod(path, stat.S_IWUSR)
                os.remove(path)
            else:
                shutil.rmtree(path, onerror=_onerror)


register_command(Wipe)
示例#23
0
class CleanOne(Command):
    doc = N_("Clean a single recipe without its dependencies")
    name = "cleanone"

    def __init__(self):
        Command.__init__(self, [ArgparseArgument("recipe", nargs=1, help=_("name of the recipe to clean"))])

    def run(self, config, args):
        cookbook = CookBook(config)
        recipe_name = args.recipe[0]

        recipe = cookbook.get_recipe(recipe_name)
        # call step function
        stepfunc = None
        try:
            stepfunc = getattr(recipe, "clean")
        except:
            print "%s has no clean step, skipped" % recipe.name

        if stepfunc:
            try:
                stepfunc()
            except FatalError, e:
                raise e
            except Exception, ex:
                raise FatalError(_("Error running %s checks: %s") % (recipe.name, ex))


register_command(CleanOne)
示例#24
0
            [ArgparseArgument('-o', '--output_dir', default='.',
                help=_('output directory where .xcconfig files will be saved')),
            ArgparseArgument('-f', '--filename', default=None,
                help=_('filename of the .xcconfig file')),
            ArgparseArgument('libraries', nargs='*',
                help=_('List of libraries to include')),
            ])

    def run(self, config, args):
        self.runargs(config, args.output_dir, args.filename, args.libraries)

    def runargs(self, config, output_dir, filename, libraries):
        if not os.path.exists(output_dir):
            os.makedirs(output_dir)

        if len(libraries) == 0:
            raise UsageError("You need to specify at least one library name")

        filename = filename or libraries[0]
        filepath = os.path.join(output_dir, '%s.xcconfig' % filename)

        xcconfig = XCConfig(libraries)
        xcconfig.create(filepath)
        m.action('Created %s.xcconfig' % filename)

        m.message('XCode config file were sucessfully created in %s' %
                  os.path.abspath(filepath))


register_command(GenXCodeConfig)
示例#25
0
            bundle_recipes += cookbook.list_recipe_deps(r)
        bundle_recipes = remove_list_duplicates(bundle_recipes)

        for p in packages:
            setup_args.append('--package=' + p)

        for r in bundle_recipes:
            setup_args.append('--recipe=' + r.name)
            if r.stype != SourceType.CUSTOM:
                bundle_dirs.append(r.repo_dir)

        if not args.no_bootstrap:
            build_tools = BuildTools(config)
            bs_recipes = build_tools.BUILD_TOOLS + \
                         build_tools.PLAT_BUILD_TOOLS.get(config.platform, [])
            b_recipes = []
            for r in bs_recipes:
                b_recipes += cookbook.list_recipe_deps(r)
            b_recipes = remove_list_duplicates(b_recipes)

            for r in b_recipes:
                if r.stype != SourceType.CUSTOM:
                    bundle_dirs.append(r.repo_dir)

        setup_args.append('--source-dirs=' + ','.join(bundle_dirs))

        command = str(config._relative_path('setup.py'))
        run_setup(command, setup_args)

register_command(BundleSource)
示例#26
0
                default=False,
                help=_('only print commands instead of running them ')),
            ArgparseArgument('-f', '--force', action='store_true',
                default=False, help=_('Force the creation of the binary package')),
        ]
        Command.__init__(self, args)

    def run(self, config, args):
        store = PackagesStore(config)
        cookbook = store.cookbook
        recipes = cookbook.get_recipes_list()
        fridge = Fridge(store, args.force, args.dry_run)
        built_recipes = []
        # get all built recipes
        for recipe in recipes:
            bv = cookbook.recipe_built_version(recipe.name)
            cv = recipe.built_version()
            if bv == cv:
                built_recipes.append(recipe)

        # finally freeze them
        i = 1
        for recipe in built_recipes:
            try:
                fridge.freeze_recipe(recipe, i, len(built_recipes))
            except:
                pass
            i += 1

register_command(GenBinaries)
示例#27
0
        if args.deps:
            template += DEPS_TPL
            deps = args.deps.split(',')
            cookbook = CookBook(config)
            for dname in deps:
                try:
                    recipe = cookbook.get_recipe(dname)
                except RecipeNotFoundError as ex:
                    raise UsageError(_("Error creating recipe: "
                            "dependant recipe %s does not exist") % dname)
            template_args['deps'] = deps

        try:
            f = open(filename, 'w')
            f.write(template % template_args)
            f.close()

            m.action(_("Recipe '%s' successfully created in %s") %
                    (name, filename))
        except IOError as ex:
            raise FatalError(_("Error creating recipe: %s") % ex)

    def validate_licenses(self, licenses):
        for l in licenses:
            if l and not l in self.supported_licenses:
                raise UsageError(_("Error creating recipe: "
                    "invalid license '%s'") % l)


register_command(AddRecipe)
示例#28
0
        Command.__init__(self,
            [ArgparseArgument('-o', '--output_dir', default='.',
                help=_('output directory where .vsprops files will be saved')),
             ArgparseArgument('-p', '--prefix', default=DEFAULT_PREFIX_MACRO,
                 help=_('name of the prefix environment variable '
                        '(eg:CERBERO_SDK_ROOT_X86)')),
            ])

    def run(self, config, args):
        self.runargs(config, args.output_dir, args.prefix)

    def runargs(self, config, output_dir, prefix=DEFAULT_PREFIX_MACRO):
        if not os.path.exists(output_dir):
            os.makedirs(output_dir)

        for pc in PkgConfig.list_all():
            p2v = PkgConfig2VSProps(pc, prefix=config.prefix,
                    inherit_common=True,
                    prefix_replacement='$(%s)' % prefix)
            p2v.create(output_dir)
            m.action('Created %s.props' % pc)

        common = CommonProps(prefix)
        common.create(output_dir)

        m.message('Property sheets files were sucessfully created in %s' %
                  os.path.abspath(output_dir))


register_command(GenVSProps)
示例#29
0
        if platform_files:
            unparsed_files = platform_files.split(',')
            self.validate_platform_files(unparsed_files)

            parsed_files = {}
            for desc in unparsed_files:
                platform_index = desc.index(':')
                platform = desc[:platform_index]
                files = desc[platform_index + 1:]
                if not platform in parsed_files:
                    parsed_files[platform] = [files]
                else:
                    parsed_files[platform].append(files)

            if extra_files:
                parsed_files = self.merge_dict(parsed_files, extra_files)
        else:
            parsed_files = extra_files

        template_arg = []
        for platform, files in parsed_files.items():
            template_arg.append(
                self.supported_platforms[platform] + ': [' + \
                    ', '.join(['\'' + recipe_files + '\'' \
                        for recipe_files in files]) + \
                    ']')
        return ', '.join(template_arg)


register_command(AddPackage)
示例#30
0
文件: tag.py 项目: deepak6/cerbero
            recipes = [cookbook.get_recipe(args.recipe)]
        if len(recipes) == 0:
            m.message(_("No recipes found"))
        tagname = args.tagname
        tagdescription = args.tagdescription
        force = args.force
        for recipe in recipes:
            if recipe.stype != SourceType.GIT and \
               recipe.stype != SourceType.GIT_TARBALL:
                m.message(_("Recipe '%s' has a custom source repository, "
                        "skipping") % recipe.name)
                continue

            recipe.fetch(checkout=False)

            tags = git.list_tags(recipe.repo_dir)
            exists = (tagname in tags)
            if exists:
                if not force:
                    m.warning(_("Recipe '%s' tag '%s' already exists, "
                            "not updating" % (recipe.name, tagname)))
                    continue
                git.delete_tag(recipe.repo_dir, tagname)

            commit = 'origin/sdk-%s' % recipe.version
            git.create_tag(recipe.repo_dir, tagname, tagdescription,
                    commit)


register_command(Tag)
示例#31
0
    name = 'bootstrap'

    def __init__(self):
        args = [
            ArgparseArgument('--build-tools-only', action='store_true',
                default=False, help=_('only bootstrap the build tools')),
            ArgparseArgument('--use-binaries', action='store_true',
                default=False,
                help=_('use binaries from the repo before building')),
            ArgparseArgument('--upload-binaries', action='store_true',
                default=False,
                help=_('after a recipe is built upload the corresponding binary package')),
            ArgparseArgument('--build-missing', action='store_true',
                default=False,
                help=_('in case a binary package is missing try to build it')),
            ArgparseArgument('--assume-yes', action='store_true',
                default=False, help=_('In case of a question, assume yes')),
            ArgparseArgument('--non-interactive', action='store_true',
                default=False, help=_('Run in a non-interactive way')),
            ]
        Command.__init__(self, args)

    def run(self, config, args):
        bootstrapers = Bootstraper(config, args.build_tools_only,
                args.use_binaries, args.upload_binaries, args.build_missing,
                args.assume_yes, args.non_interactive)
        for bootstraper in bootstrapers:
            bootstraper.start()

register_command(Bootstrap)
示例#32
0
class GenLibraryFiles(Command):
    doc = N_('Generate MSVC compatible library files (.lib)')
    name = 'genlibfiles'

    def __init__(self):
        Command.__init__(self,
            [ArgparseArgument('-o', '--output_dir', default=None,
                help=_('output directory where .lib files will be saved')),
            ])

    def run(self, config, args):
        if config.target_platform != Platform.WINDOWS:
            raise UsageError(_('%s command can only be used targetting '
                             'Windows platforms') % self.name)

        if args.output_dir is not None and not os.path.exists(args.output_dir):
            os.makedirs(args.output_dir)

        cookbook = CookBook(config)
        recipes = cookbook.get_recipes_list()
        for recipe in recipes:
            try:
                recipe.gen_library_file(args.output_dir)
            except Exception, e:
                m.message(_("Error generaring library files for %s:\n %s") %
                          (recipe.name, e))


register_command(GenLibraryFiles)
示例#33
0
文件: fetch.py 项目: AlertMe/cerbero
                    default=False, help=_('do not fetch dependencies')),
                ]
        Fetch.__init__(self, args)

    def run(self, config, args):
        cookbook = CookBook(config)
        return self.fetch(cookbook, args.recipes, args.no_deps,
                          args.reset_rdeps, args.full_reset)


class FetchPackage(Fetch):
    doc = N_('Fetch the recipes sources from a package')
    name = 'fetch-package'

    def __init__(self):
        args = [
                ArgparseArgument('package', nargs=1,
                    help=_('package to fetch')),
                ]
        Fetch.__init__(self, args)

    def run(self, config, args):
        store = PackagesStore(config)
        package = store.get_package(args.package[0])
        return self.fetch(store.cookbook, package.recipes_dependencies(),
                          True, args.reset_rdeps, args.full_reset)


register_command(FetchRecipes)
register_command(FetchPackage)
示例#34
0
        recipe = cookbook.get_recipe(recipe_name)

        if recursive:
            ordered_recipes = cookbook.list_recipe_deps(recipe_name)
        else:
            ordered_recipes = [recipe]

        for recipe in ordered_recipes:
            if cookbook.recipe_needs_build(recipe.name):
                raise FatalError(_("Recipe %s is not built yet" % recipe.name))

        for recipe in ordered_recipes:
            # call step function
            stepfunc = None
            try:
                stepfunc = getattr(recipe, 'check')
            except:
                m.message('%s has no check step, skipped' % recipe.name)

            if stepfunc:
                try:
                    stepfunc()
                except FatalError as e:
                    raise e
                except Exception as ex:
                    raise FatalError(_("Error running %s checks: %s") %
                        (recipe.name, ex))

register_command(Check)
示例#35
0
        if args.only_build_deps:
            return

        if p is None:
            raise PackageNotFoundError(args.package[0])
        if args.tarball:
            pkg = DistTarball(config, p, self.store)
        else:
            pkg = Packager(config, p, self.store)
        m.action(_("Creating package for %s") % p.name)
        if args.tarball:
            paths = pkg.pack(os.path.abspath(args.output_dir), args.no_devel,
                             args.force, args.keep_temp, split=not args.no_split)
        else:
            paths = pkg.pack(os.path.abspath(args.output_dir), args.no_devel,
                             args.force, args.keep_temp)
        if None in paths:
            paths.remove(None)
        p.post_install(paths)
        m.action(_("Package successfully created in %s") %
                 ' '.join([os.path.abspath(x) for x in paths]))

    def _build_deps(self, config, package, has_devel):
        build_command = build.Build()
        build_command.runargs(config, package.recipes_dependencies(has_devel),
            cookbook=self.store.cookbook)


register_command(Package)
示例#36
0
# Free Software Foundation, Inc., 59 Temple Place - Suite 330,
# Boston, MA 02111-1307, USA.

import os
import subprocess

from cerbero.config import Platform
from cerbero.commands import Command, register_command
from cerbero.utils import N_


class Shell(Command):
    doc = N_('Starts a shell with the build environment')
    name = 'shell'

    def __init__(self):
        Command.__init__(self, [])

    def run(self, config, args):
        if config.platform == Platform.WINDOWS:
            # $MINGW_PREFIX/home/username
            msys = os.path.join(os.path.expanduser('~'), '..', '..',
                                'msys.bat')
            subprocess.check_call('%s -noxvrt' % msys)
        else:
            shell = os.environ.get('SHELL', '/bin/bash')
            os.execlp(shell, shell)


register_command(Shell)