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