当前位置: 首页>>代码示例>>Python>>正文


Python config.config函数代码示例

本文整理汇总了Python中portage.package.ebuild.config.config函数的典型用法代码示例。如果您正苦于以下问题:Python config函数的具体用法?Python config怎么用?Python config使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了config函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: testFeaturesMutation

	def testFeaturesMutation(self):
		"""
		Test whether mutation of config.features updates the FEATURES
		variable and persists through config.regenerate() calls.
		"""
		playground = ResolverPlayground()
		try:
			settings = config(clone=playground.settings)

			settings.features.add('noclean')
			self.assertEqual('noclean' in settings['FEATURES'].split(), True)
			settings.regenerate()
			self.assertEqual('noclean' in settings['FEATURES'].split(),True)

			settings.features.discard('noclean')
			self.assertEqual('noclean' in settings['FEATURES'].split(), False)
			settings.regenerate()
			self.assertEqual('noclean' in settings['FEATURES'].split(), False)

			settings.features.add('noclean')
			self.assertEqual('noclean' in settings['FEATURES'].split(), True)
			settings.regenerate()
			self.assertEqual('noclean' in settings['FEATURES'].split(),True)
		finally:
			playground.cleanup()
开发者ID:Neuvoo,项目名称:legacy-portage,代码行数:25,代码来源:test_config.py

示例2: _load_config

	def _load_config(self):
		env = {
			"ACCEPT_KEYWORDS": "x86",
			"PORTDIR": self.portdir,
			'PORTAGE_TMPDIR'       : os.path.join(self.eroot, 'var/tmp'),
		}

		# Pass along PORTAGE_USERNAME and PORTAGE_GRPNAME since they
		# need to be inherited by ebuild subprocesses.
		if 'PORTAGE_USERNAME' in os.environ:
			env['PORTAGE_USERNAME'] = os.environ['PORTAGE_USERNAME']
		if 'PORTAGE_GRPNAME' in os.environ:
			env['PORTAGE_GRPNAME'] = os.environ['PORTAGE_GRPNAME']

		settings = config(_eprefix=self.eprefix, env=env)
		settings.lock()

		trees = {
			self.root: {
					"vartree": vartree(settings=settings),
					"porttree": portagetree(self.root, settings=settings),
					"bintree": binarytree(self.root,
						os.path.join(self.eroot, "usr/portage/packages"),
						settings=settings)
				}
			}

		for root, root_trees in trees.items():
			settings = root_trees["vartree"].settings
			settings._init_dirs()
			setconfig = load_default_config(settings, root_trees)
			root_trees["root_config"] = RootConfig(settings, root_trees, setconfig)
		
		return settings, trees
开发者ID:Neuvoo,项目名称:legacy-portage,代码行数:34,代码来源:ResolverPlayground.py

示例3: testSetCpv

	def testSetCpv(self):
		"""
		Test the clone via constructor.
		"""

		ebuilds = {
			"dev-libs/A-1": {"IUSE": "static-libs"},
			"dev-libs/B-1": {"IUSE": "static-libs"},
		}

		env_files = {
			"A" : ("USE=\"static-libs\"",)
		}

		package_env = (
			"dev-libs/A A",
		)

		eprefix = normalize_path(tempfile.mkdtemp())
		playground = None
		try:
			user_config_dir = os.path.join(eprefix, USER_CONFIG_PATH)
			os.makedirs(user_config_dir)

			with io.open(os.path.join(user_config_dir, "package.env"),
				mode='w', encoding=_encodings['content']) as f:
				for line in package_env:
					f.write(line + "\n")

			env_dir = os.path.join(user_config_dir, "env")
			os.makedirs(env_dir)
			for k, v in env_files.items():
				with io.open(os.path.join(env_dir, k), mode='w',
					encoding=_encodings['content']) as f:
					for line in v:
						f.write(line + "\n")

			playground = ResolverPlayground(eprefix=eprefix, ebuilds=ebuilds)
			settings = config(clone=playground.settings)

			result = playground.run(["=dev-libs/A-1"])
			pkg, existing_node = result.depgraph._select_package(
				playground.eroot, Atom("=dev-libs/A-1"))
			settings.setcpv(pkg)
			self.assertTrue("static-libs" in
				settings["PORTAGE_USE"].split())

			# Test bug #522362, where a USE=static-libs package.env
			# setting leaked from one setcpv call to the next.
			pkg, existing_node = result.depgraph._select_package(
				playground.eroot, Atom("=dev-libs/B-1"))
			settings.setcpv(pkg)
			self.assertTrue("static-libs" not in
				settings["PORTAGE_USE"].split())

		finally:
			if playground is None:
				shutil.rmtree(eprefix)
			else:
				playground.cleanup()
