commit: b1053683ecb8e17ed69e5797c32b83dd48452f59 Author: Arthur Zamarin <arthurzam <AT> gentoo <DOT> org> AuthorDate: Sun Aug 20 19:42:04 2023 +0000 Commit: Arthur Zamarin <arthurzam <AT> gentoo <DOT> org> CommitDate: Sun Aug 20 19:42:04 2023 +0000 URL: https://gitweb.gentoo.org/proj/pkgcore/pkgcore.git/commit/?id=b1053683
operations.format.fetch_base: support proxy configuration Add support for proxy configuration to the fetch_base operation, through the environment variables ``http_proxy`` and ``https_proxy``. I see no security concern from passing those variables to the fetcher, as they are run with the same permissions as the rest of pkgcore, under user level. https://github.com/pkgcore/pkgdev/issues/103 Signed-off-by: Arthur Zamarin <arthurzam <AT> gentoo.org> src/pkgcore/fetch/custom.py | 19 ++++++++----------- src/pkgcore/operations/format.py | 2 ++ 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/src/pkgcore/fetch/custom.py b/src/pkgcore/fetch/custom.py index fce7d7c21..d7da08f45 100644 --- a/src/pkgcore/fetch/custom.py +++ b/src/pkgcore/fetch/custom.py @@ -37,20 +37,18 @@ class fetcher(base.fetcher): def __init__( self, - distdir, - command, + distdir: str, + command: str, resume_command=None, required_chksums=None, - userpriv=True, - attempts=10, - readonly=False, - **extra_env, + userpriv: bool = True, + attempts: int = 10, + readonly: bool = False, + **extra_env: str, ): """ :param distdir: directory to download files to - :type distdir: string :param command: shell command to execute to fetch a file - :type command: string :param resume_command: if not None, command to use for resuming- if None, command is reused :param required_chksums: if None, all chksums must be verified, @@ -71,7 +69,7 @@ class fetcher(base.fetcher): else: self.required_chksums = required_chksums - def rewrite_command(string): + def rewrite_command(string: str): new_command = string.replace("\\$", "$") new_command = new_command.replace("${DISTDIR}", self.distdir) new_command = new_command.replace("$DISTDIR", self.distdir) @@ -98,10 +96,9 @@ class fetcher(base.fetcher): self.readonly = readonly self.extra_env = extra_env - def fetch(self, target): + def fetch(self, target: fetchable): """Fetch a file. - :type target: :obj:`pkgcore.fetch.fetchable` instance :return: None if fetching failed, else on disk location of the copied file """ diff --git a/src/pkgcore/operations/format.py b/src/pkgcore/operations/format.py index 00746c4a8..95775f7b0 100644 --- a/src/pkgcore/operations/format.py +++ b/src/pkgcore/operations/format.py @@ -45,6 +45,8 @@ class fetch_base: resumecmd, attempts=attempts, PATH=os.environ["PATH"], + http_proxy=os.environ["http_proxy"], + https_proxy=os.environ["https_proxy"], ) def fetch_all(self, observer):