* [gentoo-commits] proj/portage:master commit in: lib/portage/util/
@ 2022-06-07 23:48 Mike Gilbert
0 siblings, 0 replies; 47+ messages in thread
From: Mike Gilbert @ 2022-06-07 23:48 UTC (permalink / raw
To: gentoo-commits
commit: 92c63ef74039e2361a4912ead5416b08cdfa8ac8
Author: David Palao <david.palao <AT> gmail <DOT> com>
AuthorDate: Sun May 22 09:40:45 2022 +0000
Commit: Mike Gilbert <floppym <AT> gentoo <DOT> org>
CommitDate: Tue Jun 7 23:47:54 2022 +0000
URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=92c63ef7
refactor(mtimedb): some little changes:
- interpolated strings (%...) replaced by f-strings
- some little simplifications
- factor out some constants to prepare for unittesting
Signed-off-by: David Palao <david.palao <AT> gmail.com>
Signed-off-by: Mike Gilbert <floppym <AT> gentoo.org>
lib/portage/util/mtimedb.py | 44 ++++++++++++++++++++++----------------------
1 file changed, 22 insertions(+), 22 deletions(-)
diff --git a/lib/portage/util/mtimedb.py b/lib/portage/util/mtimedb.py
index 7a7fe6784..df9bd494c 100644
--- a/lib/portage/util/mtimedb.py
+++ b/lib/portage/util/mtimedb.py
@@ -23,7 +23,23 @@ from portage.localization import _
from portage.util import apply_secpass_permissions, atomic_ofstream, writemsg
+_MTIMEDBKEYS = {
+ "info",
+ "ldpath",
+ "resume",
+ "resume_backup",
+ "starttime",
+ "updates",
+ "version",
+}
+
+
class MtimeDB(dict):
+ """The MtimeDB class is used to interact with a file storing the
+ current resume lists.
+ It is a subclass of ``dict`` and it reads from/writes to JSON, by
+ default, althouth it can be configured to use ``pickle``.
+ """
# JSON read support has been available since portage-2.1.10.49.
_json_write = True
@@ -46,13 +62,13 @@ class MtimeDB(dict):
pass
else:
writemsg(
- _("!!! Error loading '%s': %s\n") % (filename, e), noiselevel=-1
+ _(f"!!! Error loading '{filename}': {e}\n"), noiselevel=-1
)
finally:
if f is not None:
f.close()
- d = None
+ d = {}
if content:
try:
d = json.loads(
@@ -75,12 +91,9 @@ class MtimeDB(dict):
raise
except Exception:
writemsg(
- _("!!! Error loading '%s': %s\n") % (filename, e), noiselevel=-1
+ _(f"!!! Error loading '{filename}': {e}\n"), noiselevel=-1
)
- if d is None:
- d = {}
-
if "old" in d:
d["updates"] = d["old"]
del d["old"]
@@ -92,22 +105,9 @@ class MtimeDB(dict):
for k in ("info", "ldpath", "updates"):
d.setdefault(k, {})
- mtimedbkeys = set(
- (
- "info",
- "ldpath",
- "resume",
- "resume_backup",
- "starttime",
- "updates",
- "version",
- )
- )
-
- for k in list(d):
- if k not in mtimedbkeys:
- writemsg(_("Deleting invalid mtimedb key: %s\n") % str(k))
- del d[k]
+ for k in (d.keys()-_MTIMEDBKEYS):
+ writemsg(_(f"Deleting invalid mtimedb key: {k}\n"))
+ del d[k]
self.update(d)
self._clean_data = copy.deepcopy(d)
^ permalink raw reply related [flat|nested] 47+ messages in thread
* [gentoo-commits] proj/portage:master commit in: lib/portage/util/
@ 2024-08-15 17:30 Mike Gilbert
0 siblings, 0 replies; 47+ messages in thread
From: Mike Gilbert @ 2024-08-15 17:30 UTC (permalink / raw
To: gentoo-commits
commit: 5ee1a193982fce006aefbd5a6c5907392016b44d
Author: mid-kid <esteve.varela <AT> gmail <DOT> com>
AuthorDate: Sat Aug 3 15:04:43 2024 +0000
Commit: Mike Gilbert <floppym <AT> gentoo <DOT> org>
CommitDate: Thu Aug 15 17:29:00 2024 +0000
URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=5ee1a193
Make portage.util.compression_probe work when ctypes is unavailable
This is useful for bootstrapping purposes, as _ctypes requires a dynamic
linker.
Closes: https://github.com/gentoo/portage/pull/1363
Signed-off-by: Mike Gilbert <floppym <AT> gentoo.org>
lib/portage/util/compression_probe.py | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/lib/portage/util/compression_probe.py b/lib/portage/util/compression_probe.py
index 0879754b21..268e5840cc 100644
--- a/lib/portage/util/compression_probe.py
+++ b/lib/portage/util/compression_probe.py
@@ -1,13 +1,13 @@
# Copyright 2015-2020 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2
-import ctypes
import errno
import re
from portage import _encodings, _unicode_encode
from portage.exception import FileNotFound, PermissionDenied
+from portage.util._ctypes import ctypes
_compressors = {
"bzip2": {
@@ -49,7 +49,7 @@ _compressors = {
# if the current architecture can support it, which is true when
# sizeof(long) is at least 8 bytes.
"decompress": "zstd -d"
- + (" --long=31" if ctypes.sizeof(ctypes.c_long) >= 8 else ""),
+ + (" --long=31" if ctypes and ctypes.sizeof(ctypes.c_long) >= 8 else ""),
"package": "app-arch/zstd",
},
}
^ permalink raw reply related [flat|nested] 47+ messages in thread
* [gentoo-commits] proj/portage:master commit in: lib/portage/util/
@ 2024-05-27 20:02 Zac Medico
0 siblings, 0 replies; 47+ messages in thread
From: Zac Medico @ 2024-05-27 20:02 UTC (permalink / raw
To: gentoo-commits
commit: de19f3a7215d64d22dcc0f779314de1f1199963f
Author: Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Mon May 27 18:47:30 2024 +0000
Commit: Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Mon May 27 20:01:49 2024 +0000
URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=de19f3a7
atomic_ofstream: Use mkstemp rather than getpid (pid namespace safety)
Bug: https://bugs.gentoo.org/851015
Signed-off-by: Zac Medico <zmedico <AT> gentoo.org>
lib/portage/util/__init__.py | 47 ++++++++++++++++++++++++++------------------
1 file changed, 28 insertions(+), 19 deletions(-)
diff --git a/lib/portage/util/__init__.py b/lib/portage/util/__init__.py
index 0c88068dda..f338f274aa 100644
--- a/lib/portage/util/__init__.py
+++ b/lib/portage/util/__init__.py
@@ -1,4 +1,4 @@
-# Copyright 2004-2023 Gentoo Authors
+# Copyright 2004-2024 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2
from portage.cache.mappings import UserDict
@@ -70,6 +70,7 @@ import shlex
import stat
import string
import sys
+import tempfile
import traceback
import glob
from typing import Optional, TextIO
@@ -1446,21 +1447,22 @@ class atomic_ofstream(AbstractContextManager, ObjectProxy):
if follow_links:
canonical_path = os.path.realpath(filename)
object.__setattr__(self, "_real_name", canonical_path)
- tmp_name = "%s.%i" % (canonical_path, portage.getpid())
+ parent, basename = os.path.split(canonical_path)
+ fd, tmp_name = tempfile.mkstemp(prefix=basename, dir=parent)
+ object.__setattr__(self, "_tmp_name", tmp_name)
try:
object.__setattr__(
self,
"_file",
open_func(
- _unicode_encode(
- tmp_name, encoding=_encodings["fs"], errors="strict"
- ),
+ fd,
mode=mode,
**kargs,
),
)
return
- except OSError as e:
+ except OSError:
+ os.close(fd)
if canonical_path == filename:
raise
# Ignore this error, since it's irrelevant
@@ -1468,16 +1470,22 @@ class atomic_ofstream(AbstractContextManager, ObjectProxy):
# new error if necessary.
object.__setattr__(self, "_real_name", filename)
- tmp_name = "%s.%i" % (filename, portage.getpid())
- object.__setattr__(
- self,
- "_file",
- open_func(
- _unicode_encode(tmp_name, encoding=_encodings["fs"], errors="strict"),
- mode=mode,
- **kargs,
- ),
- )
+ parent, basename = os.path.split(filename)
+ fd, tmp_name = tempfile.mkstemp(prefix=basename, dir=parent)
+ object.__setattr__(self, "_tmp_name", tmp_name)
+ try:
+ object.__setattr__(
+ self,
+ "_file",
+ open_func(
+ fd,
+ mode=mode,
+ **kargs,
+ ),
+ )
+ except OSError:
+ os.close(fd)
+ raise
def __exit__(self, exc_type, exc_val, exc_tb):
if exc_type is not None:
@@ -1498,13 +1506,14 @@ class atomic_ofstream(AbstractContextManager, ObjectProxy):
and performs the atomic replacement via os.rename(). If the abort()
method has been called, then the temp file is closed and removed."""
f = object.__getattribute__(self, "_file")
+ tmp_name = object.__getattribute__(self, "_tmp_name")
real_name = object.__getattribute__(self, "_real_name")
if not f.closed:
try:
f.close()
if not object.__getattribute__(self, "_aborted"):
try:
- apply_stat_permissions(f.name, os.stat(real_name))
+ apply_stat_permissions(tmp_name, os.stat(real_name))
except OperationNotPermitted:
pass
except FileNotFound:
@@ -1514,12 +1523,12 @@ class atomic_ofstream(AbstractContextManager, ObjectProxy):
pass
else:
raise
- os.rename(f.name, real_name)
+ os.rename(tmp_name, real_name)
finally:
# Make sure we cleanup the temp file
# even if an exception is raised.
try:
- os.unlink(f.name)
+ os.unlink(tmp_name)
except OSError as oe:
pass
^ permalink raw reply related [flat|nested] 47+ messages in thread
* [gentoo-commits] proj/portage:master commit in: lib/portage/util/
@ 2024-03-07 20:42 Mike Gilbert
0 siblings, 0 replies; 47+ messages in thread
From: Mike Gilbert @ 2024-03-07 20:42 UTC (permalink / raw
To: gentoo-commits
commit: b7e89f866a9a1d73ab72670d74e2292b05893849
Author: Mike Gilbert <floppym <AT> gentoo <DOT> org>
AuthorDate: Wed Mar 6 04:01:27 2024 +0000
Commit: Mike Gilbert <floppym <AT> gentoo <DOT> org>
CommitDate: Wed Mar 6 18:19:31 2024 +0000
URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=b7e89f86
util: set a timeout for urlopen calls
A hung urlopen call can cause emerge to produce no output when fetching
binhost data.
Bug: https://bugs.gentoo.org/926221
Signed-off-by: Mike Gilbert <floppym <AT> gentoo.org>
lib/portage/util/_urlopen.py | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/lib/portage/util/_urlopen.py b/lib/portage/util/_urlopen.py
index 22f0e08df0..d451a94a89 100644
--- a/lib/portage/util/_urlopen.py
+++ b/lib/portage/util/_urlopen.py
@@ -26,10 +26,10 @@ def have_pep_476():
return hasattr(__import__("ssl"), "_create_unverified_context")
-def urlopen(url, if_modified_since=None, headers={}, proxies=None):
+def urlopen(url, timeout=10, if_modified_since=None, headers={}, proxies=None):
parse_result = urllib_parse.urlparse(url)
if parse_result.scheme not in ("http", "https"):
- return _urlopen(url)
+ return _urlopen(url, timeout=timeout)
netloc = parse_result.netloc.rpartition("@")[-1]
url = urllib_parse.urlunparse(
@@ -59,7 +59,7 @@ def urlopen(url, if_modified_since=None, headers={}, proxies=None):
handlers.append(urllib_request.ProxyHandler(proxies))
opener = urllib_request.build_opener(*handlers)
- hdl = opener.open(request)
+ hdl = opener.open(request, timeout=timeout)
if hdl.headers.get("last-modified", ""):
try:
add_header = hdl.headers.add_header
^ permalink raw reply related [flat|nested] 47+ messages in thread
* [gentoo-commits] proj/portage:master commit in: lib/portage/util/
@ 2024-03-01 16:20 Mike Gilbert
0 siblings, 0 replies; 47+ messages in thread
From: Mike Gilbert @ 2024-03-01 16:20 UTC (permalink / raw
To: gentoo-commits
commit: d8089d1af39c80e1edfb1669ae92fef7ab30e08a
Author: Mike Gilbert <floppym <AT> gentoo <DOT> org>
AuthorDate: Fri Mar 1 15:49:26 2024 +0000
Commit: Mike Gilbert <floppym <AT> gentoo <DOT> org>
CommitDate: Fri Mar 1 16:19:55 2024 +0000
URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=d8089d1a
Improve whitespace handling when parsing /proc/self/mountinfo
Only break lines on "\n" (line feed).
Only split lines on " " (space).
Bug: https://bugs.gentoo.org/925888
Signed-off-by: Mike Gilbert <floppym <AT> gentoo.org>
lib/portage/util/writeable_check.py | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/lib/portage/util/writeable_check.py b/lib/portage/util/writeable_check.py
index 3427315cf7..ad1d9edff0 100644
--- a/lib/portage/util/writeable_check.py
+++ b/lib/portage/util/writeable_check.py
@@ -47,6 +47,7 @@ def linux_ro_checker(dir_list):
"/proc/self/mountinfo",
encoding=_encodings["content"],
errors="replace",
+ newline="\n",
) as f:
for line in f:
# we're interested in dir and both attr fields which always
@@ -58,7 +59,7 @@ def linux_ro_checker(dir_list):
# to the left of the ' - ', after the attr's, so split it there
mount = line.split(" - ", 1)
try:
- _dir, attr1 = mount[0].split()[4:6]
+ _dir, attr1 = mount[0].split(" ")[4:6]
except ValueError:
# If it raises ValueError we can simply ignore the line.
invalids.append(line)
@@ -68,10 +69,10 @@ def linux_ro_checker(dir_list):
# for example: 16 1 0:16 / /root rw,noatime - lxfs rw
if len(mount) > 1:
try:
- attr2 = mount[1].split()[2]
+ attr2 = mount[1].split(" ")[2]
except IndexError:
try:
- attr2 = mount[1].split()[1]
+ attr2 = mount[1].split(" ")[1]
except IndexError:
invalids.append(line)
continue
^ permalink raw reply related [flat|nested] 47+ messages in thread
* [gentoo-commits] proj/portage:master commit in: lib/portage/util/
@ 2024-02-09 8:22 Zac Medico
0 siblings, 0 replies; 47+ messages in thread
From: Zac Medico @ 2024-02-09 8:22 UTC (permalink / raw
To: gentoo-commits
commit: ba33bc425363977eaf549a087b2469720a79e2a4
Author: Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Thu Feb 8 06:46:04 2024 +0000
Commit: Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Fri Feb 9 08:19:00 2024 +0000
URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=ba33bc42
check_locale: Use multiprocessing.Process instead of os.fork()
Since os.fork() is unsafe in threaded processes, use
multiprocessing.Process instead. This way the fork will be
eliminated when the default multiprocessing start method
changes to "spawn".
TODO: Make async version of check_locale and call it from
EbuildPhase instead of config.environ(), since it's bad to
synchronously wait for the process in the main event loop
thread where config.environ() tends to be called.
Bug: https://bugs.gentoo.org/923841
Signed-off-by: Zac Medico <zmedico <AT> gentoo.org>
lib/portage/util/locale.py | 56 +++++++++++++++++++++++++++-------------------
1 file changed, 33 insertions(+), 23 deletions(-)
diff --git a/lib/portage/util/locale.py b/lib/portage/util/locale.py
index a620dbd544..b5da8d949b 100644
--- a/lib/portage/util/locale.py
+++ b/lib/portage/util/locale.py
@@ -9,7 +9,8 @@ locale.
import locale
import logging
-import os
+import multiprocessing
+import sys
import textwrap
import traceback
@@ -96,6 +97,24 @@ def _check_locale(silent):
return True
+def _set_and_check_locale(silent, env, mylocale):
+ try:
+ if env is not None:
+ try:
+ locale.setlocale(locale.LC_CTYPE, mylocale)
+ except locale.Error:
+ sys.exit(2)
+
+ ret = _check_locale(silent)
+ if ret is None:
+ sys.exit(2)
+ else:
+ sys.exit(0 if ret else 1)
+ except Exception:
+ traceback.print_exc()
+ sys.exit(2)
+
+
def check_locale(silent=False, env=None):
"""
Check whether the locale is sane. Returns True if it is, prints
@@ -116,29 +135,20 @@ def check_locale(silent=False, env=None):
except KeyError:
pass
- pid = os.fork()
- if pid == 0:
- try:
- if env is not None:
- try:
- locale.setlocale(locale.LC_CTYPE, portage._native_string(mylocale))
- except locale.Error:
- os._exit(2)
-
- ret = _check_locale(silent)
- if ret is None:
- os._exit(2)
- else:
- os._exit(0 if ret else 1)
- except Exception:
- traceback.print_exc()
- os._exit(2)
-
- pid2, ret = os.waitpid(pid, 0)
- assert pid == pid2
+ # TODO: Make async version of check_locale and call it from
+ # EbuildPhase instead of config.environ(), since it's bad to
+ # synchronously wait for the process in the main event loop
+ # thread where config.environ() tends to be called.
+ proc = multiprocessing.Process(
+ target=_set_and_check_locale,
+ args=(silent, env, None if env is None else portage._native_string(mylocale)),
+ )
+ proc.start()
+ proc.join()
+
pyret = None
- if os.WIFEXITED(ret):
- ret = os.WEXITSTATUS(ret)
+ if proc.exitcode >= 0:
+ ret = proc.exitcode
if ret != 2:
pyret = ret == 0
^ permalink raw reply related [flat|nested] 47+ messages in thread
* [gentoo-commits] proj/portage:master commit in: lib/portage/util/
@ 2024-02-07 2:35 Zac Medico
0 siblings, 0 replies; 47+ messages in thread
From: Zac Medico @ 2024-02-07 2:35 UTC (permalink / raw
To: gentoo-commits
commit: fa8e8f1895ed889aece2f67725df55d6ccf127fb
Author: Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Sat Feb 3 23:41:45 2024 +0000
Commit: Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Wed Feb 7 00:55:46 2024 +0000
URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=fa8e8f18
socks5: Migrate to spawn returnproc parameter
Bug: https://bugs.gentoo.org/916566
Signed-off-by: Zac Medico <zmedico <AT> gentoo.org>
lib/portage/util/socks5.py | 36 +++++++++++++++++++-----------------
1 file changed, 19 insertions(+), 17 deletions(-)
diff --git a/lib/portage/util/socks5.py b/lib/portage/util/socks5.py
index fedb8599d5..6c68ff4106 100644
--- a/lib/portage/util/socks5.py
+++ b/lib/portage/util/socks5.py
@@ -1,10 +1,9 @@
# SOCKSv5 proxy manager for network-sandbox
-# Copyright 2015-2021 Gentoo Authors
+# Copyright 2015-2024 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2
import errno
import os
-import signal
import socket
import portage.data
@@ -22,7 +21,8 @@ class ProxyManager:
def __init__(self):
self.socket_path = None
- self._pids = []
+ self._proc = None
+ self._proc_waiter = None
def start(self, settings):
"""
@@ -51,9 +51,9 @@ class ProxyManager:
spawn_kwargs.update(
uid=portage_uid, gid=portage_gid, groups=userpriv_groups, umask=0o077
)
- self._pids = spawn(
+ self._proc = spawn(
[_python_interpreter, server_bin, self.socket_path],
- returnpid=True,
+ returnproc=True,
**spawn_kwargs,
)
@@ -61,12 +61,19 @@ class ProxyManager:
"""
Stop the SOCKSv5 server.
"""
- for p in self._pids:
- os.kill(p, signal.SIGINT)
- os.waitpid(p, 0)
+ if self._proc is not None:
+ self._proc.terminate()
+ loop = asyncio.get_event_loop()
+ if self._proc_waiter is None:
+ self._proc_waiter = asyncio.ensure_future(self._proc.wait(), loop)
+ if loop.is_running():
+ self._proc_waiter.add_done_callback(lambda future: future.result())
+ else:
+ loop.run_until_complete(self._proc_waiter)
self.socket_path = None
- self._pids = []
+ self._proc = None
+ self._proc_waiter = None
def is_running(self):
"""
@@ -80,16 +87,11 @@ class ProxyManager:
"""
Wait for the proxy socket to become ready. This method is a coroutine.
"""
+ if self._proc_waiter is None:
+ self._proc_waiter = asyncio.ensure_future(self._proc.wait())
while True:
- try:
- wait_retval = os.waitpid(self._pids[0], os.WNOHANG)
- except OSError as e:
- if e.errno == errno.EINTR:
- continue
- raise
-
- if wait_retval is not None and wait_retval != (0, 0):
+ if self._proc_waiter.done():
raise OSError(3, "No such process")
try:
^ permalink raw reply related [flat|nested] 47+ messages in thread
* [gentoo-commits] proj/portage:master commit in: lib/portage/util/
@ 2023-10-02 21:40 James Le Cuirot
0 siblings, 0 replies; 47+ messages in thread
From: James Le Cuirot @ 2023-10-02 21:40 UTC (permalink / raw
To: gentoo-commits
commit: 7ff8f85350ad3bf35cfdac1c471e399a04220ed1
Author: James Le Cuirot <chewi <AT> gentoo <DOT> org>
AuthorDate: Sun Oct 1 09:15:50 2023 +0000
Commit: James Le Cuirot <chewi <AT> gentoo <DOT> org>
CommitDate: Mon Oct 2 21:33:21 2023 +0000
URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=7ff8f853
env_update: Write prefixed paths to files and terminal where appropriate
This change is entirely cosmetic as it only affects comments and
informational messages.
I wasn't sure what to do in the FreeBSD/DragonFly case because
/var/run/ld-elf.so.hints probably isn't prefixed, so I left it alone.
Signed-off-by: James Le Cuirot <chewi <AT> gentoo.org>
lib/portage/util/env_update.py | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/lib/portage/util/env_update.py b/lib/portage/util/env_update.py
index a827963ab4..04fde5a52c 100644
--- a/lib/portage/util/env_update.py
+++ b/lib/portage/util/env_update.py
@@ -216,7 +216,7 @@ def _env_update(makelinks, target_root, prev_mtimes, contents, env, writemsg_lev
# ld.so.conf needs updating and ldconfig needs to be run
myfd = atomic_ofstream(ldsoconf_path)
myfd.write("# ld.so.conf autogenerated by env-update; make all changes to\n")
- myfd.write("# contents of /etc/env.d directory\n")
+ myfd.write(f"# contents of {eprefix}/etc/env.d directory.\n")
for x in specials["LDPATH"]:
myfd.write(x + "\n")
myfd.close()
@@ -242,7 +242,7 @@ def _env_update(makelinks, target_root, prev_mtimes, contents, env, writemsg_lev
newprelink.write(
"# prelink.conf autogenerated by env-update; make all changes to\n"
)
- newprelink.write("# contents of /etc/env.d directory\n")
+ newprelink.write(f"# contents of {eprefix}/etc/env.d directory\n")
for x in sorted(potential_lib_dirs) + ["bin", "sbin"]:
newprelink.write(f"-l /{x}\n")
@@ -286,7 +286,7 @@ def _env_update(makelinks, target_root, prev_mtimes, contents, env, writemsg_lev
== b"# prelink.conf autogenerated by env-update; make all changes to\n"
):
f = atomic_ofstream(prelink_conf)
- f.write("-c /etc/prelink.conf.d/*.conf\n")
+ f.write(f"-c {eprefix}/etc/prelink.conf.d/*.conf\n")
f.close()
except OSError as e:
if e.errno != errno.ENOENT:
@@ -361,7 +361,7 @@ def _env_update(makelinks, target_root, prev_mtimes, contents, env, writemsg_lev
# an older package installed ON TOP of a newer version will cause ldconfig
# to overwrite the symlinks we just made. -X means no links. After 'clean'
# we can safely create links.
- writemsg_level(_(f">>> Regenerating {target_root}etc/ld.so.cache...\n"))
+ writemsg_level(_(f">>> Regenerating {eroot}etc/ld.so.cache...\n"))
ret = subprocess.run(
[ldconfig, "-X", "-r", target_root], cwd="/"
).returncode
@@ -392,8 +392,8 @@ def _env_update(makelinks, target_root, prev_mtimes, contents, env, writemsg_lev
notice += "# DO NOT EDIT THIS FILE."
penvnotice = notice + " CHANGES TO STARTUP PROFILES\n"
cenvnotice = penvnotice[:]
- penvnotice += "# GO INTO /etc/profile NOT /etc/profile.env\n\n"
- cenvnotice += "# GO INTO /etc/csh.cshrc NOT /etc/csh.env\n\n"
+ penvnotice += f"# GO INTO {eprefix}/etc/profile NOT {eprefix}/etc/profile.env\n\n"
+ cenvnotice += f"# GO INTO {eprefix}/etc/csh.cshrc NOT {eprefix}/etc/csh.env\n\n"
# create /etc/profile.env for bash support
profile_env_path = os.path.join(eroot, "etc", "profile.env")
^ permalink raw reply related [flat|nested] 47+ messages in thread
* [gentoo-commits] proj/portage:master commit in: lib/portage/util/
@ 2023-07-26 14:30 Mike Gilbert
0 siblings, 0 replies; 47+ messages in thread
From: Mike Gilbert @ 2023-07-26 14:30 UTC (permalink / raw
To: gentoo-commits
commit: 581f923b9f888efc3313b6e06ba8a3cf84641d75
Author: Mike Gilbert <floppym <AT> gentoo <DOT> org>
AuthorDate: Wed Jul 26 14:27:48 2023 +0000
Commit: Mike Gilbert <floppym <AT> gentoo <DOT> org>
CommitDate: Wed Jul 26 14:27:48 2023 +0000
URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=581f923b
env_update: drop os.waitstatus_to_exitcode
The subprocess.run() function does this translation already.
Fixes: 3bba408e214ae27bdf924ba90ad4b0919a85f3c8
Signed-off-by: Mike Gilbert <floppym <AT> gentoo.org>
lib/portage/util/env_update.py | 1 -
1 file changed, 1 deletion(-)
diff --git a/lib/portage/util/env_update.py b/lib/portage/util/env_update.py
index 9d3b5bb25..a827963ab 100644
--- a/lib/portage/util/env_update.py
+++ b/lib/portage/util/env_update.py
@@ -381,7 +381,6 @@ def _env_update(makelinks, target_root, prev_mtimes, contents, env, writemsg_lev
cwd="/",
).returncode
- ret = os.waitstatus_to_exitcode(ret)
if ret > 0:
writemsg(f"!!! ldconfig failed with exit status {ret}\n", noiselevel=-1)
if ret < 0:
^ permalink raw reply related [flat|nested] 47+ messages in thread
* [gentoo-commits] proj/portage:master commit in: lib/portage/util/
@ 2023-07-26 7:58 Sam James
0 siblings, 0 replies; 47+ messages in thread
From: Sam James @ 2023-07-26 7:58 UTC (permalink / raw
To: gentoo-commits
commit: a777662890a7552927ee794506a92ddffc43523e
Author: Sam James <sam <AT> gentoo <DOT> org>
AuthorDate: Tue Jul 25 03:19:14 2023 +0000
Commit: Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Wed Jul 26 07:58:31 2023 +0000
URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=a7776628
lib: env_update: use more f-strings
Signed-off-by: Sam James <sam <AT> gentoo.org>
lib/portage/util/env_update.py | 10 ++++------
1 file changed, 4 insertions(+), 6 deletions(-)
diff --git a/lib/portage/util/env_update.py b/lib/portage/util/env_update.py
index a7015669e..9d3b5bb25 100644
--- a/lib/portage/util/env_update.py
+++ b/lib/portage/util/env_update.py
@@ -361,19 +361,17 @@ def _env_update(makelinks, target_root, prev_mtimes, contents, env, writemsg_lev
# an older package installed ON TOP of a newer version will cause ldconfig
# to overwrite the symlinks we just made. -X means no links. After 'clean'
# we can safely create links.
- writemsg_level(
- _(">>> Regenerating %setc/ld.so.cache...\n") % (target_root,)
- )
+ writemsg_level(_(f">>> Regenerating {target_root}etc/ld.so.cache...\n"))
ret = subprocess.run(
- [f"{ldconfig}", "-X", "-r", f"{target_root}"], cwd="/"
+ [ldconfig, "-X", "-r", target_root], cwd="/"
).returncode
elif ostype in ("FreeBSD", "DragonFly"):
writemsg_level(
- _(">>> Regenerating %svar/run/ld-elf.so.hints...\n") % target_root
+ _(f">>> Regenerating {target_root}var/run/ld-elf.so.hints...\n")
)
ret = subprocess.run(
[
- f"{ldconfig}",
+ ldconfig,
"-elf",
"-i",
"-f",
^ permalink raw reply related [flat|nested] 47+ messages in thread
* [gentoo-commits] proj/portage:master commit in: lib/portage/util/
@ 2023-07-26 7:58 Sam James
0 siblings, 0 replies; 47+ messages in thread
From: Sam James @ 2023-07-26 7:58 UTC (permalink / raw
To: gentoo-commits
commit: 3bba408e214ae27bdf924ba90ad4b0919a85f3c8
Author: Sam James <sam <AT> gentoo <DOT> org>
AuthorDate: Tue Jul 25 03:16:36 2023 +0000
Commit: Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Wed Jul 26 07:58:30 2023 +0000
URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=3bba408e
lib: env_update: port to subprocess
os.system is a bit janky here, let's use subprocess so we're not injecting
multiple commands.
Thanks to mgorny for the suggestion.
Bug: https://bugs.gentoo.org/910376
Signed-off-by: Sam James <sam <AT> gentoo.org>
lib/portage/util/env_update.py | 24 +++++++++++++++---------
1 file changed, 15 insertions(+), 9 deletions(-)
diff --git a/lib/portage/util/env_update.py b/lib/portage/util/env_update.py
index 5c2b2fdd5..a7015669e 100644
--- a/lib/portage/util/env_update.py
+++ b/lib/portage/util/env_update.py
@@ -6,7 +6,7 @@ __all__ = ["env_update"]
import errno
import glob
import stat
-import sys
+import subprocess
import time
import portage
@@ -364,18 +364,24 @@ def _env_update(makelinks, target_root, prev_mtimes, contents, env, writemsg_lev
writemsg_level(
_(">>> Regenerating %setc/ld.so.cache...\n") % (target_root,)
)
- ret = os.system(f"cd / ; {ldconfig} -X -r '{target_root}'")
+ ret = subprocess.run(
+ [f"{ldconfig}", "-X", "-r", f"{target_root}"], cwd="/"
+ ).returncode
elif ostype in ("FreeBSD", "DragonFly"):
writemsg_level(
_(">>> Regenerating %svar/run/ld-elf.so.hints...\n") % target_root
)
- ret = os.system(
- (
- "cd / ; %s -elf -i "
- + "-f '%svar/run/ld-elf.so.hints' '%setc/ld.so.conf'"
- )
- % (ldconfig, target_root, target_root)
- )
+ ret = subprocess.run(
+ [
+ f"{ldconfig}",
+ "-elf",
+ "-i",
+ "-f",
+ f"{target_root}var/run/ld-elf.so.hints",
+ f"{target_root}etc/ld.so.conf",
+ ],
+ cwd="/",
+ ).returncode
ret = os.waitstatus_to_exitcode(ret)
if ret > 0:
^ permalink raw reply related [flat|nested] 47+ messages in thread
* [gentoo-commits] proj/portage:master commit in: lib/portage/util/
@ 2023-06-29 8:19 Sam James
0 siblings, 0 replies; 47+ messages in thread
From: Sam James @ 2023-06-29 8:19 UTC (permalink / raw
To: gentoo-commits
commit: f95d78c1636d081b906e613a0f26e2c318c80c5d
Author: Berin Aniesh <berinaniesh <AT> gmail <DOT> com>
AuthorDate: Sun Jun 18 04:53:01 2023 +0000
Commit: Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Thu Jun 29 08:19:28 2023 +0000
URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=f95d78c1
ExtractKernelVersion.py: Remove repeated/unreachable code
Signed-off-by: Berin Aniesh <berinaniesh <AT> gmail.com>
Signed-off-by: Sam James <sam <AT> gentoo.org>
| 4 ----
1 file changed, 4 deletions(-)
--git a/lib/portage/util/ExtractKernelVersion.py b/lib/portage/util/ExtractKernelVersion.py
index 5914dd020..6a6501b5d 100644
--- a/lib/portage/util/ExtractKernelVersion.py
+++ b/lib/portage/util/ExtractKernelVersion.py
@@ -31,16 +31,12 @@ def ExtractKernelVersion(base_dir):
)
except OSError as details:
return (None, str(details))
- except OSError as details:
- return (None, str(details))
try:
for i in range(4):
lines.append(f.readline())
except OSError as details:
return (None, str(details))
- except OSError as details:
- return (None, str(details))
finally:
f.close()
^ permalink raw reply related [flat|nested] 47+ messages in thread
* [gentoo-commits] proj/portage:master commit in: lib/portage/util/
@ 2023-06-06 6:52 Sam James
0 siblings, 0 replies; 47+ messages in thread
From: Sam James @ 2023-06-06 6:52 UTC (permalink / raw
To: gentoo-commits
commit: 0911ea932d81020abe87774ff4819499c0cb891a
Author: Berin Aniesh <berinaniesh <AT> gmail <DOT> com>
AuthorDate: Tue Jun 6 06:16:35 2023 +0000
Commit: Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Tue Jun 6 06:52:40 2023 +0000
URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=0911ea93
portage.util.writemsg_level: Add return type type annotation
Signed-off-by: Berin Aniesh <berinaniesh <AT> gmail.com>
Closes: https://github.com/gentoo/portage/pull/1048
Signed-off-by: Sam James <sam <AT> gentoo.org>
lib/portage/util/__init__.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/lib/portage/util/__init__.py b/lib/portage/util/__init__.py
index f0115aea3..1f8c9e94f 100644
--- a/lib/portage/util/__init__.py
+++ b/lib/portage/util/__init__.py
@@ -130,7 +130,7 @@ def writemsg_stdout(mystr: str, noiselevel: int = 0) -> None:
writemsg(mystr, noiselevel=noiselevel, fd=sys.stdout)
-def writemsg_level(msg: str, level: int = 0, noiselevel: int = 0):
+def writemsg_level(msg: str, level: int = 0, noiselevel: int = 0) -> None:
"""
Show a message for the given level as defined by the logging module
(default is 0).
^ permalink raw reply related [flat|nested] 47+ messages in thread
* [gentoo-commits] proj/portage:master commit in: lib/portage/util/
@ 2022-12-31 13:33 Sam James
0 siblings, 0 replies; 47+ messages in thread
From: Sam James @ 2022-12-31 13:33 UTC (permalink / raw
To: gentoo-commits
commit: 118df436abd49eecfeaf95df8a052861d463a896
Author: Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Fri Dec 30 10:57:12 2022 +0000
Commit: Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Sat Dec 31 13:33:04 2022 +0000
URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=118df436
Report a warning when unaccelerated Whirlpool is being used
The warning serves two purposes: it informs the user that they should
expect very slow hashing (i.e. Portage did not hang) and that they
should inform the repository owner about the problem. Far from ideal
but probably good enough given how rare Whirlpool-only ebuilds are.
Signed-off-by: Michał Górny <mgorny <AT> gentoo.org>
Closes: https://github.com/gentoo/portage/pull/967
Signed-off-by: Sam James <sam <AT> gentoo.org>
lib/portage/util/whirlpool.py | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/lib/portage/util/whirlpool.py b/lib/portage/util/whirlpool.py
index 8454a874a..d26780604 100644
--- a/lib/portage/util/whirlpool.py
+++ b/lib/portage/util/whirlpool.py
@@ -30,6 +30,10 @@
# pylint: disable=mixed-indentation
+import warnings
+
+from portage.localization import _
+
try:
from ._whirlpool import Whirlpool as WhirlpoolExt
except ImportError:
@@ -47,6 +51,13 @@ class PyWhirlpool:
hashed."""
def __init__(self, arg=b""):
+ warnings.warn(
+ _(
+ "The last-resort unaccelerated Whirlpool implementation is "
+ "being used. It is known to be absurdly slow. Please report "
+ "that the Whirlpool hash is deprecated to the repository owner."
+ )
+ )
self.ctx = WhirlpoolStruct()
self.update(arg)
^ permalink raw reply related [flat|nested] 47+ messages in thread
* [gentoo-commits] proj/portage:master commit in: lib/portage/util/
@ 2022-06-07 23:48 Mike Gilbert
0 siblings, 0 replies; 47+ messages in thread
From: Mike Gilbert @ 2022-06-07 23:48 UTC (permalink / raw
To: gentoo-commits
commit: f4fd289c7e3cbbd1a17a1510b1b126d314eea053
Author: David Palao <david.palao <AT> gmail <DOT> com>
AuthorDate: Tue May 31 15:52:56 2022 +0000
Commit: Mike Gilbert <floppym <AT> gentoo <DOT> org>
CommitDate: Tue Jun 7 23:47:56 2022 +0000
URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=f4fd289c
improvement(mtimedb): using is_readonly instead "if not self.filename"
Signed-off-by: David Palao <david.palao <AT> gmail.com>
Signed-off-by: Mike Gilbert <floppym <AT> gentoo.org>
lib/portage/util/mtimedb.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/lib/portage/util/mtimedb.py b/lib/portage/util/mtimedb.py
index 9884746f3..497c01e05 100644
--- a/lib/portage/util/mtimedb.py
+++ b/lib/portage/util/mtimedb.py
@@ -124,7 +124,7 @@ class MtimeDB(dict):
self._clean_data = copy.deepcopy(d)
def commit(self):
- if not self.filename:
+ if self.is_readonly:
return
d = {}
d.update(self)
^ permalink raw reply related [flat|nested] 47+ messages in thread
* [gentoo-commits] proj/portage:master commit in: lib/portage/util/
@ 2022-05-21 10:12 Michał Górny
0 siblings, 0 replies; 47+ messages in thread
From: Michał Górny @ 2022-05-21 10:12 UTC (permalink / raw
To: gentoo-commits
commit: 1f33f97b9e9c132d77d586d10bfe6ba0d3123050
Author: Thomas Bracht Laumann Jespersen <t <AT> laumann <DOT> xyz>
AuthorDate: Thu May 19 09:50:05 2022 +0000
Commit: Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Sat May 21 10:11:50 2022 +0000
URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=1f33f97b
lib/portage/util: fix bundled whirlpool on empty bytestring input
The WhirlpoolAdd function did not consider zero-length input, so calls
to update(b'') would produce out-of-bounds errors. This was not covered
by any tests, because the constructor implicitly skipped the call to
update on zero-length input.
Add check for zero-length input to WhirlpoolAdd, and have the Whirlpool
constructor skip calling update() only if arg is None.
Closes: https://bugs.gentoo.org/846389
Signed-off-by: Thomas Bracht Laumann Jespersen <t <AT> laumann.xyz>
Closes: https://github.com/gentoo/portage/pull/832
Signed-off-by: Michał Górny <mgorny <AT> gentoo.org>
lib/portage/util/whirlpool.py | 16 +++++++++++-----
1 file changed, 11 insertions(+), 5 deletions(-)
diff --git a/lib/portage/util/whirlpool.py b/lib/portage/util/whirlpool.py
index de344d8eb..9178d70c7 100644
--- a/lib/portage/util/whirlpool.py
+++ b/lib/portage/util/whirlpool.py
@@ -37,11 +37,9 @@ class Whirlpool:
may be provided; if present, this string will be automatically
hashed."""
- def __init__(self, arg=None):
+ def __init__(self, arg=b""):
self.ctx = WhirlpoolStruct()
- if arg:
- self.update(arg)
- self.digest_status = 0
+ self.update(arg)
def update(self, arg):
"""update(arg)"""
@@ -71,7 +69,7 @@ class Whirlpool:
return copy.deepcopy(self)
-def new(init=None):
+def new(init=b""):
"""Return a new Whirlpool object. An optional string argument
may be provided; if present, this string will be automatically
hashed."""
@@ -2183,6 +2181,8 @@ def WhirlpoolInit(ctx):
def WhirlpoolAdd(source, sourceBits, ctx):
if not isinstance(source, bytes):
raise TypeError("Expected %s, got %s" % (bytes, type(source)))
+ if sourceBits == 0:
+ return
carry = 0
value = sourceBits
@@ -2350,3 +2350,9 @@ if __name__ == "__main__":
Whirlpool(b"").hexdigest()
== "19fa61d75522a4669b44e39c1d2e1726c530232130d407f89afee0964997f7a73e83be698b288febcf88e3e03c4f0757ea8964e59b63d93708b138cc42a66eb3"
)
+ w = Whirlpool()
+ w.update(b"")
+ assert (
+ w.hexdigest()
+ == "19fa61d75522a4669b44e39c1d2e1726c530232130d407f89afee0964997f7a73e83be698b288febcf88e3e03c4f0757ea8964e59b63d93708b138cc42a66eb3"
+ )
^ permalink raw reply related [flat|nested] 47+ messages in thread
* [gentoo-commits] proj/portage:master commit in: lib/portage/util/
@ 2022-04-15 2:46 Sam James
0 siblings, 0 replies; 47+ messages in thread
From: Sam James @ 2022-04-15 2:46 UTC (permalink / raw
To: gentoo-commits
commit: fa82725ba03ffa5edf0b82db7307c87fc97e83f2
Author: Mike Frysinger <vapier <AT> chromium <DOT> org>
AuthorDate: Wed Mar 30 06:32:07 2022 +0000
Commit: Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Fri Apr 15 02:46:19 2022 +0000
URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=fa82725b
movefile: merge symlinks atomically
Since POSIX allows renaming symlinks with symlinks, use that to get
atomic updates. This is faster and less flaky to parallel processes:
removing a live symlink and then recreating it leaves a small window
where other things might try to use it but fail.
[sam: cherry-picked from chromiumos' third_party/portage_tool repo]
(cherry picked from commit cherry-pick 80ed2dac95db81acac8043e6685d0a853a08d268)
Bug: https://bugs.gentoo.org/836400
Signed-off-by: Sam James <sam <AT> gentoo.org>
Closes: https://github.com/gentoo/portage/pull/816
Signed-off-by: Sam James <sam <AT> gentoo.org>
lib/portage/util/movefile.py | 16 +++++++++++++---
1 file changed, 13 insertions(+), 3 deletions(-)
diff --git a/lib/portage/util/movefile.py b/lib/portage/util/movefile.py
index ddafe5571..4dc08af26 100644
--- a/lib/portage/util/movefile.py
+++ b/lib/portage/util/movefile.py
@@ -171,7 +171,7 @@ def movefile(
bsd_chflags.chflags(os.path.dirname(dest), 0)
if destexists:
- if stat.S_ISLNK(dstat[stat.ST_MODE]):
+ if not stat.S_ISLNK(sstat[stat.ST_MODE]) and stat.S_ISLNK(dstat[stat.ST_MODE]):
try:
os.unlink(dest)
destexists = 0
@@ -185,8 +185,18 @@ def movefile(
target = os.readlink(src)
if mysettings and "D" in mysettings and target.startswith(mysettings["D"]):
target = target[len(mysettings["D"]) - 1 :]
- if destexists and not stat.S_ISDIR(dstat[stat.ST_MODE]):
- os.unlink(dest)
+ # Atomically update the path if it exists.
+ try:
+ os.rename(src, dest)
+ return sstat.st_mtime_ns
+ except OSError:
+ # If it failed due to cross-link device, fallthru below.
+ # Clear the target first so we can create it.
+ try:
+ os.unlink(dest)
+ except FileNotFoundError:
+ pass
+
try:
if selinux_enabled:
selinux.symlink(target, dest, src)
^ permalink raw reply related [flat|nested] 47+ messages in thread
* [gentoo-commits] proj/portage:master commit in: lib/portage/util/
@ 2021-05-24 6:13 Zac Medico
0 siblings, 0 replies; 47+ messages in thread
From: Zac Medico @ 2021-05-24 6:13 UTC (permalink / raw
To: gentoo-commits
commit: 21739ea1e0a793e207b7ae28d524e45582d9b2ca
Author: Florian Schmaus <flo <AT> geekplace <DOT> eu>
AuthorDate: Tue Apr 27 11:02:56 2021 +0000
Commit: Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Mon May 24 06:13:07 2021 +0000
URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=21739ea1
env-update: skip PATH in systemd user environment definition
Having PATH in the systemd user environment created by env-update
makes it impossible to use "systemctl --user import-environment PATH"
to set PATH in systemd user units according to the current value of
PATH. Using "systemctl --user import-environment PATH" is a well known
idiom, and hence should work. Therefore, we skip the creation of the
PATH entry by env-update.
Closes: https://github.com/gentoo/portage/pull/701
Signed-off-by: Florian Schmaus <flo <AT> geekplace.eu>
Signed-off-by: Zac Medico <zmedico <AT> gentoo.org>
lib/portage/util/env_update.py | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/lib/portage/util/env_update.py b/lib/portage/util/env_update.py
index 5588931a8..abf261fbc 100644
--- a/lib/portage/util/env_update.py
+++ b/lib/portage/util/env_update.py
@@ -367,6 +367,11 @@ def _env_update(makelinks, target_root, prev_mtimes, contents, env,
systemd_gentoo_env.write(senvnotice)
for env_key in env_keys:
+ # Skip PATH since this makes it impossible to use
+ # "systemctl --user import-environment PATH".
+ if env_key == 'PATH':
+ continue
+
env_key_value = env[env_key]
# Skip variables with the empty string
^ permalink raw reply related [flat|nested] 47+ messages in thread
* [gentoo-commits] proj/portage:master commit in: lib/portage/util/
@ 2021-03-07 16:04 Zac Medico
0 siblings, 0 replies; 47+ messages in thread
From: Zac Medico @ 2021-03-07 16:04 UTC (permalink / raw
To: gentoo-commits
commit: b08e21e5a7e07da02a2d64dac80635ca82a12979
Author: Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Sun Mar 7 16:00:54 2021 +0000
Commit: Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Sun Mar 7 16:01:47 2021 +0000
URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=b08e21e5
bin_entry_point: fix sys.argv[0] for non-python programs
Signed-off-by: Zac Medico <zmedico <AT> gentoo.org>
lib/portage/util/bin_entry_point.py | 1 +
1 file changed, 1 insertion(+)
diff --git a/lib/portage/util/bin_entry_point.py b/lib/portage/util/bin_entry_point.py
index 7d359052e..3ead95d98 100644
--- a/lib/portage/util/bin_entry_point.py
+++ b/lib/portage/util/bin_entry_point.py
@@ -28,6 +28,7 @@ def bin_entry_point():
script_path,
] + sys.argv[1:]
os.execvp(sys.argv[0], sys.argv)
+ sys.argv[0] = script_path
os.execvp(sys.argv[0], sys.argv)
else:
print("File not found:", script_path, file=sys.stderr)
^ permalink raw reply related [flat|nested] 47+ messages in thread
* [gentoo-commits] proj/portage:master commit in: lib/portage/util/
@ 2021-03-06 20:21 Zac Medico
0 siblings, 0 replies; 47+ messages in thread
From: Zac Medico @ 2021-03-06 20:21 UTC (permalink / raw
To: gentoo-commits
commit: 4f60b68fca342cc92ed7729d241e2c60132876e8
Author: Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Sat Mar 6 20:20:30 2021 +0000
Commit: Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Sat Mar 6 20:20:46 2021 +0000
URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=4f60b68f
bin_entry_point: handle versioned python shebangs
Signed-off-by: Zac Medico <zmedico <AT> gentoo.org>
lib/portage/util/bin_entry_point.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/lib/portage/util/bin_entry_point.py b/lib/portage/util/bin_entry_point.py
index ce95231eb..7d359052e 100644
--- a/lib/portage/util/bin_entry_point.py
+++ b/lib/portage/util/bin_entry_point.py
@@ -20,7 +20,7 @@ def bin_entry_point():
if os.access(script_path, os.X_OK):
with open(script_path, "rt") as f:
shebang = f.readline()
- python_match = re.search(r"/python\s+([^/]*)\s+$", shebang)
+ python_match = re.search(r"/python[\d\.]*\s+([^/]*)\s+$", shebang)
if python_match:
sys.argv = [
os.path.join(os.path.dirname(sys.argv[0]), "python"),
^ permalink raw reply related [flat|nested] 47+ messages in thread
* [gentoo-commits] proj/portage:master commit in: lib/portage/util/
@ 2021-03-03 12:20 Zac Medico
0 siblings, 0 replies; 47+ messages in thread
From: Zac Medico @ 2021-03-03 12:20 UTC (permalink / raw
To: gentoo-commits
commit: ce86ddecf168af06926f95092f29fa19c1f3885a
Author: Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Wed Mar 3 10:46:02 2021 +0000
Commit: Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Wed Mar 3 12:09:58 2021 +0000
URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=ce86ddec
bin_entry_point: rewrite python shebangs for venv
Signed-off-by: Zac Medico <zmedico <AT> gentoo.org>
lib/portage/util/bin_entry_point.py | 12 +++++++++++-
1 file changed, 11 insertions(+), 1 deletion(-)
diff --git a/lib/portage/util/bin_entry_point.py b/lib/portage/util/bin_entry_point.py
index 7f2ee3849..ce95231eb 100644
--- a/lib/portage/util/bin_entry_point.py
+++ b/lib/portage/util/bin_entry_point.py
@@ -3,6 +3,7 @@
__all__ = ["bin_entry_point"]
+import re
import sys
from portage.const import PORTAGE_BIN_PATH
@@ -17,7 +18,16 @@ def bin_entry_point():
"""
script_path = os.path.join(PORTAGE_BIN_PATH, os.path.basename(sys.argv[0]))
if os.access(script_path, os.X_OK):
- sys.argv[0] = script_path
+ with open(script_path, "rt") as f:
+ shebang = f.readline()
+ python_match = re.search(r"/python\s+([^/]*)\s+$", shebang)
+ if python_match:
+ sys.argv = [
+ os.path.join(os.path.dirname(sys.argv[0]), "python"),
+ python_match.group(1),
+ script_path,
+ ] + sys.argv[1:]
+ os.execvp(sys.argv[0], sys.argv)
os.execvp(sys.argv[0], sys.argv)
else:
print("File not found:", script_path, file=sys.stderr)
^ permalink raw reply related [flat|nested] 47+ messages in thread
* [gentoo-commits] proj/portage:master commit in: lib/portage/util/
@ 2021-02-25 10:21 Zac Medico
0 siblings, 0 replies; 47+ messages in thread
From: Zac Medico @ 2021-02-25 10:21 UTC (permalink / raw
To: gentoo-commits
commit: 061a895f7b0a310b374dff03af622b11146337d4
Author: Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Thu Feb 25 10:14:18 2021 +0000
Commit: Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Thu Feb 25 10:18:02 2021 +0000
URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=061a895f
iter_parents: prevent infinite loop after empty os.path.dirname result
Reported-by: dkjii <AT> cock.li
Bug: https://bugs.gentoo.org/772806
Signed-off-by: Zac Medico <zmedico <AT> gentoo.org>
lib/portage/util/path.py | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/lib/portage/util/path.py b/lib/portage/util/path.py
index a0b96c7f3..f174bd71f 100644
--- a/lib/portage/util/path.py
+++ b/lib/portage/util/path.py
@@ -1,4 +1,4 @@
-# Copyright 2014 Gentoo Foundation
+# Copyright 2014-2021 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2
import errno
@@ -45,4 +45,6 @@ def iter_parents(path):
yield path
while path != os.sep:
path = os.path.dirname(path)
+ if not path:
+ break
yield path
^ permalink raw reply related [flat|nested] 47+ messages in thread
* [gentoo-commits] proj/portage:master commit in: lib/portage/util/
@ 2021-01-19 0:50 Zac Medico
0 siblings, 0 replies; 47+ messages in thread
From: Zac Medico @ 2021-01-19 0:50 UTC (permalink / raw
To: gentoo-commits
commit: 4f77b1ca80a7ae7987c0d3e0ef988b3c06d18744
Author: Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Tue Jan 19 00:50:13 2021 +0000
Commit: Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Tue Jan 19 00:50:26 2021 +0000
URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=4f77b1ca
ProxyManager: remove unused loop parameter
Signed-off-by: Zac Medico <zmedico <AT> gentoo.org>
lib/portage/util/socks5.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/lib/portage/util/socks5.py b/lib/portage/util/socks5.py
index ddf6bb4d0..4aa08e1ab 100644
--- a/lib/portage/util/socks5.py
+++ b/lib/portage/util/socks5.py
@@ -73,7 +73,7 @@ class ProxyManager:
"""
return self.socket_path is not None
- async def ready(self, loop=None):
+ async def ready(self):
"""
Wait for the proxy socket to become ready. This method is a coroutine.
"""
^ permalink raw reply related [flat|nested] 47+ messages in thread
* [gentoo-commits] proj/portage:master commit in: lib/portage/util/
@ 2021-01-02 1:18 Zac Medico
0 siblings, 0 replies; 47+ messages in thread
From: Zac Medico @ 2021-01-02 1:18 UTC (permalink / raw
To: gentoo-commits
commit: 84b555bb33f24b7628bebbaa16fe43325b7823a9
Author: Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Sat Jan 2 01:18:30 2021 +0000
Commit: Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Sat Jan 2 01:18:43 2021 +0000
URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=84b555bb
lib/portage/util/__init__.py: Fix useless-return
Signed-off-by: Zac Medico <zmedico <AT> gentoo.org>
lib/portage/util/__init__.py | 1 -
1 file changed, 1 deletion(-)
diff --git a/lib/portage/util/__init__.py b/lib/portage/util/__init__.py
index bedcbcfe6..b0922bf09 100644
--- a/lib/portage/util/__init__.py
+++ b/lib/portage/util/__init__.py
@@ -1293,7 +1293,6 @@ class atomic_ofstream(AbstractContextManager, ObjectProxy):
self.abort()
else:
self.close()
- return None
def _get_target(self):
return object.__getattribute__(self, '_file')
^ permalink raw reply related [flat|nested] 47+ messages in thread
* [gentoo-commits] proj/portage:master commit in: lib/portage/util/
@ 2020-12-31 2:17 Zac Medico
0 siblings, 0 replies; 47+ messages in thread
From: Zac Medico @ 2020-12-31 2:17 UTC (permalink / raw
To: gentoo-commits
commit: 1574ae127b270739c4293271c959d1d981684906
Author: Florian Schmaus <flo <AT> geekplace <DOT> eu>
AuthorDate: Fri Dec 18 18:46:39 2020 +0000
Commit: Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Thu Dec 31 01:43:22 2020 +0000
URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=1574ae12
env_update: use "with statement" on atomic_ofstream
Signed-off-by: Florian Schmaus <flo <AT> geekplace.eu>
Signed-off-by: Zac Medico <zmedico <AT> gentoo.org>
lib/portage/util/env_update.py | 30 ++++++++++++------------------
1 file changed, 12 insertions(+), 18 deletions(-)
diff --git a/lib/portage/util/env_update.py b/lib/portage/util/env_update.py
index dec086cf8..5588931a8 100644
--- a/lib/portage/util/env_update.py
+++ b/lib/portage/util/env_update.py
@@ -342,18 +342,17 @@ def _env_update(makelinks, target_root, prev_mtimes, contents, env,
#create /etc/profile.env for bash support
profile_env_path = os.path.join(eroot, "etc", "profile.env")
- outfile = atomic_ofstream(profile_env_path)
- outfile.write(penvnotice)
-
- env_keys = [x for x in env if x != "LDPATH"]
- env_keys.sort()
- for k in env_keys:
- v = env[k]
- if v.startswith('$') and not v.startswith('${'):
- outfile.write("export %s=$'%s'\n" % (k, v[1:]))
- else:
- outfile.write("export %s='%s'\n" % (k, v))
- outfile.close()
+ with atomic_ofstream(profile_env_path) as outfile:
+ outfile.write(penvnotice)
+
+ env_keys = [x for x in env if x != "LDPATH"]
+ env_keys.sort()
+ for k in env_keys:
+ v = env[k]
+ if v.startswith('$') and not v.startswith('${'):
+ outfile.write("export %s=$'%s'\n" % (k, v[1:]))
+ else:
+ outfile.write("export %s='%s'\n" % (k, v))
# Create the systemd user environment configuration file
# /etc/environment.d/10-gentoo-env.conf with the
@@ -363,8 +362,7 @@ def _env_update(makelinks, target_root, prev_mtimes, contents, env,
systemd_gentoo_env_path = os.path.join(systemd_environment_dir,
"10-gentoo-env.conf")
- systemd_gentoo_env = atomic_ofstream(systemd_gentoo_env_path)
- try:
+ with atomic_ofstream(systemd_gentoo_env_path) as systemd_gentoo_env:
senvnotice = notice + "\n\n"
systemd_gentoo_env.write(senvnotice)
@@ -384,10 +382,6 @@ def _env_update(makelinks, target_root, prev_mtimes, contents, env,
line = f"{env_key}={env_key_value}\n"
systemd_gentoo_env.write(line)
- except:
- systemd_gentoo_env.abort()
- raise
- systemd_gentoo_env.close()
#create /etc/csh.env for (t)csh support
outfile = atomic_ofstream(os.path.join(eroot, "etc", "csh.env"))
^ permalink raw reply related [flat|nested] 47+ messages in thread
* [gentoo-commits] proj/portage:master commit in: lib/portage/util/
@ 2020-12-31 2:17 Zac Medico
0 siblings, 0 replies; 47+ messages in thread
From: Zac Medico @ 2020-12-31 2:17 UTC (permalink / raw
To: gentoo-commits
commit: e93e6d65fa1ca75f676a227f7918f8b6d747425c
Author: Florian Schmaus <flo <AT> geekplace <DOT> eu>
AuthorDate: Fri Dec 18 18:46:38 2020 +0000
Commit: Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Thu Dec 31 01:40:42 2020 +0000
URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=e93e6d65
Make atomic_ofstream a Context Manager
This allows using a "with statement" together with instances of
atomic_ofstream. Allowing for more readable, less error prone and
shorter code.
Signed-off-by: Florian Schmaus <flo <AT> geekplace.eu>
Signed-off-by: Zac Medico <zmedico <AT> gentoo.org>
lib/portage/util/__init__.py | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
diff --git a/lib/portage/util/__init__.py b/lib/portage/util/__init__.py
index 0412b2b59..bedcbcfe6 100644
--- a/lib/portage/util/__init__.py
+++ b/lib/portage/util/__init__.py
@@ -11,6 +11,7 @@ __all__ = ['apply_permissions', 'apply_recursive_permissions',
'stack_dicts', 'stack_lists', 'unique_array', 'unique_everseen', 'varexpand',
'write_atomic', 'writedict', 'writemsg', 'writemsg_level', 'writemsg_stdout']
+from contextlib import AbstractContextManager
from copy import deepcopy
import errno
import io
@@ -1246,7 +1247,7 @@ def apply_secpass_permissions(filename, uid=-1, gid=-1, mode=-1, mask=-1,
stat_cached=stat_cached, follow_links=follow_links)
return all_applied
-class atomic_ofstream(ObjectProxy):
+class atomic_ofstream(AbstractContextManager, ObjectProxy):
"""Write a file atomically via os.rename(). Atomic replacement prevents
interprocess interference and prevents corruption of the target
file when the write is interrupted (for example, when an 'out of space'
@@ -1287,6 +1288,13 @@ class atomic_ofstream(ObjectProxy):
encoding=_encodings['fs'], errors='strict'),
mode=mode, **kargs))
+ def __exit__(self, exc_type, exc_val, exc_tb):
+ if exc_type is not None:
+ self.abort()
+ else:
+ self.close()
+ return None
+
def _get_target(self):
return object.__getattribute__(self, '_file')
^ permalink raw reply related [flat|nested] 47+ messages in thread
* [gentoo-commits] proj/portage:master commit in: lib/portage/util/
@ 2020-11-22 19:41 Zac Medico
0 siblings, 0 replies; 47+ messages in thread
From: Zac Medico @ 2020-11-22 19:41 UTC (permalink / raw
To: gentoo-commits
commit: ae8b18f868c9bd039643f89f28f9d92ce8966c3c
Author: Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Sun Nov 22 19:37:05 2020 +0000
Commit: Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Sun Nov 22 19:38:51 2020 +0000
URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=ae8b18f8
compare_files: fix missing xattr handling
Fixes: a2e7bf7d1c7d ("compare_files: handle missing xattr support")
Bug: https://bugs.gentoo.org/755950
Signed-off-by: Zac Medico <zmedico <AT> gentoo.org>
lib/portage/util/_compare_files.py | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/lib/portage/util/_compare_files.py b/lib/portage/util/_compare_files.py
index 60d43aefa..7692797fc 100644
--- a/lib/portage/util/_compare_files.py
+++ b/lib/portage/util/_compare_files.py
@@ -9,7 +9,7 @@ import stat
from portage import _encodings
from portage import _unicode_encode
-from portage.util._xattr import xattr
+from portage.util._xattr import XATTRS_WORKS, xattr
def compare_files(file1, file2, skipped_types=()):
"""
@@ -45,7 +45,7 @@ def compare_files(file1, file2, skipped_types=()):
if "device_number" not in skipped_types and file1_stat.st_rdev != file2_stat.st_rdev:
differences.append("device_number")
- if (xattr.XATTRS_WORKS and "xattr" not in skipped_types and
+ if (XATTRS_WORKS and "xattr" not in skipped_types and
sorted(xattr.get_all(file1, nofollow=True)) != sorted(xattr.get_all(file2, nofollow=True))):
differences.append("xattr")
^ permalink raw reply related [flat|nested] 47+ messages in thread
* [gentoo-commits] proj/portage:master commit in: lib/portage/util/
@ 2020-11-22 6:20 Zac Medico
0 siblings, 0 replies; 47+ messages in thread
From: Zac Medico @ 2020-11-22 6:20 UTC (permalink / raw
To: gentoo-commits
commit: a2e7bf7d1c7d518fe8d7cf2c0e6cb30020b8aa94
Author: Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Sat Nov 21 21:13:27 2020 +0000
Commit: Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Sun Nov 22 06:17:29 2020 +0000
URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=a2e7bf7d
compare_files: handle missing xattr support
Bug: https://bugs.gentoo.org/755950
Signed-off-by: Zac Medico <zmedico <AT> gentoo.org>
lib/portage/util/_compare_files.py | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/lib/portage/util/_compare_files.py b/lib/portage/util/_compare_files.py
index de97a9d9d..60d43aefa 100644
--- a/lib/portage/util/_compare_files.py
+++ b/lib/portage/util/_compare_files.py
@@ -45,7 +45,8 @@ def compare_files(file1, file2, skipped_types=()):
if "device_number" not in skipped_types and file1_stat.st_rdev != file2_stat.st_rdev:
differences.append("device_number")
- if "xattr" not in skipped_types and sorted(xattr.get_all(file1, nofollow=True)) != sorted(xattr.get_all(file2, nofollow=True)):
+ if (xattr.XATTRS_WORKS and "xattr" not in skipped_types and
+ sorted(xattr.get_all(file1, nofollow=True)) != sorted(xattr.get_all(file2, nofollow=True))):
differences.append("xattr")
if "atime" not in skipped_types and file1_stat.st_atime_ns != file2_stat.st_atime_ns:
^ permalink raw reply related [flat|nested] 47+ messages in thread
* [gentoo-commits] proj/portage:master commit in: lib/portage/util/
@ 2020-10-06 1:35 Zac Medico
0 siblings, 0 replies; 47+ messages in thread
From: Zac Medico @ 2020-10-06 1:35 UTC (permalink / raw
To: gentoo-commits
commit: c446394e5b0e71a611ed5cfa0fb923e05802ef5f
Author: Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Tue Oct 6 01:21:58 2020 +0000
Commit: Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Tue Oct 6 01:35:09 2020 +0000
URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=c446394e
movefile: remove dest_tmp_bytes on failure
Reported-by: Boleyn Su <boleyn.su <AT> gmail.com>
Bug: https://bugs.gentoo.org/745588
Signed-off-by: Zac Medico <zmedico <AT> gentoo.org>
lib/portage/util/movefile.py | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
diff --git a/lib/portage/util/movefile.py b/lib/portage/util/movefile.py
index a251d369d..9c6054209 100644
--- a/lib/portage/util/movefile.py
+++ b/lib/portage/util/movefile.py
@@ -262,6 +262,7 @@ def movefile(src, dest, newmtime=None, sstat=None, mysettings=None,
dest_tmp = dest + "#new"
dest_tmp_bytes = _unicode_encode(dest_tmp, encoding=encoding,
errors='strict')
+ success = False
try: # For safety copy then move it over.
_copyfile(src_bytes, dest_tmp_bytes)
_apply_stat(sstat, dest_tmp_bytes)
@@ -281,13 +282,18 @@ def movefile(src, dest, newmtime=None, sstat=None, mysettings=None,
raise
_rename(dest_tmp_bytes, dest_bytes)
_os.unlink(src_bytes)
- except SystemExit as e:
- raise
+ success = True
except Exception as e:
writemsg("!!! %s\n" % _('copy %(src)s -> %(dest)s failed.') %
{"src": src, "dest": dest}, noiselevel=-1)
writemsg("!!! %s\n" % (e,), noiselevel=-1)
return None
+ finally:
+ if not success:
+ try:
+ _os.unlink(dest_tmp_bytes)
+ except OSError:
+ pass
else:
#we don't yet handle special, so we need to fall back to /bin/mv
a = spawn([MOVE_BINARY, '-f', src, dest], env=os.environ)
^ permalink raw reply related [flat|nested] 47+ messages in thread
* [gentoo-commits] proj/portage:master commit in: lib/portage/util/
@ 2020-09-08 0:04 Zac Medico
0 siblings, 0 replies; 47+ messages in thread
From: Zac Medico @ 2020-09-08 0:04 UTC (permalink / raw
To: gentoo-commits
commit: 45a5982fe8076066323e91f6b5fe860f3a429f9f
Author: Florian Schmaus <flo <AT> geekplace <DOT> eu>
AuthorDate: Sat Sep 5 07:18:17 2020 +0000
Commit: Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Tue Sep 8 00:01:47 2020 +0000
URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=45a5982f
env-update: create systemd user-session environment definition
Portage's env-update currently transforms the environment information
from /etc/env.d into /etc/profile.env, which is typically sourced by
every user session, setting up its environment.
However, /etc/profile.env is not sourced by systemd user
services. Instead, for the definition of a systemd user session
environment, the 'environment.d' machinery exists. Unfortunately, up
to now, env-update does not produce a profile.env equivalent for this
machinery, causing issues for systemd user services. For example, an
emacs daemon run as user systemd service does not have a complete
PATH (bug #704412 [1]), because some PATH components are injected by
packages via /etc/env.d. For example, an LLVM ebuild may set
PATH="/usr/lib/llvm/9/bin".
This commit changes env-update so that a systemd user session
environment configuration file named
/etc/environment.d/10-gentoo-env.conf
is created.
Thanks to Michael 'veremitz' Everitt, Arfrever Frehtes Taifersar
Arahesis, Ulrich Müller, Joakim Tjernlund, and Zac Medico for the
useful feedback.
1: https://bugs.gentoo.org/704412
Bug: https://bugs.gentoo.org/704416
Signed-off-by: Florian Schmaus <flo <AT> geekplace.eu>
Signed-off-by: Zac Medico <zmedico <AT> gentoo.org>
lib/portage/util/env_update.py | 42 +++++++++++++++++++++++++++++++++++++++---
1 file changed, 39 insertions(+), 3 deletions(-)
diff --git a/lib/portage/util/env_update.py b/lib/portage/util/env_update.py
index f130b6f6b..dec086cf8 100644
--- a/lib/portage/util/env_update.py
+++ b/lib/portage/util/env_update.py
@@ -333,14 +333,16 @@ def _env_update(makelinks, target_root, prev_mtimes, contents, env,
del specials["LDPATH"]
- penvnotice = "# THIS FILE IS AUTOMATICALLY GENERATED BY env-update.\n"
- penvnotice += "# DO NOT EDIT THIS FILE. CHANGES TO STARTUP PROFILES\n"
+ notice = "# THIS FILE IS AUTOMATICALLY GENERATED BY env-update.\n"
+ notice += "# DO NOT EDIT THIS FILE."
+ penvnotice = notice + " CHANGES TO STARTUP PROFILES\n"
cenvnotice = penvnotice[:]
penvnotice += "# GO INTO /etc/profile NOT /etc/profile.env\n\n"
cenvnotice += "# GO INTO /etc/csh.cshrc NOT /etc/csh.env\n\n"
#create /etc/profile.env for bash support
- outfile = atomic_ofstream(os.path.join(eroot, "etc", "profile.env"))
+ profile_env_path = os.path.join(eroot, "etc", "profile.env")
+ outfile = atomic_ofstream(profile_env_path)
outfile.write(penvnotice)
env_keys = [x for x in env if x != "LDPATH"]
@@ -353,6 +355,40 @@ def _env_update(makelinks, target_root, prev_mtimes, contents, env,
outfile.write("export %s='%s'\n" % (k, v))
outfile.close()
+ # Create the systemd user environment configuration file
+ # /etc/environment.d/10-gentoo-env.conf with the
+ # environment configuration from /etc/env.d.
+ systemd_environment_dir = os.path.join(eroot, "etc", "environment.d")
+ os.makedirs(systemd_environment_dir, exist_ok=True)
+
+ systemd_gentoo_env_path = os.path.join(systemd_environment_dir,
+ "10-gentoo-env.conf")
+ systemd_gentoo_env = atomic_ofstream(systemd_gentoo_env_path)
+ try:
+ senvnotice = notice + "\n\n"
+ systemd_gentoo_env.write(senvnotice)
+
+ for env_key in env_keys:
+ env_key_value = env[env_key]
+
+ # Skip variables with the empty string
+ # as value. Those sometimes appear in
+ # profile.env (e.g. "export GCC_SPECS=''"),
+ # but are invalid in systemd's syntax.
+ if not env_key_value:
+ continue
+
+ # Transform into systemd environment.d
+ # conf syntax, basically shell variable
+ # assignment (without "export ").
+ line = f"{env_key}={env_key_value}\n"
+
+ systemd_gentoo_env.write(line)
+ except:
+ systemd_gentoo_env.abort()
+ raise
+ systemd_gentoo_env.close()
+
#create /etc/csh.env for (t)csh support
outfile = atomic_ofstream(os.path.join(eroot, "etc", "csh.env"))
outfile.write(cenvnotice)
^ permalink raw reply related [flat|nested] 47+ messages in thread
* [gentoo-commits] proj/portage:master commit in: lib/portage/util/
@ 2020-08-04 3:09 Zac Medico
0 siblings, 0 replies; 47+ messages in thread
From: Zac Medico @ 2020-08-04 3:09 UTC (permalink / raw
To: gentoo-commits
commit: 5d48806c78febc559d6ae726303f35dd32435474
Author: Aaron Bauman <bman <AT> gentoo <DOT> org>
AuthorDate: Tue Aug 4 02:44:58 2020 +0000
Commit: Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Tue Aug 4 03:08:47 2020 +0000
URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=5d48806c
lib/portage/util/socks5.py: fix reimport
* This drops the internal class import of the asyncio module. It is not
available in all supported Python versions.
Suggested-by: Zac Medico <zmedico <AT> gentoo.org>
Signed-off-by: Aaron Bauman <bman <AT> gentoo.org>
Signed-off-by: Zac Medico <zmedico <AT> gentoo.org>
lib/portage/util/socks5.py | 7 +------
1 file changed, 1 insertion(+), 6 deletions(-)
diff --git a/lib/portage/util/socks5.py b/lib/portage/util/socks5.py
index c0657ae2a..65d2400e8 100644
--- a/lib/portage/util/socks5.py
+++ b/lib/portage/util/socks5.py
@@ -1,5 +1,5 @@
# SOCKSv5 proxy manager for network-sandbox
-# Copyright 2015-2019 Gentoo Authors
+# Copyright 2015-2020 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2
import errno
@@ -14,7 +14,6 @@ from portage.process import atexit_register, spawn
from portage.util.futures.compat_coroutine import coroutine
from portage.util.futures import asyncio
-
class ProxyManager:
"""
A class to start and control a single running SOCKSv5 server process
@@ -33,10 +32,6 @@ class ProxyManager:
paths)
@type settings: portage.config
"""
- try:
- import asyncio # NOQA
- except ImportError:
- raise NotImplementedError('SOCKSv5 proxy requires asyncio module')
tmpdir = os.path.join(settings['PORTAGE_TMPDIR'], 'portage')
ensure_dirs_kwargs = {}
^ permalink raw reply related [flat|nested] 47+ messages in thread
* [gentoo-commits] proj/portage:master commit in: lib/portage/util/
@ 2020-08-04 1:39 Zac Medico
0 siblings, 0 replies; 47+ messages in thread
From: Zac Medico @ 2020-08-04 1:39 UTC (permalink / raw
To: gentoo-commits
commit: 86b9c28c6abb7193fb39fef1fe7620fc2d0bab72
Author: Aaron Bauman <bman <AT> gentoo <DOT> org>
AuthorDate: Tue Aug 4 00:16:18 2020 +0000
Commit: Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Tue Aug 4 01:08:27 2020 +0000
URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=86b9c28c
lib/portage/util/env_update.py: fix unnecessary-semicolon
Signed-off-by: Aaron Bauman <bman <AT> gentoo.org>
Signed-off-by: Zac Medico <zmedico <AT> gentoo.org>
lib/portage/util/env_update.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/lib/portage/util/env_update.py b/lib/portage/util/env_update.py
index 9c6fe3cdd..7a2ee2551 100644
--- a/lib/portage/util/env_update.py
+++ b/lib/portage/util/env_update.py
@@ -213,7 +213,7 @@ def _env_update(makelinks, target_root, prev_mtimes, contents, env,
newprelink.write("# contents of /etc/env.d directory\n")
for x in sorted(potential_lib_dirs) + ['bin', 'sbin']:
- newprelink.write('-l /%s\n' % (x,));
+ newprelink.write('-l /%s\n' % (x,))
prelink_paths = set()
prelink_paths |= set(specials.get('LDPATH', []))
prelink_paths |= set(specials.get('PATH', []))
^ permalink raw reply related [flat|nested] 47+ messages in thread
* [gentoo-commits] proj/portage:master commit in: lib/portage/util/
@ 2020-08-03 21:42 Zac Medico
0 siblings, 0 replies; 47+ messages in thread
From: Zac Medico @ 2020-08-03 21:42 UTC (permalink / raw
To: gentoo-commits
commit: 79df13ade89cf8de236df8e59d3d0790a8a508cc
Author: Aaron Bauman <bman <AT> gentoo <DOT> org>
AuthorDate: Mon Aug 3 20:20:32 2020 +0000
Commit: Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Mon Aug 3 21:25:54 2020 +0000
URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=79df13ad
lib/portage/util/netlink.py: drop unused-import
* Drop unused-import
* Update copyright
Signed-off-by: Aaron Bauman <bman <AT> gentoo.org>
Signed-off-by: Zac Medico <zmedico <AT> gentoo.org>
lib/portage/util/netlink.py | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/lib/portage/util/netlink.py b/lib/portage/util/netlink.py
index 950ed8f69..ad9e8ca30 100644
--- a/lib/portage/util/netlink.py
+++ b/lib/portage/util/netlink.py
@@ -1,4 +1,4 @@
-# Copyright 2019 Gentoo Authors
+# Copyright 2019-2020 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2
from io import BytesIO
@@ -8,7 +8,6 @@ from struct import Struct
import socket
from socket import (
AF_NETLINK, AF_UNSPEC,
- MSG_PEEK, MSG_TRUNC,
NETLINK_ROUTE,
SOCK_DGRAM,
inet_pton,
^ permalink raw reply related [flat|nested] 47+ messages in thread
* [gentoo-commits] proj/portage:master commit in: lib/portage/util/
@ 2020-08-03 19:43 Ulrich Müller
0 siblings, 0 replies; 47+ messages in thread
From: Ulrich Müller @ 2020-08-03 19:43 UTC (permalink / raw
To: gentoo-commits
commit: 73bf5fc49d9e0cd98c490706240df6ae8a767cd1
Author: Ulrich Müller <ulm <AT> gentoo <DOT> org>
AuthorDate: Mon Aug 3 19:43:00 2020 +0000
Commit: Ulrich Müller <ulm <AT> gentoo <DOT> org>
CommitDate: Mon Aug 3 19:43:00 2020 +0000
URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=73bf5fc4
lib/portage/util/_desktop_entry.py: Fix copyright notice.
Signed-off-by: Ulrich Müller <ulm <AT> gentoo.org>
lib/portage/util/_desktop_entry.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/lib/portage/util/_desktop_entry.py b/lib/portage/util/_desktop_entry.py
index 68cec7a61..4a49cd4ce 100644
--- a/lib/portage/util/_desktop_entry.py
+++ b/lib/portage/util/_desktop_entry.py
@@ -1,4 +1,4 @@
-# Copyright 2020 Gentoo Authors
+# Copyright 2012-2020 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2
import re
^ permalink raw reply related [flat|nested] 47+ messages in thread
* [gentoo-commits] proj/portage:master commit in: lib/portage/util/
@ 2020-08-03 19:30 Zac Medico
0 siblings, 0 replies; 47+ messages in thread
From: Zac Medico @ 2020-08-03 19:30 UTC (permalink / raw
To: gentoo-commits
commit: e9ce010c55cffa440881613b8485c38a125c2ad1
Author: Aaron Bauman <bman <AT> gentoo <DOT> org>
AuthorDate: Mon Aug 3 19:05:40 2020 +0000
Commit: Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Mon Aug 3 19:21:07 2020 +0000
URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=e9ce010c
lib/portage/util/_desktop_entry.py: fix unused-import
* Remove unused-imports
* Updated copyright
Signed-off-by: Aaron Bauman <bman <AT> gentoo.org>
Signed-off-by: Zac Medico <zmedico <AT> gentoo.org>
lib/portage/util/_desktop_entry.py | 9 +++------
1 file changed, 3 insertions(+), 6 deletions(-)
diff --git a/lib/portage/util/_desktop_entry.py b/lib/portage/util/_desktop_entry.py
index 74053a30f..68cec7a61 100644
--- a/lib/portage/util/_desktop_entry.py
+++ b/lib/portage/util/_desktop_entry.py
@@ -1,16 +1,13 @@
-# Copyright 2012-2013 Gentoo Foundation
+# Copyright 2020 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2
import re
import subprocess
import sys
-import portage
-from portage import _encodings, _unicode_encode, _unicode_decode
+from portage import _unicode_encode, _unicode_decode
from portage.util import writemsg
-from portage.util.configparser import (ConfigParserError, RawConfigParser,
- read_configs)
-
+from portage.util.configparser import (RawConfigParser, read_configs)
def parse_desktop_entry(path):
"""
^ permalink raw reply related [flat|nested] 47+ messages in thread
* [gentoo-commits] proj/portage:master commit in: lib/portage/util/
@ 2020-07-18 22:56 Zac Medico
0 siblings, 0 replies; 47+ messages in thread
From: Zac Medico @ 2020-07-18 22:56 UTC (permalink / raw
To: gentoo-commits
commit: db7d19213e46a3a0185ab0cd94aed378c3aaf404
Author: Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Sat Jul 18 22:14:34 2020 +0000
Commit: Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Sat Jul 18 22:54:53 2020 +0000
URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=db7d1921
validate_desktop_entry: update _trivial_warnings regex (bug 733154)
The message has changed in desktop-file-utils-0.25.
See: https://gitlab.freedesktop.org/xdg/desktop-file-utils/-/commit/e935a1b0c300d8fc97661e01a8200af14876e627
Bug: https://bugs.gentoo.org/733154
Signed-off-by: Zac Medico <zmedico <AT> gentoo.org>
lib/portage/util/_desktop_entry.py | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/lib/portage/util/_desktop_entry.py b/lib/portage/util/_desktop_entry.py
index ee6572588..9fa06b97b 100644
--- a/lib/portage/util/_desktop_entry.py
+++ b/lib/portage/util/_desktop_entry.py
@@ -25,7 +25,12 @@ def parse_desktop_entry(path):
return parser
-_trivial_warnings = re.compile(r' looks redundant with value ')
+_trivial_warnings = re.compile(r' looks '
+ # >=desktop-file-utils-0.25
+ r'(?:the same as that of key|'
+
+ # <desktop-file-utils-0.25
+ r'redundant with value) ')
_ignored_errors = (
# Ignore error for emacs.desktop:
^ permalink raw reply related [flat|nested] 47+ messages in thread
* [gentoo-commits] proj/portage:master commit in: lib/portage/util/
@ 2020-03-14 23:40 Zac Medico
0 siblings, 0 replies; 47+ messages in thread
From: Zac Medico @ 2020-03-14 23:40 UTC (permalink / raw
To: gentoo-commits
commit: 07da257cfc80509c50104560b1e1508b9e585b98
Author: Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Sat Mar 14 23:18:55 2020 +0000
Commit: Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Sat Mar 14 23:21:55 2020 +0000
URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=07da257c
compression_probe: omit zstd --long=31 on 32-bit arch (bug 710444)
Omit the zstd --long=31 argument for decompression on 32-bit
architectures, since the latest version of zstd will otherwise
abort with an error on 32-bit architectures.
Bug: https://bugs.gentoo.org/710444
Bug: https://bugs.gentoo.org/634980
Signed-off-by: Zac Medico <zmedico <AT> gentoo.org>
lib/portage/util/compression_probe.py | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
diff --git a/lib/portage/util/compression_probe.py b/lib/portage/util/compression_probe.py
index 90880b1cd..7d595670b 100644
--- a/lib/portage/util/compression_probe.py
+++ b/lib/portage/util/compression_probe.py
@@ -1,6 +1,7 @@
-# Copyright 2015 Gentoo Foundation
+# Copyright 2015-2020 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2
+import ctypes
import errno
import re
import sys
@@ -45,7 +46,12 @@ _compressors = {
},
"zstd": {
"compress": "zstd ${BINPKG_COMPRESS_FLAGS}",
- "decompress": "zstd -d --long=31",
+ # If the compression windowLog was larger than the default of 27,
+ # then --long=windowLog needs to be passed to the decompressor.
+ # Therefore, pass a larger --long=31 value to the decompressor
+ # if the current architecture can support it, which is true when
+ # sizeof(long) is at least 8 bytes.
+ "decompress": "zstd -d" + (" --long=31" if ctypes.sizeof(ctypes.c_long) >= 8 else ""),
"package": "app-arch/zstd",
},
}
^ permalink raw reply related [flat|nested] 47+ messages in thread
* [gentoo-commits] proj/portage:master commit in: lib/portage/util/
@ 2019-10-19 6:03 Zac Medico
0 siblings, 0 replies; 47+ messages in thread
From: Zac Medico @ 2019-10-19 6:03 UTC (permalink / raw
To: gentoo-commits
commit: c366e1a755ed4d6b49883b8d8b20629fe32b6b43
Author: Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Sat Oct 19 05:46:53 2019 +0000
Commit: Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Sat Oct 19 05:59:07 2019 +0000
URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=c366e1a7
urlopen: eliminate deprecated urllib.parse.splituser
Signed-off-by: Zac Medico <zmedico <AT> gentoo.org>
lib/portage/util/_urlopen.py | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/lib/portage/util/_urlopen.py b/lib/portage/util/_urlopen.py
index fc9db74a0..1d8ba3fd3 100644
--- a/lib/portage/util/_urlopen.py
+++ b/lib/portage/util/_urlopen.py
@@ -1,4 +1,4 @@
-# Copyright 2012-2014 Gentoo Foundation
+# Copyright 2012-2019 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2
import io
@@ -11,12 +11,10 @@ try:
from urllib.request import urlopen as _urlopen
import urllib.parse as urllib_parse
import urllib.request as urllib_request
- from urllib.parse import splituser as urllib_parse_splituser
except ImportError:
from urllib import urlopen as _urlopen
import urlparse as urllib_parse
import urllib2 as urllib_request
- from urllib import splituser as urllib_parse_splituser
if sys.hexversion >= 0x3000000:
# pylint: disable=W0622
@@ -43,7 +41,7 @@ def urlopen(url, if_modified_since=None):
if parse_result.scheme not in ("http", "https"):
return _urlopen(url)
else:
- netloc = urllib_parse_splituser(parse_result.netloc)[1]
+ netloc = parse_result.netloc.rpartition('@')[-1]
url = urllib_parse.urlunparse((parse_result.scheme, netloc, parse_result.path, parse_result.params, parse_result.query, parse_result.fragment))
password_manager = urllib_request.HTTPPasswordMgrWithDefaultRealm()
request = urllib_request.Request(url)
^ permalink raw reply related [flat|nested] 47+ messages in thread
* [gentoo-commits] proj/portage:master commit in: lib/portage/util/
@ 2019-08-08 22:58 Zac Medico
0 siblings, 0 replies; 47+ messages in thread
From: Zac Medico @ 2019-08-08 22:58 UTC (permalink / raw
To: gentoo-commits
commit: 90ffe62d5b7b224753927f2fa61daf19488e14f9
Author: Arfrever Frehtes Taifersar Arahesis <Arfrever <AT> Apache <DOT> Org>
AuthorDate: Wed Aug 7 02:41:51 2019 +0000
Commit: Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Thu Aug 8 22:57:28 2019 +0000
URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=90ffe62d
_xattr._XattrSystemCommands.{get,list}: Do not hide stderr and fix ResourceWarning.
Bug: https://bugs.gentoo.org/691638
Signed-off-by: Arfrever Frehtes Taifersar Arahesis <Arfrever <AT> Apache.Org>
Signed-off-by: Zac Medico <zmedico <AT> gentoo.org>
lib/portage/util/_xattr.py | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/lib/portage/util/_xattr.py b/lib/portage/util/_xattr.py
index 9a8704d70..c118589a3 100644
--- a/lib/portage/util/_xattr.py
+++ b/lib/portage/util/_xattr.py
@@ -1,4 +1,4 @@
-# Copyright 2010-2015 Gentoo Foundation
+# Copyright 2010-2019 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2
"""Portability shim for xattr support
@@ -63,7 +63,7 @@ class _XattrSystemCommands(_XattrGetAll):
cmd = ['getfattr', '--absolute-names', '-n', name, item]
if nofollow:
cmd += ['-h']
- proc = cls._call(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
+ proc = cls._call(cmd, stdout=subprocess.PIPE)
value = None
for _, value in cls._parse_output(proc.stdout):
@@ -94,7 +94,7 @@ class _XattrSystemCommands(_XattrGetAll):
if nofollow:
cmd += ['-h']
cmd += ['-m', ('^%s[.]' % namespace) if namespace else '-']
- proc = cls._call(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
+ proc = cls._call(cmd, stdout=subprocess.PIPE)
ret = []
if namespace:
^ permalink raw reply related [flat|nested] 47+ messages in thread
* [gentoo-commits] proj/portage:master commit in: lib/portage/util/
@ 2019-06-10 18:20 Zac Medico
0 siblings, 0 replies; 47+ messages in thread
From: Zac Medico @ 2019-06-10 18:20 UTC (permalink / raw
To: gentoo-commits
commit: c71fa8faf1fd83af7ab7422e0fbe25e0539cbb22
Author: Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Mon Jun 10 18:16:33 2019 +0000
Commit: Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Mon Jun 10 18:19:09 2019 +0000
URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=c71fa8fa
_raise_exc: handle EISDIR
Signed-off-by: Zac Medico <zmedico <AT> gentoo.org>
lib/portage/util/install_mask.py | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/lib/portage/util/install_mask.py b/lib/portage/util/install_mask.py
index 037fc8bc3..0013effa1 100644
--- a/lib/portage/util/install_mask.py
+++ b/lib/portage/util/install_mask.py
@@ -12,7 +12,12 @@ import sys
from portage import os, _unicode_decode
from portage.exception import (
- OperationNotPermitted, PermissionDenied, ReadOnlyFileSystem, FileNotFound)
+ FileNotFound,
+ IsADirectory,
+ OperationNotPermitted,
+ PermissionDenied,
+ ReadOnlyFileSystem,
+)
from portage.util import normalize_path
if sys.hexversion >= 0x3000000:
@@ -127,6 +132,7 @@ class InstallMask(object):
_exc_map = {
+ errno.EISDIR: IsADirectory,
errno.ENOENT: FileNotFound,
errno.EPERM: OperationNotPermitted,
errno.EACCES: PermissionDenied,
^ permalink raw reply related [flat|nested] 47+ messages in thread
* [gentoo-commits] proj/portage:master commit in: lib/portage/util/
@ 2019-05-20 4:46 Zac Medico
0 siblings, 0 replies; 47+ messages in thread
From: Zac Medico @ 2019-05-20 4:46 UTC (permalink / raw
To: gentoo-commits
commit: f69c2596ff6f483bec55c17918e4e17df6236b89
Author: Arfrever Frehtes Taifersar Arahesis <Arfrever <AT> Apache <DOT> Org>
AuthorDate: Mon May 13 15:15:03 2019 +0000
Commit: Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Mon May 20 04:44:54 2019 +0000
URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=f69c2596
get_vm_info: Set C locale for subprocesses.
Parsing of localized output of subprocesses would fail, making
`emerge --info` not display information about memory and swap.
Bug: https://bugs.gentoo.org/685854
Signed-off-by: Arfrever Frehtes Taifersar Arahesis <Arfrever <AT> Apache.Org>
Signed-off-by: Zac Medico <zmedico <AT> gentoo.org>
lib/portage/util/_get_vm_info.py | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/lib/portage/util/_get_vm_info.py b/lib/portage/util/_get_vm_info.py
index e8ad93805..802365dd7 100644
--- a/lib/portage/util/_get_vm_info.py
+++ b/lib/portage/util/_get_vm_info.py
@@ -1,4 +1,4 @@
-# Copyright 2013 Gentoo Foundation
+# Copyright 2013-2019 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2
import os
@@ -11,10 +11,13 @@ def get_vm_info():
vm_info = {}
+ env = os.environ.copy()
+ env["LC_ALL"] = "C"
+
if platform.system() == 'Linux':
try:
proc = subprocess.Popen(["free"],
- stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
+ stdout=subprocess.PIPE, stderr=subprocess.STDOUT, env=env)
except OSError:
pass
else:
@@ -49,7 +52,7 @@ def get_vm_info():
try:
proc = subprocess.Popen(["sysctl", "-a"],
- stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
+ stdout=subprocess.PIPE, stderr=subprocess.STDOUT, env=env)
except OSError:
pass
else:
^ permalink raw reply related [flat|nested] 47+ messages in thread
* [gentoo-commits] proj/portage:master commit in: lib/portage/util/
@ 2019-04-15 23:04 Zac Medico
0 siblings, 0 replies; 47+ messages in thread
From: Zac Medico @ 2019-04-15 23:04 UTC (permalink / raw
To: gentoo-commits
commit: 63b509e6d2c0db4343b255455fda1aa3b666bd9c
Author: Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Thu Apr 11 03:07:09 2019 +0000
Commit: Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Mon Apr 15 23:03:54 2019 +0000
URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=63b509e6
socks5: use ${PORTAGE_TMPDIR}/portage (bug 683040)
Write temporary socket files in ${PORTAGE_TMPDIR}/portage,
since writing files directly in ${PORTAGE_TMPDIR} is generally
unexpected.
Bug: https://bugs.gentoo.org/683040
Signed-off-by: Zac Medico <zmedico <AT> gentoo.org>
lib/portage/util/socks5.py | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
diff --git a/lib/portage/util/socks5.py b/lib/portage/util/socks5.py
index 59e6699ec..86bb24f25 100644
--- a/lib/portage/util/socks5.py
+++ b/lib/portage/util/socks5.py
@@ -38,7 +38,15 @@ class ProxyManager(object):
except ImportError:
raise NotImplementedError('SOCKSv5 proxy requires asyncio module')
- self.socket_path = os.path.join(settings['PORTAGE_TMPDIR'],
+ tmpdir = os.path.join(settings['PORTAGE_TMPDIR'], 'portage')
+ ensure_dirs_kwargs = {}
+ if portage.secpass >= 1:
+ ensure_dirs_kwargs['gid'] = portage_gid
+ ensure_dirs_kwargs['mode'] = 0o70
+ ensure_dirs_kwargs['mask'] = 0
+ portage.util.ensure_dirs(tmpdir, **ensure_dirs_kwargs)
+
+ self.socket_path = os.path.join(tmpdir,
'.portage.%d.net.sock' % os.getpid())
server_bin = os.path.join(settings['PORTAGE_BIN_PATH'], 'socks5-server.py')
spawn_kwargs = {}
^ permalink raw reply related [flat|nested] 47+ messages in thread
* [gentoo-commits] proj/portage:master commit in: lib/portage/util/
@ 2019-02-16 17:42 Robin H. Johnson
0 siblings, 0 replies; 47+ messages in thread
From: Robin H. Johnson @ 2019-02-16 17:42 UTC (permalink / raw
To: gentoo-commits
commit: 33ece61c9ca1d0be1d14306ed183477fbe755793
Author: Robin H. Johnson <robbat2 <AT> gentoo <DOT> org>
AuthorDate: Sat Feb 16 17:42:18 2019 +0000
Commit: Robin H. Johnson <robbat2 <AT> gentoo <DOT> org>
CommitDate: Sat Feb 16 17:42:18 2019 +0000
URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=33ece61c
util: fix whitespace bug introduced in cleanup of get_cpu_count work
Signed-off-by: Robin H. Johnson <robbat2 <AT> gentoo.org>
lib/portage/util/cpuinfo.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/lib/portage/util/cpuinfo.py b/lib/portage/util/cpuinfo.py
index 9ab1c119d..78b969f47 100644
--- a/lib/portage/util/cpuinfo.py
+++ b/lib/portage/util/cpuinfo.py
@@ -31,7 +31,7 @@ def get_cpu_count():
@return: Number of CPUs or None if unable to obtain.
"""
- try:
+ try:
import os
# This was introduced in Python 3.3 only, but exists in Linux
# all the way back to the 2.5.8 kernel.
^ permalink raw reply related [flat|nested] 47+ messages in thread
* [gentoo-commits] proj/portage:master commit in: lib/portage/util/
@ 2019-02-16 16:48 Robin H. Johnson
0 siblings, 0 replies; 47+ messages in thread
From: Robin H. Johnson @ 2019-02-16 16:48 UTC (permalink / raw
To: gentoo-commits
commit: 00354a2443c1a0f7f64d55daadd52324868b085f
Author: Robin H. Johnson <robbat2 <AT> gentoo <DOT> org>
AuthorDate: Sat Feb 16 06:06:41 2019 +0000
Commit: Robin H. Johnson <robbat2 <AT> gentoo <DOT> org>
CommitDate: Sat Feb 16 06:06:41 2019 +0000
URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=00354a24
cpuinfo: use better available CPU calculation
The existing portage.util.cpuinfo.get_cpu_count() behavior is wrong when
run in any environment where the cpuset is a subset of online CPUs.
The solution recommended by the 'os.cpu_count()' help is to use:
len(os.sched_getaffinity(0))
This only works on line, so keep multiprocessing.cpu_count() as a
fallback. In newer version of Python, multiprocessing.cpu_count() is a
wrapper for os.cpu_count().
Reported-By: Daniel Robbins <drobbins <AT> funtoo.org>
Fixes: https://bugs.funtoo.org/browse/FL-6227
Signed-off-by: Robin H. Johnson <robbat2 <AT> gentoo.org>
lib/portage/util/cpuinfo.py | 33 +++++++++++++++++++++++++++++++--
1 file changed, 31 insertions(+), 2 deletions(-)
diff --git a/lib/portage/util/cpuinfo.py b/lib/portage/util/cpuinfo.py
index 669e707b5..9ab1c119d 100644
--- a/lib/portage/util/cpuinfo.py
+++ b/lib/portage/util/cpuinfo.py
@@ -1,15 +1,44 @@
-# Copyright 2015 Gentoo Foundation
+# Copyright 2015-2019 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2
__all__ = ['get_cpu_count']
+# Before you set out to change this function, figure out what you're really
+# asking:
+#
+# - How many CPUs exist in this system (e.g. that the kernel is aware of?)
+# This is 'getconf _NPROCESSORS_CONF' / get_nprocs_conf(3)
+# In modern Linux, implemented by counting CPUs in /sys/devices/system/cpu/
+#
+# - How many CPUs in this system are ONLINE right now?
+# This is 'getconf _NPROCESSORS_ONLN' / get_nprocs(3)
+# In modern Linux, implemented by parsing /sys/devices/system/cpu/online
+#
+# - How many CPUs are available to this program?
+# This is 'nproc' / sched_getaffinity(2), which is implemented in modern
+# Linux kernels by querying the kernel scheduler; This might not be available
+# in some non-Linux systems!
+#
+# - How many CPUs are available to this thread?
+# This is pthread_getaffinity_np(3)
+#
+# As a further warning, the results returned by this function can differ
+# between runs, if altered by the scheduler or other external factors.
def get_cpu_count():
"""
- Try to obtain the number of CPUs available.
+ Try to obtain the number of CPUs available to this process.
@return: Number of CPUs or None if unable to obtain.
"""
+ try:
+ import os
+ # This was introduced in Python 3.3 only, but exists in Linux
+ # all the way back to the 2.5.8 kernel.
+ # This NOT available in FreeBSD!
+ return len(os.sched_getaffinity(0))
+ except (ImportError, NotImplementedError, AttributeError):
+ pass
try:
import multiprocessing
^ permalink raw reply related [flat|nested] 47+ messages in thread
* [gentoo-commits] proj/portage:master commit in: lib/portage/util/
@ 2019-02-06 22:45 Zac Medico
0 siblings, 0 replies; 47+ messages in thread
From: Zac Medico @ 2019-02-06 22:45 UTC (permalink / raw
To: gentoo-commits
commit: 42c120139aeb72a12299593d8601cb13d00f0547
Author: Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Wed Feb 6 22:44:08 2019 +0000
Commit: Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Wed Feb 6 22:44:45 2019 +0000
URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=42c12013
_raise_exc: handle EROFS
Signed-off-by: Zac Medico <zmedico <AT> gentoo.org>
lib/portage/util/install_mask.py | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/lib/portage/util/install_mask.py b/lib/portage/util/install_mask.py
index a8c0cbda5..037fc8bc3 100644
--- a/lib/portage/util/install_mask.py
+++ b/lib/portage/util/install_mask.py
@@ -1,4 +1,4 @@
-# Copyright 2018 Gentoo Foundation
+# Copyright 2018-2019 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2
__all__ = ['install_mask_dir', 'InstallMask']
@@ -12,7 +12,7 @@ import sys
from portage import os, _unicode_decode
from portage.exception import (
- OperationNotPermitted, PermissionDenied, FileNotFound)
+ OperationNotPermitted, PermissionDenied, ReadOnlyFileSystem, FileNotFound)
from portage.util import normalize_path
if sys.hexversion >= 0x3000000:
@@ -130,6 +130,7 @@ _exc_map = {
errno.ENOENT: FileNotFound,
errno.EPERM: OperationNotPermitted,
errno.EACCES: PermissionDenied,
+ errno.EROFS: ReadOnlyFileSystem,
}
^ permalink raw reply related [flat|nested] 47+ messages in thread
* [gentoo-commits] proj/portage:master commit in: lib/portage/util/
@ 2018-12-17 7:09 Zac Medico
0 siblings, 0 replies; 47+ messages in thread
From: Zac Medico @ 2018-12-17 7:09 UTC (permalink / raw
To: gentoo-commits
commit: d2e1c414c4cec97b1a2d3343d60016c100fe9062
Author: Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Mon Dec 17 06:35:28 2018 +0000
Commit: Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Mon Dec 17 06:44:24 2018 +0000
URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=d2e1c414
ExtractKernelVersion: use KeyValuePairFileLoader (bug 673224)
Use KeyValuePairFileLoader to parse the kernel config and report errors
without raising an exception. Silently handle empty settings like the
CONFIG_UEVENT_HELPER_PATH= setting that triggered the ParseError reported
in bug 673224.
Bug: https://bugs.gentoo.org/673224
Signed-off-by: Zac Medico <zmedico <AT> gentoo.org>
| 17 +++++++++++++----
1 file changed, 13 insertions(+), 4 deletions(-)
--git a/lib/portage/util/ExtractKernelVersion.py b/lib/portage/util/ExtractKernelVersion.py
index af4a4fe63..d02d648cb 100644
--- a/lib/portage/util/ExtractKernelVersion.py
+++ b/lib/portage/util/ExtractKernelVersion.py
@@ -1,12 +1,14 @@
-# Copyright 2010-2011 Gentoo Foundation
+# Copyright 2010-2018 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2
__all__ = ['ExtractKernelVersion']
import io
+import logging
from portage import os, _encodings, _unicode_encode
-from portage.util import getconfig, grabfile
+from portage.env.loaders import KeyValuePairFileLoader
+from portage.util import grabfile, shlex_split, writemsg_level
def ExtractKernelVersion(base_dir):
"""
@@ -71,8 +73,15 @@ def ExtractKernelVersion(base_dir):
version += "".join(" ".join(grabfile(base_dir + "/" + lv)).split())
# Check the .config for a CONFIG_LOCALVERSION and append that too, also stripping whitespace
- kernelconfig = getconfig(base_dir+"/.config")
+ loader = KeyValuePairFileLoader(os.path.join(base_dir, ".config"), None)
+ kernelconfig, loader_errors = loader.load()
+ if loader_errors:
+ for file_path, file_errors in loader_errors.items():
+ for error_str in file_errors:
+ writemsg_level("%s: %s\n" % (file_path, error_str),
+ level=logging.ERROR, noiselevel=-1)
+
if kernelconfig and "CONFIG_LOCALVERSION" in kernelconfig:
- version += "".join(kernelconfig["CONFIG_LOCALVERSION"].split())
+ version += "".join(shlex_split(kernelconfig["CONFIG_LOCALVERSION"]))
return (version, None)
^ permalink raw reply related [flat|nested] 47+ messages in thread
* [gentoo-commits] proj/portage:master commit in: lib/portage/util/
@ 2018-08-04 20:27 Zac Medico
0 siblings, 0 replies; 47+ messages in thread
From: Zac Medico @ 2018-08-04 20:27 UTC (permalink / raw
To: gentoo-commits
commit: f391b2cc5384fc38e99a0598cb3de2346e297c25
Author: Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Sat Aug 4 20:18:47 2018 +0000
Commit: Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Sat Aug 4 20:25:23 2018 +0000
URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=f391b2cc
compression_probe: decompress zstd --long=31 (bug 634980)
In order to decompress files compressed with zstd --long=31, add
--long=31 to the zstd decompress options. Even though zstd compression
does not support --long=31 on 32-bit platforms, decompression with
--long=31 still works as long as the file was compressed with a
smaller windowLog.
Reported-by: Martin Väth <martin <AT> mvath.de>
Bug: https://bugs.gentoo.org/634980
lib/portage/util/compression_probe.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/lib/portage/util/compression_probe.py b/lib/portage/util/compression_probe.py
index 29d0eedff..90880b1cd 100644
--- a/lib/portage/util/compression_probe.py
+++ b/lib/portage/util/compression_probe.py
@@ -45,7 +45,7 @@ _compressors = {
},
"zstd": {
"compress": "zstd ${BINPKG_COMPRESS_FLAGS}",
- "decompress": "zstd -d",
+ "decompress": "zstd -d --long=31",
"package": "app-arch/zstd",
},
}
^ permalink raw reply related [flat|nested] 47+ messages in thread
end of thread, other threads:[~2024-08-15 17:30 UTC | newest]
Thread overview: 47+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-06-07 23:48 [gentoo-commits] proj/portage:master commit in: lib/portage/util/ Mike Gilbert
-- strict thread matches above, loose matches on Subject: below --
2024-08-15 17:30 Mike Gilbert
2024-05-27 20:02 Zac Medico
2024-03-07 20:42 Mike Gilbert
2024-03-01 16:20 Mike Gilbert
2024-02-09 8:22 Zac Medico
2024-02-07 2:35 Zac Medico
2023-10-02 21:40 James Le Cuirot
2023-07-26 14:30 Mike Gilbert
2023-07-26 7:58 Sam James
2023-07-26 7:58 Sam James
2023-06-29 8:19 Sam James
2023-06-06 6:52 Sam James
2022-12-31 13:33 Sam James
2022-06-07 23:48 Mike Gilbert
2022-05-21 10:12 Michał Górny
2022-04-15 2:46 Sam James
2021-05-24 6:13 Zac Medico
2021-03-07 16:04 Zac Medico
2021-03-06 20:21 Zac Medico
2021-03-03 12:20 Zac Medico
2021-02-25 10:21 Zac Medico
2021-01-19 0:50 Zac Medico
2021-01-02 1:18 Zac Medico
2020-12-31 2:17 Zac Medico
2020-12-31 2:17 Zac Medico
2020-11-22 19:41 Zac Medico
2020-11-22 6:20 Zac Medico
2020-10-06 1:35 Zac Medico
2020-09-08 0:04 Zac Medico
2020-08-04 3:09 Zac Medico
2020-08-04 1:39 Zac Medico
2020-08-03 21:42 Zac Medico
2020-08-03 19:43 Ulrich Müller
2020-08-03 19:30 Zac Medico
2020-07-18 22:56 Zac Medico
2020-03-14 23:40 Zac Medico
2019-10-19 6:03 Zac Medico
2019-08-08 22:58 Zac Medico
2019-06-10 18:20 Zac Medico
2019-05-20 4:46 Zac Medico
2019-04-15 23:04 Zac Medico
2019-02-16 17:42 Robin H. Johnson
2019-02-16 16:48 Robin H. Johnson
2019-02-06 22:45 Zac Medico
2018-12-17 7:09 Zac Medico
2018-08-04 20:27 Zac Medico
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox