commit:     355b6598225e3ffa921d2fb6646539bcbcc694a7
Author:     Sheng Yu <syu.os <AT> protonmail <DOT> com>
AuthorDate: Thu Sep 15 15:52:31 2022 +0000
Commit:     Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Tue Sep 20 03:39:23 2022 +0000
URL:        https://gitweb.gentoo.org/proj/portage.git/commit/?id=355b6598

GPKG quickpkg allow missing files

Bug: https://bugs.gentoo.org/870229
Signed-off-by: Sheng Yu <syu.os <AT> protonmail.com>
Closes: https://github.com/gentoo/portage/pull/900
Signed-off-by: Sam James <sam <AT> gentoo.org>

 lib/portage/gpkg.py | 16 +++++++++++++---
 1 file changed, 13 insertions(+), 3 deletions(-)

diff --git a/lib/portage/gpkg.py b/lib/portage/gpkg.py
index 5f8e19341..c0a80208f 100644
--- a/lib/portage/gpkg.py
+++ b/lib/portage/gpkg.py
@@ -33,7 +33,7 @@ from portage.exception import (
     MissingSignature,
     InvalidSignature,
 )
-from portage.output import colorize
+from portage.output import colorize, EOutput
 from portage.util._urlopen import urlopen
 from portage.util import writemsg
 from portage.util import shlex_split, varexpand
@@ -1271,6 +1271,7 @@ class gpkg:
         Will compress the given files to image with root,
         ignoring all other files.
         """
+        eout = EOutput()
 
         protect_file = io.BytesIO(
             b"# empty file because --include-config=n when `quickpkg` was 
used\n"
@@ -1284,7 +1285,7 @@ class gpkg:
 
         # Get pre image info
         container_tar_format, image_tar_format = 
self._get_tar_format_from_stats(
-            *self._check_pre_quickpkg_files(contents, root_dir)
+            *self._check_pre_quickpkg_files(contents, root_dir, 
ignore_missing=True)
         )
 
         # Long CPV
@@ -1341,6 +1342,7 @@ class gpkg:
                     except OSError as e:
                         if e.errno != errno.ENOENT:
                             raise
+                        eout.ewarn(f'Missing file from local system: "{path}"')
                         del e
                         continue
                     contents_type = contents[path][0]
@@ -1984,7 +1986,9 @@ class gpkg:
             image_total_size,
         )
 
-    def _check_pre_quickpkg_files(self, contents, root, image_prefix="image"):
+    def _check_pre_quickpkg_files(
+        self, contents, root, image_prefix="image", ignore_missing=False
+    ):
         """
         Check the pre quickpkg files size and path, return the longest
         path length, largest single file size, and total files size.
@@ -2034,6 +2038,12 @@ class gpkg:
                 + image_prefix_length
             )
 
+            if not os.path.exists(path):
+                if ignore_missing:
+                    continue
+                else:
+                    raise FileNotFound(path)
+
             file_stat = os.lstat(path)
 
             if os.path.islink(path):

Reply via email to