Gentoo Archives: gentoo-portage-dev

From: Zac Medico <zmedico@g.o>
To: gentoo-portage-dev@l.g.o
Cc: Zac Medico <zmedico@g.o>
Subject: [gentoo-portage-dev] [PATCH] fetch: minimal skiprocheck fixes (bug 220533)
Date: Sun, 13 Oct 2019 22:40:24
Message-Id: 20191013223319.14801-1-zmedico@gentoo.org
1 Fix cases here fetch assumes that DISTDIR is writable when it's actually
2 read-only. This preserves old behavior which allowed users to override
3 FETCHCOMMAND to fetch files on a remote system, even though DISTDIR is
4 locally mounted in read-only mode.
5
6 Bug: https://bugs.gentoo.org/220533
7 Fixes: ebbde237d33e ("fetch: atomic downloads (bug 175612)")
8 Signed-off-by: Zac Medico <zmedico@g.o>
9 ---
10 lib/portage/package/ebuild/fetch.py | 28 ++++++++++++++++------------
11 1 file changed, 16 insertions(+), 12 deletions(-)
12
13 diff --git a/lib/portage/package/ebuild/fetch.py b/lib/portage/package/ebuild/fetch.py
14 index cd204b755..b564ab2e3 100644
15 --- a/lib/portage/package/ebuild/fetch.py
16 +++ b/lib/portage/package/ebuild/fetch.py
17 @@ -790,7 +790,7 @@ def fetch(myuris, mysettings, listonly=0, fetchonly=0,
18 pruned_digests["size"] = size
19
20 myfile_path = os.path.join(mysettings["DISTDIR"], myfile)
21 - download_path = myfile_path + _download_suffix
22 + download_path = myfile_path if fetch_to_ro else myfile_path + _download_suffix
23 has_space = True
24 has_space_superuser = True
25 file_lock = None
26 @@ -1058,7 +1058,8 @@ def fetch(myuris, mysettings, listonly=0, fetchonly=0,
27 "File renamed to '%s'\n\n") % \
28 temp_filename, noiselevel=-1)
29 else:
30 - _movefile(download_path, myfile_path, mysettings=mysettings)
31 + if not fetch_to_ro:
32 + _movefile(download_path, myfile_path, mysettings=mysettings)
33 eout = EOutput()
34 eout.quiet = \
35 mysettings.get("PORTAGE_QUIET", None) == "1"
36 @@ -1177,7 +1178,7 @@ def fetch(myuris, mysettings, listonly=0, fetchonly=0,
37 del e
38 fetched = 0
39 else:
40 - if mystat.st_size < fetch_resume_size:
41 + if distdir_writable and mystat.st_size < fetch_resume_size:
42 writemsg(_(">>> Deleting distfile with size "
43 "%d (smaller than " "PORTAGE_FETCH_RESU"
44 "ME_MIN_SIZE)\n") % mystat.st_size)
45 @@ -1315,13 +1316,14 @@ def fetch(myuris, mysettings, listonly=0, fetchonly=0,
46 (reason[1], reason[2]), noiselevel=-1)
47 if reason[0] == _("Insufficient data for checksum verification"):
48 return 0
49 - temp_filename = \
50 - _checksum_failure_temp_file(
51 - mysettings, mysettings["DISTDIR"],
52 - os.path.basename(download_path))
53 - writemsg_stdout(_("Refetching... "
54 - "File renamed to '%s'\n\n") % \
55 - temp_filename, noiselevel=-1)
56 + if distdir_writable:
57 + temp_filename = \
58 + _checksum_failure_temp_file(
59 + mysettings, mysettings["DISTDIR"],
60 + os.path.basename(download_path))
61 + writemsg_stdout(_("Refetching... "
62 + "File renamed to '%s'\n\n") % \
63 + temp_filename, noiselevel=-1)
64 fetched=0
65 checksum_failure_count += 1
66 if checksum_failure_count == \
67 @@ -1338,7 +1340,8 @@ def fetch(myuris, mysettings, listonly=0, fetchonly=0,
68 checksum_failure_max_tries:
69 break
70 else:
71 - _movefile(download_path, myfile_path, mysettings=mysettings)
72 + if not fetch_to_ro:
73 + _movefile(download_path, myfile_path, mysettings=mysettings)
74 eout = EOutput()
75 eout.quiet = mysettings.get("PORTAGE_QUIET", None) == "1"
76 if digests:
77 @@ -1349,7 +1352,8 @@ def fetch(myuris, mysettings, listonly=0, fetchonly=0,
78 break
79 else: # no digests available
80 if not myret:
81 - _movefile(download_path, myfile_path, mysettings=mysettings)
82 + if not fetch_to_ro:
83 + _movefile(download_path, myfile_path, mysettings=mysettings)
84 fetched=2
85 break
86 elif mydigests!=None:
87 --
88 2.21.0