开发者ID:gentoo,项目名称:portage,代码行数:60,代码来源:test_config.py

示例4: getmaskingstatus

def getmaskingstatus(mycpv, settings=None, portdb=None, myrepo=None):
	if settings is None:
		settings = config(clone=portage.settings)
	if portdb is None:
		portdb = portage.portdb

	return [mreason.message for \
		mreason in _getmaskingstatus(mycpv, settings, portdb,myrepo)]
开发者ID:Spencerx,项目名称:portage,代码行数:8,代码来源:getmaskingstatus.py

示例5: testFakedbapi

	def testFakedbapi(self):
		packages = (
			("sys-apps/portage-2.1.10", {
				"EAPI"         : "2",
				"IUSE"         : "ipc doc",
				"repository"   : "gentoo",
				"SLOT"         : "0",
				"USE"          : "ipc missing-iuse",
			}),
			("virtual/package-manager-0", {
				"EAPI"         : "0",
				"repository"   : "gentoo",
				"SLOT"         : "0",
			}),
		)

		match_tests = (
			("sys-apps/portage:0[ipc]",             ["sys-apps/portage-2.1.10"]),
			("sys-apps/portage:0[-ipc]",            []),
			("sys-apps/portage:0[doc]",             []),
			("sys-apps/portage:0[-doc]",            ["sys-apps/portage-2.1.10"]),
			("sys-apps/portage:0",                  ["sys-apps/portage-2.1.10"]),
			("sys-apps/portage:0[missing-iuse]",    []),
			("sys-apps/portage:0[-missing-iuse]",   []),
			("sys-apps/portage:0::gentoo[ipc]",     ["sys-apps/portage-2.1.10"]),
			("sys-apps/portage:0::multilib[ipc]",   []),
			("virtual/package-manager",             ["virtual/package-manager-0"]),
		)

		tempdir = tempfile.mkdtemp()
		try:
			test_repo = os.path.join(tempdir, "var", "repositories", "test_repo")
			os.makedirs(os.path.join(test_repo, "profiles"))
			with open(os.path.join(test_repo, "profiles", "repo_name"), "w") as f:
				f.write("test_repo")
			env = {
				"PORTAGE_REPOSITORIES": "[DEFAULT]\nmain-repo = test_repo\n[test_repo]\nlocation = %s" % test_repo
			}

			# Tests may override portage.const.EPREFIX in order to
			# simulate a prefix installation. It's reasonable to do
			# this because tests should be self-contained such that
			# the "real" value of portage.const.EPREFIX is entirely
			# irrelevant (see bug #492932).
			portage.const.EPREFIX = tempdir

			fakedb = fakedbapi(settings=config(config_profile_path="",
				env=env, eprefix=tempdir))
			for cpv, metadata in packages:
				fakedb.cpv_inject(cpv, metadata=metadata)

			for atom, expected_result in match_tests:
				result = fakedb.match(atom)
				self.assertEqual(fakedb.match(atom), expected_result,
					"fakedb.match('%s') = %s != %s" %
					(atom, result, expected_result))
		finally:
			shutil.rmtree(tempdir)
开发者ID:aeroniero33,项目名称:portage,代码行数:58,代码来源:test_fakedbapi.py

