* [gentoo-commits] proj/portage:master commit in: pym/portage/tests/emerge/, pym/portage/package/ebuild/_config/, bin/, ...
@ 2011-12-10 6:32 Zac Medico
0 siblings, 0 replies; 3+ messages in thread
From: Zac Medico @ 2011-12-10 6:32 UTC (permalink / raw
To: gentoo-commits
commit: ce1e80852ace9779a1bb70d16465b7fd73e705b4
Author: Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Sat Dec 10 06:32:44 2011 +0000
Commit: Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Sat Dec 10 06:32:44 2011 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=ce1e8085
Rename override var to PORTAGE_OVERRIDE_EPREFIX.
---
bin/phase-functions.sh | 2 +-
pym/portage/const.py | 4 ++--
.../package/ebuild/_config/special_env_vars.py | 2 +-
pym/portage/tests/emerge/test_simple.py | 2 +-
pym/portage/tests/repoman/test_simple.py | 2 +-
5 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/bin/phase-functions.sh b/bin/phase-functions.sh
index 482b5b1..f862b30 100644
--- a/bin/phase-functions.sh
+++ b/bin/phase-functions.sh
@@ -28,7 +28,7 @@ PORTAGE_READONLY_VARS="D EBUILD EBUILD_PHASE \
PORTAGE_TMPDIR PORTAGE_UPDATE_ENV PORTAGE_USERNAME \
PORTAGE_VERBOSE PORTAGE_WORKDIR_MODE PORTDIR PORTDIR_OVERLAY \
PROFILE_PATHS REPLACING_VERSIONS REPLACED_BY_VERSION T WORKDIR \
- __PORTAGE_TEST_EPREFIX"
+ PORTAGE_OVERRIDE_EPREFIX"
PORTAGE_SAVED_READONLY_VARS="A CATEGORY P PF PN PR PV PVR"
diff --git a/pym/portage/const.py b/pym/portage/const.py
index 553dfc5..a32933c 100644
--- a/pym/portage/const.py
+++ b/pym/portage/const.py
@@ -149,8 +149,8 @@ MANIFEST2_IDENTIFIERS = ("AUX", "MISC", "DIST", "EBUILD")
EPREFIX=""
# pick up EPREFIX from the environment if set
-if "__PORTAGE_TEST_EPREFIX" in os.environ:
- EPREFIX = os.environ["__PORTAGE_TEST_EPREFIX"]
+if "PORTAGE_OVERRIDE_EPREFIX" in os.environ:
+ EPREFIX = os.environ["PORTAGE_OVERRIDE_EPREFIX"]
if EPREFIX:
EPREFIX = os.path.normpath(EPREFIX)
diff --git a/pym/portage/package/ebuild/_config/special_env_vars.py b/pym/portage/package/ebuild/_config/special_env_vars.py
index 9ac37fb..3911e97 100644
--- a/pym/portage/package/ebuild/_config/special_env_vars.py
+++ b/pym/portage/package/ebuild/_config/special_env_vars.py
@@ -66,7 +66,7 @@ environ_whitelist += [
"REPLACING_VERSIONS", "REPLACED_BY_VERSION",
"ROOT", "ROOTPATH", "T", "TMP", "TMPDIR",
"USE_EXPAND", "USE_ORDER", "WORKDIR",
- "XARGS", "__PORTAGE_TEST_EPREFIX",
+ "XARGS", "PORTAGE_OVERRIDE_EPREFIX",
]
# user config variables
diff --git a/pym/portage/tests/emerge/test_simple.py b/pym/portage/tests/emerge/test_simple.py
index 5f285c2..5177229 100644
--- a/pym/portage/tests/emerge/test_simple.py
+++ b/pym/portage/tests/emerge/test_simple.py
@@ -300,7 +300,7 @@ pkg_preinst() {
pythonpath = PORTAGE_PYM_PATH + pythonpath
env = {
- "__PORTAGE_TEST_EPREFIX" : eprefix,
+ "PORTAGE_OVERRIDE_EPREFIX" : eprefix,
"CLEAN_DELAY" : "0",
"DISTDIR" : distdir,
"EMERGE_WARNING_DELAY" : "0",
diff --git a/pym/portage/tests/repoman/test_simple.py b/pym/portage/tests/repoman/test_simple.py
index b3186d7..5f6d7fc 100644
--- a/pym/portage/tests/repoman/test_simple.py
+++ b/pym/portage/tests/repoman/test_simple.py
@@ -184,7 +184,7 @@ class SimpleRepomanTestCase(TestCase):
pythonpath = PORTAGE_PYM_PATH + pythonpath
env = {
- "__PORTAGE_TEST_EPREFIX" : eprefix,
+ "PORTAGE_OVERRIDE_EPREFIX" : eprefix,
"DISTDIR" : distdir,
"GENTOO_COMMITTER_NAME" : committer_name,
"GENTOO_COMMITTER_EMAIL" : committer_email,
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [gentoo-commits] proj/portage:master commit in: pym/portage/tests/emerge/, pym/portage/package/ebuild/_config/, bin/, ...
@ 2011-12-14 4:04 Zac Medico
0 siblings, 0 replies; 3+ messages in thread
From: Zac Medico @ 2011-12-14 4:04 UTC (permalink / raw
To: gentoo-commits
commit: 518d11aaf47af172231e97531803c1ed993d46f0
Author: Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Wed Dec 14 04:04:11 2011 +0000
Commit: Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Wed Dec 14 04:04:11 2011 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=518d11aa
ebuils-ipc.py: _exit in finally block after fork
---
bin/ebuild-ipc.py | 38 +++--
pym/portage/locks.py | 177 ++++++++++++++------
.../package/ebuild/_config/special_env_vars.py | 2 +-
pym/portage/tests/ebuild/test_doebuild_spawn.py | 5 +
pym/portage/tests/ebuild/test_ipc_daemon.py | 9 +
pym/portage/tests/emerge/test_simple.py | 4 +
pym/portage/tests/locks/test_asynchronous_lock.py | 48 +++++-
pym/portage/tests/locks/test_lock_nonblock.py | 12 ++-
8 files changed, 224 insertions(+), 71 deletions(-)
diff --git a/bin/ebuild-ipc.py b/bin/ebuild-ipc.py
index 68ad985..372585f 100755
--- a/bin/ebuild-ipc.py
+++ b/bin/ebuild-ipc.py
@@ -13,6 +13,7 @@ import select
import signal
import sys
import time
+import traceback
def debug_signal(signum, frame):
import pdb
@@ -228,14 +229,22 @@ class EbuildIpc(object):
pid = os.fork()
if pid == 0:
- os.close(pr)
-
- # File streams are in unbuffered mode since we do atomic
- # read and write of whole pickles.
- output_file = open(self.ipc_in_fifo, 'wb', 0)
- output_file.write(pickle.dumps(args))
- output_file.close()
- os._exit(os.EX_OK)
+ retval = 1
+ try:
+ os.close(pr)
+
+ # File streams are in unbuffered mode since we do atomic
+ # read and write of whole pickles.
+ output_file = open(self.ipc_in_fifo, 'wb', 0)
+ output_file.write(pickle.dumps(args))
+ output_file.close()
+ retval = os.EX_OK
+ except SystemExit:
+ raise
+ except:
+ traceback.print_exc()
+ finally:
+ os._exit(retval)
os.close(pw)
@@ -258,9 +267,16 @@ class EbuildIpc(object):
pid = os.fork()
if pid == 0:
- os.close(pr)
- retval = self._receive_reply(input_fd)
- os._exit(retval)
+ retval = 1
+ try:
+ os.close(pr)
+ retval = self._receive_reply(input_fd)
+ except SystemExit:
+ raise
+ except:
+ traceback.print_exc()
+ finally:
+ os._exit(retval)
os.close(pw)
retval = self._wait(pid, pr, portage.localization._('during read'))
diff --git a/pym/portage/locks.py b/pym/portage/locks.py
index 41539ba..0171dcf 100644
--- a/pym/portage/locks.py
+++ b/pym/portage/locks.py
@@ -9,13 +9,12 @@ __all__ = ["lockdir", "unlockdir", "lockfile", "unlockfile", \
import errno
import fcntl
import platform
-import stat
import sys
import time
+import warnings
import portage
from portage import os
-from portage.const import PORTAGE_BIN_PATH
from portage.exception import DirectoryNotFound, FileNotFound, \
InvalidData, TryAgain, OperationNotPermitted, PermissionDenied
from portage.data import portage_gid
@@ -26,6 +25,7 @@ if sys.hexversion >= 0x3000000:
basestring = str
HARDLINK_FD = -2
+_HARDLINK_POLL_LATENCY = 3 # seconds
_default_lock_fn = fcntl.lockf
if platform.python_implementation() == 'PyPy':
@@ -54,7 +54,9 @@ def lockfile(mypath, wantnewlockfile=0, unlinkfile=0,
if isinstance(mypath, basestring) and mypath[-1] == '/':
mypath = mypath[:-1]
+ lockfilename_path = mypath
if hasattr(mypath, 'fileno'):
+ lockfilename_path = getattr(mypath, 'name', None)
mypath = mypath.fileno()
if isinstance(mypath, int):
lockfilename = mypath
@@ -63,7 +65,7 @@ def lockfile(mypath, wantnewlockfile=0, unlinkfile=0,
elif wantnewlockfile:
base, tail = os.path.split(mypath)
lockfilename = os.path.join(base, "." + tail + ".portage_lockfile")
- del base, tail
+ lockfilename_path = lockfilename
unlinkfile = 1
else:
lockfilename = mypath
@@ -117,6 +119,8 @@ def lockfile(mypath, wantnewlockfile=0, unlinkfile=0,
# we're waiting on lockfile and use a blocking attempt.
locking_method = _default_lock_fn
try:
+ if "__PORTAGE_TEST_HARDLINK_LOCKS" in os.environ:
+ raise IOError(errno.ENOSYS, "Function not implemented")
locking_method(myfd, fcntl.LOCK_EX|fcntl.LOCK_NB)
except IOError as e:
if not hasattr(e, "errno"):
@@ -148,20 +152,20 @@ def lockfile(mypath, wantnewlockfile=0, unlinkfile=0,
raise
if out is not None:
out.eend(os.EX_OK)
- elif e.errno == errno.ENOLCK:
+ elif e.errno in (errno.ENOSYS, errno.ENOLCK):
# We're not allowed to lock on this FS.
- os.close(myfd)
- link_success = False
- if lockfilename == str(lockfilename):
- if wantnewlockfile:
- try:
- if os.stat(lockfilename)[stat.ST_NLINK] == 1:
- os.unlink(lockfilename)
- except OSError:
- pass
- link_success = hardlink_lockfile(lockfilename)
+ if not isinstance(lockfilename, int):
+ # If a file object was passed in, it's not safe
+ # to close the file descriptor because it may
+ # still be in use (for example, see emergelog).
+ os.close(myfd)
+ if not isinstance(lockfilename_path, basestring):
+ raise
+ link_success = hardlink_lockfile(lockfilename_path,
+ waiting_msg=waiting_msg, flags=flags)
if not link_success:
raise
+ lockfilename = lockfilename_path
locking_method = None
myfd = HARDLINK_FD
else:
@@ -208,7 +212,7 @@ def unlockfile(mytuple):
raise InvalidData
if(myfd == HARDLINK_FD):
- unhardlink_lockfile(lockfilename)
+ unhardlink_lockfile(lockfilename, unlinkfile=unlinkfile)
return True
# myfd may be None here due to myfd = mypath in lockfile()
@@ -273,61 +277,126 @@ def hardlock_name(path):
def hardlink_is_mine(link,lock):
try:
- return os.stat(link).st_nlink == 2
+ lock_st = os.stat(lock)
+ if lock_st.st_nlink == 2:
+ link_st = os.stat(link)
+ return lock_st.st_ino == link_st.st_ino and \
+ lock_st.st_dev == link_st.st_dev
except OSError:
return False
-def hardlink_lockfile(lockfilename, max_wait=14400):
+def hardlink_lockfile(lockfilename, max_wait=DeprecationWarning,
+ waiting_msg=None, flags=0):
"""Does the NFS, hardlink shuffle to ensure locking on the disk.
- We create a PRIVATE lockfile, that is just a placeholder on the disk.
- Then we HARDLINK the real lockfile to that private file.
+ We create a PRIVATE hardlink to the real lockfile, that is just a
+ placeholder on the disk.
If our file can 2 references, then we have the lock. :)
Otherwise we lather, rise, and repeat.
- We default to a 4 hour timeout.
"""
- start_time = time.time()
+ if max_wait is not DeprecationWarning:
+ warnings.warn("The 'max_wait' parameter of "
+ "portage.locks.hardlink_lockfile() is now unused. Use "
+ "flags=os.O_NONBLOCK instead.",
+ DeprecationWarning, stacklevel=2)
+
+ global _quiet
+ out = None
+ displayed_waiting_msg = False
myhardlock = hardlock_name(lockfilename)
- reported_waiting = False
-
- while(time.time() < (start_time + max_wait)):
- # We only need it to exist.
- myfd = os.open(myhardlock, os.O_CREAT|os.O_RDWR,0o660)
- os.close(myfd)
-
- if not os.path.exists(myhardlock):
- raise FileNotFound(
- _("Created lockfile is missing: %(filename)s") % \
- {"filename" : myhardlock})
- try:
- res = os.link(myhardlock, lockfilename)
- except OSError:
+ # myhardlock must not exist prior to our link() call, and we can
+ # can safely unlink it since its file name is unique to our PID
+ try:
+ os.unlink(myhardlock)
+ except OSError as e:
+ if e.errno in (errno.ENOENT, errno.ESTALE):
pass
+ else:
+ func_call = "unlink('%s')" % myhardlock
+ if e.errno == OperationNotPermitted.errno:
+ raise OperationNotPermitted(func_call)
+ elif e.errno == PermissionDenied.errno:
+ raise PermissionDenied(func_call)
+ else:
+ raise
+
+ while True:
+ # create lockfilename if it doesn't exist yet
+ try:
+ myfd = os.open(lockfilename, os.O_CREAT|os.O_RDWR, 0o660)
+ except OSError as e:
+ func_call = "open('%s')" % lockfilename
+ if e.errno == OperationNotPermitted.errno:
+ raise OperationNotPermitted(func_call)
+ elif e.errno == PermissionDenied.errno:
+ raise PermissionDenied(func_call)
+ else:
+ raise
+ else:
+ try:
+ if os.fstat(myfd).st_gid != portage_gid:
+ os.fchown(myfd, -1, portage_gid)
+ except OSError as e:
+ if e.errno not in (errno.ENOENT, errno.ESTALE):
+ writemsg("%s: fchown('%s', -1, %d)\n" % \
+ (e, lockfilename, portage_gid), noiselevel=-1)
+ writemsg(_("Cannot chown a lockfile: '%s'\n") % \
+ lockfilename, noiselevel=-1)
+ writemsg(_("Group IDs of current user: %s\n") % \
+ " ".join(str(n) for n in os.getgroups()),
+ noiselevel=-1)
+ finally:
+ os.close(myfd)
+
+ try:
+ os.link(lockfilename, myhardlock)
+ except OSError as e:
+ func_call = "link('%s', '%s')" % (lockfilename, myhardlock)
+ if e.errno == OperationNotPermitted.errno:
+ raise OperationNotPermitted(func_call)
+ elif e.errno == PermissionDenied.errno:
+ raise PermissionDenied(func_call)
+ elif e.errno in (errno.ESTALE, errno.ENOENT):
+ # another process has removed the file, so we'll have
+ # to create it again
+ continue
+ else:
+ raise
if hardlink_is_mine(myhardlock, lockfilename):
- # We have the lock.
- if reported_waiting:
- writemsg("\n", noiselevel=-1)
- return True
+ if out is not None:
+ out.eend(os.EX_OK)
+ break
- if reported_waiting:
- writemsg(".", noiselevel=-1)
- else:
- reported_waiting = True
- msg = _("\nWaiting on (hardlink) lockfile: (one '.' per 3 seconds)\n"
- "%(bin_path)s/clean_locks can fix stuck locks.\n"
- "Lockfile: %(lockfilename)s\n") % \
- {"bin_path": PORTAGE_BIN_PATH, "lockfilename": lockfilename}
- writemsg(msg, noiselevel=-1)
- time.sleep(3)
-
- os.unlink(myhardlock)
- return False
+ try:
+ os.unlink(myhardlock)
+ except OSError as e:
+ # This should not happen, since the file name of
+ # myhardlock is unique to our host and PID,
+ # and the above link() call succeeded.
+ if e.errno not in (errno.ENOENT, errno.ESTALE):
+ raise
+ raise FileNotFound(myhardlock)
+
+ if flags & os.O_NONBLOCK:
+ raise TryAgain(lockfilename)
+
+ if out is None and not _quiet:
+ out = portage.output.EOutput()
+ if out is not None and not displayed_waiting_msg:
+ displayed_waiting_msg = True
+ if waiting_msg is None:
+ waiting_msg = _("waiting for lock on %s\n") % lockfilename
+ out.ebegin(waiting_msg)
+
+ time.sleep(_HARDLINK_POLL_LATENCY)
+
+ return True
-def unhardlink_lockfile(lockfilename):
+def unhardlink_lockfile(lockfilename, unlinkfile=True):
myhardlock = hardlock_name(lockfilename)
- if hardlink_is_mine(myhardlock, lockfilename):
+ if unlinkfile and hardlink_is_mine(myhardlock, lockfilename):
# Make sure not to touch lockfilename unless we really have a lock.
try:
os.unlink(lockfilename)
diff --git a/pym/portage/package/ebuild/_config/special_env_vars.py b/pym/portage/package/ebuild/_config/special_env_vars.py
index 6b378b3..d6ee647 100644
--- a/pym/portage/package/ebuild/_config/special_env_vars.py
+++ b/pym/portage/package/ebuild/_config/special_env_vars.py
@@ -66,7 +66,7 @@ environ_whitelist += [
"REPLACING_VERSIONS", "REPLACED_BY_VERSION",
"ROOT", "ROOTPATH", "T", "TMP", "TMPDIR",
"USE_EXPAND", "USE_ORDER", "WORKDIR",
- "XARGS",
+ "XARGS", "__PORTAGE_TEST_HARDLINK_LOCKS",
]
# user config variables
diff --git a/pym/portage/tests/ebuild/test_doebuild_spawn.py b/pym/portage/tests/ebuild/test_doebuild_spawn.py
index daa6e75..89e27a3 100644
--- a/pym/portage/tests/ebuild/test_doebuild_spawn.py
+++ b/pym/portage/tests/ebuild/test_doebuild_spawn.py
@@ -26,6 +26,11 @@ class DoebuildSpawnTestCase(TestCase):
playground = ResolverPlayground()
try:
settings = config(clone=playground.settings)
+ if "__PORTAGE_TEST_HARDLINK_LOCKS" in os.environ:
+ settings["__PORTAGE_TEST_HARDLINK_LOCKS"] = \
+ os.environ["__PORTAGE_TEST_HARDLINK_LOCKS"]
+ settings.backup_changes("__PORTAGE_TEST_HARDLINK_LOCKS")
+
cpv = 'sys-apps/portage-2.1'
metadata = {
'EAPI' : '2',
diff --git a/pym/portage/tests/ebuild/test_ipc_daemon.py b/pym/portage/tests/ebuild/test_ipc_daemon.py
index 379953d..c638437 100644
--- a/pym/portage/tests/ebuild/test_ipc_daemon.py
+++ b/pym/portage/tests/ebuild/test_ipc_daemon.py
@@ -10,6 +10,7 @@ from portage.tests import TestCase
from portage.const import PORTAGE_BIN_PATH
from portage.const import PORTAGE_PYM_PATH
from portage.const import BASH_BINARY
+from portage.locks import hardlock_cleanup
from portage.package.ebuild._ipc.ExitCommand import ExitCommand
from portage.util import ensure_dirs
from _emerge.SpawnProcess import SpawnProcess
@@ -39,6 +40,10 @@ class IpcDaemonTestCase(TestCase):
env['PORTAGE_PYM_PATH'] = PORTAGE_PYM_PATH
env['PORTAGE_BUILDDIR'] = os.path.join(tmpdir, 'cat', 'pkg-1')
+ if "__PORTAGE_TEST_HARDLINK_LOCKS" in os.environ:
+ env["__PORTAGE_TEST_HARDLINK_LOCKS"] = \
+ os.environ["__PORTAGE_TEST_HARDLINK_LOCKS"]
+
task_scheduler = TaskScheduler(max_jobs=2)
build_dir = EbuildBuildDir(
scheduler=task_scheduler.sched_iface,
@@ -75,6 +80,8 @@ class IpcDaemonTestCase(TestCase):
start_time = time.time()
task_scheduler.run(timeout=self._SCHEDULE_TIMEOUT)
task_scheduler.clear()
+ hardlock_cleanup(env['PORTAGE_BUILDDIR'],
+ remove_all_locks=True)
self.assertEqual(self.received_command, True,
"command not received after %d seconds" % \
@@ -110,6 +117,8 @@ class IpcDaemonTestCase(TestCase):
start_time = time.time()
task_scheduler.run(timeout=short_timeout_ms)
task_scheduler.clear()
+ hardlock_cleanup(env['PORTAGE_BUILDDIR'],
+ remove_all_locks=True)
self.assertEqual(self.received_command, False,
"command received after %d seconds" % \
diff --git a/pym/portage/tests/emerge/test_simple.py b/pym/portage/tests/emerge/test_simple.py
index a3efa62..8691950 100644
--- a/pym/portage/tests/emerge/test_simple.py
+++ b/pym/portage/tests/emerge/test_simple.py
@@ -318,6 +318,10 @@ pkg_preinst() {
"PYTHONPATH" : pythonpath,
}
+ if "__PORTAGE_TEST_HARDLINK_LOCKS" in os.environ:
+ env["__PORTAGE_TEST_HARDLINK_LOCKS"] = \
+ os.environ["__PORTAGE_TEST_HARDLINK_LOCKS"]
+
updates_dir = os.path.join(portdir, "profiles", "updates")
dirs = [cachedir, cachedir_pregen, distdir, fake_bin,
portage_tmpdir, updates_dir,
diff --git a/pym/portage/tests/locks/test_asynchronous_lock.py b/pym/portage/tests/locks/test_asynchronous_lock.py
index 0d6f116..c896cb4 100644
--- a/pym/portage/tests/locks/test_asynchronous_lock.py
+++ b/pym/portage/tests/locks/test_asynchronous_lock.py
@@ -12,7 +12,7 @@ from _emerge.PollScheduler import PollScheduler
class AsynchronousLockTestCase(TestCase):
- def testAsynchronousLock(self):
+ def _testAsynchronousLock(self):
scheduler = PollScheduler().sched_iface
tempdir = tempfile.mkdtemp()
try:
@@ -39,7 +39,17 @@ class AsynchronousLockTestCase(TestCase):
finally:
shutil.rmtree(tempdir)
- def testAsynchronousLockWait(self):
+ def testAsynchronousLock(self):
+ self._testAsynchronousLock()
+
+ def testAsynchronousLockHardlink(self):
+ os.environ["__PORTAGE_TEST_HARDLINK_LOCKS"] = "1"
+ try:
+ self._testAsynchronousLock()
+ finally:
+ os.environ.pop("__PORTAGE_TEST_HARDLINK_LOCKS", None)
+
+ def _testAsynchronousLockWait(self):
scheduler = PollScheduler().sched_iface
tempdir = tempfile.mkdtemp()
try:
@@ -67,7 +77,17 @@ class AsynchronousLockTestCase(TestCase):
finally:
shutil.rmtree(tempdir)
- def testAsynchronousLockWaitCancel(self):
+ def testAsynchronousLockWait(self):
+ self._testAsynchronousLockWait()
+
+ def testAsynchronousLockWaitHardlink(self):
+ os.environ["__PORTAGE_TEST_HARDLINK_LOCKS"] = "1"
+ try:
+ self._testAsynchronousLockWait()
+ finally:
+ os.environ.pop("__PORTAGE_TEST_HARDLINK_LOCKS", None)
+
+ def _testAsynchronousLockWaitCancel(self):
scheduler = PollScheduler().sched_iface
tempdir = tempfile.mkdtemp()
try:
@@ -92,7 +112,17 @@ class AsynchronousLockTestCase(TestCase):
finally:
shutil.rmtree(tempdir)
- def testAsynchronousLockWaitKill(self):
+ def testAsynchronousLockWaitCancel(self):
+ self._testAsynchronousLockWaitCancel()
+
+ def testAsynchronousLockWaitCancelHardlink(self):
+ os.environ["__PORTAGE_TEST_HARDLINK_LOCKS"] = "1"
+ try:
+ self._testAsynchronousLockWaitCancel()
+ finally:
+ os.environ.pop("__PORTAGE_TEST_HARDLINK_LOCKS", None)
+
+ def _testAsynchronousLockWaitKill(self):
scheduler = PollScheduler().sched_iface
tempdir = tempfile.mkdtemp()
try:
@@ -122,3 +152,13 @@ class AsynchronousLockTestCase(TestCase):
lock1.unlock()
finally:
shutil.rmtree(tempdir)
+
+ def testAsynchronousLockWaitKill(self):
+ self._testAsynchronousLockWaitKill()
+
+ def testAsynchronousLockWaitKillHardlink(self):
+ os.environ["__PORTAGE_TEST_HARDLINK_LOCKS"] = "1"
+ try:
+ self._testAsynchronousLockWaitKill()
+ finally:
+ os.environ.pop("__PORTAGE_TEST_HARDLINK_LOCKS", None)
diff --git a/pym/portage/tests/locks/test_lock_nonblock.py b/pym/portage/tests/locks/test_lock_nonblock.py
index cc1b28e..914084c 100644
--- a/pym/portage/tests/locks/test_lock_nonblock.py
+++ b/pym/portage/tests/locks/test_lock_nonblock.py
@@ -11,7 +11,7 @@ from portage.tests import TestCase
class LockNonblockTestCase(TestCase):
- def testLockNonblock(self):
+ def _testLockNonblock(self):
tempdir = tempfile.mkdtemp()
try:
path = os.path.join(tempdir, 'lock_me')
@@ -44,3 +44,13 @@ class LockNonblockTestCase(TestCase):
finally:
shutil.rmtree(tempdir)
+ def testLockNonblock(self):
+ self._testLockNonblock()
+
+ def testLockNonblockHardlink(self):
+ os.environ["__PORTAGE_TEST_HARDLINK_LOCKS"] = "1"
+ try:
+ self._testLockNonblock()
+ finally:
+ os.environ.pop("__PORTAGE_TEST_HARDLINK_LOCKS", None)
+
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [gentoo-commits] proj/portage:master commit in: pym/portage/tests/emerge/, pym/portage/package/ebuild/_config/, bin/, ...
@ 2013-06-19 23:41 Zac Medico
0 siblings, 0 replies; 3+ messages in thread
From: Zac Medico @ 2013-06-19 23:41 UTC (permalink / raw
To: gentoo-commits
commit: 40400439b0c48fbc822b622c1758be3587f4a1f1
Author: Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Wed Jun 19 23:41:12 2013 +0000
Commit: Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Wed Jun 19 23:41:12 2013 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=40400439
Fix cross-prefix bugs, and test.
* Fix create_trees to correctly handle the case where ROOT=/ for two
different EPREFIX offsets.
* For best/has_version, handle the case where ROOT=/ for bug prefixes,
though each has a different EPREFIX offset.
* Use portage.const.EPREFIX for default EMERGE_LOG_DIR offset, which
is analogous to existing un-prefixed behavior.
* Use portage.const.EPREFIX for default PORTAGE_CONFIGROOT, which is
analogous to existing un-prefixed behavior.
* Add cross-prefix cases to emerge tests, including chpathtool for
binpkgs.
---
bin/phase-helpers.sh | 10 ++++++++--
pym/_emerge/actions.py | 3 +--
pym/portage/__init__.py | 4 ++--
.../package/ebuild/_config/LocationsManager.py | 2 +-
pym/portage/tests/emerge/test_simple.py | 20 ++++++++++++++++++++
5 files changed, 32 insertions(+), 7 deletions(-)
diff --git a/bin/phase-helpers.sh b/bin/phase-helpers.sh
index 3d51eb0..ba12f1f 100644
--- a/bin/phase-helpers.sh
+++ b/bin/phase-helpers.sh
@@ -676,7 +676,10 @@ has_version() {
fi
if ___eapi_has_prefix_variables; then
- if [[ ${root} == / ]] ; then
+ # [[ ${root} == / ]] would be ambiguous here,
+ # since both prefixes can share root=/ while
+ # having different EPREFIX offsets.
+ if ${host_root} ; then
eroot=${root%/}${PORTAGE_OVERRIDE_EPREFIX}/
else
eroot=${root%/}${EPREFIX}/
@@ -732,7 +735,10 @@ best_version() {
fi
if ___eapi_has_prefix_variables; then
- if [[ ${root} == / ]] ; then
+ # [[ ${root} == / ]] would be ambiguous here,
+ # since both prefixes can share root=/ while
+ # having different EPREFIX offsets.
+ if ${host_root} ; then
eroot=${root%/}${PORTAGE_OVERRIDE_EPREFIX}/
else
eroot=${root%/}${EPREFIX}/
diff --git a/pym/_emerge/actions.py b/pym/_emerge/actions.py
index b331b10..c31ad1d 100644
--- a/pym/_emerge/actions.py
+++ b/pym/_emerge/actions.py
@@ -3800,8 +3800,7 @@ def run_action(emerge_config):
_emerge.emergelog._emerge_log_dir = emerge_log_dir
else:
_emerge.emergelog._emerge_log_dir = os.path.join(os.sep,
- emerge_config.target_config.settings["EPREFIX"].lstrip(os.sep),
- "var", "log")
+ portage.const.EPREFIX.lstrip(os.sep), "var", "log")
portage.util.ensure_dirs(_emerge.emergelog._emerge_log_dir)
if not "--pretend" in emerge_config.opts:
diff --git a/pym/portage/__init__.py b/pym/portage/__init__.py
index 2510f86..7656c6e 100644
--- a/pym/portage/__init__.py
+++ b/pym/portage/__init__.py
@@ -577,7 +577,7 @@ def create_trees(config_root=None, target_root=None, trees=None, env=None,
trees._target_eroot = settings['EROOT']
myroots = [(settings['EROOT'], settings)]
- if settings["ROOT"] == "/":
+ if settings["ROOT"] == "/" and settings["EPREFIX"] == const.EPREFIX:
trees._running_eroot = trees._target_eroot
else:
@@ -593,7 +593,7 @@ def create_trees(config_root=None, target_root=None, trees=None, env=None,
if v is not None:
clean_env[k] = v
settings = config(config_root=None, target_root="/",
- env=clean_env, eprefix=eprefix)
+ env=clean_env, eprefix=None)
settings.lock()
trees._running_eroot = settings['EROOT']
myroots.append((settings['EROOT'], settings))
diff --git a/pym/portage/package/ebuild/_config/LocationsManager.py b/pym/portage/package/ebuild/_config/LocationsManager.py
index 7e799b8..e328441 100644
--- a/pym/portage/package/ebuild/_config/LocationsManager.py
+++ b/pym/portage/package/ebuild/_config/LocationsManager.py
@@ -49,7 +49,7 @@ class LocationsManager(object):
self.eprefix = portage.const.EPREFIX
if self.config_root is None:
- self.config_root = self.eprefix + os.sep
+ self.config_root = portage.const.EPREFIX + os.sep
self.config_root = normalize_path(os.path.abspath(
self.config_root)).rstrip(os.path.sep) + os.path.sep
diff --git a/pym/portage/tests/emerge/test_simple.py b/pym/portage/tests/emerge/test_simple.py
index c1abd52..dc7ddb7 100644
--- a/pym/portage/tests/emerge/test_simple.py
+++ b/pym/portage/tests/emerge/test_simple.py
@@ -201,6 +201,8 @@ pkg_preinst() {
test_ebuild = portdb.findname("dev-libs/A-1")
self.assertFalse(test_ebuild is None)
+ cross_prefix = os.path.join(eprefix, "cross_prefix")
+
test_commands = (
env_update_cmd,
portageq_cmd + ("envvar", "-v", "CONFIG_PROTECT", "EROOT",
@@ -266,6 +268,24 @@ pkg_preinst() {
emerge_cmd + ("-p", "--unmerge", "-q", eroot + "usr"),
emerge_cmd + ("--unmerge", "--quiet", "dev-libs/A"),
emerge_cmd + ("-C", "--quiet", "dev-libs/B"),
+
+ # Test cross-prefix usage, including chpathtool for binpkgs.
+ ({"EPREFIX" : cross_prefix},) + \
+ emerge_cmd + ("--usepkgonly", "dev-libs/A"),
+ ({"EPREFIX" : cross_prefix},) + \
+ portageq_cmd + ("has_version", cross_prefix, "dev-libs/A"),
+ ({"EPREFIX" : cross_prefix},) + \
+ portageq_cmd + ("has_version", cross_prefix, "dev-libs/B"),
+ ({"EPREFIX" : cross_prefix},) + \
+ emerge_cmd + ("-C", "--quiet", "dev-libs/B"),
+ ({"EPREFIX" : cross_prefix},) + \
+ emerge_cmd + ("-C", "--quiet", "dev-libs/A"),
+ ({"EPREFIX" : cross_prefix},) + \
+ emerge_cmd + ("dev-libs/A",),
+ ({"EPREFIX" : cross_prefix},) + \
+ portageq_cmd + ("has_version", cross_prefix, "dev-libs/A"),
+ ({"EPREFIX" : cross_prefix},) + \
+ portageq_cmd + ("has_version", cross_prefix, "dev-libs/B"),
)
distdir = playground.distdir
^ permalink raw reply related [flat|nested] 3+ messages in thread
end of thread, other threads:[~2013-06-19 23:41 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-06-19 23:41 [gentoo-commits] proj/portage:master commit in: pym/portage/tests/emerge/, pym/portage/package/ebuild/_config/, bin/, Zac Medico
-- strict thread matches above, loose matches on Subject: below --
2011-12-14 4:04 Zac Medico
2011-12-10 6:32 Zac Medico
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox