Skip to content

Commit 5eaf9f2

Browse files
Etienne Buirazmedico
authored andcommitted
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 <[email protected]> Bug: https://bugs.gentoo.org/942512 Signed-off-by: Zac Medico <[email protected]>
1 parent ea889ce commit 5eaf9f2

File tree

2 files changed

+10
-16
lines changed

2 files changed

+10
-16
lines changed

NEWS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ Bug fixes:
1212
* binarytree: Fix _inject_repo_revisions to ignore remote packages for which
1313
source repostories are missing, triggering KeyError (PR #1391).
1414

15+
* gpkg: do not consider symlinks targets for size estimation (bug #942512).
16+
1517
portage-3.0.66.1 (2024-09-18)
1618
--------------
1719

lib/portage/gpkg.py

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1960,14 +1960,10 @@ def _check_pre_image_files(self, root_dir, image_prefix="image"):
19601960

19611961
image_max_link_length = max(image_max_link_length, path_link_length)
19621962

1963-
try:
1964-
file_size = os.path.getsize(f)
1965-
except FileNotFoundError:
1966-
# Ignore file not found if symlink to non-existing file
1967-
if os.path.islink(f):
1968-
continue
1969-
else:
1970-
raise
1963+
if stat.S_ISLNK(file_stat.st_mode):
1964+
continue
1965+
1966+
file_size = os.path.getsize(f)
19711967
image_total_size += file_size
19721968
image_max_file_size = max(image_max_file_size, file_size)
19731969

@@ -2055,14 +2051,10 @@ def _check_pre_quickpkg_files(
20552051
image_max_link_length = max(image_max_link_length, path_link_length)
20562052

20572053
if os.path.isfile(path):
2058-
try:
2059-
file_size = os.path.getsize(path)
2060-
except FileNotFoundError:
2061-
# Ignore file not found if symlink to non-existing file
2062-
if os.path.islink(path):
2063-
continue
2064-
else:
2065-
raise
2054+
if stat.S_ISLNK(file_stat.st_mode):
2055+
continue
2056+
2057+
file_size = os.path.getsize(path)
20662058
image_total_size += file_size
20672059
if file_size > image_max_file_size:
20682060
image_max_file_size = file_size

0 commit comments

Comments
 (0)