All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] wget: Add CHECKMD_wget option
@ 2022-12-19  8:55 alp.oezmert
  2022-12-19 10:58 ` [bitbake-devel] " Richard Purdie
  0 siblings, 1 reply; 7+ messages in thread
From: alp.oezmert @ 2022-12-19  8:55 UTC (permalink / raw)
  To: bitbake-devel; +Cc: changhyeok.bae

`CHECKCMD_wget` defines a command that the wget fetcher module will execute
instead of the built-in HTTP client when checking if URLs exist. This
allows to completely match the behavior of the wget fetcher including proxy
and authentication.

By default, this option is empty, and wget fetcher behavior is not changed.

Signed-off-by: Alp Özmert <alp.oezmert@mercedes-benz.com>
---
 lib/bb/fetch2/wget.py |  7 +++++++
 lib/bb/tests/fetch.py | 14 ++++++++++++++
 2 files changed, 21 insertions(+)

diff --git a/lib/bb/fetch2/wget.py b/lib/bb/fetch2/wget.py
index 821afa5b..56afd24e 100644
--- a/lib/bb/fetch2/wget.py
+++ b/lib/bb/fetch2/wget.py
@@ -153,6 +153,13 @@ class Wget(FetchMethod):
         return True

     def checkstatus(self, fetch, ud, d, try_again=True):
+        checkcmd = d.getVar("CHECKCMD_wget")
+        if checkcmd:
+            if checkcmd == "auto":
+                checkcmd = "%s --spider --quiet" % self.basecmd
+            uri = ud.url.split(";")[0]
+            return os.system("%s %s" % (checkcmd, uri)) == os.EX_OK
+
         class HTTPConnectionCache(http.client.HTTPConnection):
             if fetch.connection_cache:
                 def connect(self):
diff --git a/lib/bb/tests/fetch.py b/lib/bb/tests/fetch.py
index 0af06e46..6eb77e5c 100644
--- a/lib/bb/tests/fetch.py
+++ b/lib/bb/tests/fetch.py
@@ -1498,6 +1498,20 @@ class FetchCheckStatusTest(FetcherTest):
                 ret = m.checkstatus(fetch, ud, self.d)
                 self.assertTrue(ret, msg="URI %s, can't check status" % (u))

+    @skipIfNoNetwork()
+    def test_wget_checkstatus_external_wget(self):
+        # exclude test case ftp:// as wget has been observed to wrongly return '8'
+        self.test_wget_uris = [uri for uri in self.test_wget_uris if "ftp://" not in uri]
+        self.d.setVar("CHECKCMD_wget", "wget --spider --quiet")
+        self.test_wget_checkstatus()
+
+    @skipIfNoNetwork()
+    def test_wget_checkstatus_external_auto(self):
+        # exclude test case ftp:// as wget has been observed to wrongly return '8'
+        self.test_wget_uris = [uri for uri in self.test_wget_uris if "ftp://" not in uri]
+        self.d.setVar("CHECKCMD_wget", "auto")
+        self.test_wget_checkstatus()
+
     @skipIfNoNetwork()
     def test_wget_checkstatus_connection_cache(self):
         from bb.fetch2 import FetchConnectionCache
--
2.38.1


If you are not the addressee, please inform us immediately that you have received this e-mail by mistake, and delete it. We thank you for your support.


^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2022-12-19 15:32 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-12-19  8:55 [PATCH] wget: Add CHECKMD_wget option alp.oezmert
2022-12-19 10:58 ` [bitbake-devel] " Richard Purdie
2022-12-19 13:44   ` alp.oezmert
2022-12-19 14:26     ` Richard Purdie
2022-12-19 14:57       ` alp.oezmert
2022-12-19 15:02         ` Richard Purdie
2022-12-19 15:32           ` Alexander Kanavin

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.