1 |
commit: ef8469befbd7b61f1bae8f21ffd95e0c0306a4f8 |
2 |
Author: Zac Medico <zmedico <AT> gentoo <DOT> org> |
3 |
AuthorDate: Sun Aug 5 21:30:57 2018 +0000 |
4 |
Commit: Zac Medico <zmedico <AT> gentoo <DOT> org> |
5 |
CommitDate: Thu Apr 18 17:52:54 2019 +0000 |
6 |
URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=ef8469be |
7 |
|
8 |
Change /usr/portage council approved locations (bug 378603) |
9 |
|
10 |
This includes a _compat_upgrade.default_locations script that the |
11 |
ebuild can call in pkg_preinst in order to maintain backward-compatible |
12 |
defaults when appropriate. The new defaults are specified in the |
13 |
summary of the 20180729 council meeting: |
14 |
|
15 |
Vote: Default locations for the Gentoo repository, distfiles, and |
16 |
binary packages will be, respectively: |
17 |
/var/db/repos/gentoo |
18 |
/var/cache/distfiles |
19 |
/var/cache/binpkgs |
20 |
Accepted with 6 yes votes and 1 no vote. |
21 |
|
22 |
See: https://projects.gentoo.org/council/meeting-logs/20180729-summary.txt |
23 |
Bug: https://bugs.gentoo.org/378603 |
24 |
Signed-off-by: Zac Medico <zmedico <AT> gentoo.org> |
25 |
|
26 |
cnf/make.globals | 4 +- |
27 |
cnf/repos.conf | 2 +- |
28 |
lib/portage/_compat_upgrade/__init__.py | 0 |
29 |
lib/portage/_compat_upgrade/default_locations.py | 82 ++++++++++++++++++++++++ |
30 |
4 files changed, 85 insertions(+), 3 deletions(-) |
31 |
|
32 |
diff --git a/cnf/make.globals b/cnf/make.globals |
33 |
index b4ed8c466..b01cca599 100644 |
34 |
--- a/cnf/make.globals |
35 |
+++ b/cnf/make.globals |
36 |
@@ -27,8 +27,8 @@ ACCEPT_PROPERTIES="*" |
37 |
ACCEPT_RESTRICT="*" |
38 |
|
39 |
# Miscellaneous paths |
40 |
-DISTDIR="/usr/portage/distfiles" |
41 |
-PKGDIR="/usr/portage/packages" |
42 |
+DISTDIR="/var/cache/distfiles" |
43 |
+PKGDIR="/var/cache/binpkgs" |
44 |
RPMDIR="/usr/portage/rpm" |
45 |
|
46 |
# Temporary build directory |
47 |
|
48 |
diff --git a/cnf/repos.conf b/cnf/repos.conf |
49 |
index 352073cfd..e84840bf2 100644 |
50 |
--- a/cnf/repos.conf |
51 |
+++ b/cnf/repos.conf |
52 |
@@ -2,7 +2,7 @@ |
53 |
main-repo = gentoo |
54 |
|
55 |
[gentoo] |
56 |
-location = /usr/portage |
57 |
+location = /var/db/repos/gentoo |
58 |
sync-type = rsync |
59 |
sync-uri = rsync://rsync.gentoo.org/gentoo-portage |
60 |
auto-sync = yes |
61 |
|
62 |
diff --git a/lib/portage/_compat_upgrade/__init__.py b/lib/portage/_compat_upgrade/__init__.py |
63 |
new file mode 100644 |
64 |
index 000000000..e69de29bb |
65 |
|
66 |
diff --git a/lib/portage/_compat_upgrade/default_locations.py b/lib/portage/_compat_upgrade/default_locations.py |
67 |
new file mode 100644 |
68 |
index 000000000..91f300637 |
69 |
--- /dev/null |
70 |
+++ b/lib/portage/_compat_upgrade/default_locations.py |
71 |
@@ -0,0 +1,82 @@ |
72 |
+# Copyright 2018-2019 Gentoo Authors |
73 |
+# Distributed under the terms of the GNU General Public License v2 |
74 |
+ |
75 |
+import re |
76 |
+ |
77 |
+import portage |
78 |
+from portage import os |
79 |
+from portage.const import GLOBAL_CONFIG_PATH |
80 |
+ |
81 |
+COMPAT_DISTDIR = 'usr/portage/distfiles' |
82 |
+COMPAT_PKGDIR = 'usr/portage/packages' |
83 |
+COMPAT_MAIN_REPO = 'usr/portage' |
84 |
+ |
85 |
+ |
86 |
+def main(): |
87 |
+ """ |
88 |
+ If the current installation is still configured to use any of the |
89 |
+ legacy default /usr/portage locations, then patch make.globals and |
90 |
+ repos.conf inside ${ED} to maintain compatible defaults. This is |
91 |
+ intended to be called from the ebuild as follows: |
92 |
+ |
93 |
+ pkg_preinst() { |
94 |
+ python_setup |
95 |
+ python_export PYTHON_SITEDIR |
96 |
+ env -u DISTDIR \ |
97 |
+ -u PORTAGE_OVERRIDE_EPREFIX \ |
98 |
+ -u PORTAGE_REPOSITORIES \ |
99 |
+ -u PORTDIR \ |
100 |
+ -u PORTDIR_OVERLAY \ |
101 |
+ PYTHONPATH="${ED%/}${PYTHON_SITEDIR}${PYTHONPATH:+:${PYTHONPATH}}" \ |
102 |
+ "${PYTHON}" -m portage._compat_upgrade.default_locations || die |
103 |
+ } |
104 |
+ """ |
105 |
+ out = portage.output.EOutput() |
106 |
+ config = portage.settings |
107 |
+ |
108 |
+ compat_distdir = os.path.join(portage.const.EPREFIX or '/', COMPAT_DISTDIR) |
109 |
+ try: |
110 |
+ do_distdir = os.path.samefile(config['DISTDIR'], compat_distdir) |
111 |
+ except OSError: |
112 |
+ do_distdir = False |
113 |
+ |
114 |
+ compat_pkgdir = os.path.join(portage.const.EPREFIX or '/', COMPAT_PKGDIR) |
115 |
+ try: |
116 |
+ do_pkgdir = os.path.samefile(config['PKGDIR'], compat_pkgdir) |
117 |
+ except OSError: |
118 |
+ do_pkgdir = False |
119 |
+ |
120 |
+ compat_main_repo = os.path.join(portage.const.EPREFIX or '/', COMPAT_MAIN_REPO) |
121 |
+ try: |
122 |
+ do_main_repo = os.path.samefile(config.repositories.mainRepoLocation(), compat_main_repo) |
123 |
+ except OSError: |
124 |
+ do_main_repo = False |
125 |
+ |
126 |
+ if do_distdir or do_pkgdir: |
127 |
+ config_path = os.path.join(os.environ['ED'], GLOBAL_CONFIG_PATH.lstrip(os.sep), 'make.globals') |
128 |
+ with open(config_path) as f: |
129 |
+ content = f.read() |
130 |
+ if do_distdir: |
131 |
+ compat_setting = 'DISTDIR="{}"'.format(compat_distdir) |
132 |
+ out.einfo('Setting make.globals default {} for backward compatibility'.format(compat_setting)) |
133 |
+ content = re.sub('^DISTDIR=.*$', compat_setting, content, flags=re.MULTILINE) |
134 |
+ if do_pkgdir: |
135 |
+ compat_setting = 'PKGDIR="{}"'.format(compat_pkgdir) |
136 |
+ out.einfo('Setting make.globals default {} for backward compatibility'.format(compat_setting)) |
137 |
+ content = re.sub('^PKGDIR=.*$', compat_setting, content, flags=re.MULTILINE) |
138 |
+ with open(config_path, 'wt') as f: |
139 |
+ f.write(content) |
140 |
+ |
141 |
+ if do_main_repo: |
142 |
+ config_path = os.path.join(os.environ['ED'], GLOBAL_CONFIG_PATH.lstrip(os.sep), 'repos.conf') |
143 |
+ with open(config_path) as f: |
144 |
+ content = f.read() |
145 |
+ compat_setting = 'location = {}'.format(compat_main_repo) |
146 |
+ out.einfo('Setting repos.conf default {} for backward compatibility'.format(compat_setting)) |
147 |
+ content = re.sub('^location =.*$', compat_setting, content, flags=re.MULTILINE) |
148 |
+ with open(config_path, 'wt') as f: |
149 |
+ f.write(content) |
150 |
+ |
151 |
+ |
152 |
+if __name__ == '__main__': |
153 |
+ main() |