示例6: testDoebuildSpawn

	def testDoebuildSpawn(self):
		playground = ResolverPlayground()
		try:
			settings = config(clone=playground.settings)
			cpv = 'sys-apps/portage-2.1'
			metadata = {
				'EAPI'      : '2',
				'INHERITED' : 'python eutils',
				'IUSE'      : 'build doc epydoc python3 selinux',
				'LICENSE'   : 'GPL-2',
				'PROVIDE'   : 'virtual/portage',
				'RDEPEND'   : '>=app-shells/bash-3.2_p17 >=dev-lang/python-2.6',
				'SLOT'      : '0',
			}
			root_config = playground.trees[playground.eroot]['root_config']
			pkg = Package(built=False, cpv=cpv, installed=False,
				metadata=metadata, root_config=root_config,
				type_name='ebuild')
			settings.setcpv(pkg)
			settings['PORTAGE_PYTHON'] = _python_interpreter
			settings['PORTAGE_BUILDDIR'] = os.path.join(
				settings['PORTAGE_TMPDIR'], cpv)
			settings['T'] = os.path.join(
				settings['PORTAGE_BUILDDIR'], 'temp')
			for x in ('PORTAGE_BUILDDIR', 'T'):
				os.makedirs(settings[x])
			# Create a fake environment, to pretend as if the ebuild
			# has been sourced already.
			open(os.path.join(settings['T'], 'environment'), 'wb').close()

			scheduler = PollScheduler().sched_iface
			for phase in ('_internal_test',):

				# Test EbuildSpawnProcess by calling doebuild.spawn() with
				# returnpid=False. This case is no longer used by portage
				# internals since EbuildPhase is used instead and that passes
				# returnpid=True to doebuild.spawn().
				rval = doebuild_spawn("%s %s" % (_shell_quote(
					os.path.join(settings["PORTAGE_BIN_PATH"],
					os.path.basename(EBUILD_SH_BINARY))), phase),
					settings, free=1)
				self.assertEqual(rval, os.EX_OK)

				ebuild_phase = EbuildPhase(background=False,
					phase=phase, scheduler=scheduler,
					settings=settings)
				ebuild_phase.start()
				ebuild_phase.wait()
				self.assertEqual(ebuild_phase.returncode, os.EX_OK)

			ebuild_phase = MiscFunctionsProcess(background=False,
				commands=['success_hooks'],
				scheduler=scheduler, settings=settings)
			ebuild_phase.start()
			ebuild_phase.wait()
			self.assertEqual(ebuild_phase.returncode, os.EX_OK)
		finally:
			playground.cleanup()
开发者ID:Acidburn0zzz,项目名称:portage-funtoo,代码行数:58,代码来源:test_doebuild_spawn.py

示例7: testClone

    def testClone(self):
        """
		Test the clone via constructor.
		"""

        ebuilds = {"dev-libs/A-1": {}}

        playground = ResolverPlayground(ebuilds=ebuilds)
        try:
            settings = config(clone=playground.settings)
            result = playground.run(["=dev-libs/A-1"])
            pkg, existing_node = result.depgraph._select_package(playground.eroot, "=dev-libs/A-1")
            settings.setcpv(pkg)

            # clone after setcpv tests deepcopy of LazyItemsDict
            settings2 = config(clone=settings)
        finally:
            playground.cleanup()
开发者ID:sysrqb,项目名称:portage-funtoo,代码行数:18,代码来源:test_config.py

示例8: _create_ebuild_manifests

	def _create_ebuild_manifests(self, ebuilds):
		for cpv in ebuilds:
			a = Atom("=" + cpv)
			ebuild_dir = os.path.join(self.portdir, a.cp)
			ebuild_path = os.path.join(ebuild_dir, a.cpv.split("/")[1] + ".ebuild")

			portage.util.noiselimit = -1
			tmpsettings = config(clone=self.settings)
			portdb = self.trees[self.root]["porttree"].dbapi
			portage.doebuild(ebuild_path, "digest", self.root, tmpsettings,
				tree="porttree", mydbapi=portdb)
			portage.util.noiselimit = 0
开发者ID:Neuvoo,项目名称:legacy-portage,代码行数:12,代码来源:ResolverPlayground.py

