diff options
author | Arthur Zamarin <arthurzam@gentoo.org> | 2023-08-20 22:42:04 +0300 |
---|---|---|
committer | Arthur Zamarin <arthurzam@gentoo.org> | 2023-08-20 22:42:04 +0300 |
commit | b1053683ecb8e17ed69e5797c32b83dd48452f59 (patch) | |
tree | 1ff3121701661ede97e8b050fadd0b738b93cf95 /src | |
parent | CI: add Python 3.12 (diff) | |
download | pkgcore-b1053683ecb8e17ed69e5797c32b83dd48452f59.tar.gz pkgcore-b1053683ecb8e17ed69e5797c32b83dd48452f59.tar.bz2 pkgcore-b1053683ecb8e17ed69e5797c32b83dd48452f59.zip |
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@gentoo.org>
Diffstat (limited to 'src')
-rw-r--r-- | src/pkgcore/fetch/custom.py | 19 | ||||
-rw-r--r-- | 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 fce7d7c2..d7da08f4 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 00746c4a..95775f7b 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): |