Re: [gentoo-portage-dev] [PATCH 2/2] Update /usr/portage references (bug 378603)

2018-08-05 Thread Zac Medico
On 08/05/2018 09:59 PM, Ulrich Mueller wrote:
>> On Sun, 5 Aug 2018, Zac Medico wrote:
> 
>> --- a/cnf/make.conf.example
>> +++ b/cnf/make.conf.example
>> [...]
> 
>> @@ -119,16 +119,16 @@
>>  # fetched on demand for a given build. If you would like to
>>  # selectively prune obsolete files from this directory, see
>>  # eclean from the gentoolkit package. Note that locations under
>> -# /usr/portage are not necessarily safe for data storage. See the
>> +# /var/db/repos/gentoo are not necessarily safe for data storage. See 
>> the
>>  # PORTDIR documentation for more information.
>> -#DISTDIR=/usr/portage/distfiles
>> +#DISTDIR=/var/db/repos/gentoo/distfiles
> 
> Shouldn't this be /var/cache/distfiles ...
> 
>>  #
>>  # PKGDIR is the location of binary packages that you can have created
>>  # with '--buildpkg' or '-b' while emerging a package. This can get
>>  # up to several hundred megs, or even a few gigs. Note that
>> -# locations under /usr/portage are not necessarily safe for data
>> +# locations under /var/db/repos/gentoo are not necessarily safe for data
>>  # storage. See the PORTDIR documentation for more information.
>> -#PKGDIR=/usr/portage/packages
>> +#PKGDIR=/var/db/repos/gentoo/packages
> 
> ... and /var/cache/binpkgs?

Thanks, I've fixed the /var/cache/{distfiles,binpkgs} locations in v2.

>> --- a/lib/portage/cache/flat_hash.py
>> +++ b/lib/portage/cache/flat_hash.py
>> @@ -144,7 +144,7 @@ class database(fs_template.FsBased):
>>  # Only recurse 1 deep, in order to 
>> avoid iteration over
>>  # entries from another nested cache 
>> instance. This can
>>  # happen if the user nests an overlay 
>> inside
>> -# /usr/portage/local as in bug #302764.
>> +# /var/db/repos/gentoo/local as in bug 
>> #302764.
> 
> Shouldn't a local overlay be in /var/db/repos/local, but never inside
> of the gentoo repo?

Yes, but for a long time /usr/local/portage was somewhat standard, in
fact it's still mentioned here:

https://wiki.gentoo.org/wiki/Custom_repository

Nowadays, repository verification will prevent that from working...

>> --- a/man/make.conf.5
>> +++ b/man/make.conf.5
>> @@ -219,10 +219,10 @@ Use the \fBPORTAGE_RO_DISTDIRS\fR variable to specify 
>> one or
>>  more read-only directories containing distfiles.
>>  
>>  Note
>> -that locations under /usr/portage are not necessarily safe for data storage.
>> +that locations under /var/db/repos/gentoo are not necessarily safe for data 
>> storage.
> 
> IMHO this statement should be made much stronger.

Yes, we could also say something about repository verification here. The
old defaults set a really bad example, so we needed statements like this
to steer people in the right direction.
--
Thanks,
Zac



signature.asc
Description: OpenPGP digital signature


[gentoo-portage-dev] [PATCH 2/2 v2] Update /usr/portage references (bug 378603)

2018-08-05 Thread Zac Medico
Update all relevant references in docs, messages, and comments
to refer to /var/db/repos/gentoo instead of /usr/portage. Also
update DISTDIR and PKGDIR references to refer to the new
/var/cache/{distfiles,binpkgs} locations.

Bug: https://bugs.gentoo.org/378603
---
[PATCH 2/2 v2] fixes DISTDIR and PKGDIR references to rever to the
new /var/cache/{distfiles,binpkgs} locations

 cnf/make.conf.example| 12 +--
 lib/portage/__init__.py  |  2 +-
 lib/portage/cache/flat_hash.py   |  2 +-
 lib/portage/tests/news/test_NewsItem.py  |  2 +-
 lib/portage/tests/resolver/ResolverPlayground.py |  2 +-
 lib/portage/xml/metadata.py  |  4 ++--
 man/ebuild.5 |  4 ++--
 man/emerge.1 |  6 +++---
 man/make.conf.5  | 20 +-
 man/portage.5| 26 
 man/quickpkg.1   |  2 +-
 repoman/lib/repoman/__init__.py  |  2 +-
 repoman/lib/repoman/checks/herds/herdbase.py |  2 +-
 13 files changed, 43 insertions(+), 43 deletions(-)