示例9: _start

	def _start(self):
		settings = self.settings
		if settings is None:
			settings = self.portdb.settings

		if 'PORTAGE_PARALLEL_FETCHONLY' in settings:
			# parallel-fetch mode
			self.returncode = os.EX_OK
			self._async_wait()
			return

		# Prevent temporary config changes from interfering
		# with config instances that are reused.
		settings = self.settings = config(clone=settings)

		# We must create our private PORTAGE_TMPDIR before calling
		# doebuild_environment(), since lots of variables such
		# as PORTAGE_BUILDDIR refer to paths inside PORTAGE_TMPDIR.
		portage_tmpdir = settings.get('PORTAGE_TMPDIR')
		if not portage_tmpdir or not os.access(portage_tmpdir, os.W_OK):
			portage_tmpdir = None
		private_tmpdir = self._private_tmpdir = tempfile.mkdtemp(
			dir=portage_tmpdir)
		settings['PORTAGE_TMPDIR'] = private_tmpdir
		settings.backup_changes('PORTAGE_TMPDIR')
		# private temp dir was just created, so it's not locked yet
		settings.pop('PORTAGE_BUILDDIR_LOCKED', None)

		doebuild_environment(self.ebuild_path, 'nofetch',
			settings=settings, db=self.portdb)
		restrict = settings['PORTAGE_RESTRICT'].split()
		defined_phases = settings['DEFINED_PHASES'].split()
		if not defined_phases:
			# When DEFINED_PHASES is undefined, assume all
			# phases are defined.
			defined_phases = EBUILD_PHASES

		if 'fetch' not in restrict and \
			'nofetch' not in defined_phases:
			self.returncode = os.EX_OK
			self._async_wait()
			return

		prepare_build_dirs(settings=settings)

		ebuild_phase = EbuildPhase(background=self.background,
			phase='nofetch',
			scheduler=self.scheduler,
			fd_pipes=self.fd_pipes, settings=settings)

		self._start_task(ebuild_phase, self._nofetch_exit)
开发者ID:gentoo,项目名称:portage,代码行数:51,代码来源:_spawn_nofetch.py

示例10: testFakedbapi

	def testFakedbapi(self):
		packages = (
			("sys-apps/portage-2.1.10", {
				"EAPI"         : "2",
				"IUSE"         : "ipc doc",
				"repository"   : "gentoo",
				"SLOT"         : "0",
				"USE"          : "ipc missing-iuse",
			}),
			("virtual/package-manager-0", {
				"EAPI"         : "0",
				"repository"   : "gentoo",
				"SLOT"         : "0",
			}),
		)

		match_tests = (
			("sys-apps/portage:0[ipc]",             ["sys-apps/portage-2.1.10"]),
			("sys-apps/portage:0[-ipc]",            []),
			("sys-apps/portage:0[doc]",             []),
			("sys-apps/portage:0[-doc]",            ["sys-apps/portage-2.1.10"]),
			("sys-apps/portage:0",                  ["sys-apps/portage-2.1.10"]),
			("sys-apps/portage:0[missing-iuse]",    []),
			("sys-apps/portage:0[-missing-iuse]",   []),
			("sys-apps/portage:0::gentoo[ipc]",     ["sys-apps/portage-2.1.10"]),
			("sys-apps/portage:0::multilib[ipc]",   []),
			("virtual/package-manager",             ["virtual/package-manager-0"]),
		)

		tempdir = tempfile.mkdtemp()
		try:
			portdir = os.path.join(tempdir, "usr/portage")
			os.makedirs(portdir)
			env = {
				"PORTDIR": portdir,
			}
			fakedb = fakedbapi(settings=config(config_profile_path="",
				env=env, eprefix=tempdir))
			for cpv, metadata in packages:
				fakedb.cpv_inject(cpv, metadata=metadata)

			for atom, expected_result in match_tests:
				result = fakedb.match(atom)
				self.assertEqual(fakedb.match(atom), expected_result,
					"fakedb.match('%s') = %s != %s" %
					(atom, result, expected_result))
		finally:
			shutil.rmtree(tempdir)
