public inbox for gentoo-portage-dev@lists.gentoo.org
 help / color / mirror / Atom feed
From: Zac Medico <zmedico@gentoo.org>
To: gentoo-portage-dev@lists.gentoo.org
Cc: Zac Medico <zmedico@gentoo.org>
Subject: [gentoo-portage-dev] [PATCH 1/2] Change /usr/portage council approved locations (bug 378603)
Date: Sun,  5 Aug 2018 17:23:46 -0700	[thread overview]
Message-ID: <20180806002347.18237-2-zmedico@gentoo.org> (raw)
In-Reply-To: <20180806002347.18237-1-zmedico@gentoo.org>

This includes a _compat_upgrade.default_locations script that the
ebuild can call in pkg_preinst in order to maintain backward-compatible
defaults when appropriate. The new defaults are specified in the
summary of the 20180729 council meeting:

Vote: Default locations for the Gentoo repository, distfiles, and
binary packages will be, respectively:
   /var/db/repos/gentoo
   /var/cache/distfiles
   /var/cache/binpkgs
Accepted with 6 yes votes and 1 no vote.

See: https://projects.gentoo.org/council/meeting-logs/20180729-summary.txt
Bug: https://bugs.gentoo.org/378603
---
 cnf/make.globals                                 |  4 +-
 cnf/repos.conf                                   |  2 +-
 lib/portage/_compat_upgrade/__init__.py          |  0
 lib/portage/_compat_upgrade/default_locations.py | 82 ++++++++++++++++++++++++
 4 files changed, 85 insertions(+), 3 deletions(-)
 create mode 100644 lib/portage/_compat_upgrade/__init__.py
 create mode 100644 lib/portage/_compat_upgrade/default_locations.py

diff --git a/cnf/make.globals b/cnf/make.globals
index 04a708af8..bc81a6a73 100644
--- a/cnf/make.globals
+++ b/cnf/make.globals
@@ -28,8 +28,8 @@ ACCEPT_PROPERTIES="*"
 ACCEPT_RESTRICT="*"
 
 # Miscellaneous paths
-DISTDIR="/usr/portage/distfiles"
-PKGDIR="/usr/portage/packages"
+DISTDIR="/var/cache/distfiles"
+PKGDIR="/var/cache/binpkgs"
 RPMDIR="/usr/portage/rpm"
 
 # Temporary build directory
diff --git a/cnf/repos.conf b/cnf/repos.conf
index 352073cfd..e84840bf2 100644
--- a/cnf/repos.conf
+++ b/cnf/repos.conf
@@ -2,7 +2,7 @@
 main-repo = gentoo
 
 [gentoo]
-location = /usr/portage
+location = /var/db/repos/gentoo
 sync-type = rsync
 sync-uri = rsync://rsync.gentoo.org/gentoo-portage
 auto-sync = yes
diff --git a/lib/portage/_compat_upgrade/__init__.py b/lib/portage/_compat_upgrade/__init__.py
new file mode 100644
index 000000000..e69de29bb
diff --git a/lib/portage/_compat_upgrade/default_locations.py b/lib/portage/_compat_upgrade/default_locations.py
new file mode 100644
index 000000000..484a2dea4
--- /dev/null
+++ b/lib/portage/_compat_upgrade/default_locations.py
@@ -0,0 +1,82 @@
+# Copyright 2018 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+import re
+
+import portage
+from portage import os
+from portage.const import GLOBAL_CONFIG_PATH
+
+COMPAT_DISTDIR = 'usr/portage/distfiles'
+COMPAT_PKGDIR = 'usr/portage/packages'
+COMPAT_MAIN_REPO = 'usr/portage'
+
+
+def main():
+	"""
+	If the current installation is still configured to use any of the
+	legacy default /usr/portage locations, then patch make.globals and
+	repos.conf inside ${ED} to maintain compatible defaults. This is
+	intended to be called from the ebuild as follows:
+
+	pkg_preinst() {
+		python_setup
+		python_export PYTHON_SITEDIR
+		env -u DISTDIR \
+			-u PORTAGE_OVERRIDE_EPREFIX \
+			-u PORTAGE_REPOSITORIES \
+			-u PORTDIR \
+			-u PORTDIR_OVERLAY \
+			PYTHONPATH="${ED%/}${PYTHON_SITEDIR}${PYTHONPATH:+:${PYTHONPATH}}" \
+			"${PYTHON}" -m portage._compat_upgrade.default_locations || die
+	}
+	"""
+	out = portage.output.EOutput()
+	config = portage.settings
+
+	compat_distdir = os.path.join(portage.const.EPREFIX or '/', COMPAT_DISTDIR)
+	try:
+		do_distdir = os.path.samefile(config['DISTDIR'], compat_distdir)
+	except OSError:
+		do_distdir = False
+
+	compat_pkgdir = os.path.join(portage.const.EPREFIX or '/', COMPAT_PKGDIR)
+	try:
+		do_pkgdir = os.path.samefile(config['PKGDIR'], compat_pkgdir)
+	except OSError:
+		do_pkgdir = False
+
+	compat_main_repo = os.path.join(portage.const.EPREFIX or '/', COMPAT_MAIN_REPO)
+	try:
+		do_main_repo = os.path.samefile(config.repositories.mainRepoLocation(), compat_main_repo)
+	except OSError:
+		do_main_repo = False
+
+	if do_distdir or do_pkgdir:
+		config_path = os.path.join(os.environ['ED'], GLOBAL_CONFIG_PATH.lstrip(os.sep), 'make.globals')
+		with open(config_path) as f:
+			content = f.read()
+			if do_distdir:
+				compat_setting = 'DISTDIR="{}"'.format(compat_distdir)
+				out.einfo('Setting make.globals default {} for backward compatibility'.format(compat_setting))
+				content = re.sub('^DISTDIR=.*$', compat_setting, content, flags=re.MULTILINE)
+			if do_pkgdir:
+				compat_setting = 'PKGDIR="{}"'.format(compat_pkgdir)
+				out.einfo('Setting make.globals default {} for backward compatibility'.format(compat_setting))
+				content = re.sub('^PKGDIR=.*$', compat_setting, content, flags=re.MULTILINE)
+		with open(config_path, 'wt') as f:
+			f.write(content)
+
+	if do_main_repo:
+		config_path = os.path.join(os.environ['ED'], GLOBAL_CONFIG_PATH.lstrip(os.sep), 'repos.conf')
+		with open(config_path) as f:
+			content = f.read()
+			compat_setting = 'location = {}'.format(compat_main_repo)
+			out.einfo('Setting repos.conf default {} for backward compatibility'.format(compat_setting))
+			content = re.sub('^location =.*$', compat_setting, content, flags=re.MULTILINE)
+		with open(config_path, 'wt') as f:
+			f.write(content)
+
+
+if __name__ == '__main__':
+	main()
-- 
2.16.4



  reply	other threads:[~2018-08-06  0:26 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-08-06  0:23 [gentoo-portage-dev] [PATCH 0/2] Change /usr/portage council approved locations (bug 378603) Zac Medico
2018-08-06  0:23 ` Zac Medico [this message]
2018-08-06  0:23 ` [gentoo-portage-dev] [PATCH 2/2] Update /usr/portage references " Zac Medico
2018-08-06  4:59   ` Ulrich Mueller
2018-08-06  5:46     ` Zac Medico
2018-08-06  6:03       ` Zac Medico
2018-08-06  7:30       ` Brian Dolbec
2018-08-06 10:29         ` Ulrich Mueller
2018-08-06 18:35         ` Zac Medico
2018-08-06 21:50           ` M. J. Everitt
2018-08-06 22:39             ` Zac Medico
2018-08-06  5:32   ` [gentoo-portage-dev] [PATCH 2/2 v2] " Zac Medico
2018-08-06  7:44     ` Brian Dolbec
2018-08-06 18:46       ` Zac Medico
2019-04-18 17:03   ` [gentoo-portage-dev] [PATCH 2/2 v3] " Zac Medico
2019-04-18 17:28     ` Ulrich Mueller
2019-04-18 17:54       ` Zac Medico
2019-04-18 17:58   ` [gentoo-portage-dev] [PATCH 2/2 v4] " Zac Medico

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180806002347.18237-2-zmedico@gentoo.org \
    --to=zmedico@gentoo.org \
    --cc=gentoo-portage-dev@lists.gentoo.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox