1 |
--- |
2 |
pym/_emerge/EbuildExecuter.py | 4 +-- |
3 |
pym/portage/package/ebuild/doebuild.py | 34 ++---------------------- |
4 |
pym/portage/package/ebuild/prepare_build_dirs.py | 33 ++++++++++++++++++++++- |
5 |
3 files changed, 36 insertions(+), 35 deletions(-) |
6 |
|
7 |
diff --git a/pym/_emerge/EbuildExecuter.py b/pym/_emerge/EbuildExecuter.py |
8 |
index 5587d4eb0..ab79ce901 100644 |
9 |
--- a/pym/_emerge/EbuildExecuter.py |
10 |
+++ b/pym/_emerge/EbuildExecuter.py |
11 |
@@ -1,4 +1,4 @@ |
12 |
-# Copyright 1999-2011 Gentoo Foundation |
13 |
+# Copyright 1999-2018 Gentoo Foundation |
14 |
# Distributed under the terms of the GNU General Public License v2 |
15 |
|
16 |
from _emerge.EbuildPhase import EbuildPhase |
17 |
@@ -8,7 +8,7 @@ import portage |
18 |
from portage import os |
19 |
from portage.eapi import eapi_has_src_prepare_and_src_configure, \ |
20 |
eapi_exports_replace_vars |
21 |
-from portage.package.ebuild.doebuild import _prepare_fake_distdir |
22 |
+from portage.package.ebuild.prepare_build_dirs import _prepare_fake_distdir |
23 |
|
24 |
class EbuildExecuter(CompositeTask): |
25 |
|
26 |
diff --git a/pym/portage/package/ebuild/doebuild.py b/pym/portage/package/ebuild/doebuild.py |
27 |
index f75f11a1a..c8df9b744 100644 |
28 |
--- a/pym/portage/package/ebuild/doebuild.py |
29 |
+++ b/pym/portage/package/ebuild/doebuild.py |
30 |
@@ -1,4 +1,4 @@ |
31 |
-# Copyright 2010-2015 Gentoo Foundation |
32 |
+# Copyright 2010-2018 Gentoo Foundation |
33 |
# Distributed under the terms of the GNU General Public License v2 |
34 |
|
35 |
from __future__ import unicode_literals |
36 |
@@ -31,6 +31,7 @@ portage.proxy.lazyimport.lazyimport(globals(), |
37 |
'portage.package.ebuild.digestcheck:digestcheck', |
38 |
'portage.package.ebuild.digestgen:digestgen', |
39 |
'portage.package.ebuild.fetch:fetch', |
40 |
+ 'portage.package.ebuild.prepare_build_dirs:_prepare_fake_distdir', |
41 |
'portage.package.ebuild._ipc.QueryCommand:QueryCommand', |
42 |
'portage.dep._slot_operator:evaluate_slot_operator_equal_deps', |
43 |
'portage.package.ebuild._spawn_nofetch:spawn_nofetch', |
44 |
@@ -1351,37 +1352,6 @@ def _prepare_env_file(settings): |
45 |
env_extractor.wait() |
46 |
return env_extractor.returncode |
47 |
|
48 |
-def _prepare_fake_distdir(settings, alist): |
49 |
- orig_distdir = settings["DISTDIR"] |
50 |
- settings["PORTAGE_ACTUAL_DISTDIR"] = orig_distdir |
51 |
- edpath = settings["DISTDIR"] = \ |
52 |
- os.path.join(settings["PORTAGE_BUILDDIR"], "distdir") |
53 |
- portage.util.ensure_dirs(edpath, gid=portage_gid, mode=0o755) |
54 |
- |
55 |
- # Remove any unexpected files or directories. |
56 |
- for x in os.listdir(edpath): |
57 |
- symlink_path = os.path.join(edpath, x) |
58 |
- st = os.lstat(symlink_path) |
59 |
- if x in alist and stat.S_ISLNK(st.st_mode): |
60 |
- continue |
61 |
- if stat.S_ISDIR(st.st_mode): |
62 |
- shutil.rmtree(symlink_path) |
63 |
- else: |
64 |
- os.unlink(symlink_path) |
65 |
- |
66 |
- # Check for existing symlinks and recreate if necessary. |
67 |
- for x in alist: |
68 |
- symlink_path = os.path.join(edpath, x) |
69 |
- target = os.path.join(orig_distdir, x) |
70 |
- try: |
71 |
- link_target = os.readlink(symlink_path) |
72 |
- except OSError: |
73 |
- os.symlink(target, symlink_path) |
74 |
- else: |
75 |
- if link_target != target: |
76 |
- os.unlink(symlink_path) |
77 |
- os.symlink(target, symlink_path) |
78 |
- |
79 |
def _spawn_actionmap(settings): |
80 |
features = settings.features |
81 |
restrict = settings["PORTAGE_RESTRICT"].split() |
82 |
diff --git a/pym/portage/package/ebuild/prepare_build_dirs.py b/pym/portage/package/ebuild/prepare_build_dirs.py |
83 |
index e3ae318bd..16afc3f98 100644 |
84 |
--- a/pym/portage/package/ebuild/prepare_build_dirs.py |
85 |
+++ b/pym/portage/package/ebuild/prepare_build_dirs.py |
86 |
@@ -1,4 +1,4 @@ |
87 |
-# Copyright 2010-2013 Gentoo Foundation |
88 |
+# Copyright 2010-2018 Gentoo Foundation |
89 |
# Distributed under the terms of the GNU General Public License v2 |
90 |
|
91 |
from __future__ import unicode_literals |
92 |
@@ -409,3 +409,34 @@ def _prepare_fake_filesdir(settings): |
93 |
if link_target != real_filesdir: |
94 |
os.unlink(symlink_path) |
95 |
os.symlink(real_filesdir, symlink_path) |
96 |
+ |
97 |
+def _prepare_fake_distdir(settings, alist): |
98 |
+ orig_distdir = settings["DISTDIR"] |
99 |
+ settings["PORTAGE_ACTUAL_DISTDIR"] = orig_distdir |
100 |
+ edpath = settings["DISTDIR"] = \ |
101 |
+ os.path.join(settings["PORTAGE_BUILDDIR"], "distdir") |
102 |
+ portage.util.ensure_dirs(edpath, gid=portage_gid, mode=0o755) |
103 |
+ |
104 |
+ # Remove any unexpected files or directories. |
105 |
+ for x in os.listdir(edpath): |
106 |
+ symlink_path = os.path.join(edpath, x) |
107 |
+ st = os.lstat(symlink_path) |
108 |
+ if x in alist and stat.S_ISLNK(st.st_mode): |
109 |
+ continue |
110 |
+ if stat.S_ISDIR(st.st_mode): |
111 |
+ shutil.rmtree(symlink_path) |
112 |
+ else: |
113 |
+ os.unlink(symlink_path) |
114 |
+ |
115 |
+ # Check for existing symlinks and recreate if necessary. |
116 |
+ for x in alist: |
117 |
+ symlink_path = os.path.join(edpath, x) |
118 |
+ target = os.path.join(orig_distdir, x) |
119 |
+ try: |
120 |
+ link_target = os.readlink(symlink_path) |
121 |
+ except OSError: |
122 |
+ os.symlink(target, symlink_path) |
123 |
+ else: |
124 |
+ if link_target != target: |
125 |
+ os.unlink(symlink_path) |
126 |
+ os.symlink(target, symlink_path) |
127 |
-- |
128 |
2.16.1 |