开发者ID:clickbeetle,项目名称:portage-cb,代码行数:48,代码来源:test_fakedbapi.py

示例11: testHookDirectory

    def testHookDirectory(self):
        """
		Tests to be sure a hook loads and reads the right settings
		Based on test_PackageKeywordsFile.py
		"""

        self.tmp_dir_path = self.BuildTmp("/etc/portage/hooks/test.d")
        try:
            settings = config()
            settings["PORTAGE_CONFIGROOT"] = self.tmp_dir_path
            settings["FEATURES"] += " hooks"
            hooks = HookDirectory(phase="test", settings=settings)
            hooks.execute()
            self.assert_(settings["hookonlytest"] == "")
        finally:
            rmtree(self.tmp_dir_path)
开发者ID:Neuvoo,项目名称:legacy-portage,代码行数:16,代码来源:test_HookDirectory.py

示例12: env_update

def env_update(makelinks=1, target_root=None, prev_mtimes=None, contents=None,
	env=None, writemsg_level=None, vardbapi=None):
	"""
	Parse /etc/env.d and use it to generate /etc/profile.env, csh.env,
	ld.so.conf, and prelink.conf. Finally, run ldconfig. When ldconfig is
	called, its -X option will be used in order to avoid potential
	interference with installed soname symlinks that are required for
	correct operation of FEATURES=preserve-libs for downgrade operations.
	It's not necessary for ldconfig to create soname symlinks, since
	portage will use NEEDED.ELF.2 data to automatically create them
	after src_install if they happen to be missing.
	@param makelinks: True if ldconfig should be called, False otherwise
	@param target_root: root that is passed to the ldconfig -r option,
		defaults to portage.settings["ROOT"].
	@type target_root: String (Path)
	"""
	if vardbapi is None:
		if isinstance(env, config):
			vardbapi = vartree(settings=env).dbapi
		else:
			if target_root is None:
				eprefix = portage.settings["EPREFIX"]
				target_root = portage.settings["ROOT"]
				target_eroot = portage.settings['EROOT']
			else:
				eprefix = portage.const.EPREFIX
				target_eroot = os.path.join(target_root,
					eprefix.lstrip(os.sep))
				target_eroot = target_eroot.rstrip(os.sep) + os.sep
			if hasattr(portage, "db") and target_eroot in portage.db:
				vardbapi = portage.db[target_eroot]["vartree"].dbapi
			else:
				settings = config(config_root=target_root,
					target_root=target_root, eprefix=eprefix)
				target_root = settings["ROOT"]
				if env is None:
					env = settings
				vardbapi = vartree(settings=settings).dbapi

	# Lock the config memory file to prevent symlink creation
	# in merge_contents from overlapping with env-update.
	vardbapi._fs_lock()
	try:
		return _env_update(makelinks, target_root, prev_mtimes, contents,
			env, writemsg_level)
	finally:
		vardbapi._fs_unlock()
开发者ID:zy-sunshine,项目名称:easymgc,代码行数:47,代码来源:env_update.py

示例13: _create_ebuild_manifests

	def _create_ebuild_manifests(self, ebuilds):
		tmpsettings = config(clone=self.settings)
		tmpsettings['PORTAGE_QUIET'] = '1'
		for cpv in ebuilds:
			a = Atom("=" + cpv, allow_repo=True)
			repo = a.repo
			if repo is None:
				repo = "test_repo"

			repo_dir = self._get_repo_dir(repo)
			ebuild_dir = os.path.join(repo_dir, a.cp)
			ebuild_path = os.path.join(ebuild_dir, a.cpv.split("/")[1] + ".ebuild")

			portdb = self.trees[self.eroot]["porttree"].dbapi
			tmpsettings['O'] = ebuild_dir
			if not digestgen(mysettings=tmpsettings, myportdb=portdb):
				raise AssertionError('digest creation failed for %s' % ebuild_path)
开发者ID:zy-sunshine,项目名称:easymgc,代码行数:17,代码来源:ResolverPlayground.py

