diff mbox series

[v2,2/6] fetch2/wget: use long arguments for clarity

Message ID 20250325122441.2521891-2-ross.burton@arm.com
State Accepted, archived
Commit 54039bc9d169871af6d36578df4c21bff296f6de
Headers show
Series [v2,1/6] fetch2/wget: consider downloadfilename when checking for upstream | expand

Commit Message

Ross Burton March 25, 2025, 12:24 p.m. UTC
It's best practise to use long-form arguments in scripts where the
conciseness of short arguments is less useful than in an interactive
terminal.

Signed-off-by: Ross Burton <ross.burton@arm.com>
---
 bitbake/lib/bb/fetch2/wget.py | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

Comments

Richard Purdie March 25, 2025, 10:59 p.m. UTC | #1
On Tue, 2025-03-25 at 12:24 +0000, Ross Burton via lists.openembedded.org wrote:
> @@ -106,7 +106,7 @@ class Wget(FetchMethod):
>          dldir = os.path.realpath(d.getVar("DL_DIR"))
>          localpath = os.path.join(dldir, ud.localfile) + ".tmp"
>          bb.utils.mkdirhier(os.path.dirname(localpath))
> -        fetchcmd += " -O %s" % shlex.quote(localpath)
> +        fetchcmd += " --output-document-%s" % shlex.quote(localpath)
>  
>          if ud.user and ud.pswd:
>              fetchcmd += " --auth-no-challenge"

I think the typo above proves why sometimes making improvements like
this needs to be carefully balanced.

This broke the builds on the autobuilder in obscure ways...

Cheers,

Richard
diff mbox series

Patch

diff --git a/bitbake/lib/bb/fetch2/wget.py b/bitbake/lib/bb/fetch2/wget.py
index df3e649312f..7b9eb6ed096 100644
--- a/bitbake/lib/bb/fetch2/wget.py
+++ b/bitbake/lib/bb/fetch2/wget.py
@@ -82,7 +82,7 @@  class Wget(FetchMethod):
         if not ud.localfile:
             ud.localfile = ud.host + ud.path.replace("/", ".")
 
-        self.basecmd = d.getVar("FETCHCMD_wget") or "/usr/bin/env wget -t 2 -T 100"
+        self.basecmd = d.getVar("FETCHCMD_wget") or "/usr/bin/env wget --tries=2 --timeout=100"
 
         if ud.type == 'ftp' or ud.type == 'ftps':
             self.basecmd += " --passive-ftp"
@@ -96,7 +96,7 @@  class Wget(FetchMethod):
 
         logger.debug2("Fetching %s using command '%s'" % (ud.url, command))
         bb.fetch2.check_network_access(d, command, ud.url)
-        runfetchcmd(command + ' --progress=dot -v', d, quiet, log=progresshandler, workdir=workdir)
+        runfetchcmd(command + ' --progress=dot --verbose', d, quiet, log=progresshandler, workdir=workdir)
 
     def download(self, ud, d):
         """Fetch urls"""
@@ -106,7 +106,7 @@  class Wget(FetchMethod):
         dldir = os.path.realpath(d.getVar("DL_DIR"))
         localpath = os.path.join(dldir, ud.localfile) + ".tmp"
         bb.utils.mkdirhier(os.path.dirname(localpath))
-        fetchcmd += " -O %s" % shlex.quote(localpath)
+        fetchcmd += " --output-document-%s" % shlex.quote(localpath)
 
         if ud.user and ud.pswd:
             fetchcmd += " --auth-no-challenge"
@@ -124,9 +124,9 @@  class Wget(FetchMethod):
         uri = ud.url.split(";")[0]
         if os.path.exists(ud.localpath):
             # file exists, but we didnt complete it.. trying again..
-            fetchcmd += " -c -P " + dldir + " '" + uri + "'"
+            fetchcmd += " --continue --directory-prefix=" + dldir + " '" + uri + "'"
         else:
-            fetchcmd += " -P " + dldir + " '" + uri + "'"
+            fetchcmd += " --directory-prefix=" + dldir + " '" + uri + "'"
 
         self._runwget(ud, d, fetchcmd, False)
 
@@ -490,7 +490,7 @@  class Wget(FetchMethod):
         f = tempfile.NamedTemporaryFile()
         with tempfile.TemporaryDirectory(prefix="wget-index-") as workdir, tempfile.NamedTemporaryFile(dir=workdir, prefix="wget-listing-") as f:
             fetchcmd = self.basecmd
-            fetchcmd += " -O " + f.name + " '" + uri + "'"
+            fetchcmd += " --output-document=%s '%s'" % (f.name, uri)
             try:
                 self._runwget(ud, d, fetchcmd, True, workdir=workdir)
                 fetchresult = f.read()