diff --git a/cnf/make.conf.example b/cnf/make.conf.example
index 04f3a0274..c16f2afbd 100644
--- a/cnf/make.conf.example
+++ b/cnf/make.conf.example
@@ -14,7 +14,7 @@
 # https://wiki.gentoo.org/wiki/Handbook:X86/Working/USE
 #
 # The available list of use flags with descriptions is in your portage tree.
-# Use 'less' to view them:  --> less /usr/portage/profiles/use.desc <--
+# Use 'less' to view them:  --> less /var/db/repos/gentoo/profiles/use.desc <--
 #
 # 'ufed' is an ncurses/dialog interface available in portage to make handling
 # useflags for you. 'emerge app-portage/ufed'
@@ -111,7 +111,7 @@
 # will protect the default locations of DISTDIR and PKGDIR, but users are
 # warned that any other locations inside PORTDIR are not necessarily safe
 # for data storage.
-#PORTDIR=/usr/portage
+#PORTDIR=/var/db/repos/gentoo
 #
 # DISTDIR is where all of the source code tarballs will be placed for
 # emerges. After packages are built, it is safe to remove any and
@@ -119,16 +119,16 @@
 # fetched on demand for a given build. If you would like to
 # selectively prune obsolete files from this directory, see
 # eclean from the gentoolkit package. Note that locations under
-# /usr/portage are not necessarily safe for data storage. See the
+# /var/db/repos/gentoo are not necessarily safe for data storage. See the
 # PORTDIR documentation for more information.
-#DISTDIR=/usr/portage/distfiles
+#DISTDIR=/var/cache/distfiles
 #
 # PKGDIR is the location of binary packages that you can have created
 # with '--buildpkg' or '-b' while emerging a package. This can get
 # up to several hundred megs, or even a few gigs. Note that
-# locations under /usr/portage are not necessarily safe for data
+# locations under /var/db/repos/gentoo are not necessarily safe for data
 # storage. See the PORTDIR documentation for more information.
-#PKGDIR=/usr/portage/packages
+#PKGDIR=/var/cache/binpkgs
 #
 # PORT_LOGDIR is the location where portage will store all the logs it
 # creates from each individual merge. They are stored as