示例14: __init__

   def __init__(self, root = None, portage_arch = None):
      """Constructor.

      str root
         Portage root directory; defaults to Portage’s ${ROOT}.
      str portage_arch
         Portage architecture; defaults to Portage’s ${ARCH}.
      """

      if root:
         # Set this now to override Portage’s default root.
         os.environ['ROOT'] = root
      self._category = None # Set by make_package_name()
      self._portage_config = portage_config.config()
      if not root:
         # Set this now to override the null root with Portage’s default root.
         os.environ['ROOT'] = root = self._portage_config['ROOT']
      self._cross_compiler_prefix = None
      self._dev_null = open(os.devnull, 'w')
      self._ebuild_file_path = None
      self._ebuild_pkg_root = None
      self._indent = ''
      self._irf_compressor = None
      self._irf_archive_path = None
      self._irf_source_path = None
      self._kernel_release = None # Set by set_sources()
      self._kernel_version = None # Set by set_sources()
      self._kmake_args = ['make']
      self._kmake_args.extend(shlex.split(self._portage_config['MAKEOPTS']))
      self._kmake_env = dict(os.environ)
      if not portage_arch:
         portage_arch = self._portage_config['ARCH']
      self._kmake_env['ARCH'] = self._portage_arch_to_kernel_arch.get(
         portage_arch, portage_arch
      )
      self._module_packages = None # Set by build_kernel()
      self._package_name = None # Set by make_package_name()
      self._package_version = None # Set by make_package_name()
      self._root = root
      self._source_path = None
      self._src_config_path = None
      self._src_image_path = None
开发者ID:raffaellod,项目名称:kernel-tools,代码行数:42,代码来源:Generator.py

示例15: testFakedbapi

    def testFakedbapi(self):
        packages = (
            (
                "sys-apps/portage-2.1.10",
                {"EAPI": "2", "IUSE": "ipc doc", "repository": "gentoo", "SLOT": "0", "USE": "ipc missing-iuse"},
            ),
            ("virtual/package-manager-0", {"EAPI": "0", "repository": "gentoo", "SLOT": "0"}),
        )

        match_tests = (
            ("sys-apps/portage:0[ipc]", ["sys-apps/portage-2.1.10"]),
            ("sys-apps/portage:0[-ipc]", []),
            ("sys-apps/portage:0[doc]", []),
            ("sys-apps/portage:0[-doc]", ["sys-apps/portage-2.1.10"]),
            ("sys-apps/portage:0", ["sys-apps/portage-2.1.10"]),
            ("sys-apps/portage:0[missing-iuse]", []),
            ("sys-apps/portage:0[-missing-iuse]", []),
            ("sys-apps/portage:0::gentoo[ipc]", ["sys-apps/portage-2.1.10"]),
            ("sys-apps/portage:0::multilib[ipc]", []),
            ("virtual/package-manager", ["virtual/package-manager-0"]),
        )

        tempdir = tempfile.mkdtemp()
        try:
            test_repo = os.path.join(tempdir, "var", "repositories", "test_repo")
            os.makedirs(os.path.join(test_repo, "profiles"))
            with open(os.path.join(test_repo, "profiles", "repo_name"), "w") as f:
                f.write("test_repo")
            env = {"PORTAGE_REPOSITORIES": "[DEFAULT]\nmain-repo = test_repo\n[test_repo]\nlocation = %s" % test_repo}
            fakedb = fakedbapi(settings=config(config_profile_path="", env=env, eprefix=tempdir))
            for cpv, metadata in packages:
                fakedb.cpv_inject(cpv, metadata=metadata)

            for atom, expected_result in match_tests:
                result = fakedb.match(atom)
                self.assertEqual(
                    fakedb.match(atom),
                    expected_result,
                    "fakedb.match('%s') = %s != %s" % (atom, result, expected_result),
                )
        finally:
            shutil.rmtree(tempdir)
开发者ID:nullishzero,项目名称:portage-1,代码行数:42,代码来源:test_fakedbapi.py


注:本文中的portage.package.ebuild.config.config函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。