Gentoo Logo
Gentoo Spaceship




Note: Due to technical difficulties, the Archives are currently not up to date. GMANE provides an alternative service for most mailing lists.
c.f. bug 424647
List Archive: gentoo-commits
Navigation:
Lists: gentoo-commits: < Prev By Thread Next > < Prev By Date Next >
Headers:
To: gentoo-commits@g.o
From: "Zac Medico (zmedico)" <zmedico@g.o>
Subject: portage r11453 - main/trunk/bin
Date: Fri, 22 Aug 2008 23:53:23 +0000
Author: zmedico
Date: 2008-08-22 23:53:22 +0000 (Fri, 22 Aug 2008)
New Revision: 11453

Modified:
   main/trunk/bin/portageq
Log:
Add a new is_protected command which queries whether or not CONFIG_PROTECT
applies to a given file, using logic identical to the merge code.


Modified: main/trunk/bin/portageq
===================================================================
--- main/trunk/bin/portageq	2008-08-22 23:30:13 UTC (rev 11452)
+++ main/trunk/bin/portageq	2008-08-22 23:53:22 UTC (rev 11453)
@@ -214,6 +214,53 @@
 
 owners.uses_root = True
 
+def is_protected(argv):
+	"""<root> <filename>
+	Given a single filename, return code 0 if it's protected, 1 otherwise.
+	The filename must begin with <root>.
+	"""
+	if len(argv) != 2:
+		sys.stderr.write("ERROR: expeced 2 parameters, got %d!\n" % len(argv))
+		sys.stderr.flush()
+		return 2
+
+	root, filename = argv
+
+	err = sys.stderr
+	cwd = None
+	try:
+		cwd = os.getcwd()
+	except OSError:
+		pass
+
+	f = portage.normalize_path(filename)
+	if not f.startswith(os.path.sep):
+		if cwd is None:
+			err.write("ERROR: cwd does not exist!\n")
+			err.flush()
+			return 2
+		f = os.path.join(cwd, f)
+		f = portage.normalize_path(f)
+
+	if not f.startswith(root):
+		err.write("ERROR: file paths must begin with <root>!\n")
+		err.flush()
+		return 2
+
+	import shlex
+	from portage.util import ConfigProtect
+
+	settings = portage.settings
+	protect = shlex.split(settings.get("CONFIG_PROTECT", ""))
+	protect_mask = shlex.split(settings.get("CONFIG_PROTECT_MASK", ""))
+	protect_obj = ConfigProtect(root, protect, protect_mask)
+
+	if protect_obj.isprotected(f):
+		return 0
+	return 1
+
+is_protected.uses_root = True
+
 def best_visible(argv):
 	"""<root> [<category/package>]+
 	Returns category/package-version (without .ebuild).



Navigation:
Lists: gentoo-commits: < Prev By Thread Next > < Prev By Date Next >
Previous by thread:
gentoo-x86 commit in net-im/twinkle/files: twinkle-1.3-gcc4.3.patch
Next by thread:
gentoo-x86 commit in app-emulation/kvm: ChangeLog metadata.xml kvm-73.ebuild
Previous by date:
gentoo-x86 commit in dev-util/qmtest: qmtest-2.4.ebuild ChangeLog
Next by date:
gentoo-x86 commit in app-emulation/kvm: ChangeLog metadata.xml kvm-73.ebuild


Updated Nov 01, 2010

Summary: Archive of the gentoo-commits mailing list.

Donate to support our development efforts.

Copyright 2001-2013 Gentoo Foundation, Inc. Questions, Comments? Contact us.