aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEtienne Buira <etienne.buira@free.fr>2024-11-01 16:33:30 -0700
committerZac Medico <zmedico@gentoo.org>2024-11-01 16:33:30 -0700
commit5eaf9f2e491ae9c6f54d77c821b46b2cb5af3f35 (patch)
treee31ce45ef0c5df996809e86feb3b2038d1769230
parentAlway import iscoroutinefunction from inspect (diff)
downloadportage-5eaf9f2e491ae9c6f54d77c821b46b2cb5af3f35.tar.gz
portage-5eaf9f2e491ae9c6f54d77c821b46b2cb5af3f35.tar.bz2
portage-5eaf9f2e491ae9c6f54d77c821b46b2cb5af3f35.zip
gpkg: do not consider symlinks targets for size estimation
Symlinks size is already accounted for, so there is no need to account for the pointed to file. Moreover, previous code failed to handle permission error when using ROOT= and having absolute symlinks pointing to running root. Signed-off-by: Etienne Buira <etienne.buira@free.fr> Bug: https://bugs.gentoo.org/942512 Signed-off-by: Zac Medico <zmedico@gentoo.org>
-rw-r--r--NEWS2
-rw-r--r--lib/portage/gpkg.py24
2 files changed, 10 insertions, 16 deletions
diff --git a/NEWS b/NEWS
index 5c1cea5c2..8847f0209 100644
--- a/NEWS
+++ b/NEWS
@@ -12,6 +12,8 @@ Bug fixes:
* binarytree: Fix _inject_repo_revisions to ignore remote packages for which
source repostories are missing, triggering KeyError (PR #1391).
+* gpkg: do not consider symlinks targets for size estimation (bug #942512).
+
portage-3.0.66.1 (2024-09-18)
--------------
diff --git a/lib/portage/gpkg.py b/lib/portage/gpkg.py
index 06e2283ce..5f392e95e 100644
--- a/lib/portage/gpkg.py
+++ b/lib/portage/gpkg.py
@@ -1960,14 +1960,10 @@ class gpkg:
image_max_link_length = max(image_max_link_length, path_link_length)
- try:
- file_size = os.path.getsize(f)
- except FileNotFoundError:
- # Ignore file not found if symlink to non-existing file
- if os.path.islink(f):
- continue
- else:
- raise
+ if stat.S_ISLNK(file_stat.st_mode):
+ continue
+
+ file_size = os.path.getsize(f)
image_total_size += file_size
image_max_file_size = max(image_max_file_size, file_size)
@@ -2055,14 +2051,10 @@ class gpkg:
image_max_link_length = max(image_max_link_length, path_link_length)
if os.path.isfile(path):
- try:
- file_size = os.path.getsize(path)
- except FileNotFoundError:
- # Ignore file not found if symlink to non-existing file
- if os.path.islink(path):
- continue
- else:
- raise
+ if stat.S_ISLNK(file_stat.st_mode):
+ continue
+
+ file_size = os.path.getsize(path)
image_total_size += file_size
if file_size > image_max_file_size:
image_max_file_size = file_size