diff --git a/lib/portage/__init__.py b/lib/portage/__init__.py
index 166bfc700..61a240100 100644
--- a/lib/portage/__init__.py
+++ b/lib/portage/__init__.py
@@ -133,7 +133,7 @@ except ImportError as e:
sys.stderr.write("!!! Failed to complete portage imports. There are 
internal modules for\n")
sys.stderr.write("!!! portage and failure here indicates that you have 
a problem with your\n")
sys.stderr.write("!!! installation of portage. Please try a rescue 
portage located in the\n")
-   sys.stderr.write("!!! portage tree under 
'/usr/portage/sys-apps/portage/files/' (default).\n")
+   sys.stderr.write("!!! portage tree under 
'/var/db/repos/gentoo/sys-apps/portage/files/' (default).\n")
sys.stderr.write("!!! There is a README.RESCUE file that details the 
steps required to perform\n")
sys.stderr.write("!!! a recovery of portage.\n")
sys.stderr.write(""+str(e)+"\n\n")
diff --git a/lib/portage/cache/flat_hash.py b/lib/portage/cache/flat_hash.py
index 79783245b..1ec32fb5b 100644
--- a/lib/portage/cache/flat_hash.py
+++ b/lib/portage/cache/flat_hash.py
@@ -144,7 +144,7 @@ class database(fs_template.FsBased):
# Only recurse 1 deep, in order to 
avoid iteration over
# entries from another nested cache 
instance. This can
# happen if the user nests an overlay 
inside
-   # /usr/portage/local as in bug #302764.
+   # /var/db/repos/gentoo/local as in bug 
#302764.
 

Re: [gentoo-portage-dev] [PATCH 2/2] Update /usr/portage references (bug 378603)

2018-08-05 Thread Ulrich Mueller
> On Sun, 5 Aug 2018, Zac Medico wrote:

> --- a/cnf/make.conf.example
> +++ b/cnf/make.conf.example
> [...]

> @@ -119,16 +119,16 @@
>  # fetched on demand for a given build. If you would like to
>  # selectively prune obsolete files from this directory, see
>  # eclean from the gentoolkit package. Note that locations under
> -# /usr/portage are not necessarily safe for data storage. See the
> +# /var/db/repos/gentoo are not necessarily safe for data storage. See the
>  # PORTDIR documentation for more information.
> -#DISTDIR=/usr/portage/distfiles
> +#DISTDIR=/var/db/repos/gentoo/distfiles

Shouldn't this be /var/cache/distfiles ...

>  #
>  # PKGDIR is the location of binary packages that you can have created
>  # with '--buildpkg' or '-b' while emerging a package. This can get
>  # up to several hundred megs, or even a few gigs. Note that
> -# locations under /usr/portage are not necessarily safe for data
> +# locations under /var/db/repos/gentoo are not necessarily safe for data
>  # storage. See the PORTDIR documentation for more information.
> -#PKGDIR=/usr/portage/packages
> +#PKGDIR=/var/db/repos/gentoo/packages

... and /var/cache/binpkgs?

> --- a/lib/portage/cache/flat_hash.py
> +++ b/lib/portage/cache/flat_hash.py
> @@ -144,7 +144,7 @@ class database(fs_template.FsBased):
>   # Only recurse 1 deep, in order to 
> avoid iteration over
>   # entries from another nested cache 
> instance. This can
>   # happen if the user nests an overlay 
> inside
> - # /usr/portage/local as in bug #302764.
> + # /var/db/repos/gentoo/local as in bug 
> #302764.

Shouldn't a local overlay be in /var/db/repos/local, but never inside
of the gentoo repo?

> --- a/man/make.conf.5
> +++ b/man/make.conf.5
> @@ -219,10 +219,10 @@ Use the \fBPORTAGE_RO_DISTDIRS\fR variable to specify 
> one or
>  more read-only directories containing distfiles.
>  
>  Note
> -that locations under /usr/portage are not necessarily safe for data storage.
> +that locations under /var/db/repos/gentoo are not necessarily safe for data 
> storage.

IMHO this statement should be made much stronger.

>  See the \fBPORTDIR\fR documentation for more information.
>  .br
> -Defaults to /usr/portage/distfiles.
> +Defaults to /var/db/repos/gentoo/distfiles.

/var/cache/distfiles

> @@ -800,10 +800,10 @@ to it's category. However, for backward compatibility 
> with the layout
>  used by older versions of portage, if the \fI${PKGDIR}/All\fR directory
>  exists then all packages will be stored inside of it and symlinks to
>  the packages will be created in the category subdirectories. Note
> -that locations under /usr/portage are not necessarily safe for data storage.
> +that locations under /var/db/repos/gentoo are not necessarily safe for data 
> storage.

See above.

>  See the \fBPORTDIR\fR documentation for more information.
>  .br
> -Defaults to /usr/portage/packages.
> +Defaults to /var/db/repos/gentoo/packages.

/var/cache/binpkgs

> --- a/man/quickpkg.1
> +++ b/man/quickpkg.1
> @@ -17,7 +17,7 @@ modified since they were first installed.
>  .br
>  The packages, after being created, will be placed in \fBPKGDIR\fR.
>  This variable is defined in \fBmake.conf\fR(5) and defaults to
> -/usr/portage/packages.
> +/var/db/repos/gentoo/packages.

See above.



[gentoo-portage-dev] [PATCH 1/2] Change /usr/portage council approved locations (bug 378603)

2018-08-05 Thread Zac Medico
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 0..e69de29bb
diff --git a/lib/portage/_compat_upgrade/default_locations.py 
b/lib/portage/_compat_upgrade/default_locations.py
new file mode 100644
index 0..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 = 

[gentoo-portage-dev] [PATCH 2/2] Update /usr/portage references (bug 378603)

2018-08-05 Thread Zac Medico
Update all relevant references in docs, messages, and comments
to refer to /var/db/repos/gentoo instead of /usr/portage.

Bug: https://bugs.gentoo.org/378603
---
 cnf/make.conf.example| 12 +--
 lib/portage/__init__.py  |  2 +-
 lib/portage/cache/flat_hash.py   |  2 +-
 lib/portage/tests/news/test_NewsItem.py  |  2 +-
 lib/portage/tests/resolver/ResolverPlayground.py |  2 +-
 lib/portage/xml/metadata.py  |  4 ++--
 man/ebuild.5 |  4 ++--
 man/emerge.1 |  6 +++---
 man/make.conf.5  | 20 +-
 man/portage.5| 26 
 man/quickpkg.1   |  2 +-
 repoman/lib/repoman/__init__.py  |  2 +-
 repoman/lib/repoman/checks/herds/herdbase.py |  2 +-
 13 files changed, 43 insertions(+), 43 deletions(-)

diff --git a/cnf/make.conf.example b/cnf/make.conf.example
index 04f3a0274..539ea4e9b 100644
--- a/cnf/make.conf.example
+++ b/cnf/make.conf.example
@@ -14,7 +14,7 @@
 # https://wiki.gentoo.org/wiki/Handbook:X86/Working/USE
 #
 # The available list of use flags with descriptions is in your portage tree.
-# Use 'less' to view them:  --> less /usr/portage/profiles/use.desc <--
+# Use 'less' to view them:  --> less /var/db/repos/gentoo/profiles/use.desc <--
 #
 # 'ufed' is an ncurses/dialog interface available in portage to make handling
 # useflags for you. 'emerge app-portage/ufed'
@@ -111,7 +111,7 @@
 # will protect the default locations of DISTDIR and PKGDIR, but users are
 # warned that any other locations inside PORTDIR are not necessarily safe
 # for data storage.
-#PORTDIR=/usr/portage
+#PORTDIR=/var/db/repos/gentoo
 #
 # DISTDIR is where all of the source code tarballs will be placed for
 # emerges. After packages are built, it is safe to remove any and
@@ -119,16 +119,16 @@
 # fetched on demand for a given build. If you would like to
 # selectively prune obsolete files from this directory, see
 # eclean from the gentoolkit package. Note that locations under
-# /usr/portage are not necessarily safe for data storage. See the
+# /var/db/repos/gentoo are not necessarily safe for data storage. See the
 # PORTDIR documentation for more information.
-#DISTDIR=/usr/portage/distfiles
+#DISTDIR=/var/db/repos/gentoo/distfiles
 #
 # PKGDIR is the location of binary packages that you can have created
 # with '--buildpkg' or '-b' while emerging a package. This can get
 # up to several hundred megs, or even a few gigs. Note that
-# locations under /usr/portage are not necessarily safe for data
+# locations under /var/db/repos/gentoo are not necessarily safe for data
 # storage. See the PORTDIR documentation for more information.
-#PKGDIR=/usr/portage/packages
+#PKGDIR=/var/db/repos/gentoo/packages
 #
 # PORT_LOGDIR is the location where portage will store all the logs it
 # creates from each individual merge. They are stored as
diff --git a/lib/portage/__init__.py b/lib/portage/__init__.py
index 166bfc700..61a240100 100644
--- a/lib/portage/__init__.py
+++ b/lib/portage/__init__.py
@@ -133,7 +133,7 @@ except ImportError as e:
sys.stderr.write("!!! Failed to complete portage imports. There are 
internal modules for\n")
sys.stderr.write("!!! portage and failure here indicates that you have 
a problem with your\n")
sys.stderr.write("!!! installation of portage. Please try a rescue 
portage located in the\n")
-   sys.stderr.write("!!! portage tree under 
'/usr/portage/sys-apps/portage/files/' (default).\n")
+   sys.stderr.write("!!! portage tree under 
'/var/db/repos/gentoo/sys-apps/portage/files/' (default).\n")
sys.stderr.write("!!! There is a README.RESCUE file that details the 
steps required to perform\n")
sys.stderr.write("!!! a recovery of portage.\n")
sys.stderr.write(""+str(e)+"\n\n")
diff --git a/lib/portage/cache/flat_hash.py b/lib/portage/cache/flat_hash.py
index 79783245b..1ec32fb5b 100644
--- a/lib/portage/cache/flat_hash.py
+++ b/lib/portage/cache/flat_hash.py
@@ -144,7 +144,7 @@ class database(fs_template.FsBased):
# Only recurse 1 deep, in order to 
avoid iteration over
# entries from another nested cache 
instance. This can
# happen if the user nests an overlay 
inside
-   # /usr/portage/local as in bug #302764.
+   # /var/db/repos/gentoo/local as in bug 
#302764.
if depth < 1:
dirs.append((depth+1, p))
continue
diff --git 

[gentoo-portage-dev] [PATCH 0/2] Change /usr/portage council approved locations (bug 378603)

2018-08-05 Thread Zac Medico
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

Zac Medico (2):
  Change /usr/portage council approved locations (bug 378603)
  Update /usr/portage references (bug 378603)

 cnf/make.conf.example| 12 ++--
 cnf/make.globals |  4 +-
 cnf/repos.conf   |  2 +-
 lib/portage/__init__.py  |  2 +-
 lib/portage/_compat_upgrade/__init__.py  |  0
 lib/portage/_compat_upgrade/default_locations.py | 82 
 lib/portage/cache/flat_hash.py   |  2 +-
 lib/portage/tests/news/test_NewsItem.py  |  2 +-
 lib/portage/tests/resolver/ResolverPlayground.py |  2 +-
 lib/portage/xml/metadata.py  |  4 +-
 man/ebuild.5 |  4 +-
 man/emerge.1 |  6 +-
 man/make.conf.5  | 20 +++---
 man/portage.5| 26 
 man/quickpkg.1   |  2 +-
 repoman/lib/repoman/__init__.py  |  2 +-
 repoman/lib/repoman/checks/herds/herdbase.py |  2 +-
 17 files changed, 128 insertions(+), 46 deletions(-)
 create mode 100644 lib/portage/_compat_upgrade/__init__.py
 create mode 100644 lib/portage/_compat_upgrade/default_locations.py

-- 
2.16.4