bitbake: fetch2: remove unnecessary expand function calls

The fetch data class already expands the type, host, path, user, pswd
and parm variables. The fetcher classes already expand the localfile
variable. The getVar function expands the returned string per default.
Remove unnecessary expand function calls to simplify the code.

(Bitbake rev: 1b1eb037b861fbf20491ac17e519e9eaf232b858)

Signed-off-by: Stefan Herbrechtsmeier <stefan.herbrechtsmeier@weidmueller.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
Stefan Herbrechtsmeier
2025-02-07 13:46:54 +01:00
committed by Richard Purdie
parent 2935d76bb4
commit 3e543e8eaa
7 changed files with 11 additions and 10 deletions

View File

@@ -1147,7 +1147,7 @@ def trusted_network(d, url):
if bb.utils.to_boolean(d.getVar("BB_NO_NETWORK")):
return True
pkgname = d.expand(d.getVar('PN', False))
pkgname = d.getVar('PN')
trusted_hosts = None
if pkgname:
trusted_hosts = d.getVarFlag('BB_ALLOWED_NETWORKS', pkgname, False)
@@ -1782,7 +1782,7 @@ class Fetch(object):
self.ud[url] = FetchData(url, self.d)
self.ud[url].setup_localpath(self.d)
return self.d.expand(self.ud[url].localpath)
return self.ud[url].localpath
def localpaths(self):
"""

View File

@@ -66,11 +66,12 @@ class Az(Wget):
else:
azuri = '%s%s%s' % ('https://', ud.host, ud.path)
dldir = d.getVar("DL_DIR")
if os.path.exists(ud.localpath):
# file exists, but we didnt complete it.. trying again.
fetchcmd += d.expand(" -c -P ${DL_DIR} '%s'" % azuri)
fetchcmd += " -c -P %s '%s'" % (dldir, azuri)
else:
fetchcmd += d.expand(" -P ${DL_DIR} '%s'" % azuri)
fetchcmd += " -P %s '%s'" % (dldir, azuri)
try:
self._runwget(ud, d, fetchcmd, False)

View File

@@ -46,7 +46,7 @@ class GCP(FetchMethod):
else:
ud.basename = os.path.basename(ud.path)
ud.localfile = d.expand(urllib.parse.unquote(ud.basename))
ud.localfile = urllib.parse.unquote(ud.basename)
def get_gcp_client(self):
from google.cloud import storage

View File

@@ -166,7 +166,7 @@ class Npm(FetchMethod):
# Using the 'downloadfilename' parameter as local filename
# or the npm package name.
if "downloadfilename" in ud.parm:
ud.localfile = npm_localfile(d.expand(ud.parm["downloadfilename"]))
ud.localfile = npm_localfile(ud.parm["downloadfilename"])
else:
ud.localfile = npm_localfile(ud.package, ud.version)

View File

@@ -77,7 +77,7 @@ class S3(FetchMethod):
else:
ud.basename = os.path.basename(ud.path)
ud.localfile = d.expand(urllib.parse.unquote(ud.basename))
ud.localfile = urllib.parse.unquote(ud.basename)
ud.basecmd = d.getVar("FETCHCMD_s3") or "/usr/bin/env aws s3"

View File

@@ -77,7 +77,7 @@ class SFTP(FetchMethod):
else:
ud.basename = os.path.basename(ud.path)
ud.localfile = d.expand(urllib.parse.unquote(ud.basename))
ud.localfile = urllib.parse.unquote(ud.basename)
def download(self, ud, d):
"""Fetch urls"""

View File

@@ -78,9 +78,9 @@ class Wget(FetchMethod):
else:
ud.basename = os.path.basename(ud.path)
ud.localfile = d.expand(urllib.parse.unquote(ud.basename))
ud.localfile = urllib.parse.unquote(ud.basename)
if not ud.localfile:
ud.localfile = d.expand(urllib.parse.unquote(ud.host + ud.path).replace("/", "."))
ud.localfile = urllib.parse.unquote(ud.host + ud.path).replace("/", ".")
self.basecmd = d.getVar("FETCHCMD_wget") or "/usr/bin/env wget -t 2 -T 100"