1 |
commit: bd9569342d1f6ca1c21cf34770bc403f8508c1ad |
2 |
Author: Zac Medico <zmedico <AT> gentoo <DOT> org> |
3 |
AuthorDate: Wed Feb 18 02:25:04 2015 +0000 |
4 |
Commit: Zac Medico <zmedico <AT> gentoo <DOT> org> |
5 |
CommitDate: Wed Mar 4 21:32:07 2015 +0000 |
6 |
URL: http://sources.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=bd956934 |
7 |
|
8 |
binpkg-multi-instance 6 of 7 |
9 |
|
10 |
Remove unused binarytree _remove_symlink, _create_symlink, |
11 |
prevent_collision, _move_to_all, and _move_from_all methods. These are |
12 |
all related to the oldest PKGDIR layout, which put all of the tbz2 |
13 |
files in $PKGDIR/All, and created symlinks to them in the category |
14 |
directories. The $PKGDIR/All layout should be practically extinct by |
15 |
now. Now portage recognizes all existing layouts, or mixtures of them, |
16 |
and uses the old packages in place. It never puts new packages in |
17 |
$PKGDIR/All, so there's no need to move packages around to prevent file |
18 |
name collisions between packages from different categories. It also |
19 |
only uses regular files (any symlinks are ignored). |
20 |
|
21 |
pym/portage/dbapi/bintree.py | 117 ++----------------------------------------- |
22 |
1 file changed, 4 insertions(+), 113 deletions(-) |
23 |
|
24 |
diff --git a/pym/portage/dbapi/bintree.py b/pym/portage/dbapi/bintree.py |
25 |
index f5e7303..2f0bc47 100644 |
26 |
--- a/pym/portage/dbapi/bintree.py |
27 |
+++ b/pym/portage/dbapi/bintree.py |
28 |
@@ -471,89 +471,11 @@ class binarytree(object): |
29 |
|
30 |
return moves |
31 |
|
32 |
- def _remove_symlink(self, cpv): |
33 |
- """Remove a ${PKGDIR}/${CATEGORY}/${PF}.tbz2 symlink and also remove |
34 |
- the ${PKGDIR}/${CATEGORY} directory if empty. The file will not be |
35 |
- removed if os.path.islink() returns False.""" |
36 |
- mycat, mypkg = catsplit(cpv) |
37 |
- mylink = os.path.join(self.pkgdir, mycat, mypkg + ".tbz2") |
38 |
- if os.path.islink(mylink): |
39 |
- """Only remove it if it's really a link so that this method never |
40 |
- removes a real package that was placed here to avoid a collision.""" |
41 |
- os.unlink(mylink) |
42 |
- try: |
43 |
- os.rmdir(os.path.join(self.pkgdir, mycat)) |
44 |
- except OSError as e: |
45 |
- if e.errno not in (errno.ENOENT, |
46 |
- errno.ENOTEMPTY, errno.EEXIST): |
47 |
- raise |
48 |
- del e |
49 |
- |
50 |
- def _create_symlink(self, cpv): |
51 |
- """Create a ${PKGDIR}/${CATEGORY}/${PF}.tbz2 symlink (and |
52 |
- ${PKGDIR}/${CATEGORY} directory, if necessary). Any file that may |
53 |
- exist in the location of the symlink will first be removed.""" |
54 |
- mycat, mypkg = catsplit(cpv) |
55 |
- full_path = os.path.join(self.pkgdir, mycat, mypkg + ".tbz2") |
56 |
- self._ensure_dir(os.path.dirname(full_path)) |
57 |
- try: |
58 |
- os.unlink(full_path) |
59 |
- except OSError as e: |
60 |
- if e.errno != errno.ENOENT: |
61 |
- raise |
62 |
- del e |
63 |
- os.symlink(os.path.join("..", "All", mypkg + ".tbz2"), full_path) |
64 |
- |
65 |
def prevent_collision(self, cpv): |
66 |
- """Make sure that the file location ${PKGDIR}/All/${PF}.tbz2 is safe to |
67 |
- use for a given cpv. If a collision will occur with an existing |
68 |
- package from another category, the existing package will be bumped to |
69 |
- ${PKGDIR}/${CATEGORY}/${PF}.tbz2 so that both can coexist.""" |
70 |
- if not self._all_directory: |
71 |
- return |
72 |
- |
73 |
- # Copy group permissions for new directories that |
74 |
- # may have been created. |
75 |
- for path in ("All", catsplit(cpv)[0]): |
76 |
- path = os.path.join(self.pkgdir, path) |
77 |
- self._ensure_dir(path) |
78 |
- if not os.access(path, os.W_OK): |
79 |
- raise PermissionDenied("access('%s', W_OK)" % path) |
80 |
- |
81 |
- full_path = self.getname(cpv) |
82 |
- if "All" == full_path.split(os.path.sep)[-2]: |
83 |
- return |
84 |
- """Move a colliding package if it exists. Code below this point only |
85 |
- executes in rare cases.""" |
86 |
- mycat, mypkg = catsplit(cpv) |
87 |
- myfile = mypkg + ".tbz2" |
88 |
- mypath = os.path.join("All", myfile) |
89 |
- dest_path = os.path.join(self.pkgdir, mypath) |
90 |
- |
91 |
- try: |
92 |
- st = os.lstat(dest_path) |
93 |
- except OSError: |
94 |
- st = None |
95 |
- else: |
96 |
- if stat.S_ISLNK(st.st_mode): |
97 |
- st = None |
98 |
- try: |
99 |
- os.unlink(dest_path) |
100 |
- except OSError: |
101 |
- if os.path.exists(dest_path): |
102 |
- raise |
103 |
- |
104 |
- if st is not None: |
105 |
- # For invalid packages, other_cat could be None. |
106 |
- other_cat = portage.xpak.tbz2(dest_path).getfile(b"CATEGORY") |
107 |
- if other_cat: |
108 |
- other_cat = _unicode_decode(other_cat, |
109 |
- encoding=_encodings['repo.content'], errors='replace') |
110 |
- other_cat = other_cat.strip() |
111 |
- other_cpv = other_cat + "/" + mypkg |
112 |
- self._move_from_all(other_cpv) |
113 |
- self.inject(other_cpv) |
114 |
- self._move_to_all(cpv) |
115 |
+ warnings.warn("The " |
116 |
+ "portage.dbapi.bintree.binarytree.prevent_collision " |
117 |
+ "method is deprecated.", |
118 |
+ DeprecationWarning, stacklevel=2) |
119 |
|
120 |
def _ensure_dir(self, path): |
121 |
""" |
122 |
@@ -589,37 +511,6 @@ class binarytree(object): |
123 |
except PortageException: |
124 |
pass |
125 |
|
126 |
- def _move_to_all(self, cpv): |
127 |
- """If the file exists, move it. Whether or not it exists, update state |
128 |
- for future getname() calls.""" |
129 |
- mycat, mypkg = catsplit(cpv) |
130 |
- myfile = mypkg + ".tbz2" |
131 |
- self._pkg_paths[cpv] = os.path.join("All", myfile) |
132 |
- src_path = os.path.join(self.pkgdir, mycat, myfile) |
133 |
- try: |
134 |
- mystat = os.lstat(src_path) |
135 |
- except OSError as e: |
136 |
- mystat = None |
137 |
- if mystat and stat.S_ISREG(mystat.st_mode): |
138 |
- self._ensure_dir(os.path.join(self.pkgdir, "All")) |
139 |
- dest_path = os.path.join(self.pkgdir, "All", myfile) |
140 |
- _movefile(src_path, dest_path, mysettings=self.settings) |
141 |
- self._create_symlink(cpv) |
142 |
- self.inject(cpv) |
143 |
- |
144 |
- def _move_from_all(self, cpv): |
145 |
- """Move a package from ${PKGDIR}/All/${PF}.tbz2 to |
146 |
- ${PKGDIR}/${CATEGORY}/${PF}.tbz2 and update state from getname calls.""" |
147 |
- self._remove_symlink(cpv) |
148 |
- mycat, mypkg = catsplit(cpv) |
149 |
- myfile = mypkg + ".tbz2" |
150 |
- mypath = os.path.join(mycat, myfile) |
151 |
- dest_path = os.path.join(self.pkgdir, mypath) |
152 |
- self._ensure_dir(os.path.dirname(dest_path)) |
153 |
- src_path = os.path.join(self.pkgdir, "All", myfile) |
154 |
- _movefile(src_path, dest_path, mysettings=self.settings) |
155 |
- self._pkg_paths[cpv] = mypath |
156 |
- |
157 |
def populate(self, getbinpkgs=0): |
158 |
"populates the binarytree" |